Overture  Version 25
InterpolatePointsOnAGrid.h
Go to the documentation of this file.
1 #ifndef INTERPOLATE_POINTS_ONAGRID_H
2 #define INTERPOLATE_POINTS_ONAGRID_H
3 
4 // -----------------------------------------------------------------------------
5 // This class can be used to interpolate arbitrary points on a Composite grid.
6 // *new* parallel version
7 // -----------------------------------------------------------------------------
8 
9 // class ParallelOverlappingGridInterpolatePoints; // forward declaration
10 
11 #include "SparseArray.h"
12 // class SparseArray; // forward declaration
13 
15 {
16 public:
17 
19 {
23 };
24 
25 enum
26 {
29 };
30 
32 {
33  precomputeAllCoefficients, // requires w^d coefficients per interp pt (w=width of interp stencil)
34  precomputeSomeCoefficients, // requires w*d coefficients per interp pt (d=dimension, 1,2, or 3)
35  precomputeNoCoefficients // requires d coefficients per interp point
36 };
37 
38 
40 {
43 };
44 
45 
48 
49 // This function will find the nearest valid (mask!=0) grid point on a CompositeGrid
50 static int findNearestValidGridPoint( CompositeGrid & cg, const RealArray & x, IntegerArray & il, RealArray & ci );
51 
53 
54 // These functions return info about the last interpolation operation
56 int getNumberExtrapolated() const;
57 int getNumberInterpolated() const;
58 int getNumberUnassigned() const;
59 
60 
61 // Utility function to compute the lower left index in the interpolation stencil
62 static int getInterpolationStencil( MappedGrid & mg, const int width, const real *rv, int *iv );
63 
64 // return the total number of points that are assigned from a grid
65 int getTotalNumberOfPointsAssigned( int grid );
66 
67 // Interpolate points : The first time this function is called the interpolation schedule will be generated.
68 int interpolatePoints(const RealArray & positionToInterpolate,
69  const realCompositeGridFunction & u,
70  RealArray & uInterpolated,
71  const Range & R0=nullRange,
72  const Range & R1=nullRange,
73  const Range & R2=nullRange,
74  const Range & R3=nullRange,
75  const Range & R4=nullRange );
76 
78  RealArray & uInterpolationCoeff);
79 
82  const Range & componentsFrom=nullRange,
83  const Range & componentsTo=nullRange,
84  const int numberOfGhostPointsToInterpolate=interpolateAllGhostPoints );
85 
88  const Range & componentsFrom=nullRange,
89  const Range & componentsTo=nullRange,
90  const int numberOfGhostPointsToInterpolate=interpolateAllGhostPoints );
91 
92 
93 // Here is a way to interpolate in two steps, this will save the interpolation info
94 int buildInterpolationInfo(const RealArray & positionToInterpolate,CompositeGrid & cg,
95  RealArray *projectedPoints=NULL,
96  IntegerArray *checkTheseGrids=NULL );
98  RealArray & uInterpolated,
99  const Range & R0=nullRange,
100  const Range & R1=nullRange,
101  const Range & R2=nullRange,
102  const Range & R3=nullRange,
103  const Range & R4=nullRange );
104 
105 // return the status array for the last interpolation.
106 const IntegerArray & getStatus() const;
107 
108 // return the index values and interpoleeGrid for the last interpolation.
109 int getInterpolationInfo(CompositeGrid & cg, IntegerArray & indexValues, IntegerArray & interpoleeGrid) const;
110 
111 // Indicate whether all points should be assigned, using extrapolation if necessary
112 int setAssignAllPoints( bool trueOrFalse=true );
113 
114 // return size of this object
115 real sizeOf(FILE *file = NULL ) const;
116 
118 
119 // flag for specfying what information messages should be printed:
120 int setInfoLevel( int info );
121 
122 // Set the width the interpolation stencil.
123 int setInterpolationWidth( int width );
124 
125 // Set the offset in grid lines from the unit cube where we are allowed to interpolate
126 int setInterpolationOffset( real widthInGridLines );
127 
128 // Specify whether to use implicit or explicit interpolation
130 
131 int setMaximumRefinementLevelToInterpolate(int maxLevelToInterpolate );
132 
133 // Set the number of valid ghost points that can be used when interpolating from a grid function
135 
136 static int debug;
137 
138 protected:
139 
140 friend class InterfaceTransfer;
141 
142 int parallelInterpolate( RealArray & ui, // save results here
143  const realCompositeGridFunction & u, // interpolate from this grid function.
144  const Range & C0 = nullRange, // optionally specify components to interpolate
145  const Range & C1 = nullRange,
146  const Range & C2 = nullRange );
147 
148 // Setup routine that creates the parallel communication schedule for interpolation a list of points
149 int parallelSetup( CompositeGrid & cg,
150  const RealArray & xp,
153  const IntegerArray *indirection,
156 
157 int interpolationIsInitialized; // this is set to true when the interpolation has been initialized.
158 
163 
168 
171 
172 real interpolationOffset; // offset in grid lines from the unit cube where we are allowed to interpolate
173 
174 int interpolationWidth; // width of the interpolation stencil.
175 InterpolationTypeEnum interpolationType; // explicit or implicit interpolation
176 int infoLevel; // flag for specifying what information messages should be printed.
178 
179 bool assignAllPoints; // if true assign all points using extrapolation if necessary
180 
181 // For interpolateAll:
185 
186 // ParallelOverlappingGridInterpolatePoints *pogip; // for parallel interpolation of points
187 
188 
189 FILE *logFile,*plogFile; // log file to save info for users (plogFile = log file for a given processor)
190 
191 // -- replace the next by plogFile:
192 FILE *debugFile;
193 
195 
197 
198 // Here is the routine that actually performs the interpolation in serial
199 int internalInterpolate( RealArray & ui, // save results here
200  const realCompositeGridFunction & u, // interpolate from this grid function.
201  const Range & C0,
202  const Range & C1,
203  const Range & C2 );
204 
205 // Here is the routine that actually performs the interpolation in parallel
206 int parallelInternalInterpolate( RealArray & ui, // save results here
207  const realCompositeGridFunction & u, // interpolate from this grid function.
208  const Range & C0,
209  const Range & C1,
210  const Range & C2 );
211 
212 // destroy all data
213 int destroy();
214 
215 // put this here for now:
216 // static int checkCanInterpolate(CompositeGrid & cg ,
217 // int grid, int donor, RealArray & r, IntegerArray & interpolates,
218 // IntegerArray & useBackupRules );
219 
222 int coeffWidthDimension; // dimension of the 2nd component of coeff
224 
225 // Store interp data in sparse arrays:
229 
230 int npr,nps;
231 int *pMapr, *pMaps;
232 
234 
235 #ifdef USE_PPP
236  MPI_Comm POGI_COMM; // Communicator for the parallel interpolator
237 #else
239 #endif
240 
241 };
242 
243 #endif