CG  Version 25
Parameters.h
Go to the documentation of this file.
1 #ifndef PARAMETERS
2 #define PARAMETERS
3 
4 #include <string>
5 
6 #include "Overture.h"
7 #include "OGFunction.h"
8 #include "display.h"
9 #include "PlotStuffParameters.h"
10 #include "MovingGrids.h"
11 #include "ShowFileParameter.h"
12 #include "BoundaryData.h"
13 
14 #include OV_STD_INCLUDE(map)
15 #include "ParallelOverlappingGridInterpolator.h"
16 #include "ArraySimple.h"
17 
18 #define KK_DEBUG
19 #include "DBase.hh"
20 using namespace DBase;
21 
22 // --- forward declarations of classes --
23 class GenericGraphicsInterface;
24 class Ogshow;
25 class Reactions;
26 class FileOutput;
27 class Regrid;
28 class InterpolateRefinements;
29 class ErrorEstimator;
30 class Ogen;
31 class DialogData;
32 class GUIState;
33 class Insbc4WorkSpace;
34 class GridFunction;
36 class SurfaceEquation;
37 class ShowFileReader;
38 class BodyForceRegionParameters;
39 
40 int
41 addPrefix(const aString label[], const aString & prefix, aString cmd[], const int maxCommands);
42 
43 // Here are the run time and PDE parameters
45 {
46 public:
47 
49 mutable DataBase dbase;
50 
51 
53 {
54  noForcing = 0,
56  numberOfForcingTypes
57 };
58 
59 enum Stuff
60 {
61  defaultValue=-12345678,
62  maximumNumberOfOutputFiles=10
63 };
64 
65 aString pdeName;
67 
69 {
70  noTurbulenceModel=0,
71  BaldwinLomax=1,
72  kEpsilon=2,
73  kOmega=3,
74  SpalartAllmaras=4,
75  LargeEddySimulation=5,
76  numberOfTurbulenceModels
77 };
78 
79 static aString turbulenceModelName[numberOfTurbulenceModels+1];
80 
83 {
99  adi,
100  numberOfTimeSteppingMethods
101 };
102 
103 
104 static aString timeSteppingName[numberOfTimeSteppingMethods+1];
105 
106 // These must match those in inspf.bf
109 {
113  axisymmetric=13,
114  interfaceBoundaryCondition=17,
115  neumannBoundaryCondition=18,
116  dirichletInterface=21,
117  neumannInterface=22,
118 
119  // these appear to be needed by the turbulence models
120  // and are so common we might as well have them here
123  noSlipWallInterface=19,
124  slipWallInterface=20,
125 
126  // here is one for penalty boundary conditions
127  penaltyBoundaryCondition=100,
128 };
129 
130 // Here are the different types of interfaces that we know about
132 {
133  noInterface, // no interface conditions are imposed
134  heatFluxInterface, // [ T.n ] = g
135  tractionInterface, // [ n.tau ] = g
136  tractionAndHeatFluxInterface
137 };
138 
139 // Here are the different data that can be requested at an interface. Multiple items are
140 // chosen by bit-wise or of the different options
142 {
143  heatFluxInterfaceData = 1 , // bit 0
144  positionInterfaceData = heatFluxInterfaceData << 1, // bit 1
145  velocityInterfaceData = positionInterfaceData << 1, // bit 2
146  accelerationInterfaceData = velocityInterfaceData << 1, // bit 3
147  tractionInterfaceData = accelerationInterfaceData << 1, // bit 4
148  tractionRateInterfaceData = tractionInterfaceData << 1 // bit 5
149 };
150 
151 
154 {
158  uniformInflowWithTimeDependence, // use this instead ?
171  ramped, // here are new more generic types -- also look at bc to get real type
175  numberOfPredefinedBoundaryConditionTypes // userDefinedBoundaryData,
176 };
177 
178 
180 {
181  notImplicit=0,
187  approximateFactorization
188 };
189 
191 {
195  computeAllWithWeightedImplicitTerms
196 };
197 
198  std::map<int,aString> bcNames, icNames, bcmNames;
199 typedef std::map<int,aString>::iterator BCIterator;
200 
201 bool registerBC(int id, const aString & name, bool replace= false );
202 
203 bool registerInterfaceType(int id, const aString & name, bool replace= false );
204 
205 
206 class BCModifier {
207  public:
208  BCModifier(const aString &nm) : name(nm) {}
209  virtual ~BCModifier() {}
210 
211  aString name;
212  virtual const bool isPenaltyBC() const;
213 
214  virtual bool inputFromGI(GenericGraphicsInterface &gi)=0;
215  virtual bool applyBC(Parameters &parameters,
216  const real & t, const real &dt,
217  realMappedGridFunction &u,
218  const int & grid,
219  int side0 /* = -1 */,
220  int axis0 /* = -1 */,
221  realMappedGridFunction *gridVelocity = 0)=0;
222 
223  virtual bool setBCCoefficients(Parameters &parameters,
224  const real & t, const real &dt,
225  realMappedGridFunction &u,
226  realMappedGridFunction &coeff,
227  const int & grid,
228  int side0 /* = -1 */,
229  int axis0 /* = -1 */,
230  realMappedGridFunction *gridVelocity = 0)=0;
231 
232 
233  virtual bool addPenaltyForcing(Parameters &parameters,
234  const real & t, const real &dt,
235  const realMappedGridFunction &u,
236  realMappedGridFunction &dudt,
237  const int & grid,
238  int side0 /* = -1 */,
239  int axis0 /* = -1 */,
240  const realMappedGridFunction *gridVelocity = 0)=0;
241 
242 
243 };
244 
245 
246 
247 typedef BCModifier*(*CreateBCModifierFromName)(const aString &name);
248 typedef std::map<size_t,BCModifier*>::iterator BCModifierIterator;
249 typedef std::map<std::string,CreateBCModifierFromName>::iterator BCModCreatorIterator;
250 
251 std::map<size_t,BCModifier*> bcModifiers;
252 std::map<std::string, CreateBCModifierFromName> bcModCreators;
253 
254 bool registerBCModifier(const aString &name, Parameters::CreateBCModifierFromName createBCMod, bool replace=false);
255 
256 
258 {
267  knownSolutionInitialCondition
268 };
269 
270 
272 {
275  pulse
276 };
277 
279 {
280  noReactions=0,
289  ignitionPressureReactionRate // 9
290 };
291 
293 {
294  defaultInterpolationType, // interpolate conservative/primitive variables based on computational variables
295  interpolateConservativeVariables, // interpolate conservative variables
296  interpolatePrimitiveVariables, // interpolate primitive variables (rho,u,T)
297  interpolatePrimitiveAndPressure // interpolate primitive and pressure, (rho,u,p)
298 };
299 
300 // This enum defines the frame of reference for the PDEs in a domain.
301 // The frame of reference is needed so that we know how to transform the PDE when the grids move.
302 // Often the PDEs are defined in a fixed reference frame (even if some boundaries are moving).
303 // If we are solving for a PDE inside a moving rigid body, then the PDE (e.g. the heat equation)
304 // may be defined in the frame of reference of the rigid body.
306 {
307  fixedReferenceFrame=0, // PDEs are defined in a fixed reference frame
308  rigidBodyReferenceFrame, // PDEs are defined w.r.t. the motion of a rigid body.
309  specifiedReferenceFrame // PDEs are defined w.r.t. some other specified reference frame.
310 };
311 
312 
313 // Here are some known solutions that we can compare to
315 {
317  userDefinedKnownSolution, // put new known solutions here
318  knownSolutionFromAShowFile
319 // supersonicFlowInAnExpandingChannel // put this here for now -- add this to userDefined ---
320 };
321 
322 
323 // public functions
324 Parameters(const int & numberOfDimensions0=3);
325 virtual ~Parameters();
326 
327 // ** note: functions are in alphabetical order ***
328 
329 virtual
330 int addShowVariable( const aString & name, int component, bool variableIsOn = TRUE );
331 
332 int addTiming( const aString & timeVariableName, const aString & timeLabel );
333 
334 virtual
335 int assignParameterValues(const aString & label, RealArray & values,
336  const int & numRead, aString *c, real val[],
337  char *extraName1 = 0, const int & extraValue1Location = 0,
338  char *extraName2 = 0, const int & extraValue2Location = 0,
339  char *extraName3 = 0, const int & extraValue3Location = 0 );
340 virtual
341 int assignParameterValues(const aString & label, RealArray & values,
342  const int & numRead, char c[][10], real val[],
343  char *extraName1 = 0, const int & extraValue1Location = 0,
344  char *extraName2 = 0, const int & extraValue2Location = 0,
345  char *extraName3 = 0, const int & extraValue3Location = 0 );
346 
347 virtual
348 int bcIsAnInterface(int bc) const;
349 
350 virtual
351 int bcIsTimeDependent(int side, int axis, int grid) const;
352 
353 virtual
354 int bcType(int side, int axis,int grid) const;
355 
356 virtual
357 int bcVariesInSpace(int side, int axis, int grid) const;
358 
359 virtual
360 int bcVariesInSpace(const Index & side = nullIndex,
361  const Index & axis = nullIndex,
362  const Index & grid = nullIndex ) const;
363 
364 virtual int
365 buildBodyForceRegionsDialog(DialogData & dialog, BodyForceRegionParameters & regionPar );
366 
367 virtual
368 int buildErrorEstimator();
369 
370 virtual int
371 buildForcingProfilesDialog(DialogData & dialog, BodyForceRegionParameters & regionPar );
372 
373 virtual int
374 buildMaterialParametersDialog(DialogData & dialog, BodyForceRegionParameters & regionPar );
375 
376 virtual
377 int buildReactions();
378 
379 virtual int
380 buildTemperatureBoundaryConditionsDialog(DialogData & dialog, BodyForceRegionParameters & regionPar );
381 
382 virtual
383 int checkForValidBoundaryCondition( const int & bc, bool reportErrors=true );
384 
385 virtual
386 int chooseUserDefinedBoundaryValues(int side, int axis, int grid, CompositeGrid & cg);
387 
388 virtual int
389 conservativeToPrimitive(GridFunction & gf, int gridToConvert=-1, int fixupUnsedPoints=false);
390 
391 virtual
392 int defineBoundaryConditions(CompositeGrid & cg,
393  const IntegerArray & originalBoundaryCondition,
394  const aString & command =nullString,
395  DialogData *interface=NULL);
396 
397 virtual
398 int defineVariableBoundaryValues(int side, int axis, int grid, CompositeGrid & cg);
399 
400 virtual
401 int displayPdeParameters(FILE *file = stdout );
402 
403 virtual
404 void displayPolynomialCoefficients(RealArray & cx, RealArray & ct, aString * componentName,
405  int numberOfComponents, FILE *file);
406 virtual
407 int get( const GenericDataBase & dir, const aString & name);
408 
409 virtual int
410 getBodyForceRegionsOption(const aString & answer,
411  BodyForceRegionParameters & regionPar,
412  DialogData & dialog );
413 
414 // allocate the boundary data for a given side of a grid and return the array
415 RealArray &
416 getBoundaryData(int side, int axis, int grid, MappedGrid & mg );
417 
418 // return the boundary data for a grid
420 getBoundaryData(int grid);
421 
422 virtual int
423 getForcingProfilesOption(const aString & answer,
424  BodyForceRegionParameters & regionPar,
425  DialogData & dialog );
426 virtual
427 int getComponents( IntegerArray &components );
428 
429 virtual int
430 getDerivedFunction( const aString & name, const realCompositeGridFunction & u,
431  realCompositeGridFunction & v, const int component, const real t,
432  Parameters & parameters);
433 virtual int
434 getDerivedFunction( const aString & name, const realMappedGridFunction & u,
435  realMappedGridFunction & v,
436  const int component, const int grid, const real t, Parameters & parameters);
437 
438 // virtual int
439 // getDerivedFunction( const aString & name, const realCompositeGridFunction & u, realCompositeGridFunction & v,
440 // const int component, Parameters & parameters);
441 // virtual int
442 // getDerivedFunction( const aString & name, const realMappedGridFunction & u, realMappedGridFunction & vIn,
443 // const int component, Parameters & parameters);
444 
445 // Return 1 or 2 if grid was chosen to be implicit AND time stepping is implicit:
446 virtual
447 int getGridIsImplicit(int grid) const;
448 
449 // evaluate the known solution: (if there is one defined)
450 virtual
451 realCompositeGridFunction& getKnownSolution( CompositeGrid & cg, real t );
452 virtual
453 realMappedGridFunction& getKnownSolution(real t, int grid,
454  const Index & I1, const Index &I2, const Index &I3,
455  bool initialCall=false );
456 
457 virtual int
458 getMaterialParametersOption(const aString & answer,
459  BodyForceRegionParameters & regionPar,
460  DialogData & dialog );
461 
462 // compute the normal force on a boundary (for moving grid problems)
463 virtual
464 int getNormalForce( realCompositeGridFunction & u, realSerialArray & normalForce, int *ipar, real *rpar );
465 
466 const ReferenceFrameEnum
467 getReferenceFrame();
468 
469 int
470 getShowVariable( const aString & name, int & component, bool & variableIsOn ) const;
471 
472 virtual int
473 getTemperatureBoundaryConditionsOption(const aString & answer,
474  BodyForceRegionParameters & regionPar,
475  DialogData & dialog );
476 virtual
477 int getTimeDependenceBoundaryConditionParameters(int side, int axis, int grid, RealArray & values) const;
478 
479 virtual
480 aString getTimeSteppingName() const;
481 
482 virtual
483 int getUserBoundaryConditionParameters(int side, int axis, int grid, RealArray & values) const;
484 
485 virtual
486 int getUserDefinedKnownSolution(real t, CompositeGrid & cg, int grid, realArray & ua,
487  const Index & I1, const Index &I2, const Index &I3 );
488 virtual
489 bool gridIsMoving(int grid) const;
490 
491 virtual
492 int howManyBcTypes(const Index & side,
493  const Index & axis,
494  const Index & grid,
495  BoundaryConditionType bc) const;
496 
497 virtual
498 int initializeTimings();
499 
500 virtual
501 int inputParameterValues(const aString & answer, const aString & label, RealArray & values );
502 
503 virtual
504 bool isAdaptiveGridProblem() const{ return dbase.get<bool>("adaptiveGridProblem");} //
505 virtual
506 bool isAxisymmetric() const;
507 
508 virtual
509 bool isMixedBC( int bc );
510 
511 virtual
512 bool isMovingGridProblem() const;
513 
514 virtual
515 bool isSteadyStateSolver() const;
516 
517 
518 virtual
519 int numberOfGhostPointsNeeded() const; // number of ghost points needed by this method.
520 
521 virtual
522 int numberOfGhostPointsNeededForImplicitMatrix() const; // number of ghost points needed for implicit matrix
523 
524 virtual
525 int openLogFiles(const aString & name);
526 
527 virtual
528 int parseValues( const aString & answer, aString *name, real *value, int maxNumber );
529 
530 virtual int
531 primitiveToConservative(GridFunction & gf, int gridToConvert=-1, int fixupUnsedPoints=false);
532 
533 virtual
534 int put( GenericDataBase & dir, const aString & name) const;
535 
536 virtual
537 int
538 readFromAShowFile(ShowFileReader & showFileReader,
539  CompositeGrid & cgRef,
540  CompositeGrid & cg,
541  realCompositeGridFunction & u,
542  int & solutionNumber );
543 
544 // return true if we save the linearized solution for implicit methods.
545 virtual
546 bool saveLinearizedSolution();
547 
548 virtual
549 int saveParametersToShowFile();
550 
551 virtual
552 int setBcIsTimeDependent(int side, int axis, int grid, bool trueOrFalse=true);
553 
554 virtual
555 int setBcType(int side, int axis,int grid, BoundaryConditionType bc);
556 
557 virtual
558 int setBcModifier(int side, int axis, int grid, int bcm);
559 
560 virtual
561 int setBcVariesInSpace(int side, int axis, int grid, bool trueOrFalse=true);
562 
563 virtual
564 int
565 setBoundaryConditionValues(const aString & answer,
566  const IntegerArray & originalBoundaryCondition,
567  CompositeGrid & cg);
568 virtual
569 int setDefaultDataForABoundaryCondition(const int & side,
570  const int & axis,
571  const int & grid,
572  CompositeGrid & cg);
573 virtual
574 int setGridIsImplicit(int grid=-1, int value=1 );
575 
576 virtual int
577 setInfoFile(FILE *file);
578 
579 virtual
580 int setParameters(const int & numberOfDimensions0=2,
581  const aString & reactionName =nullString);
582 
583 virtual
584 int setPdeParameters(CompositeGrid & cg,
585  const aString & command =nullString,
586  DialogData *interface=NULL);
587 
588 int
589 setShowVariable( const aString & name, const bool variableIsOn );
590 
591 virtual
592 int setUserDefinedParameters(); // allow user defined pdeParameters to be passed to C or Fortran routines.
593 
594 virtual
595 int setTimeDependenceBoundaryConditionParameters(int side, int axis, int grid, RealArray & values);
596 
597 virtual
598 int setTwilightZoneFunction(const TwilightZoneChoice & choice,
599  const int & degreeSpace=2,
600  const int & degreeTime=2 );
601 
602 virtual
603 int setTwilightZoneParameters(CompositeGrid & cg,
604  const aString & command =nullString,
605  DialogData *interface=NULL );
606 
607 virtual
608 int setUserBcType(int side, int axis,int grid, int bc); // for user defined BC's
609 
610 virtual
611 int thereAreTimeDependentUserBoundaryConditions(const Index & side,
612  const Index & axis,
613  const Index & grid) const;
614 
615 virtual int
616 setupBodyForcing(CompositeGrid & cg);
617 
618 
619 virtual
620 int setUserBoundaryConditionParameters(int side, int axis, int grid, RealArray & values);
621 
622 virtual
623 int updateKnownSolutionToMatchGrid( CompositeGrid & cg );
624 
625 virtual
626 int updatePDEparameters();
627 
628 virtual
629 int updateShowFile(const aString & command = nullString,
630  DialogData *interface=NULL);
631 
632 virtual
633 int updateToMatchGrid( CompositeGrid & cg,
634  IntegerArray & sharedBoundaryCondition = Overture::nullIntArray() );
635 
636 virtual
637 int updateTurbulenceModels(CompositeGrid & cg);
638 
639 virtual int
640 updateUserDefinedEOS(GenericGraphicsInterface & gi);
641 
642 virtual
643 int updateUserDefinedKnownSolution(GenericGraphicsInterface & gi);
644 
645 virtual
646 bool useConservativeVariables(int grid=-1) const; // if true we are using a solver that uses conservative variables
647 
648 virtual
649 int userBcType(int side, int axis,int grid) const;
650 
651 
652 // ** note: functions are in alphabetical order ***
653 
654 
655 
656 static real spalartAllmarasScaleFactor; // factor to artificially increase the SA production term
657 static real spalartAllmarasDistanceScale; // small parameter to add to the distance to the wall
658 static int checkForFloatingPointErrors; // check for nan's and inf's
659 
660 };
661 
662 
663 #endif