Overture  Version 25
GenericGridCollectionOperators.h
Go to the documentation of this file.
1 /* -*-Mode: c++; -*- */
2 
3 #ifndef GENERIC_GRID_COLLECTION_OPERATORS
4 #define GENERIC_GRID_COLLECTION_OPERATORS
5 
6 // The file GenericCompositeGridOperators.h is created from GenericGridCollectionOperators.h by the
7 // perl script makeOperators.p
8 
9 #undef COMPOSITE_GRID_OPERATORS
10 // The next line is uncommented in GenericCompositeGridOperators.h
11 // define COMPOSITE_GRID_OPERATORS
12 
13 
18 
19 // extern BoundaryConditionParameters Overture::defaultBoundaryConditionParameters();
20 
22 
23 
24 //-----------------------------------------------------------------------------------
25 //
26 // Define differential and Boundary operators associated with GridCollections,
27 // GridCollectionFunctions (and CompositeGrid/CompositeGridFunctions)
28 //
29 //-----------------------------------------------------------------------------------
30 
32 {
33 
34  public:
35 
36  enum
37  {
40  };
41 
42 
43  GridCollection gridCollection; // operators are defined for this GridCollection
44 
45  // ********************************************************************
46  // **************** Miscellaneous Functions **************************
47  // ********************************************************************
48 
49  // default constructor
51  // contructor taking a GridCollection
53  // copy constructor
55 
58  // create a new object of this class
60 
62 
64 
65  // here is the operator for a GenericMappedGrid
66  GenericMappedGridOperators & operator[]( const int grid ) const;
67 
68  // return size of this object
69  virtual real sizeOf(FILE *file = NULL ) const;
70 
71  // supply a new grid to use
72  virtual void updateToMatchGrid( GridCollection & g );
73  // Use some new operators
75 
76  // get from a database file
77  virtual int get( const GenericDataBase & dir, const aString & name);
78  // put to a database file
79  virtual int put( GenericDataBase & dir, const aString & name) const;
80 
81  // set the order of accuracy
82  virtual void setOrderOfAccuracy( const int & orderOfAccuracy );
83  // get the order of accuracy
84  int getOrderOfAccuracy() const;
85 
86  // Indicate the stencil size for functions returning coefficients
87  virtual void setStencilSize(const int stencilSize);
88 
89  // Indicate the number of components (system size) for functions returning coefficients
90  virtual void setNumberOfComponentsForCoefficients(const int number);
91 
92  // Indicate if twilight-zone forcing should be added to boundary conditions
93  void setTwilightZoneFlow( const int & twilightZoneFlow );
94 
95  // Supply a twilight-zone forcing to use for boundary conditions
97 
98  virtual void useConservativeApproximations(bool trueOrFalse = TRUE );
100 
101  // ************************************************
102  // ***** DIFFERENTIATION CLASS FUNCTIONS **********
103  // ************************************************
104 
105 
106 // Macro to define a typical function call
107 #define FUNCTION(type) \
108  virtual realGridCollectionFunction type(const realGridCollectionFunction & u, \
109  const Index & C1 = nullIndex, \
110  const Index & C2 = nullIndex, \
111  const Index & C3 = nullIndex, \
112  const Index & C4 = nullIndex, \
113  const Index & C5 = nullIndex ); \
114  virtual realGridCollectionFunction type(const realGridCollectionFunction & u, \
115  const GridFunctionParameters & gfType, \
116  const Index & C1 = nullIndex, \
117  const Index & C2 = nullIndex, \
118  const Index & C3 = nullIndex, \
119  const Index & C4 = nullIndex, \
120  const Index & C5 = nullIndex );
121 
122 
123 #define FUNCTION_COEFFICIENTS(type) \
124  virtual realGridCollectionFunction type(const Index & C0 = nullIndex, \
125  const Index & C1 = nullIndex, \
126  const Index & C2 = nullIndex, \
127  const Index & C3 = nullIndex ); \
128  \
129  virtual realGridCollectionFunction type(const GridFunctionParameters & gfType, \
130  const Index & C0 = nullIndex, \
131  const Index & C1 = nullIndex, \
132  const Index & C2 = nullIndex, \
133  const Index & C3 = nullIndex );
134 
135  // parametric derivatives in the r1,r2,r3 directions
136  FUNCTION(r1)
137  FUNCTION_COEFFICIENTS(r1Coefficients)
138  FUNCTION(r2)
139  FUNCTION_COEFFICIENTS(r2Coefficients)
140  FUNCTION(r3)
141  FUNCTION_COEFFICIENTS(r3Coefficients)
142  FUNCTION(r1r1)
143  FUNCTION_COEFFICIENTS(r1r1Coefficients)
144  FUNCTION(r1r2)
145  FUNCTION_COEFFICIENTS(r1r2Coefficients)
146  FUNCTION(r1r3)
147  FUNCTION_COEFFICIENTS(r1r3Coefficients)
148  FUNCTION(r2r2)
149  FUNCTION_COEFFICIENTS(r2r2Coefficients)
150  FUNCTION(r2r3)
151  FUNCTION_COEFFICIENTS(r2r3Coefficients)
152  FUNCTION(r3r3)
153  FUNCTION_COEFFICIENTS(r3r3Coefficients)
154 
155  // FUNCTIONs in the x,y,z directions
156  FUNCTION(x)
157  FUNCTION_COEFFICIENTS(xCoefficients)
158  FUNCTION(y)
159  FUNCTION_COEFFICIENTS(yCoefficients)
160  FUNCTION(z)
161  FUNCTION_COEFFICIENTS(zCoefficients)
162  FUNCTION(xx)
163  FUNCTION_COEFFICIENTS(xxCoefficients)
164  FUNCTION(xy)
165  FUNCTION_COEFFICIENTS(xyCoefficients)
166  FUNCTION(xz)
167  FUNCTION_COEFFICIENTS(xzCoefficients)
168  FUNCTION(yy)
169  FUNCTION_COEFFICIENTS(yyCoefficients)
170  FUNCTION(yz)
171  FUNCTION_COEFFICIENTS(yzCoefficients)
172  FUNCTION(zz)
173  FUNCTION_COEFFICIENTS(zzCoefficients)
174 
175  // other forms of derivatives
176 
177  // compute face-centered variable from cell-centered variable
178  FUNCTION(cellsToFaces)
179 
180  //compute (u.grad)u (convective derivative)
182 
183  // compute contravariant velocity from either cell-centered or face-centered input velocity
184  FUNCTION(contravariantVelocity)
185 
186  FUNCTION(div)
187  FUNCTION_COEFFICIENTS(divCoefficients)
188 
189  //returns cell-centered divergence given normal velocities
190  FUNCTION(divNormal)
191 
192  // compute faceArea-weighted normal velocity from either cell-centered or
193  // face-centered input velocity (this is just an alias for contravariantVelocity)
194  FUNCTION(normalVelocity)
195 
196  FUNCTION(grad)
197  FUNCTION_COEFFICIENTS(gradCoefficients)
198 
199  FUNCTION(identity)
200  FUNCTION_COEFFICIENTS(identityCoefficients)
201 
202  FUNCTION(laplacian)
203  FUNCTION_COEFFICIENTS(laplacianCoefficients)
204 
205  FUNCTION(vorticity)
206 
207 #undef FUNCTION
208 #undef FUNCTION_COEFFICIENTS
209  // ******* derivatives in non-standard form ***********
210 
211  //compute (u.grad)w (convective derivative of passive variable(s))
213  const realGridCollectionFunction &u,
215  const Index & C1 = nullIndex,
216  const Index & C2 = nullIndex,
217  const Index & C3 = nullIndex
218  );
220  const realGridCollectionFunction &u,
221  const GridFunctionParameters & gfType,
223  const Index & C1 = nullIndex,
224  const Index & C2 = nullIndex,
225  const Index & C3 = nullIndex
226  );
227 
228 // Macro to define a typical function call
229 #define SCALAR_FUNCTION(type) \
230  virtual realGridCollectionFunction type(const realGridCollectionFunction & u, \
231  const realGridCollectionFunction & s, \
232  const Index & C1 = nullIndex, \
233  const Index & C2 = nullIndex, \
234  const Index & C3 = nullIndex, \
235  const Index & C4 = nullIndex ); \
236  virtual realGridCollectionFunction type(const realGridCollectionFunction & u, \
237  const GridFunctionParameters & gfType, \
238  const realGridCollectionFunction & s, \
239  const Index & C1 = nullIndex, \
240  const Index & C2 = nullIndex, \
241  const Index & C3 = nullIndex, \
242  const Index & C4 = nullIndex );
243 
244 
245 #define SCALAR_FUNCTION_COEFFICIENTS(type) \
246  virtual realGridCollectionFunction type(const realGridCollectionFunction & s, \
247  const Index & C0 = nullIndex, \
248  const Index & C1 = nullIndex, \
249  const Index & C2 = nullIndex, \
250  const Index & C3 = nullIndex ); \
251  \
252  virtual realGridCollectionFunction type(const GridFunctionParameters & gfType, \
253  const realGridCollectionFunction & s, \
254  const Index & C0 = nullIndex, \
255  const Index & C1 = nullIndex, \
256  const Index & C2 = nullIndex, \
257  const Index & C3 = nullIndex );
258 
259 
260  // div(s grad(u)), s=scalar field
261  SCALAR_FUNCTION(divScalarGrad)
262  SCALAR_FUNCTION_COEFFICIENTS(divScalarGradCoefficients)
263 
264  SCALAR_FUNCTION(divInverseScalarGrad)
265  SCALAR_FUNCTION_COEFFICIENTS(divInverseScalarGradCoefficients)
266 
267  SCALAR_FUNCTION(scalarGrad)
268  SCALAR_FUNCTION_COEFFICIENTS(scalarGradCoefficients)
269 
270  SCALAR_FUNCTION(divVectorScalar)
271  SCALAR_FUNCTION_COEFFICIENTS(divVectorScalarCoefficients)
272 
273 
274 #undef SCALAR_FUNCTION
275 #undef SCALAR_FUNCTION_COEFFICIENTS
276 
277 
279  const realGridCollectionFunction & s,
280  const int & direction1,
281  const int & direction2,
282  const Index & C1 = nullIndex,
283  const Index & C2 = nullIndex,
284  const Index & C3 = nullIndex,
285  const Index & C4 = nullIndex );
287  const GridFunctionParameters & gfType,
288  const realGridCollectionFunction & s,
289  const int & direction1,
290  const int & direction2,
291  const Index & C1 = nullIndex,
292  const Index & C2 = nullIndex,
293  const Index & C3 = nullIndex,
294  const Index & C4 = nullIndex );
295 
296 
298  const int & direction1,
299  const int & direction2,
300  const Index & C0 = nullIndex,
301  const Index & C1 = nullIndex,
302  const Index & C2 = nullIndex,
303  const Index & C3 = nullIndex );
304 
306  const realGridCollectionFunction & s,
307  const int & direction1,
308  const int & direction2,
309  const Index & C0 = nullIndex,
310  const Index & C1 = nullIndex,
311  const Index & C2 = nullIndex,
312  const Index & C3 = nullIndex );
313 
314 
315  //returns face-centered gradients
317  const int c0 = 0,
318  const int c1 = 0,
319  const int c2 = 0,
320  const int c3 = 0,
321  const int c4 = 0
322  );
324  const GridFunctionParameters & gfType,
325  const int c0 = 0,
326  const int c1 = 0,
327  const int c2 = 0,
328  const int c3 = 0,
329  const int c4 = 0
330  );
331 
332 
333 
334  // ********************************************************************
335  // ------------- Here we define the Boundary Conditions ---------------
336  // ********************************************************************
337 
338  public:
339 
341  const real & time = 0.,
342  const int & grid =forAll);
343  // fill in coefficients for the boundary conditions
345  const real & time = 0.,
346  const int & grid =forAll);
347 
348 
349  // new BC interface:
351  const Index & Components,
352  const BCTypes::BCNames & boundaryConditionType=BCTypes::dirichlet,
353  const int & boundaryCondition = BCTypes::allBoundaries,
354  const real & forcing = 0.,
355  const real & time = 0.,
356  const BoundaryConditionParameters & bcParameters
358 
359 
361  const Index & Components,
362  const BCTypes::BCNames & boundaryConditionType,
363  const int & boundaryCondition,
364  const RealArray & forcing,
365  const real & time = 0.,
366  const BoundaryConditionParameters & bcParameters
368 
370  const Index & Components,
371  const BCTypes::BCNames & boundaryConditionType,
372  const int & boundaryCondition,
373  const realGridCollectionFunction & forcing,
374  const real & time = 0.,
375  const BoundaryConditionParameters & bcParameters
377 
378 #ifdef USE_PPP
379 // virtual void applyBoundaryCondition(realGridCollectionFunction & u,
380 // const Index & Components,
381 // const BCTypes::BCNames & boundaryConditionType,
382 // const int & boundaryCondition,
383 // const RealDistributedArray & forcing,
384 // const real & time = 0.,
385 // const BoundaryConditionParameters & bcParameters
386 // = Overture::defaultBoundaryConditionParameters());
387 #endif
388  // fix corners and periodic update:
389  virtual void finishBoundaryConditions
392  const Range & C0=nullRange,
393  const IntegerArray & gridsToUpdate = Overture::nullIntArray() );
394 
395  // fill in the BC's for a coefficient grid function
397  const Index & Equations,
398  const Index & Components,
399  const BCTypes::BCNames & boundaryConditionType=BCTypes::dirichlet,
400  const int & boundaryCondition= BCTypes::allBoundaries,
401  const BoundaryConditionParameters & bcParameters
403  protected:
404 
405 // this next function is only found in GenericCompositeGridOperators:
406 #ifdef COMPOSITE_GRID_OPERATORS
407  void getInterpolationCoefficients(realCompositeGridFunction & coeff,
408  const IntegerArray & gridsToUpdate = Overture::nullIntArray() );
409 #endif
410 
411 #undef COMPOSITE_GRID_OPERATORS
412 
414 
415  Index I1,I2,I3;
416  // realGridCollectionFunction result; // derivative is returned in this grid function
418  GenericMappedGridOperators *mappedGridOperatorsPointer; // pointer to an MappedGridOperators object
419  // (this may point to a derived class object)
422 
423  void setup();
424 
425 };
426 
427 
428 
429 
430 
431 
432 #endif