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
ActuatorLineFAST.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 #ifdef NALU_USES_OPENFAST
9 
15 #ifndef ActuatorLineFAST_h
16 #define ActuatorLineFAST_h
17 
18 #include <stk_util/parallel/ParallelVectorConcat.hpp>
19 #include "Actuator.h"
20 
21 // OpenFAST C++ API
22 #include "OpenFAST.H"
23 
24 namespace sierra{
25 namespace nalu{
26 
27 class Realm;
28 
33 //
34 class ActuatorLineFASTInfo {
35 public:
36  ActuatorLineFASTInfo();
37  ~ActuatorLineFASTInfo();
38 
39  int processorId_;
40  int numPoints_;
41  std::string turbineName_;
42  Coordinates epsilon_;
43 };
44 
49 //
50 class ActuatorLineFASTPointInfo {
51  public:
52  ActuatorLineFASTPointInfo(
53  size_t globTurbId, Point centroidCoords, double searchRadius, Coordinates epsilon, fast::ActuatorNodeType nType);
54  ~ActuatorLineFASTPointInfo();
55  size_t globTurbId_;
56  Point centroidCoords_;
57  double searchRadius_;
58  Coordinates epsilon_;
59  double bestX_;
60  stk::mesh::Entity bestElem_;
61 
62  fast::ActuatorNodeType nodeType_;
63 
64  std::vector<double> isoParCoords_;
65  std::vector<stk::mesh::Entity> elementVec_;
66 };
67 
139 class ActuatorLineFAST: public Actuator {
140  public:
141 
142  ActuatorLineFAST(
143  Realm &realm,
144  const YAML::Node &node);
145  ~ActuatorLineFAST();
146 
147  // load all of the options
148  void load(
149  const YAML::Node & node);
150 
151  // load the options for each turbine
152  void readTurbineData(int iTurb, fast::fastInputs & fi, YAML::Node turbNode);
153 
154  // setup part creation and nodal field registration (before populate_mesh())
155  void setup();
156 
157  // allocate turbines to processors containing hub location
158  void allocateTurbinesToProcs() ;
159 
160  // Allocate turbines to processors, initialize FAST and get location of actuator points
161  void initialize();
162 
163  // setup part creation and nodal field registration (after populate_mesh())
164  void update();
165 
166  // determine processor bounding box in the mesh
167  void populate_candidate_procs();
168 
169  // determine element bounding box in the mesh
170  void populate_candidate_elements();
171 
172  // fill in the map that will hold point and ghosted elements
173  void create_actuator_line_point_info_map();
174 
175  // figure out the set of elements that belong in the custom ghosting data structure
176  void determine_elems_to_ghost();
177 
178  // deal with custom ghosting
179  void manage_ghosting();
180 
181  // populate vector of elements
182  void complete_search();
183 
184  // populate nodal field and output norms (if appropriate)
185  void execute();
186 
187  // support methods to gather data; scalar and vector
188  void resize_std_vector(
189  const int &sizeOfField,
190  std::vector<double> &theVector,
191  stk::mesh::Entity elem,
192  const stk::mesh::BulkData & bulkData);
193 
194  // general gather methods for scalar and vector (both double)
195  void gather_field(
196  const int &sizeOfField,
197  double *fieldToFill,
198  const stk::mesh::FieldBase &stkField,
199  stk::mesh::Entity const* elem_node_rels,
200  const int &nodesPerElement);
201 
202  void gather_field_for_interp(
203  const int &sizeOfField,
204  double *fieldToFill,
205  const stk::mesh::FieldBase &stkField,
206  stk::mesh::Entity const* elem_node_rels,
207  const int &nodesPerElement);
208 
209  // element volume and scv volume populated
210  double compute_volume(
211  const int &nDim,
212  stk::mesh::Entity elem,
213  const stk::mesh::BulkData & bulkData);
214 
215  // interpolate field to point centroid
216  void interpolate_field(
217  const int &sizeOfField,
218  stk::mesh::Entity elem,
219  const stk::mesh::BulkData & bulkData,
220  double *isoParCoords,
221  const double *fieldAtNodes,
222  double *pointField);
223 
224  // centroid of the element
225  void compute_elem_centroid(
226  const int &nDim,
227  double *elemCentroid,
228  const int &nodesPerElement);
229 
230  // distance from element centroid to point centroid
231  double compute_distance(
232  const int &nDim,
233  const double *elemCentroid,
234  const double *pointCentroid);
235 
236  // compute the body force at an element given a
237  // projection weighting.
238  void compute_elem_force_given_weight(
239  const int &nDim,
240  const double &g,
241  const double *pointForce,
242  double *elemForce);
243 
244  // isotropic Gaussian projection function.
245  double isotropic_Gaussian_projection(
246  const int &nDim,
247  const double &dis,
248  const Coordinates &epsilon);
249 
250  // finally, perform the assembly
251  void assemble_source_to_nodes(
252  const int &nDim,
253  stk::mesh::Entity elem,
254  const stk::mesh::BulkData & bulkData,
255  const double &elemVolume,
256  const std::vector<double> & elemForce,
257  const double &gLocal,
258  stk::mesh::FieldBase & elemCoords,
259  stk::mesh::FieldBase &actuator_source,
260  stk::mesh::FieldBase &g,
261  stk::mesh::FieldBase &dualNodalVolume,
262  const std::vector<double> & hubPt,
263  const std::vector<double> & hubShftDir,
264  std::vector<double> & thr,
265  std::vector<double> & tor);
266 
267  void assemble_source_to_nodes(
268  const int &nDim,
269  stk::mesh::Entity elem,
270  const stk::mesh::BulkData & bulkData,
271  const double &elemVolume,
272  const std::vector<double> & elemForce,
273  const double &gLocal,
274  stk::mesh::FieldBase & elemCoords,
275  stk::mesh::FieldBase &actuator_source,
276  stk::mesh::FieldBase &g,
277  stk::mesh::FieldBase &dualNodalVolume,
278  const std::vector<double> & hubPt,
279  const std::vector<double> & hubShftDir);
280 
281  Realm &realm_;
282 
283  stk::search::SearchMethod searchMethod_;
284 
285  stk::mesh::Ghosting *actuatorLineGhosting_;
286  uint64_t needToGhostCount_;
287  stk::mesh::EntityProcVec elemsToGhost_;
288 
289  int tStepRatio_;
290 
291  std::vector<std::pair<theKey, theKey> > searchKeyPair_;
292 
293  // bounding box data types for stk_search
294  std::vector<boundingSphere> boundingSphereVec_;
295  std::vector<boundingElementBox> boundingElementBoxVec_;
296  std::vector<boundingSphere> boundingHubSphereVec_;
297  std::vector<boundingElementBox> boundingProcBoxVec_;
298 
299  std::vector<std::string> searchTargetNames_;
300 
301  std::vector<ActuatorLineFASTInfo *> actuatorLineInfo_;
302 
303  std::map<size_t, ActuatorLineFASTPointInfo *> actuatorLinePointInfoMap_;
304 
305  // scratch space
306  std::vector<double> ws_coordinates_;
307  std::vector<double> ws_scv_volume_;
308  std::vector<double> ws_velocity_;
309  std::vector<double> ws_density_;
310  std::vector<double> ws_viscosity_;
311 
312  fast::fastInputs fi;
313  fast::OpenFAST FAST;
314 
315  std::vector<std::vector<double>> thrust;
316  std::vector<std::vector<double>> torque;
317 
318 };
319 
320 
321 } // namespace nalu
322 } // namespace Sierra
323 
324 #endif
325 
326 #endif
Definition: ABLForcingAlgorithm.C:26
void initialize(int N, aligned_vector &x, aligned_vector &y)
Definition: UnitTestSimdBasic.C:37
stk::search::Point< double > Point
Definition: OversetManager.h:32
Tpetra::Map< LocalOrdinal, GlobalOrdinal >::node_type Node
Definition: LinearSolver.h:32