Nalu
Nalu: a generalized unstructured massively parallel low Mach flow code designed to support a variety of energy applications of interest (most notably Wind ECP) built on the Sierra Toolkit and Trilinos solver Tpetra/Epetra stack. The open source BSD, clause 3 license model has been chosen for the code base. See LICENSE for more information. http://NaluCFD.org
Realm.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2014 Sandia Corporation. */
3 /* This software is released under the license detailed */
4 /* in the file, LICENSE, which is located in the top-level Nalu */
5 /* directory structure */
6 /*------------------------------------------------------------------------*/
7 
8 
9 #ifndef Realm_h
10 #define Realm_h
11 
12 #include <Enums.h>
13 #include <FieldTypeDef.h>
14 
15 // yaml for parsing..
16 #include <yaml-cpp/yaml.h>
17 
18 #include <BoundaryConditions.h>
19 #include <InitialConditions.h>
20 #include <MaterialPropertys.h>
21 #include <EquationSystems.h>
22 #include <Teuchos_RCP.hpp>
23 
24 #include <stk_util/util/ParameterList.hpp>
25 
26 // standard c++
27 #include <map>
28 #include <string>
29 #include <vector>
30 #include <stdint.h>
31 
32 namespace stk {
33 namespace mesh {
34 class Part;
35 }
36 namespace io {
37  class StkMeshIoBroker;
38 }
39 }
40 
41 namespace YAML {
42 class Node;
43 }
44 
45 namespace sierra{
46 namespace nalu{
47 
48 class Algorithm;
49 class AlgorithmDriver;
50 class AuxFunctionAlgorithm;
51 class ComputeGeometryAlgorithmDriver;
52 class OversetManager;
53 class NonConformalManager;
54 class ErrorIndicatorAlgorithmDriver;
55 #if defined (NALU_USES_PERCEPT)
56 class Adapter;
57 #endif
58 class EquationSystems;
59 class OutputInfo;
60 class PostProcessingInfo;
61 class PeriodicManager;
62 class Realms;
63 class Simulation;
64 class SolutionOptions;
65 class TimeIntegrator;
66 class MasterElement;
67 class PropertyEvaluator;
68 class HDF5FilePtr;
69 class Transfer;
70 
71 class SolutionNormPostProcessing;
72 class TurbulenceAveragingPostProcessing;
73 class DataProbePostProcessing;
74 class Actuator;
75 class ABLForcingAlgorithm;
76 
77 class TensorProductQuadratureRule;
78 class LagrangeBasis;
79 class PromotedElementIO;
80 struct ElementDescription;
81 
82 class Realm {
83  public:
84 
85  Realm(Realms&, const YAML::Node & node);
86  virtual ~Realm();
87 
88  typedef size_t SizeType;
89 
90  virtual void load(const YAML::Node & node);
91  void look_ahead_and_creation(const YAML::Node & node);
92 
93  virtual void breadboard();
94 
95  virtual void initialize();
96 
97  Simulation *root() const;
98  Simulation *root();
99  Realms *parent() const;
100  Realms *parent();
101 
102  bool debug() const;
103  bool get_activate_memory_diagnostic();
104  void provide_memory_summary();
105  std::string convert_bytes(double bytes);
106 
107  void create_mesh();
108 
109  void setup_adaptivity();
110 
111  void setup_nodal_fields();
112  void setup_edge_fields();
113  void setup_element_fields();
114 
115  void setup_interior_algorithms();
116  void setup_post_processing_algorithms();
117  void setup_bc();
118  void enforce_bc_on_exposed_faces();
119  void setup_initial_conditions();
120  void setup_property();
121  void extract_universal_constant(
122  const std::string name, double &value, const bool useDefault);
123  void augment_property_map(
124  PropertyIdentifier propID,
125  ScalarFieldType *theField);
126 
127  void makeSureNodesHaveValidTopology();
128 
129  void initialize_global_variables();
130 
131  void balance_nodes();
132 
133  void create_output_mesh();
134  void create_restart_mesh();
135  void input_variables_from_mesh();
136 
137  void augment_output_variable_list(
138  const std::string fieldName);
139 
140  void augment_restart_variable_list(
141  std::string restartFieldName);
142 
143  void create_edges();
144  void provide_entity_count();
145  void delete_edges();
146  void commit();
147 
148  void process_mesh_motion();
149  void compute_centroid_on_parts(
150  std::vector<std::string> partNames,
151  std::vector<double> &centroid);
152 
153  void init_current_coordinates();
154 
155  std::string get_coordinates_name();
156  bool has_mesh_motion();
157  bool has_mesh_deformation();
158  bool does_mesh_move();
159  bool has_non_matching_boundary_face_alg();
160 
161  // overset boundary condition requires elemental field registration
162  bool query_for_overset();
163 
164  void set_omega(
165  stk::mesh::Part *targetPart,
166  double omega);
167  void set_current_displacement(
168  stk::mesh::Part *targetPart,
169  const std::vector<double> &centroidCoords,
170  const std::vector<double> &unitVec);
171  void set_current_coordinates(
172  stk::mesh::Part *targetPart);
173  void set_mesh_velocity(
174  stk::mesh::Part *targetPart,
175  const std::vector<double> &centroidCoords,
176  const std::vector<double> &unitVec);
177  void mesh_velocity_cross_product(double *o, double *c, double *u);
178 
179  // non-conformal-like algorithm suppoer
180  void initialize_non_conformal();
181  void initialize_overset();
182  void initialize_post_processing_algorithms();
183 
184  void compute_geometry();
185  void compute_vrtm();
186  void compute_l2_scaling();
187  void output_converged_results();
188  void provide_output();
189  void provide_restart_output();
190 
191  void register_interior_algorithm(
192  stk::mesh::Part *part);
193 
194  void register_nodal_fields(
195  stk::mesh::Part *part);
196 
197  void register_wall_bc(
198  stk::mesh::Part *part,
199  const stk::topology &theTopo);
200 
201  void register_inflow_bc(
202  stk::mesh::Part *part,
203  const stk::topology &theTopo);
204 
205  void register_open_bc(
206  stk::mesh::Part *part,
207  const stk::topology &theTopo);
208 
209  void register_symmetry_bc(
210  stk::mesh::Part *part,
211  const stk::topology &theTopo);
212 
213  void register_periodic_bc(
214  stk::mesh::Part *masterMeshPart,
215  stk::mesh::Part *slaveMeshPart,
216  const double &searchTolerance,
217  const std::string &searchMethodName);
218 
219  void setup_non_conformal_bc(
220  stk::mesh::PartVector currentPartVec,
221  stk::mesh::PartVector opposingPartVec,
222  const NonConformalBoundaryConditionData &nonConformalBCData);
223 
224  void register_non_conformal_bc(
225  stk::mesh::Part *part,
226  const stk::topology &theTopo);
227 
228  void setup_overset_bc(
229  const OversetBoundaryConditionData &oversetBCData);
230 
231  void periodic_field_update(
232  stk::mesh::FieldBase *theField,
233  const unsigned &sizeOfTheField,
234  const bool &bypassFieldCheck = true) const;
235 
236  void periodic_delta_solution_update(
237  stk::mesh::FieldBase *theField,
238  const unsigned &sizeOfField) const;
239 
240  void periodic_max_field_update(
241  stk::mesh::FieldBase *theField,
242  const unsigned &sizeOfField) const;
243 
244  const stk::mesh::PartVector &get_slave_part_vector();
245 
246  void overset_orphan_node_field_update(
247  stk::mesh::FieldBase *theField,
248  const unsigned sizeRow,
249  const unsigned sizeCol);
250 
251  virtual void populate_initial_condition();
252  virtual void populate_boundary_data();
253  virtual void boundary_data_to_state_data();
254  virtual double populate_variables_from_input(const double currentTime);
255  virtual void populate_external_variables_from_input(const double currentTime) {}
256  virtual double populate_restart( double &timeStepNm1, int &timeStepCount);
257  virtual void populate_derived_quantities();
258  virtual void evaluate_properties();
259  virtual double compute_adaptive_time_step();
260  virtual void swap_states();
261  virtual void predict_state();
262  virtual void pre_timestep_work();
263  virtual void output_banner();
264  virtual void advance_time_step();
265 
266  virtual void initial_work();
267 
268  void set_global_id();
269 
271  void check_job(bool get_node_count);
272 
273  void dump_simulation_time();
274  double provide_mean_norm();
275 
276  double get_hybrid_factor(
277  const std::string dofname);
278  double get_alpha_factor(
279  const std::string dofname);
280  double get_alpha_upw_factor(
281  const std::string dofname);
282  double get_upw_factor(
283  const std::string dofname);
284  bool primitive_uses_limiter(
285  const std::string dofname);
286  double get_lam_schmidt(
287  const std::string dofname);
288  double get_lam_prandtl(
289  const std::string dofname, bool &prProvided);
290  double get_turb_schmidt(
291  const std::string dofname);
292  double get_turb_prandtl(
293  const std::string dofname);
294  bool get_noc_usage(
295  const std::string dofname);
296  bool get_shifted_grad_op(
297  const std::string dofname);
298  double get_divU();
299 
300  // tanh factor specifics
301  std::string get_tanh_functional_form(
302  const std::string dofname);
303  double get_tanh_trans(
304  const std::string dofname);
305  double get_tanh_width(
306  const std::string dofname);
307 
308  // consistent mass matrix for projected nodal gradient
309  bool get_consistent_mass_matrix_png(
310  const std::string dofname);
311 
312  // pressure poisson nuance
313  double get_mdot_interp();
314  bool get_cvfem_shifted_mdot();
315  bool get_cvfem_reduced_sens_poisson();
316 
317  bool has_nc_gauss_labatto_quadrature();
318  bool get_nc_alg_upwind_advection();
319  bool get_nc_alg_include_pstab();
320  bool get_nc_alg_current_normal();
321 
323  get_material_prop_eval(
324  const PropertyIdentifier thePropID);
325 
326  bool is_turbulent();
327  void is_turbulent(
328  bool isIt);
329 
330  bool needs_enthalpy();
331  void needs_enthalpy(bool needsEnthalpy);
332 
333  int number_of_states();
334 
335  std::string name();
336 
337  // redirection of stk::mesh::get_buckets to allow global selector
338  // to be applied, e.g., in adaptivity we need to avoid the parent
339  // elements
340  stk::mesh::BucketVector const& get_buckets( stk::mesh::EntityRank rank,
341  const stk::mesh::Selector & selector ,
342  bool get_all = false) const;
343 
344  // get aura, bulk and meta data
345  bool get_activate_aura();
346  stk::mesh::BulkData & bulk_data();
347  stk::mesh::MetaData & meta_data();
348 
349  // inactive part
350  stk::mesh::Selector get_inactive_selector();
351 
352  // push back equation to equation systems vector
353  void push_equation_to_systems(
354  EquationSystem *eqSystem);
355 
356  // provide all of the physics target names
357  const std::vector<std::string> &get_physics_target_names();
358  double get_tanh_blending(const std::string dofName);
359 
361 
362  std::string name_;
363  std::string type_;
364  std::string inputDBName_;
366 
371 
372  double l2Scaling_;
373 
374  // ioBroker, meta and bulk data
375  stk::mesh::MetaData *metaData_;
376  stk::mesh::BulkData *bulkData_;
377  stk::io::StkMeshIoBroker *ioBroker_;
378 
381 
382  // nalu field data
384 
385  // algorithm drivers managed by region
388 # if defined (NALU_USES_PERCEPT)
389  Adapter *adapter_;
390 #endif
392  // for element, side, edge, node rank (node not used)
393  stk::mesh::Selector adapterSelector_[4];
394  Teuchos::RCP<stk::mesh::Selector> activePartForIO_;
395 
397 
401 
403 
404  double maxCourant_;
405  double maxReynolds_;
409 
418 
419  std::vector<Algorithm *> propertyAlg_;
420  std::map<PropertyIdentifier, ScalarFieldType *> propertyMap_;
421  std::vector<Algorithm *> initCondAlg_;
422 
423  SizeType nodeCount_;
434  double timerAdapt_;
439 
444 
445  // three type of transfer operations
450 
454 
455  // global parameter list
456  stk::util::ParameterList globalParameters_;
457 
458  // part for all exposed surfaces in the mesh
459  stk::mesh::Part *exposedBoundaryPart_;
460 
461  // part for new edges
462  stk::mesh::Part *edgesPart_;
463 
465 
466  // types of physics
469 
470  // some post processing of entity counts
472 
473  // pointer to HDF5 file structure holding table
475 
476  // automatic mesh decomposition; None, rib, rcb, multikl, etc.
477  std::string autoDecompType_;
478 
479  // allow aura to be optional
481 
482  // allow detailed output (memory) to be provided
484 
485  // sometimes restarts can be missing states or dofs
487 
490  {
492  target(1.0),
493  numIters(5)
494  {};
495 
496  double target;
497  int numIters;
498  };
500 
501  // beginning wall time
503 
504  // mesh parts for all boundary conditions
506 
507  // empty part vector should it be required
509 
510  // base and promote mesh parts
513 
514  std::vector<AuxFunctionAlgorithm *> bcDataAlg_;
515 
516  // transfer information; three types
517  std::vector<Transfer *> multiPhysicsTransferVec_;
518  std::vector<Transfer *> initializationTransferVec_;
519  std::vector<Transfer *> ioTransferVec_;
520  std::vector<Transfer *> externalDataTransferVec_;
521  void augment_transfer_vector(Transfer *transfer, const std::string transferObjective, Realm *toRealm);
522  void process_multi_physics_transfer();
523  void process_initialization_transfer();
524  void process_io_transfer();
525  void process_external_data_transfer();
526 
527  // process end of time step converged work
528  void post_converged_work();
529 
530  // time information; calls through timeIntegrator
531  double get_current_time();
532  double get_time_step();
533  double get_gamma1();
534  double get_gamma2();
535  double get_gamma3();
536  int get_time_step_count() const;
537  double get_time_step_from_file();
538  bool get_is_fixed_time_step();
539  bool get_is_terminate_based_on_time();
540  double get_total_sim_time();
541  int get_max_time_step_count();
542 
543  // restart
544  bool restarted_simulation();
545  bool support_inconsistent_restart();
546 
547  double get_stefan_boltzmann();
548  double get_turb_model_constant(
549  const TurbulenceModelConstant turbModelEnum);
550  bool process_adaptivity();
551 
552  // element promotion options
553  bool doPromotion_; // conto
554  unsigned promotionOrder_;
555 
556  // id for the input mesh
558 
559  // save off the node
560  const YAML::Node & node_;
561 
562  // tools
563  std::unique_ptr<ElementDescription> desc_; // holds topo info
564  std::unique_ptr<PromotedElementIO> promotionIO_; // mesh outputer
565  std::vector<std::string> superTargetNames_;
566 
567  void setup_element_promotion(); // create super parts
568  void promote_mesh(); // create new super element / sides on parts
569  void create_promoted_output_mesh(); // method to create output of linear subelements
570  bool using_SGL_quadrature() const { return get_quad_type() == "SGL"; };
571  bool high_order_active() const { return doPromotion_; };
572 
573  std::string physics_part_name(std::string) const;
574  std::string get_quad_type() const;
575 
578 };
579 
580 } // namespace nalu
581 } // namespace Sierra
582 
583 #endif
stk::mesh::PartVector allPeriodicInteractingParts_
Definition: Realm.h:576
std::string name_
Definition: Realm.h:362
bool estimateMemoryOnly_
Definition: Realm.h:424
Definition: PeriodicManager.h:40
double timerInitializeEqs_
Definition: Realm.h:432
BalanceNodeOptions balanceNodeOptions_
Definition: Realm.h:499
std::string autoDecompType_
Definition: Realm.h:477
stk::mesh::PartVector superPartVector_
Definition: Realm.h:512
bool doBalanceNodes_
Definition: Realm.h:488
std::vector< Part * > PartVector
Definition: Algorithm.h:16
OversetManager * oversetManager_
Definition: Realm.h:441
double timerTransferExecute_
Definition: Realm.h:436
Definition: TimeIntegrator.h:26
Definition: Simulation.h:28
PropertyIdentifier
Definition: Enums.h:102
double timerPopulateMesh_
Definition: Realm.h:427
Definition: ABLForcingAlgorithm.C:26
void initialize(int N, aligned_vector &x, aligned_vector &y)
Definition: UnitTestSimdBasic.C:37
std::vector< Algorithm * > propertyAlg_
Definition: Realm.h:419
stk::mesh::BulkData * bulkData_
Definition: Realm.h:376
ComputeGeometryAlgorithmDriver * computeGeometryAlgDriver_
Definition: Realm.h:386
virtual void populate_external_variables_from_input(const double currentTime)
Definition: Realm.h:255
TimeIntegrator * timeIntegrator_
Definition: Realm.h:396
Definition: SolutionNormPostProcessing.h:35
bool hasMultiPhysicsTransfer_
Definition: Realm.h:446
size_t inputMeshIdx_
Definition: Realm.h:557
std::vector< Transfer * > multiPhysicsTransferVec_
Definition: Realm.h:517
stk::mesh::PartVector emptyPartVector_
Definition: Realm.h:508
double l2Scaling_
Definition: Realm.h:372
std::vector< Transfer * > initializationTransferVec_
Definition: Realm.h:518
Definition: TurbulenceAveragingPostProcessing.h:36
double availableMemoryPerCoreGB_
Definition: Realm.h:425
bool hasInitializationTransfer_
Definition: Realm.h:447
stk::mesh::Field< stk::mesh::EntityId > GlobalIdFieldType
Definition: FieldTypeDef.h:20
bool hasPeriodic_
Definition: Realm.h:452
Definition: NaluParsing.h:320
stk::mesh::PartVector basePartVector_
Definition: Realm.h:511
std::vector< Transfer * > ioTransferVec_
Definition: Realm.h:519
double timerTransferSearch_
Definition: Realm.h:435
std::string type_
Definition: Realm.h:363
double timerCreateMesh_
Definition: Realm.h:426
Definition: SolutionOptions.h:38
unsigned numInitialElements_
Definition: Realm.h:391
stk::util::ParameterList globalParameters_
Definition: Realm.h:456
OutputInfo * outputInfo_
Definition: Realm.h:411
Definition: Algorithm.h:14
BalanceNodeOptions()
Definition: Realm.h:491
stk::mesh::PartVector bcPartVec_
Definition: Realm.h:505
Definition: MaterialPropertys.h:37
bool supportInconsistentRestart_
Definition: Realm.h:486
double maxCourant_
Definition: Realm.h:404
A collection of Equations to be solved on a Realm.
Definition: EquationSystems.h:56
bool hasNonConformal_
Definition: Realm.h:442
bool uniformFlow_
Definition: Realm.h:468
double timerOutputFields_
Definition: Realm.h:429
double timeStepChangeFactor_
Definition: Realm.h:407
bool needsEnthalpy_
Definition: Realm.h:370
double timerPopulateFieldData_
Definition: Realm.h:428
bool realmUsesEdges_
Definition: Realm.h:367
size_t resultsFileIndex_
Definition: Realm.h:379
size_t SizeType
Definition: Realm.h:88
SolutionNormPostProcessing * solutionNormPostProcessing_
Definition: Realm.h:413
bool checkForMissingBcs_
Definition: Realm.h:464
Base class representation of a PDE.
Definition: EquationSystem.h:46
stk::mesh::Part * edgesPart_
Definition: Realm.h:462
bool hasExternalDataTransfer_
Definition: Realm.h:449
DataProbePostProcessing * dataProbePostProcessing_
Definition: Realm.h:415
stk::mesh::Part * exposedBoundaryPart_
Definition: Realm.h:459
std::unique_ptr< PromotedElementIO > promotionIO_
Definition: Realm.h:564
EquationSystems equationSystems_
Definition: Realm.h:402
int currentNonlinearIteration_
Definition: Realm.h:408
bool hasOverset_
Definition: Realm.h:443
stk::mesh::Field< double > ScalarFieldType
Definition: FieldTypeDef.h:19
size_t restartFileIndex_
Definition: Realm.h:380
PostProcessingInfo * postProcessingInfo_
Definition: Realm.h:412
bool hasIoTransfer_
Definition: Realm.h:448
std::unique_ptr< ElementDescription > desc_
Definition: Realm.h:563
Definition: OutputInfo.h:24
Definition: PostProcessingInfo.h:22
ABLForcingAlgorithm * ablForcingAlg_
Definition: Realm.h:417
double timerPropertyEval_
Definition: Realm.h:433
double timerAdapt_
Definition: Realm.h:434
double timerCreateEdges_
Definition: Realm.h:430
double maxReynolds_
Definition: Realm.h:405
const YAML::Node & node_
Definition: Realm.h:560
Definition: BoundaryConditions.h:55
Definition: NaluParsing.C:400
Actuator * actuator_
Definition: Realm.h:416
GlobalIdFieldType * naluGlobalId_
Definition: Realm.h:383
double wallTimeStart_
Definition: Realm.h:502
unsigned spatialDimension_
Definition: Realm.h:365
std::vector< Transfer * > externalDataTransferVec_
Definition: Realm.h:520
double timerSkinMesh_
Definition: Realm.h:437
bool provideEntityCount_
Definition: Realm.h:471
stk::io::StkMeshIoBroker * ioBroker_
Definition: Realm.h:377
std::map< PropertyIdentifier, ScalarFieldType * > propertyMap_
Definition: Realm.h:420
Definition: UnitTestMasterElements.C:367
NonConformalManager * nonConformalManager_
Definition: Realm.h:440
double timerPromoteMesh_
Definition: Realm.h:438
ABL Forcing Source terms for Momentum and Temperature equations.
Definition: ABLForcingAlgorithm.h:69
Definition: Transfer.h:38
unsigned promotionOrder_
Definition: Realm.h:554
bool doPromotion_
Definition: Realm.h:553
std::vector< Bucket * > BucketVector
Definition: PromotedPartHelper.h:21
double timerNonconformal_
Definition: Realm.h:431
Definition: Actuator.h:47
Teuchos::RCP< stk::mesh::Selector > activePartForIO_
Definition: Realm.h:394
HDF5FilePtr * HDF5ptr_
Definition: Realm.h:474
int numIters
Definition: Realm.h:497
Definition: PropertyEvaluator.h:19
Definition: DataProbePostProcessing.h:75
bool activateMemoryDiagnostic_
Definition: Realm.h:483
double targetCourant_
Definition: Realm.h:406
Definition: Realms.h:35
Tpetra::Map< LocalOrdinal, GlobalOrdinal >::node_type Node
Definition: LinearSolver.h:32
bool isothermalFlow_
Definition: Realm.h:467
Definition: OversetManager.h:56
Provides a HDF5 formatted file pointer.
Definition: HDF5FilePtr.h:23
Realms & realms_
Definition: Realm.h:360
std::vector< AuxFunctionAlgorithm * > bcDataAlg_
Definition: Realm.h:514
bool isTurbulent_
Definition: Realm.h:369
SolutionOptions * solutionOptions_
Definition: Realm.h:410
double target
Definition: Realm.h:494
TurbulenceAveragingPostProcessing * turbulenceAveragingPostProcessing_
Definition: Realm.h:414
SizeType nodeCount_
Definition: Realm.h:423
Definition: ComputeGeometryAlgorithmDriver.h:19
Definition: Realm.h:82
Definition: NonConformalManager.h:43
MaterialPropertys materialPropertys_
Definition: Realm.h:400
BoundaryConditions boundaryConditions_
Definition: Realm.h:398
bool using_SGL_quadrature() const
Definition: Realm.h:570
Definition: InitialConditions.h:56
stk::mesh::MetaData * metaData_
Definition: Realm.h:375
std::vector< Algorithm * > initCondAlg_
Definition: Realm.h:421
bool high_order_active() const
Definition: Realm.h:571
int solveFrequency_
Definition: Realm.h:368
PeriodicManager * periodicManager_
Definition: Realm.h:451
InitialConditions initialConditions_
Definition: Realm.h:399
std::vector< std::string > superTargetNames_
Definition: Realm.h:565
ErrorIndicatorAlgorithmDriver * errorIndicatorAlgDriver_
Definition: Realm.h:387
TurbulenceModelConstant
Definition: Enums.h:164
std::string inputDBName_
Definition: Realm.h:364
bool activateAura_
Definition: Realm.h:480
stk::mesh::PartVector allNonConformalInteractingParts_
Definition: Realm.h:577
bool hasFluids_
Definition: Realm.h:453
Definition: ErrorIndicatorAlgorithmDriver.h:23