Overture  Version 25
HyperbolicMapping.h
Go to the documentation of this file.
1 #ifndef HYPERBOLIC_MAPPING_H
2 #define HYPERBOLIC_MAPPING_H
3 
4 #include "Mapping.h"
6 #include "DataPointMapping.h"
8 
9 #ifndef OV_USE_OLD_STL_HEADERS
10 #include <vector>
12 #else
13 #include <vector.h>
14 #endif
15 
16 class TridiagonalSolver;
17 class DialogData;
18 class MatchingCurve;
19 
20 //----------------------------------------------------------------------
21 // Define a Mapping by Hyperbolic grid generation.
22 //----------------------------------------------------------------------
23 class HyperbolicMapping : public Mapping
24 {
25 public:
26 
28 {
42  THEtargetGridSpacing, // tangential directions
43  THEinitialGridSpacing, // initial grid spacing in marching direction for volume grids
46  THEgeometricFactor, // geometric spacing ratio
49 };
50 
52 {
56 };
57 
58 
60 {
66 };
67 
69 {
89 };
90 
92 
94 {
100 };
101 
103 
105 {
111 };
112 
114 {
124 } pickingOption;
125 
127 {
132 } bcOption;
133 
135 {
137 };
138 
139 
141 {
145 } spacingOption;
146 
147 
149 
150 // Copy constructor is deep by default
151 HyperbolicMapping( const HyperbolicMapping &, const CopyType copyType=DEEP );
152 HyperbolicMapping(Mapping & surface_);
153 // for a surface grid:
154 HyperbolicMapping(Mapping & surface_, Mapping & startingCurve);
155 
157 
159 
160 bool isDefined() const; // return true if the Mapping has been defined.
161 
162 virtual void display( const aString & label=blankString) const;
163 void estimateMarchingParameters( real & estimatedDistanceToMarch,
164  int & estimatedLinesToMarch,
165  int directionToMarch,
167 int getBoundaryCurves( int & numberOfBoundaryCurves_, Mapping **&boundaryCurves_ );
168 int setBoundaryCurves( const int & numberOfBoundaryCurves_, Mapping **boundaryCurves_ );
169 int addBoundaryCurves( const int & numberOfExtraBoundaryCurves, Mapping **extraBoundaryCurves );
171 int deleteBoundaryCurves(IntegerArray & curvesToDelete );
172 
173 // supply a mapping to match a boundary condition to.
174 int setBoundaryConditionMapping(const int & side,
175  const int & axis,
176  Mapping & map,
177  const int & mapSide=-1,
178  const int & mapAxis=-1);
179 
180 // supply a curve/surface
181 int setSurface(Mapping & surface, bool isSurfaceGrid=true, bool init=true );
182 void setIsSurfaceGrid( bool trueOrFalse );
183 
184 // supply a starting curve for a surface grid
185 int setStartingCurve(Mapping & startingCurve, bool init=true );
186 
187 int setParameters(const HyperbolicParameter & par,
188  real value,
189  const Direction & direction = bothDirections );
190 
191 int setParameters(const HyperbolicParameter & par,
192  int value,
193  const Direction & direction = bothDirections );
194 
195 int setParameters(const HyperbolicParameter & par,
196  const IntegerArray & ipar= Overture::nullIntArray(),
197  const RealArray & rpar = Overture::nullRealArray(),
198  const Direction & direction = bothDirections );
199 
200 // save the reference surface and starting curve when 'put' is called.
201 int saveReferenceSurfaceWhenPut(bool trueOrFalse = TRUE);
202 
203 int setPlotOption( PlotOptionEnum option, int value );
204 
205 int generateOld(); // uses hypegen
206 int generate(const int & numberOfAdditionalSteps = 0 );
207 int generateNew(const int & numberOfAdditionalSteps = 0 ); // same as above.
208 
209 virtual void useRobustInverse(const bool trueOrFalse=TRUE );
210 
211 virtual void map( const realArray & r, realArray & x, realArray & xr = Overture::nullRealDistributedArray(),
213 
214 virtual void basicInverse(const realArray & x,
215  realArray & r,
218 
219 
220 virtual void mapS( const RealArray & r, RealArray & x, RealArray &xr = Overture::nullRealArray(),
222 
223 virtual void basicInverseS(const RealArray & x,
224  RealArray & r,
227 
228 virtual int get( const GenericDataBase & dir, const aString & name); // get from a database file
229 virtual int put( GenericDataBase & dir, const aString & name) const; // put to a database file
230 
232 aString getClassName() const { return HyperbolicMapping::className; }
233 
234 int update( MappingInformation & mapInfo );
235 int update( MappingInformation & mapInfo,
236  const aString & command,
237  DialogData *interface =NULL ) ;
238 
239 const Mapping * getSurface() const { return surface; }
240 
241 const DataPointMapping* getDataPointMapping() const { return dpm; }
242 
243 protected:
244 
245 int buildMarchingParametersDialog(DialogData & marchingParametersDialog, aString bcChoices[]);
246 int assignMarchingParametersDialog(DialogData & marchingParametersDialog, aString bcChoices[] );
247 bool updateMarchingParameters(aString & answer, DialogData & marchingParametersDialog, aString bcChoices[],
248  MappingInformation & mapInfo );
249 
250 int buildPlotOptionsDialog(DialogData & plotOptionsDialog,
251  GraphicsParameters & parameters);
252 bool updatePlotOptions(aString & answer, DialogData & plotOptionsDialog,
253  MappingInformation & mapInfo,
254  GraphicsParameters & parameters,
255  GraphicsParameters & referenceSurfaceParameters );
256 
257 int buildSurfaceGridParametersDialog(DialogData & plotOptionsDialog);
258 
259 bool updateSurfaceGridParameters(aString & answer, DialogData & surfaceGridParametersDialog,
260  MappingInformation & mapInfo,
261  GraphicsParameters & referenceSurfaceParameters );
262 
266  DialogData & dialog,
267  bool checkSelection,
268  SelectionInfo & select,
269  MappingInformation & mapInfo );
270 
271 // int buildSmoothDialog(DialogData & smoothDialog );
272 // bool updateSmoothingOptions(aString & answer, DialogData & smoothDialog, MappingInformation & mapInfo );
273 // int smoothGrid();
274 
275 // int buildStretchDialog(DialogData & stretchDialog );
276 // bool updateStretchOptions(aString & answer, DialogData & dialog, MappingInformation & mapInfo );
277 
278 int buildMarchingSpacingDialog(DialogData & marchingSpacingDialog );
279 bool updateMarchingSpacingOptions(aString & answer, DialogData & dialog, MappingInformation & mapInfo );
280 
281 int buildStartCurveSpacingDialog(DialogData & stretchDialog );
282 bool updateStartCurveSpacingOptions(aString & answer, DialogData & dialog, MappingInformation & mapInfo );
283 
284 // old way:
285 bool updateOld(aString & answer,
286  MappingInformation & mapInfo,
287  GraphicsParameters & referenceSurfaceParameters );
288 
289 int initialize();
290 int setup();
291 int updateForInitialCurve(bool updateNumberOfGridLines = true );
292 
293 int setBoundaryConditionAndOffset(int side, int axis, int bc, int offset=-1 );
294 
296 int hypgen(GenericGraphicsInterface & gi, GraphicsParameters & parameters);
297 int smooth(GenericGraphicsInterface & gi, GraphicsParameters & parameters);
298 
299 int evaluateStartCurve( realArray & xStart );
300 
301 int initializeMarchingParameters(int numberOfAdditionalSteps, int & i3Start );
302 int initializeMarchingArrays( int i3Start, int numberOfAdditionalSteps, realArray & x, realArray & xt,
303  realArray & xr, realArray & normal, realArray & xrr,
304  realArray & s, realArray & ss, realArray & xrrDotN,
305  realArray & kappa);
306 
308  int numberOfAdditionalSteps, int i3Start, int i3Begin,
309  realArray & x, realArray & xt,
310  realArray & xr,
311  realArray & normal, realArray & ds, realArray & s, realArray & ss, realArray & xrr,
312  realArray & normXr, realArray & normXs,
313  realArray & xrSave );
314 
315 int removeNormalComponentOfSmoothing(int axis, const Index & I1, const Index & I2, const Index & I3,
316  realArray & xrr, realArray & xrrDotN,
317  realArray & normal, realArray & xte );
318 
319 int getNormalAndSurfaceArea(const realArray & x,
320  const int & i3,
321  realArray & normal,
322  realArray & s,
323  realArray & xr,
324  realArray & xrr,
325  const real & dSign,
326  realArray & normXr,
327  realArray & normXs,
328  realArray & ss,
329  const int & marchingDirection,
330  int stepNumber=0 );
331 
333  realArray & kappa,
334  const realArray & xrr,
335  const realArray & normal,
336  const realArray & normXr,
337  const realArray & normXs);
338 
339 int getDistanceToStep(const int & i3Delta, realArray & ds, const int & growthDirection );
340 int adjustDistanceToMarch(const int & numberOfAdditionalSteps, const int & growthDirection );
341 int applyBoundaryConditions( const realArray & x, const realArray & x0,
342  const int & marchingDirection,
343  realArray & normal,
344  realArray & xr,
345  bool initialStep = false,
346  int stepNumber=0 );
347 
349  const int & marchingDirection,
350  realArray & normal,
351  realArray & xr,
352  bool initialStep = false,
353  int option=0 );
354 
355 int matchToCurve( bool projectBoundary,
356  Index & I1, Index & I2,
357  Mapping & matchingMapping,
358  MappingProjectionParameters & mpParams,
359  int i1Shift,
360  int i2Shift,
361  const realArray & x,
362  const int & marchingDirection,
363  realArray & normal,
364  realArray & xr,
365  const int sideBlend, const int axisBlend, // side axis for numberOfLinesForNormalBlend
366  bool initialStep = false,
367  int option =0 );
368 
369 int projectNormalsToMatchCurve(Mapping & matchingMapping,
370  MappingProjectionParameters & mpParams,
371  Index & I1, Index & I2,
372  realArray & normal, realArray & nDot );
373 
374 int blendNormals(realArray & normal, realArray & xr,
375  int numberOfLinesToBlend,
376  Index Iv[3],
377  int axis, int side);
378 
379 
380 int jacobiSmooth( realArray & ss, const int & numberOfSmooths );
381 int formCMatrix(realArray & xr,
382  realArray & xt,
383  const int & i3Mod2,
384  realArray & normal,
385  realArray & normXr,
386  const int & direction );
387 
389  const realArray & normXs,
390  const realArray & normXt,
391  const int & direction,
392  int stepNumber );
393 
394 int formBlockTridiagonalSystem(const int & direction, realArray & xTri);
395 
396 int implicitSolve(realArray & xTri,
397  const int & i3Mod2,
398  realArray & xr,
399  realArray & xt,
400  realArray & normal,
401  realArray & normXr,
402  realArray & normXs,
403  realArray & normXt,
404  TridiagonalSolver & tri,
405  int stepNumber);
406 
407 
409  SelectionInfo & select,
410  Mapping* &curve,
411  Mapping *mapPointer = NULL,
412  real *xCoord = NULL,
413  real *rCoord = NULL,
414  int *boundaryCurveChosen = NULL,
415  bool resetBoundaryConditions = true );
416 
417 // build a curve from selected curves chosen interactively:
418 int buildCurve( GenericGraphicsInterface & gi, GraphicsParameters & parameters, DialogData & dialog,
419  aString & answer, SelectionInfo & select, Mapping *&newCurve, const aString & buildCurveColour,
420  bool resetBoundaryConditions = true );
421 
422 int computeCellVolumes(const realArray & xt, const int & i3Mod2,
423  real & minCellVolume, real & maxCellVolume,
424  const real & dSign );
425 
426 int equidistributeAndStretch( const int & i3, const realArray & x, const real & weight,
427  const int marchingDirection=1, bool stretchGrid = true );
428 
429 realArray normalize( const realArray & u );
430 
431 int project( const realArray & x,
432  const int & marchingDirection,
433  realArray & xr,
434  const bool & setBoundaryConditions= TRUE,
435  bool initialStep = false,
436  int stepNumber = 0);
437 
438 virtual int project( realArray & x,
439  MappingProjectionParameters & mpParams ){ return Mapping::project(x,mpParams); }
440 
442  CompositeSurface & cs,
443  const int & marchingDirection,
444  MappingProjectionParameters & mpParams);
445 
446 void
448 
450  GraphicsParameters & parameters);
451 
452 int printStatistics(FILE *file=stdout );
453 
454 // find boundary condition curves to match to
455 int findMatchingBoundaryCurve(int side, int axis, int directionToMarch,
456  GenericGraphicsInterface & gi, bool promptForChanges=false );
457 
458 int findNormalsToStartCurve(realArray & r, realArray & normal, int directionToMarch);
459 
460 // this next function is only intended to be called by the update function
462  GraphicsParameters & referenceSurfaceParameters,
463  const real & surfaceOffset,
464  const aString & referenceSurfaceColour,
465  const aString & edgeCurveColour );
466 
467 // this next function is only intended to be called by the update function
469  GraphicsParameters & parameters,
470  const aString *boundaryColour);
471 // this next function is only intended to be called by the update function
473  GraphicsParameters & parameters,
474  bool plotNonPhysicalBoundaries,
475  const real & initialOffset,
476  const aString & hyperbolicMappingColour );
477 
478 // this next function is only intended to be called by the update function
480  GraphicsParameters & parameters,
481  GraphicsParameters & referenceSurfaceParameters,
482  const real & surfaceOffset,
483  const real & initialOffset,
484  const aString & boundaryConditionMappingColour,
485  const aString & referenceSurfaceColour,
486  const aString & edgeCurveColour,
487  const aString & buildCurveColour,
488  const aString *boundaryColour );
489 
490 
491 // int destroyInteriorMatchingCurves();
492 
493 real getDissipationCoefficient( int stepNumber );
494 
495 void setLinesAndDistanceLabels(DialogData & dialog );
497 
498 // old: int chooseBoundaryConditionMappings(MappingInformation & mapInfo );
499 
500 bool evaluateTheSurface; // if TRUE the surface is re-evaluated
501 realArray xSurface; // holds the surface grid
502 
503 // parameters for Bill's generator
504 int growthOption; // +1, -1 or 2=grow in both directions
510 
517 
518 int numberOfSmoothingIterations; // for smoothGrid
519 
522 Mapping *boundaryConditionMapping[2][2]; // [side][axis] pointers to Mappings used for a boundary condition.
523 
524 bool boundaryConditionMappingWasNewed[2][2]; // true if the mapping was new'd locally.
525 // Note: MappingProjectionParameters are quite lite-weight
527 // surfaceMappingProjectionParameters[0] = backward, [1]=forward, [2]=for initial curve
528 MappingProjectionParameters surfaceMappingProjectionParameters[3]; // for projecting onto a surface grid
529 
530 // We may match an interior grid line to a curve
531 vector<MatchingCurve> matchingCurves; // array of matching curves
532 
533 // int numberOfMatchingCurves; // number of interior lines matched
534 // real *matchingCurvePosition; // r coordinate on the start curve where matchin curve starts
535 // int *matchingCurveDirection; // match when growing in this direction (forward or backward)
536 // Mapping **matchingCurve; // project grid line onto this mapping.
537 // MappingProjectionParameters **matchingProjectionParameters;
538 
540 real splayFactor[2][2]; // factor for outward splay BC.
541 int boundaryOffset[2][3]; // =1 -> move boundary one line in and use last line as the ghost lne.
542 bool boundaryOffsetWasApplied; // this means the grid dimensions were adjusted by the boundaryOffset
543 
545 {
546  extrapolateAnExtraGhostLine, // ghost line values are extrapolated in the DataPointMapping.
547  useLastLineAsGhostLine // compute ghost lines when marching
548 } ghostLineOption;
549 
550 // why are these all here??
551 realArray gridDensityWeight; // holds the inverse of the desired grid spacing (relative values only)
552 realArray xHyper; // holds the hyperbolic grid.
554 realArray normalCC; // normal at cell centre.
556 
557 
563 
564 real minimumGridSpacing; // stop marching the surface grid when spacing is less than
566 
568 
570 
572 
573 bool surfaceGrid; // true if we are generating a surface grid
574 Mapping *startCurve; // defines the starting curve for a surface grid
576 real startCurveStart, startCurveEnd; // bounds on parameter space for the start curve, normally 0. and 1.
577 
578 bool useStartCurveStretchingWhileMarching; // we can stretch just the start curve or also in the interior.
579 RealArray *pStartCurveStretchParams; // defines stretching of the starting curve or surface
581 
582 bool projectInitialCurve; // true if we project starting curve onto the surface
583 bool projectNormalsOnMatchingBoundaries; // if true, project both points and normals to matching boundary curves/surfaces
584 bool correctProjectionOfInitialCurves; // if true correct the projection of the initial curve to match edges on the triangluation
585 
586 bool useTriangulation; // if true, use the triangulation of a CompositeSurface for marching.
587 bool projectOntoReferenceSurface; // if true, project points found using the triangulation onto the actual surface
588 bool stopOnNegativeCells; // stop the generation when a negative cell is detected
589 
590 int saveReferenceSurface; // // 0=do not save, 1=save for 2D grids, 2=save for all grids
602 
606 
608 real edgeCurveMatchingTolerance; // for deciding when edge curves should be joined.
609 real distanceToBoundaryCurveTolerance; // for deciding if boundary curves match to the start curve
610 
611 realArray trailingEdgeDirection; // for airfoil like trailing edge singularities.
612 
613 // variables for the surface grid stuff
614 bool smoothAndProject; // if true smooth and project onto original surface definition.
615 
619 
622 {
635 };
637 
638 
639 // Hypgen parameters
640 // int nzreg,izstrt,ibcja,ibcjb,ibcka,ibckb,imeth,ivspec,itsvol,iaxis;
641 // real smu2, epsss, timj,timk , exaxis, volres;
642 // intArray npzreg;
643 // RealArray zreg,dz0,dz1;
644 
645 int info;
646 
647 private:
648 aString className;
649 Mapping *surface; // here is the mapping that we start with
650 DataPointMapping *dpm; // Here is where the mapping is defined.
651 
652 static FILE *debugFile;
653 
654 private:
655 
656 //
657 // Virtual member functions used only through class ReferenceCounting:
658 //
660 { return operator=((HyperbolicMapping &)x); }
661 virtual void reference( const ReferenceCounting& x)
662 { reference((HyperbolicMapping &)x); } // *** Conversion to this class for the virtual = ****
663 virtual ReferenceCounting* virtualConstructor( const CopyType copyType = DEEP ) const
664 { return ::new HyperbolicMapping(*this, copyType); }
665 
666 };
667 
668 
669 #endif