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
PeriodicManager.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 PeriodicManager_h
10 #define PeriodicManager_h
11 
12 //==============================================================================
13 // Includes and forwards
14 //==============================================================================
15 
16 #include <FieldTypeDef.h>
17 
18 // stk
19 #include <stk_mesh/base/Part.hpp>
20 #include <stk_mesh/base/Ghosting.hpp>
21 
22 #include <stk_search/BoundingBox.hpp>
23 #include <stk_search/CoarseSearch.hpp>
24 #include <stk_search/IdentProc.hpp>
25 
26 #include <vector>
27 #include <list>
28 #include <map>
29 
30 namespace sierra {
31 namespace nalu {
32 
33 class Realm;
34 
35 typedef stk::search::IdentProc<stk::mesh::EntityKey,int> theEntityKey;
36 typedef stk::search::Point<double> Point;
37 typedef stk::search::Sphere<double> Sphere;
38 typedef std::pair<Sphere,theEntityKey> sphereBoundingBox;
39 
41 
42  public:
43 
44  // constructor and destructor
46  Realm & realm);
47 
49 
51 
52  void add_periodic_pair(
53  stk::mesh::Part* meshPartsMaster,
54  stk::mesh::Part* meshPartsSlave,
55  const double &userSearchTolerance,
56  const std::string &searchMethodName);
57 
58  void build_constraints();
59 
60  // holder for master += slave; slave = master
61  void apply_constraints(
62  stk::mesh::FieldBase *,
63  const unsigned &sizeOfField,
64  const bool &bypassFieldCheck,
65  const bool &addSlaves = true,
66  const bool &setSlaves = true);
67 
68  // find the max
69  void apply_max_field(
70  stk::mesh::FieldBase *,
71  const unsigned &sizeOfField);
72 
74 
75  stk::mesh::Ghosting * get_ghosting_object();
76 
78 
79  double get_search_time();
80 
81  private:
82 
84 
86 
88  stk::mesh::Selector masterSelector,
89  stk::mesh::Selector slaveSelector,
90  std::vector<double> &translationVector,
91  std::vector<double> &rotationVector);
92 
94 
95  void finalize_search();
96 
98  stk::mesh::Selector masterSelector,
99  stk::mesh::Selector slaveSelector,
100  std::vector<double> &translationVector,
101  const stk::search::SearchMethod searchMethod);
102 
103  void error_check();
104 
105  void update_global_id_field();
106 
107  /* communicate periodicGhosting nodes */
108  void
110  stk::mesh::FieldBase *theField);
111 
112  /* communicate shared nodes and aura nodes */
113  void
115  stk::mesh::FieldBase *theField);
116 
118 
119  /* manage tolerances; each block specifies a user tolerance */
121 
122  stk::mesh::Ghosting *periodicGhosting_;
123  const std::string ghostingName_;
124  double timerSearch_;
125 
126  // algorithm to find/exclude points when M/S does not match
129  const double amplificationFactor_;
130 
131  // the data structures to hold master/slave information
132  typedef std::pair<stk::mesh::Entity, stk::mesh::Entity> EntityPair;
133  typedef std::pair<stk::mesh::Selector, stk::mesh::Selector> SelectorPair;
134  typedef std::vector<std::pair<theEntityKey,theEntityKey> > SearchKeyVector;
135 
136  // vector of master:slave selector pairs
137  std::vector<SelectorPair> periodicSelectorPairs_;
138 
139  // vector of slave parts
141 
142  // vector of search types
143  std::vector<stk::search::SearchMethod> searchMethodVec_;
144 
145  // translation and rotation
146  std::vector<std::vector<double> > translationVector_;
147  std::vector<std::vector<double> > rotationVector_;
148 
149  // vector of masterEntity:slaveEntity
150  std::vector<EntityPair> masterSlaveCommunicator_;
151 
152  // culmination of all searches
153  SearchKeyVector searchKeyVector_;
154 
155  void add_slave_to_master(
156  stk::mesh::FieldBase *theField,
157  const unsigned &sizeOfField,
158  const bool &bypassFieldCheck);
159 
160  void set_slave_to_master(
161  stk::mesh::FieldBase *theField,
162  const unsigned &sizeOfField,
163  const bool &bypassFieldCheck);
164 
165 };
166 
167 } // namespace nalu
168 } // namespace sierra
169 
170 #endif
void finalize_search()
Definition: PeriodicManager.C:375
Definition: PeriodicManager.h:40
void add_slave_to_master(stk::mesh::FieldBase *theField, const unsigned &sizeOfField, const bool &bypassFieldCheck)
Definition: PeriodicManager.C:730
std::vector< Part * > PartVector
Definition: Algorithm.h:16
std::pair< Sphere, theEntityKey > sphereBoundingBox
Definition: PeriodicManager.h:38
void error_check()
Definition: PeriodicManager.C:488
std::vector< stk::search::SearchMethod > searchMethodVec_
Definition: PeriodicManager.h:143
std::pair< stk::mesh::Selector, stk::mesh::Selector > SelectorPair
Definition: PeriodicManager.h:133
Definition: ABLForcingAlgorithm.C:26
const stk::mesh::PartVector & get_slave_part_vector()
Definition: PeriodicManager.C:103
void update_global_id_field()
Definition: PeriodicManager.C:642
stk::search::Sphere< double > Sphere
Definition: Actuator.h:40
void apply_max_field(stk::mesh::FieldBase *, const unsigned &sizeOfField)
Definition: PeriodicManager.C:698
const double amplificationFactor_
Definition: PeriodicManager.h:129
void parallel_communicate_field(stk::mesh::FieldBase *theField)
Definition: PeriodicManager.C:626
const std::string ghostingName_
Definition: PeriodicManager.h:123
double get_search_time()
Definition: PeriodicManager.C:112
std::vector< SelectorPair > periodicSelectorPairs_
Definition: PeriodicManager.h:137
int errorCount_
Definition: PeriodicManager.h:127
void set_slave_to_master(stk::mesh::FieldBase *theField, const unsigned &sizeOfField, const bool &bypassFieldCheck)
Definition: PeriodicManager.C:782
stk::search::Point< double > Point
Definition: Actuator.h:39
void augment_periodic_selector_pairs()
Definition: PeriodicManager.C:153
void initialize_error_count()
Definition: PeriodicManager.C:60
std::vector< std::vector< double > > translationVector_
Definition: PeriodicManager.h:146
stk::search::IdentProc< stk::mesh::EntityKey, int > theEntityKey
Definition: PeriodicManager.h:33
PeriodicManager(Realm &realm)
Definition: PeriodicManager.C:37
void manage_ghosting_object()
Definition: PeriodicManager.C:555
double timerSearch_
Definition: PeriodicManager.h:124
void remove_redundant_slave_nodes()
Definition: PeriodicManager.C:315
std::vector< std::vector< double > > rotationVector_
Definition: PeriodicManager.h:147
stk::mesh::Ghosting * periodicGhosting_
Definition: PeriodicManager.h:122
void build_constraints()
Definition: PeriodicManager.C:120
stk::mesh::PartVector slavePartVector_
Definition: PeriodicManager.h:140
void initialize_translation_vector()
Definition: PeriodicManager.C:218
void periodic_parallel_communicate_field(stk::mesh::FieldBase *theField)
Definition: PeriodicManager.C:613
void determine_translation(stk::mesh::Selector masterSelector, stk::mesh::Selector slaveSelector, std::vector< double > &translationVector, std::vector< double > &rotationVector)
Definition: PeriodicManager.C:234
double searchTolerance_
Definition: PeriodicManager.h:120
void add_periodic_pair(stk::mesh::Part *meshPartsMaster, stk::mesh::Part *meshPartsSlave, const double &userSearchTolerance, const std::string &searchMethodName)
Definition: PeriodicManager.C:69
stk::mesh::Ghosting * get_ghosting_object()
Definition: PeriodicManager.C:604
std::vector< EntityPair > masterSlaveCommunicator_
Definition: PeriodicManager.h:150
void apply_constraints(stk::mesh::FieldBase *, const unsigned &sizeOfField, const bool &bypassFieldCheck, const bool &addSlaves=true, const bool &setSlaves=true)
Definition: PeriodicManager.C:674
std::vector< std::pair< theEntityKey, theEntityKey > > SearchKeyVector
Definition: PeriodicManager.h:134
int maxErrorCount_
Definition: PeriodicManager.h:128
~PeriodicManager()
Definition: PeriodicManager.C:51
Definition: Realm.h:82
Realm & realm_
Definition: PeriodicManager.h:117
SearchKeyVector searchKeyVector_
Definition: PeriodicManager.h:153
void populate_search_key_vec(stk::mesh::Selector masterSelector, stk::mesh::Selector slaveSelector, std::vector< double > &translationVector, const stk::search::SearchMethod searchMethod)
Definition: PeriodicManager.C:398
std::pair< stk::mesh::Entity, stk::mesh::Entity > EntityPair
Definition: PeriodicManager.h:132