Overture  Version 25
derivativeDefinitions.h
Go to the documentation of this file.
1 // define the keyword COLLECTION_FUNCTION to be GridCollectionFunction or CompositeGridFunction
2 // define the keyword INT_COLLECTION_FUNCTION to be intGridCollectionFunction or intCompositeGridFunction
3 // define the keyword INTEGRAL_TYPE to be one of int, float double
4 
5 
6  // define a few useful operators
10  COLLECTION_FUNCTION & operator/ ( const COLLECTION_FUNCTION & cgf ) const;
15 
18 
20  COLLECTION_FUNCTION & operator+ ( const INTEGRAL_TYPE value ) const;
21  COLLECTION_FUNCTION & operator- ( const INTEGRAL_TYPE value ) const;
22  COLLECTION_FUNCTION & operator* ( const INTEGRAL_TYPE value ) const;
23  COLLECTION_FUNCTION & operator/ ( const INTEGRAL_TYPE value ) const;
28 
29  // comparison operators return an intGridCollectionFunction
36 
37  friend COLLECTION_FUNCTION & operator+ (const INTEGRAL_TYPE value, const COLLECTION_FUNCTION & cgf);
38  friend COLLECTION_FUNCTION & operator- (const INTEGRAL_TYPE value, const COLLECTION_FUNCTION & cgf);
39  friend COLLECTION_FUNCTION & operator* (const INTEGRAL_TYPE value, const COLLECTION_FUNCTION & cgf);
40  friend COLLECTION_FUNCTION & operator/ (const INTEGRAL_TYPE value, const COLLECTION_FUNCTION & cgf);
41 
42 
43  friend INTEGRAL_TYPE max( const COLLECTION_FUNCTION & cgf );
44  friend INTEGRAL_TYPE min( const COLLECTION_FUNCTION & cgf );
45 
46 
47 // Now define derivative functions for gridCollectionFunction and compositeGridFunctions
48 
49 private:
50  void derivativeError() const;
51  void boundaryConditionError() const;
52 
53 public:
54 
55 
56 // Macro to define a typical function call
57 #define FUNCTION(type) \
58 COLLECTION_FUNCTION type(\
59  const Index & C1 = nullIndex, \
60  const Index & C2 = nullIndex, \
61  const Index & C3 = nullIndex, \
62  const Index & C4 = nullIndex, \
63  const Index & C5 = nullIndex ) const; \
64 COLLECTION_FUNCTION type(\
65  const GridFunctionParameters & gfType, \
66  const Index & C1 = nullIndex, \
67  const Index & C2 = nullIndex, \
68  const Index & C3 = nullIndex, \
69  const Index & C4 = nullIndex, \
70  const Index & C5 = nullIndex ) const;
71 
72 
73 #define FUNCTION_COEFFICIENTS(type) \
74  COLLECTION_FUNCTION type(const Index & C0 = nullIndex, \
75  const Index & C1 = nullIndex, \
76  const Index & C2 = nullIndex, \
77  const Index & C3 = nullIndex ) const; \
78  COLLECTION_FUNCTION type(const GridFunctionParameters & gfType, \
79  const Index & C0 = nullIndex, \
80  const Index & C1 = nullIndex, \
81  const Index & C2 = nullIndex, \
82  const Index & C3 = nullIndex ) const;
83 
84 
85 
86  // parametric derivatives in the r1,r2,r3 directions
87  FUNCTION(r1)
88  FUNCTION_COEFFICIENTS(r1Coefficients)
89  FUNCTION(r2)
90  FUNCTION_COEFFICIENTS(r2Coefficients)
91  FUNCTION(r3)
92  FUNCTION_COEFFICIENTS(r3Coefficients)
93  FUNCTION(r1r1)
94  FUNCTION_COEFFICIENTS(r1r1Coefficients)
95  FUNCTION(r1r2)
96  FUNCTION_COEFFICIENTS(r1r2Coefficients)
97  FUNCTION(r1r3)
98  FUNCTION_COEFFICIENTS(r1r3Coefficients)
99  FUNCTION(r2r2)
100  FUNCTION_COEFFICIENTS(r2r2Coefficients)
101  FUNCTION(r2r3)
102  FUNCTION_COEFFICIENTS(r2r3Coefficients)
103  FUNCTION(r3r3)
104  FUNCTION_COEFFICIENTS(r3r3Coefficients)
105 
106  // FUNCTIONs in the x,y,z directions
107  FUNCTION(x)
108  FUNCTION_COEFFICIENTS(xCoefficients)
109  FUNCTION(y)
110  FUNCTION_COEFFICIENTS(yCoefficients)
111  FUNCTION(z)
112  FUNCTION_COEFFICIENTS(zCoefficients)
113  FUNCTION(xx)
114  FUNCTION_COEFFICIENTS(xxCoefficients)
115  FUNCTION(xy)
116  FUNCTION_COEFFICIENTS(xyCoefficients)
117  FUNCTION(xz)
118  FUNCTION_COEFFICIENTS(xzCoefficients)
119  FUNCTION(yy)
120  FUNCTION_COEFFICIENTS(yyCoefficients)
121  FUNCTION(yz)
122  FUNCTION_COEFFICIENTS(yzCoefficients)
123  FUNCTION(zz)
124  FUNCTION_COEFFICIENTS(zzCoefficients)
125 
126  // other forms of derivatives
127 
128  // compute face-centered variable from cell-centered variable
129  FUNCTION(cellsToFaces)
130 
131  //compute (u.grad)u (convective derivative)
133 
134  // compute contravariant velocity from either cell-centered or face-centered input velocity
135  FUNCTION(contravariantVelocity)
136 
137  FUNCTION(div)
138  FUNCTION_COEFFICIENTS(divCoefficients)
139 
140  //returns cell-centered divergence given normal velocities
141  FUNCTION(divNormal)
142 
143  // compute faceArea-weighted normal velocity from either cell-centered or
144  // face-centered input velocity (this is just an alias for contravariantVelocity)
145  FUNCTION(normalVelocity)
146 
147  FUNCTION(grad)
148  FUNCTION_COEFFICIENTS(gradCoefficients)
149 
150  FUNCTION(identity)
151  FUNCTION_COEFFICIENTS(identityCoefficients)
152 
153  FUNCTION(laplacian)
154  FUNCTION_COEFFICIENTS(laplacianCoefficients)
155 
156  FUNCTION(vorticity)
157 
158 #undef FUNCTION
159 #undef FUNCTION_COEFFICIENTS
160  // ******* derivatives in non-standard form ***********
161 
162  //compute (u.grad)w (convective derivative of passive variable(s))
164  const Index & C1 = nullIndex,
165  const Index & C2 = nullIndex,
166  const Index & C3 = nullIndex
167  ) const;
168 
170  const COLLECTION_FUNCTION &w,
171  const Index & C1 = nullIndex,
172  const Index & C2 = nullIndex,
173  const Index & C3 = nullIndex
174  ) const;
175 
176 #define SCALAR_FUNCTION(type) \
177 COLLECTION_FUNCTION type(\
178  const COLLECTION_FUNCTION & s, \
179  const Index & C1 = nullIndex, \
180  const Index & C2 = nullIndex, \
181  const Index & C3 = nullIndex, \
182  const Index & C4 = nullIndex ) const; \
183 COLLECTION_FUNCTION type(\
184  const GridFunctionParameters & gfType, \
185  const COLLECTION_FUNCTION & s, \
186  const Index & C1 = nullIndex, \
187  const Index & C2 = nullIndex, \
188  const Index & C3 = nullIndex, \
189  const Index & C4 = nullIndex ) const;
190 
191 #define SCALAR_FUNCTION_COEFFICIENTS(type) \
192  COLLECTION_FUNCTION type(const COLLECTION_FUNCTION & s, \
193  const Index & C0 = nullIndex, \
194  const Index & C1 = nullIndex, \
195  const Index & C2 = nullIndex, \
196  const Index & C3 = nullIndex ) const; \
197  COLLECTION_FUNCTION type(const GridFunctionParameters & gfType, \
198  const COLLECTION_FUNCTION & s, \
199  const Index & C0 = nullIndex, \
200  const Index & C1 = nullIndex, \
201  const Index & C2 = nullIndex, \
202  const Index & C3 = nullIndex ) const;
203 
204 
205 
206  // div(s grad(u)), s=scalar field
207  SCALAR_FUNCTION(divScalarGrad)
208  SCALAR_FUNCTION_COEFFICIENTS(divScalarGradCoefficients)
209 
210  SCALAR_FUNCTION(divInverseScalarGrad)
211  SCALAR_FUNCTION_COEFFICIENTS(divInverseScalarGradCoefficients)
212 
213  SCALAR_FUNCTION(scalarGrad)
214  SCALAR_FUNCTION_COEFFICIENTS(scalarGradCoefficients)
215 
216  SCALAR_FUNCTION(divVectorScalar)
217  SCALAR_FUNCTION_COEFFICIENTS(divVectorScalarCoefficients)
218 
219 #undef SCALAR_FUNCTION
220 #undef SCALAR_FUNCTION_COEFFICIENTS
221 
223  const COLLECTION_FUNCTION & s,
224  const int & direction1,
225  const int & direction2,
226  const Index & C1 = nullIndex,
227  const Index & C2 = nullIndex,
228  const Index & C3 = nullIndex,
229  const Index & C4 = nullIndex ) const;
231  const GridFunctionParameters & gfType,
232  const COLLECTION_FUNCTION & s,
233  const int & direction1,
234  const int & direction2,
235  const Index & C1 = nullIndex,
236  const Index & C2 = nullIndex,
237  const Index & C3 = nullIndex,
238  const Index & C4 = nullIndex ) const;
239 
241  const int & direction1,
242  const int & direction2,
243  const Index & C0 = nullIndex,
244  const Index & C1 = nullIndex,
245  const Index & C2 = nullIndex,
246  const Index & C3 = nullIndex ) const;
247 
249  const COLLECTION_FUNCTION & s,
250  const int & direction1,
251  const int & direction2,
252  const Index & C0 = nullIndex,
253  const Index & C1 = nullIndex,
254  const Index & C2 = nullIndex,
255  const Index & C3 = nullIndex ) const;
256 
257 
258 
259 
260 
261  //returns face-centered gradients
263  const int c0 = 0,
264  const int c1 = 0,
265  const int c2 = 0,
266  const int c3 = 0,
267  const int c4 = 0
268  ) const;
270  const int c0 = 0,
271  const int c1 = 0,
272  const int c2 = 0,
273  const int c3 = 0,
274  const int c4 = 0
275  ) const;
276 
277 
278 
279  // ********************************************************************
280  // ------------- Here we define the Boundary Conditions ---------------
281  // ********************************************************************
282 
284  const real & time = 0.,
285  const int & grid =forAll);
286  // fill in coefficients for the boundary conditions
288  const real & time = 0.,
289  const int & grid =forAll);
290  // new BC interface:
291  void applyBoundaryCondition(const Index & Components,
292  const BCTypes::BCNames & boundaryConditionType=BCTypes::dirichlet,
293  const int & boundaryCondition = BCTypes::allBoundaries,
294  const real & forcing = 0.,
295  const real & time = 0.,
296  const BoundaryConditionParameters & bcParameters
298 
299 
300  void applyBoundaryCondition(const Index & Components,
301  const BCTypes::BCNames & boundaryConditionType,
302  const int & boundaryCondition,
303  const RealArray & forcing,
304  const real & time = 0.,
305  const BoundaryConditionParameters & bcParameters
307 
308  void applyBoundaryCondition(const Index & Components,
309  const BCTypes::BCNames & boundaryConditionType,
310  const int & boundaryCondition,
311  const COLLECTION_FUNCTION & forcing,
312  const real & time = 0.,
313  const BoundaryConditionParameters & bcParameters
315 
316 #ifdef USE_PPP
317 // void applyBoundaryCondition(const Index & Components,
318 // const BCTypes::BCNames & boundaryConditionType,
319 // const int & boundaryCondition,
320 // const RealDistributedArray & forcing,
321 // const real & time = 0.,
322 // const BoundaryConditionParameters & bcParameters
323 // = Overture::defaultBoundaryConditionParameters());
324 
325 #endif
326  // fix corners and periodic update:
328  const Range & C0=nullRange,
329  const IntegerArray & gridsToUpdate = Overture::nullIntArray());
330 
331  void applyBoundaryConditionCoefficients(const Index & Equation,
332  const Index & Components,
333  const BCTypes::BCNames & boundaryConditionType=BCTypes::dirichlet,
334  const int & boundaryCondition = BCTypes::allBoundaries,
335  const BoundaryConditionParameters & bcParameters
337