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
ABLForcingAlgorithm.h
Go to the documentation of this file.
1 
2 #ifndef ABLFORCINGALGORITHM_H
3 #define ABLFORCINGALGORITHM_H
4 
5 #include "NaluParsing.h"
6 #include "FieldTypeDef.h"
7 
8 #include "stk_mesh/base/Selector.hpp"
9 
10 #include <string>
11 #include <vector>
12 #include <stdexcept>
13 #include <sstream>
14 #include <unordered_set>
15 
16 namespace sierra {
17 namespace nalu {
18 
19 class Realm;
20 class Transfer;
21 class Transfers;
22 
70 {
71 public:
72  template <typename T>
73  using Array2D = std::vector<std::vector<T>>;
74 
79  OFF = 0,
81  COMPUTED = 2,
83  };
84 
86 
88 
90  void load(const YAML::Node&);
91 
93  void setup();
94 
96  void initialize();
97 
100  void execute();
101 
104  const double,
105  std::vector<double>&
106  );
107 
110  const double,
111  double&
112  );
113 
115  inline stk::mesh::Selector& inactive_selector() { return inactiveSelector_; }
116 
117  inline bool momentumForcingOn() { return (momSrcType_ != OFF); }
118 
119  inline bool temperatureForcingOn() { return (tempSrcType_ != OFF); }
120 
121  inline bool ablForcingOn()
122  {
123  return (momentumForcingOn() || temperatureForcingOn());
124  }
125 
126 private:
129 
131  void load_momentum_info(const YAML::Node&);
132 
134  void load_temperature_info(const YAML::Node&);
135 
138  const std::vector<double>::size_type,
139  const Array2D<double>&,
140  std::vector<double>&,
141  Array2D<double>&);
142 
146  std::vector<double>&, std::vector<std::string>&, bool, std::string&);
147 
150  void register_fields();
151 
154  void create_transfers();
155 
156  void populate_transfer_data(std::string, const std::vector<std::string>&);
157 
160 
163 
165  void calc_mean_velocity();
166 
167  void calc_mean_temperature();
168 
171 
174 
177 
180 
183 
185  std::vector<double> velHeights_; // Array of shape [num_Uheights]
186 
188  std::vector<double> tempHeights_; // Array of shape [num_Theights]
189 
191  std::vector<double> velXTimes_; // Arrays of shape [num_Utimes]
192  std::vector<double> velYTimes_;
193  std::vector<double> velZTimes_;
194 
196  std::vector<double> tempTimes_; // Array of shape [num_Ttimes]
197 
198  // The following arrays are shaped [num_UHeights, num_Utimes]
202  // The temperature array is shaped [num_Theights, num_Ttimes]
204 
207 
210 
212  std::vector<double> TmeanCalc_;
213 
215  std::vector<double> TSource_;
216 
218  std::string searchMethod_;
223 
225  std::vector<std::string> fromTargetNames_;
226 
228  std::vector<std::string> velPartNames_;
229  std::vector<std::string> tempPartNames_;
230  std::unordered_set<std::string> allPartNames_;
231 
233  stk::mesh::Selector inactiveSelector_;
234 
236 
239 
242 
244  std::string velPartFmt_;
245 
247  std::string tempPartFmt_;
248 
251 
255  std::string outFileFmt_;
256 };
257 }
258 }
259 
260 #endif /* ABLFORCINGALGORITHM_H */
double searchExpansionFactor_
stk::Transfer search expansion factor
Definition: ABLForcingAlgorithm.h:222
Guard.
Definition: ABLForcingAlgorithm.h:82
Array2D< double > velY_
Definition: ABLForcingAlgorithm.h:200
std::vector< Part * > PartVector
Definition: Algorithm.h:16
~ABLForcingAlgorithm()
Definition: ABLForcingAlgorithm.C:69
std::vector< std::string > velPartNames_
Part names.
Definition: ABLForcingAlgorithm.h:228
stk::mesh::Selector inactiveSelector_
Definition: ABLForcingAlgorithm.h:233
double alphaMomentum_
Relaxation factor for momentum sources.
Definition: ABLForcingAlgorithm.h:179
Definition: ABLForcingAlgorithm.C:26
void compute_temperature_sources()
Compute average planar temperature and estimate source term.
Definition: ABLForcingAlgorithm.C:490
No ABL forcing applied.
Definition: ABLForcingAlgorithm.h:79
std::vector< std::string > tempPartNames_
Definition: ABLForcingAlgorithm.h:229
ABLForcingTypes momSrcType_
Momentum Forcing Source Type.
Definition: ABLForcingAlgorithm.h:173
Array2D< double > velX_
Definition: ABLForcingAlgorithm.h:199
stk::mesh::Selector & inactive_selector()
Inactive selector representing union of all the parts.
Definition: ABLForcingAlgorithm.h:115
Array2D< double > USource_
U source as a function of height [3,num_UHeights].
Definition: ABLForcingAlgorithm.h:209
Source terms provided by user.
Definition: ABLForcingAlgorithm.h:80
ABLForcingTypes
Types of ABL forcing available.
Definition: ABLForcingAlgorithm.h:78
double alphaTemperature_
Relaxation factor for temperature sources.
Definition: ABLForcingAlgorithm.h:182
std::vector< std::string > fromTargetNames_
Domains where velocity/temperature are averaged.
Definition: ABLForcingAlgorithm.h:225
bool momentumForcingOn()
Definition: ABLForcingAlgorithm.h:117
Forcing computed by code given target profiles.
Definition: ABLForcingAlgorithm.h:81
bool tempGenPartList_
Flag indicating whether to generate part names list for temperature field.
Definition: ABLForcingAlgorithm.h:241
std::string searchMethod_
stk::Transfer search methods
Definition: ABLForcingAlgorithm.h:218
bool ablForcingOn()
Definition: ABLForcingAlgorithm.h:121
void compute_momentum_sources()
Compute mean velocity and estimate source term for a given timestep.
Definition: ABLForcingAlgorithm.C:430
stk::mesh::PartVector allParts_
Definition: ABLForcingAlgorithm.h:232
std::vector< double > tempTimes_
Times where temperature information is available.
Definition: ABLForcingAlgorithm.h:196
bool temperatureForcingOn()
Definition: ABLForcingAlgorithm.h:119
std::string velPartFmt_
Format string specifier for generating velocity parts list.
Definition: ABLForcingAlgorithm.h:244
void create_interp_arrays(const std::vector< double >::size_type, const Array2D< double > &, std::vector< double > &, Array2D< double > &)
Create 2-D interpolation lookup tables from YAML data structures.
Definition: ABLForcingAlgorithm.C:215
Realm & realm_
Reference to Realm.
Definition: ABLForcingAlgorithm.h:170
Transfers * transfers_
Definition: ABLForcingAlgorithm.h:235
void determine_part_names(std::vector< double > &, std::vector< std::string > &, bool, std::string &)
Helper method that determines the part corresponding to a desired vertical level and ensures that par...
Definition: ABLForcingAlgorithm.C:260
ABLForcingTypes tempSrcType_
Temperature Forcing Source Type.
Definition: ABLForcingAlgorithm.h:176
void eval_temperature_source(const double, double &)
Evaluate the ABL forcing source contribution (temperature)
Definition: ABLForcingAlgorithm.C:647
int outputFreq_
Write frequency for source term output.
Definition: ABLForcingAlgorithm.h:250
void populate_transfer_data(std::string, const std::vector< std::string > &)
Definition: ABLForcingAlgorithm.C:390
void calc_mean_temperature()
Definition: ABLForcingAlgorithm.C:585
void initialize()
Initialize ABL forcing (steps after mesh creation)
Definition: ABLForcingAlgorithm.C:320
ABL Forcing Source terms for Momentum and Temperature equations.
Definition: ABLForcingAlgorithm.h:69
void create_transfers()
Create transfer that handles mapping of velocity and temperature from fluidRealm to the planar nodese...
Definition: ABLForcingAlgorithm.C:377
std::unordered_set< std::string > allPartNames_
Definition: ABLForcingAlgorithm.h:230
std::string outFileFmt_
Format string specifier indicating the file name for output.
Definition: ABLForcingAlgorithm.h:255
std::vector< double > tempHeights_
Heights where temperature information is provided.
Definition: ABLForcingAlgorithm.h:188
Tpetra::Map< LocalOrdinal, GlobalOrdinal >::node_type Node
Definition: LinearSolver.h:32
void register_fields()
Register velocity and temperature fields on the appropriate parts based on user input.
Definition: ABLForcingAlgorithm.C:291
std::string tempPartFmt_
Format string specifier for generating temperature parts list.
Definition: ABLForcingAlgorithm.h:247
std::vector< double > TSource_
T source as a function of height [num_THeights].
Definition: ABLForcingAlgorithm.h:215
bool velGenPartList_
Flag indicating whether to generate part names list for velocity field.
Definition: ABLForcingAlgorithm.h:238
std::vector< std::vector< T >> Array2D
Definition: ABLForcingAlgorithm.h:73
double searchTolerance_
stk::Transfer search tolerance
Definition: ABLForcingAlgorithm.h:220
std::vector< double > TmeanCalc_
Planar average temperature calculated on the surface [num_THeights].
Definition: ABLForcingAlgorithm.h:212
void eval_momentum_source(const double, std::vector< double > &)
Evaluate the ABL forcing source contribution at a node.
Definition: ABLForcingAlgorithm.C:628
void load_momentum_info(const YAML::Node &)
Utility function to parse momentum forcing options from input file.
Definition: ABLForcingAlgorithm.C:108
void execute()
Execute field transfers, compute planar averaging, and determine source terms at desired levels...
Definition: ABLForcingAlgorithm.C:417
Definition: Transfers.h:31
std::vector< double > velYTimes_
Definition: ABLForcingAlgorithm.h:192
std::vector< double > velXTimes_
Times where velocity information is available.
Definition: ABLForcingAlgorithm.h:191
Definition: Realm.h:82
void calc_mean_velocity()
Helper method to compute the average velocity on a z-planes.
Definition: ABLForcingAlgorithm.C:528
void load(const YAML::Node &)
Parse input file for user options and initialize.
Definition: ABLForcingAlgorithm.C:76
Array2D< double > UmeanCalc_
Planar average velocity calculated on the surface [num_UHeights, 3].
Definition: ABLForcingAlgorithm.h:206
Array2D< double > temp_
Definition: ABLForcingAlgorithm.h:203
void setup()
Setup ABL forcing (steps before mesh creation)
Definition: ABLForcingAlgorithm.C:247
Array2D< double > velZ_
Definition: ABLForcingAlgorithm.h:201
std::vector< double > velHeights_
Heights where velocity information is provided.
Definition: ABLForcingAlgorithm.h:185
std::vector< double > velZTimes_
Definition: ABLForcingAlgorithm.h:193
void load_temperature_info(const YAML::Node &)
Helper method to parse temperature forcing options from input file.
Definition: ABLForcingAlgorithm.C:168