Overture  Version 25
doubleCompositeGridFunction.h
Go to the documentation of this file.
1 /* -*-Mode: c++; -*- */
2 #ifndef DOUBLECOMPOSITEGRIDFUNCTION
3 #define DOUBLECOMPOSITEGRIDFUNCTION
4 
7 
8 class CompositeGrid; // forward declaration
9 class CompositeGridData; // forward declaration
10 class Interpolant; // forward declaration
11 class GridCollectionOperators; // forward declaration
14 
15 
16 //===================================================================
17 // doubleCompositeGridFunction
18 //
19 // Define a grid function to be used with a composite grid.
20 // This class contains a list of doubleMappedGridFunction's
21 // and a CompositeGrid
22 //
23 // This is a reference counted class so that there is no need
24 // to keep a pointer to a grid function. Use the reference
25 // member function to make one grid function reference another.
26 //
27 // Usage:
28 // CompositeGrid cg(...); // here is a composite grid
29 // doubleCompositeGridFunction u(cg),v;
30 // u[0]=5.; // mapped grid function for grid 0
31 // Index I(0,10);
32 // u[1](I,I)=3.; // mapped grid function for grid 1
33 // v.reference(u); // v is referenced to u
34 // v[1]=7.; // changes u as well
35 // v.breakReference(); // v is no longer referenced to u
36 // ...
37 //
38 //==================================================================
39 
41 {
42  public:
43 
45  // This constructor takes ranges, the first 3 "nullRange" values are taken to be the
46  // coordinate directions in the grid function.
48  const Range & R0,
49  const Range & R1=nullRange,
50  const Range & R2=nullRange,
51  const Range & R3=nullRange,
52  const Range & R4=nullRange,
53  const Range & R5=nullRange,
54  const Range & R6=nullRange,
55  const Range & R7=nullRange );
56 
58  const Range & R0,
59  const Range & R1=nullRange,
60  const Range & R2=nullRange,
61  const Range & R3=nullRange,
62  const Range & R4=nullRange,
63  const Range & R5=nullRange,
64  const Range & R6=nullRange,
65  const Range & R7=nullRange );
66 
68  const int & i0,
69  const Range & R1=nullRange,
70  const Range & R2=nullRange,
71  const Range & R3=nullRange,
72  const Range & R4=nullRange,
73  const Range & R5=nullRange,
74  const Range & R6=nullRange,
75  const Range & R7=nullRange );
76 
78  const int & i0,
79  const Range & R1=nullRange,
80  const Range & R2=nullRange,
81  const Range & R3=nullRange,
82  const Range & R4=nullRange,
83  const Range & R5=nullRange,
84  const Range & R6=nullRange,
85  const Range & R7=nullRange );
86 
87  //
88  // This constructor takes a GridFunctionType
89  //
92  const Range & Component0=nullRange, // defaults to Range(0,0)
93  const Range & Component1=nullRange,
94  const Range & Component2=nullRange,
95  const Range & Component3=nullRange,
96  const Range & Component4=nullRange );
97 
100 
103 
105 
106  // A derived class must define the = operators
109 
110  // Return a link to some specfied components
111  doubleCompositeGridFunction operator()(const Range & component0,
112  const Range & component1=nullRange,
113  const Range & component2=nullRange,
114  const Range & component3=nullRange,
115  const Range & component4=nullRange );
116 
117 
118  CompositeGridOperators* getOperators() const; // return a pointer to the operators
120 
121  Interpolant* getInterpolant(const bool abortIfNull =TRUE ) const; // return a pointer to the Interpolant
122 
123  virtual aString getClassName() const;
124 
125  CompositeGrid* getCompositeGrid(const bool abortIfNull=TRUE) const; // return a pointer to the CompositeGrid
126 
127  void link(const doubleCompositeGridFunction & gcf,
128  const Range & R0,
129  const Range & R1=nullRange,
130  const Range & R2=nullRange,
131  const Range & R3=nullRange,
132  const Range & R4=nullRange );
133 
134  void link(const doubleGridCollectionFunction & gcf, // *New*
135  const Range & R0,
136  const Range & R1=nullRange,
137  const Range & R2=nullRange,
138  const Range & R3=nullRange,
139  const Range & R4=nullRange );
140 
141  virtual void link(const doubleCompositeGridFunction & gcf,
142  const int componentToLinkTo=0,
143  const int numberOfComponents=1 );
144 
145  virtual void link(const doubleGridCollectionFunction & gcf,
146  const int componentToLinkTo=0,
147  const int numberOfComponents=1 );
148 
149  void reference( const doubleCompositeGridFunction & cgf );
150  void reference( const doubleGridCollectionFunction & cgf ); // *new*
151 
152  virtual void setIsACoefficientMatrix(const bool trueOrFalse=TRUE,
153  const int stencilSize=defaultValue,
154  const int numberOfGhostLines=1,
155  const int numberOfComponentsForCoefficients=1,
156  const int offset=0 );
157 
158  // return size of this object
159  virtual real sizeOf(FILE *file = NULL ) const;
160 
161  // define all the update functions
164  const Range & R0,
165  const Range & R1=nullRange,
166  const Range & R2=nullRange,
167  const Range & R3=nullRange,
168  const Range & R4=nullRange,
169  const Range & R5=nullRange,
170  const Range & R6=nullRange,
171  const Range & R7=nullRange );
172 
173  updateReturnValue updateToMatchGrid(CompositeGrid & grid,
174  const Range & R0,
175  const Range & R1=nullRange,
176  const Range & R2=nullRange,
177  const Range & R3=nullRange,
178  const Range & R4=nullRange,
179  const Range & R5=nullRange,
180  const Range & R6=nullRange,
181  const Range & R7=nullRange );
182 
183  // define this version to avoid overloading ambiguities
184  updateReturnValue updateToMatchGrid(CompositeGrid & grid,
185  const int & i0,
186  const Range & R1=nullRange,
187  const Range & R2=nullRange,
188  const Range & R3=nullRange,
189  const Range & R4=nullRange,
190  const Range & R5=nullRange,
191  const Range & R6=nullRange,
192  const Range & R7=nullRange );
193 
194  updateReturnValue updateToMatchGrid(const Range & R0,
195  const Range & R1=nullRange,
196  const Range & R2=nullRange,
197  const Range & R3=nullRange,
198  const Range & R4=nullRange,
199  const Range & R5=nullRange,
200  const Range & R6=nullRange,
201  const Range & R7=nullRange );
202 
203  updateReturnValue updateToMatchGrid(CompositeGrid & grid,
205  const Range & component0,
206  const Range & component1=nullRange,
207  const Range & component2=nullRange,
208  const Range & component3=nullRange,
209  const Range & component4=nullRange );
210 
212  const Range & component0,
213  const Range & component1=nullRange,
214  const Range & component2=nullRange,
215  const Range & component3=nullRange,
216  const Range & component4=nullRange );
217  updateReturnValue updateToMatchGrid(CompositeGrid & grid,
220 
221 
222  updateReturnValue updateToMatchGrid(CompositeGrid & grid);
224 
225 
226  // update this grid function to match another grid function
228  const Range & R0,
229  const Range & R1=nullRange,
230  const Range & R2=nullRange,
231  const Range & R3=nullRange,
232  const Range & R4=nullRange,
233  const Range & R5=nullRange,
234  const Range & R6=nullRange,
235  const Range & R7=nullRange );
236 
238 
239  // make sure the number of mappedGridFunction's is correct
241 
242 
243  // Collections of grid functions having the same base grid.
244  ListOfDoubleCompositeGridFunction baseGrid; // overloads one base class
245 
246  // Collections of grid functions having the same multigrid level.
248 
249  // Collections of grid functions having the same refinement level.
251 
252 
253  int interpolate(Interpolant & interpolant,
254  const Range & C0 = nullRange,
255  const Range & C1 = nullRange,
256  const Range & C2 = nullRange );
257  int interpolate(const Range & C0 = nullRange,
258  const Range & C1 = nullRange,
259  const Range & C2 = nullRange );
260 
262 
263  // use this function to "evaulate and expression" when calling a function with an expression
264  // involving grid collection functions.
266 
267 #define COLLECTION_FUNCTION doubleCompositeGridFunction
268 #define INT_COLLECTION_FUNCTION intCompositeGridFunction
269 #define COLLECTION CompositeGrid
270 #define INTEGRAL_TYPE double
271 #include "derivativeDefinitions.h"
272 #undef COLLECTION_FUNCTION
273 #undef INT_COLLECTION_FUNCTION
274 #undef COLLECTION
275 #undef INTEGRAL_TYPE
276 
277  // These are needed to avoid compiler warnings
279  const Range & R0,
280  const Range & R1=nullRange,
281  const Range & R2=nullRange,
282  const Range & R3=nullRange,
283  const Range & R4=nullRange,
284  const Range & R5=nullRange,
285  const Range & R6=nullRange,
286  const Range & R7=nullRange );
287 
289  const Range & R0,
290  const Range & R1=nullRange,
291  const Range & R2=nullRange,
292  const Range & R3=nullRange,
293  const Range & R4=nullRange,
294  const Range & R5=nullRange,
295  const Range & R6=nullRange,
296  const Range & R7=nullRange );
297 
299  const int & i0,
300  const Range & R1=nullRange,
301  const Range & R2=nullRange,
302  const Range & R3=nullRange,
303  const Range & R4=nullRange,
304  const Range & R5=nullRange,
305  const Range & R6=nullRange,
306  const Range & R7=nullRange );
307 
308 
311  const Range & component0,
312  const Range & component1=nullRange,
313  const Range & component2=nullRange,
314  const Range & component3=nullRange,
315  const Range & component4=nullRange );
316 
319 
322 
323 
324  // update this grid function to match another grid function
326  const Range & R0,
327  const Range & R1=nullRange,
328  const Range & R2=nullRange,
329  const Range & R3=nullRange,
330  const Range & R4=nullRange,
331  const Range & R5=nullRange,
332  const Range & R6=nullRange,
333  const Range & R7=nullRange );
334 
335 
337 
338  // make sure the number of mappedGridFunction's is correct
340 
341 
342  protected:
343  void updateReferences();
344  int updateCollections(); // update refinementLevel etc.
345 
346  private:
347 
348  // These are used by list's of ReferenceCounting objects
349  virtual void reference( const ReferenceCounting & mgf )
351  virtual ReferenceCounting & operator=( const ReferenceCounting & mgf )
353  virtual ReferenceCounting* virtualConstructor( const CopyType ct = DEEP ) const
354  { return ::new doubleCompositeGridFunction(*this,ct); }
355 
356  aString className;
357 
358 };
359 
360 
361 
362 #endif