HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GAS_Analysis.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GAS_Analysis.h ( GAS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GAS_Analysis__
12 #define __GAS_Analysis__
13 
14 #include "GAS_API.h"
15 
17 #include <GU/GU_Detail.h>
18 
19 #include <SIM/SIM_RawField.h>
20 #include <SIM/SIM_ScalarField.h>
21 #include <SIM/SIM_VectorField.h>
22 #include <SIM/SIM_PhysicalParms.h>
23 
24 #include "GAS_SubSolver.h"
25 #include "GAS_Utils.h"
26 
27 class SIM_ScalarField;
28 class SIM_VectorField;
29 class SIM_MatrixField;
30 
32 {
33 public:
34  GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName);
36  GET_DATA_FUNC_S(GAS_NAME_STENCIL, StencilName);
37 
38  GET_DATA_FUNC_I("analysis", Analysis);
39  GET_DATA_FUNC_B(SIM_NAME_OPENCL, UseOpenCL);
40 
41  // Analysis methods
43  {
51  NUM_ANALYSIS
52  };
53 
54 protected:
55  explicit GAS_Analysis(const SIM_DataFactory *factory);
56  ~GAS_Analysis() override;
57 
58  bool shouldMultiThread(const SIM_RawField *field) const
59  { return field->field()->numTiles() > 1; }
60 
61  bool solveGasSubclass(SIM_Engine &engine,
62  SIM_Object *obj,
63  SIM_Time time,
64  SIM_Time timestep) override;
65 
66 private:
67  static const SIM_DopDescription *getDopDescription();
68 
69 
70  // We have helper wrappers around the same->same methods to avoid
71  // read/modify/write problems where the source and destination fields
72  // are the same. This is impossible for the ones that change
73  // dimensions.
74  void calculateCurvature(SIM_RawField *dst, SIM_RawField *src,
75  const SIM_RawField *stencil) const;
76  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst),
77  threadCurvature,
78  SIM_RawField *, dst,
79  const SIM_RawField *, src,
80  const SIM_RawField *, stencil);
81  void threadCurvaturePartial(SIM_RawField *dst,
82  const SIM_RawField *src,
83  const SIM_RawField *stencil,
84  const UT_JobInfo &info) const;
85 
86  void calculateLaplacian(SIM_RawField *dst, const SIM_RawField *src,
87  const SIM_RawField *stencil) const;
88  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst),
89  threadLaplacian,
90  SIM_RawField *, dst,
91  const SIM_RawField *, src,
92  const SIM_RawField *, stencil);
93  void threadLaplacianPartial(SIM_RawField *dst,
94  const SIM_RawField *src,
95  const SIM_RawField *stencil,
96  const UT_JobInfo &info) const;
97 
98  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(src->getField()),
99  calculateScalarGradientAligned,
100  SIM_VectorField *, dst,
101  const SIM_ScalarField *, src,
102  const SIM_RawField *, stencil);
103  void calculateScalarGradientAlignedPartial(
105  const SIM_ScalarField *src,
106  const SIM_RawField *stencil,
107  const UT_JobInfo &info) const;
108  THREADED_METHOD4_CONST(GAS_Analysis, shouldMultiThread(dst),
109  calculateScalarGradient,
110  SIM_RawField *, dst,
111  int, axis,
112  const SIM_ScalarField *, src,
113  const SIM_RawField *, stencil);
114  void calculateScalarGradientPartial(SIM_RawField *dst,
115  int axis,
116  const SIM_ScalarField *src,
117  const SIM_RawField *stencil,
118  const UT_JobInfo &info) const;
119  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(src->getField(0)),
120  calculateVectorGradientAligned,
121  SIM_MatrixField *, dst,
122  const SIM_VectorField *, src,
123  const SIM_RawField *, stencil);
124  void calculateVectorGradientAlignedPartial(
126  const SIM_VectorField *src,
127  const SIM_RawField *stencil,
128  const UT_JobInfo &info) const;
129  THREADED_METHOD5_CONST(GAS_Analysis, shouldMultiThread(dst),
130  calculateVectorGradient,
131  SIM_RawField *, dst,
132  int, a1,
133  int, a2,
134  const SIM_VectorField *, src,
135  const SIM_RawField *, stencil0);
136  void calculateVectorGradientPartial(SIM_RawField *dst,
137  int a1, int a2,
138  const SIM_VectorField *src,
139  const SIM_RawField *stencil,
140  const UT_JobInfo &info) const;
141 
142  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst),
143  calculateDivergence,
144  SIM_RawField *, dst,
145  const SIM_VectorField *, src,
146  const SIM_RawField *, stencil);
147  void calculateDivergencePartial(SIM_RawField *dst,
148  const SIM_VectorField *src,
149  const SIM_RawField *stencil,
150  const UT_JobInfo &info) const;
151 
152  void calculateCurl(SIM_VectorField *dst, const SIM_VectorField *src,
153  const SIM_RawField *stencil);
154 
155  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst[0]),
156  threadCurlAligned,
157  SIM_RawField **, dst,
158  const SIM_VectorField *, src,
159  const SIM_RawField *, stencil);
160  void threadCurlAlignedPartial(SIM_RawField **dst,
161  const SIM_VectorField *src,
162  const SIM_RawField *stencil,
163  const UT_JobInfo &info) const;
164  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst[0]),
165  threadCurlAlignedFace,
166  SIM_RawField **, dst,
167  const SIM_VectorField *, src,
168  const SIM_RawField *, stencil);
169  void threadCurlAlignedFacePartial(SIM_RawField **dst,
170  const SIM_VectorField *src,
171  const SIM_RawField *stencil,
172  const UT_JobInfo &info) const;
173  THREADED_METHOD4_CONST(GAS_Analysis, shouldMultiThread(dst),
174  threadCurl,
175  SIM_RawField *, dst,
176  int, axis,
177  const SIM_VectorField *, src,
178  const SIM_RawField *, stencil);
179  void threadCurlPartial(SIM_RawField *dst,
180  int axis,
181  const SIM_VectorField *src,
182  const SIM_RawField *stencil,
183  const UT_JobInfo &info) const;
184 
185  void calculateNormalize(SIM_VectorField *dst, const SIM_VectorField *src,
186  const SIM_RawField *stencil);
187  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst->getField(0)),
188  threadNormalizeAligned,
189  SIM_VectorField *, dst,
190  const SIM_VectorField *, src,
191  const SIM_RawField *, stencil);
192  void threadNormalizeAlignedPartial(SIM_VectorField *dst,
193  const SIM_VectorField *src,
194  const SIM_RawField *stencil,
195  const UT_JobInfo &info) const;
196  THREADED_METHOD4_CONST(GAS_Analysis, shouldMultiThread(dst),
197  threadNormalize,
198  SIM_RawField *, dst,
199  int, axis,
200  const SIM_VectorField *, src,
201  const SIM_RawField *, stencil);
202  void threadNormalizePartial(SIM_RawField *dst,
203  int axis,
204  const SIM_VectorField *src,
205  const SIM_RawField *stencil,
206  const UT_JobInfo &info) const;
207 
208  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst),
209  calculateLength,
210  SIM_RawField *, dst,
211  const SIM_VectorField *, src,
212  const SIM_RawField *, stencil);
213  void calculateLengthPartial(SIM_RawField *dst,
214  const SIM_VectorField *src,
215  const SIM_RawField *stencil,
216  const UT_JobInfo &info) const;
217 
218  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst),
219  calculateMatrixLengthAligned,
220  SIM_RawField *, dst,
221  const SIM_MatrixField *, src,
222  const SIM_RawField *, stencil);
223  void calculateMatrixLengthAlignedPartial(SIM_RawField *dst,
224  const SIM_MatrixField *src,
225  const SIM_RawField *stencil,
226  const UT_JobInfo &info) const;
227  THREADED_METHOD3_CONST(GAS_Analysis, shouldMultiThread(dst),
228  calculateMatrixLength,
229  SIM_RawField *, dst,
230  const SIM_MatrixField *, src,
231  const SIM_RawField *, stencil);
232  void calculateMatrixLengthPartial(SIM_RawField *dst,
233  const SIM_MatrixField *src,
234  const SIM_RawField *stencil,
235  const UT_JobInfo &info) const;
236 
237  // OpenCL functions
238  void calculateCurlCL(SIM_Object *obj,
240  const SIM_VectorField *src);
241  void calculateLengthCL(SIM_Object *obj,
243  const SIM_VectorField *src);
244  void calculateScalarGradientCL(SIM_Object *obj,
246  const SIM_ScalarField* src,
247  bool doNormalize = false);
248  void calculateNormalizeCL(SIM_Object *obj,
251  void calculateDivergenceCL(SIM_Object *obj,
254 
258  "Gas Analysis",
259  getDopDescription());
260 
261  // Cache our timestep for so we can calculate the timescale
262  // effects.
263  float myTimeStep;
264 };
265 
266 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#define THREADED_METHOD4_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4)
GT_API const UT_StringHolder time
bool shouldMultiThread(const SIM_RawField *field) const
Definition: GAS_Analysis.h:58
#define GAS_API
Definition: GAS_API.h:10
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)=0
#define THREADED_METHOD5_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
#define GET_DATA_FUNC_I(DataName, FuncName)
int numTiles() const
#define GAS_NAME_FIELDSOURCE
Definition: GAS_Utils.h:29
#define GAS_NAME_FIELDDEST
Definition: GAS_Utils.h:28
This class holds a three dimensional tensor field.
GLenum GLenum dst
Definition: glcorearb.h:1793
#define GET_DATA_FUNC_B(DataName, FuncName)
This class holds a three dimensional scalar field.
#define SIM_NAME_OPENCL
Definition: SIM_Names.h:222
GLint GLfloat GLint stencil
Definition: glcorearb.h:1278
#define THREADED_METHOD3_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3)
This class holds a three dimensional vector field.
#define GET_DATA_FUNC_S(DataName, FuncName)
#define GAS_NAME_STENCIL
Definition: GAS_Utils.h:19
UT_VoxelArrayF UT_VoxelArrayF & field
GLenum src
Definition: glcorearb.h:1793