CustomResultGenerator.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: UnstructGrid
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2012, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeCore/Base.h"
16 #include "CeeCore/PtrRef.h"
17 #include "CeeCore/RefCountedObject.h"
18 #include "CeeUnstructGrid/CustomResultFunction.h"
19 
20 #include <vector>
21 
22 namespace cee {
23 namespace ug {
24 
25 class DataResultGroup;
26 class DataResultScalar;
27 class DataResultVector;
28 class DataResultDisplacement;
29 class DataResultSymmetricTensor;
30 
31 class DataSource;
32 class DataState;
33 class ResultInfo;
34 
35 typedef ResultInfo CustomResultArgument;
36 
37 //==================================================================================================
38 //
39 //
40 //
41 //==================================================================================================
42 class CEE_UG_EXPORT CustomResultGenerator : public RefCountedObject
43 {
44 
45 public:
46 
47  //--------------------------------------------------------------------------------------------------
49  //--------------------------------------------------------------------------------------------------
51  {
52  std::vector<const DataResultScalar*> scalars;
53  std::vector<const DataResultVector*> vectors;
54  std::vector<const DataResultDisplacement*> displacements;
55  std::vector<const DataResultSymmetricTensor*> symmetricTensors;
56 
57  };
58 
59  //--------------------------------------------------------------------------------------------------
61  //--------------------------------------------------------------------------------------------------
63  {
64  std::vector<const double*> values;
65  std::vector<size_t> dimensions;
66  std::vector<size_t> counts;
67  };
68 
69  //--------------------------------------------------------------------------------------------------
71  //--------------------------------------------------------------------------------------------------
73  {
78  };
79 
80  //--------------------------------------------------------------------------------------------------
82  //--------------------------------------------------------------------------------------------------
84  {
85  double* values;
86  size_t dimension;
87  size_t count;
88  };
89 
90 public:
92  CustomResultGenerator(size_t argumentCount);
93  virtual ~CustomResultGenerator();
94 
95  bool operator==(const CustomResultGenerator& rhs) const;
96  bool operator!=(const CustomResultGenerator& rhs) const;
97 
98  size_t argumentCount() const;
99 
100  ResultType argumentType(size_t index) const;
101  void setArgumentType(size_t index, ResultType resultType);
102 
103  void setFunction(CustomResultFunction* function);
104 
105  bool hasFunction() const;
106  const CustomResultFunction* function() const;
107 
108  virtual bool generate(const DataSource* dataSource, const ResultInfo& result, const std::vector<CustomResultArgument>& arguments, DataState* state) const;
109 
110 protected:
111  bool checkArguments(const std::vector<CustomResultArgument>& arguments) const;
112  bool computeCustomArguments(const DataSource* dataSource, const std::vector<CustomResultArgument>& arguments, DataState* state) const;
113  bool gatherInputDataResults(const DataResultGroup* resultGroup, const std::vector<CustomResultArgument>& arguments, size_t partCount, InputDataResults* inputDataResults) const;
114  bool gatherInputValuePointers(const std::vector<CustomResultArgument>& arguments, size_t partIndex, const InputDataResults& inputDataResults, InputValueData* inputValueData) const;
115  bool getOuputDataResult(DataResultGroup* resultGroup, const ResultInfo& result, OutputDataResult* outputDataResult) const;
116  bool getOutputValuePointer(size_t partIndex, const OutputDataResult& outputDataResult, const InputValueData& inputValueData, size_t outputItemCount, OutputValueData* outputValueData) const;
117 
118 private:
119  CEE_PRIVATE_IMPL(CustomResultGenerator);
120  CEE_DISALLOW_COPY_AND_ASSIGN(CustomResultGenerator);
121 };
122 
123 } // namespace ug
124 } // namespace cee
A class to generate custom results.
Definition: CustomResultGenerator.h:42
std::vector< const double * > values
values[i] is the raw pointer to the value array of argument i
Definition: CustomResultGenerator.h:64
DataResultSymmetricTensor * symmetricTensor
The DataResultSymmetricTensor object of the generated output result if it is a symmetric tensor...
Definition: CustomResultGenerator.h:77
The data source of the model. For instance a file interface or custom built by the user...
Definition: DataSource.h:35
Symmetric tensor results for all parts in the geometry.
Definition: DataResultSymmetricTensor.h:29
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppComponent.cpp:26
DataResultVector * vector
The DataResultVector object of the generated output result if it is a vector, NULL if not...
Definition: CustomResultGenerator.h:75
Result group binding a geometry and results (scalar, vector, displacement and/or transformation) ...
Definition: DataResultGroup.h:33
Input data results.
Definition: CustomResultGenerator.h:50
Simple class containing metadata info for a result.
Definition: ResultInfo.h:34
bool operator!=(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are different.
Definition: PtrRef.h:58
DataResultDisplacement * displacement
The DataResultDisplacement object of the generated output result if it is a displacement, NULL if not.
Definition: CustomResultGenerator.h:76
Input value data.
Definition: CustomResultGenerator.h:62
size_t dimension
The dimension of the output result (1 for scalar, 3 for vector or displacement, 6 for symmetric tenso...
Definition: CustomResultGenerator.h:86
Scalar result for all parts in the geometry.
Definition: DataResultScalar.h:28
bool operator==(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are equal.
Definition: PtrRef.h:57
Base class for all reference counted objects with built-in support for intrusive reference counting...
Definition: RefCountedObject.h:34
A CustomResultFunction produces the output values of a custom result on a given item.
Definition: CustomResultFunction.h:28
Output data result.
Definition: CustomResultGenerator.h:72
std::vector< const DataResultDisplacement * > displacements
displacements[i] is the DataResultDisplacement object of argument i if the argument is a displacement...
Definition: CustomResultGenerator.h:54
Displacements results for all parts in the geometry.
Definition: DataResultDisplacement.h:30
Output value data.
Definition: CustomResultGenerator.h:83
DataResultScalar * scalar
The DataResultScalar object of the generated output result if it is a scalar, NULL if not...
Definition: CustomResultGenerator.h:74
A state contains all data available for one time step, load case or frequency.
Definition: DataState.h:28
std::vector< const DataResultSymmetricTensor * > symmetricTensors
symmetricTensors[i] is the DataResultSymmetricTensor object of argument i if the argument is a symmet...
Definition: CustomResultGenerator.h:55
std::vector< const DataResultScalar * > scalars
scalars[i] is the DataResultScalar object of argument i if the argument is a scalar, NULL if not
Definition: CustomResultGenerator.h:52
std::vector< size_t > counts
counts[i] is the number of items (nodes, elements, element-nodes) of argument i
Definition: CustomResultGenerator.h:66
ResultType
Different types of results.
Definition: Base.h:90
std::vector< size_t > dimensions
dimensions[i] is the dimension of argument i (1 for scalar, 3 for vector or displacement, 6 for symmetric tensor)
Definition: CustomResultGenerator.h:65
double * values
The raw pointer to the value array of the output result.
Definition: CustomResultGenerator.h:85
Vector results for all parts in the geometry.
Definition: DataResultVector.h:29
size_t count
The number of items of the output result (nodes, elements, element-nodes)
Definition: CustomResultGenerator.h:87
std::vector< const DataResultVector * > vectors
vectors[i] is the DataResultVector object of argument i if the argument is a vector, NULL if not
Definition: CustomResultGenerator.h:53