Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_PhysicsBlock.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef PANZER_PHYSICS_BLOCK_HPP
12 #define PANZER_PHYSICS_BLOCK_HPP
13 
14 #include <string>
15 #include <vector>
16 #include <map>
17 
18 #include "Teuchos_RCP.hpp"
19 #include "Phalanx_FieldManager.hpp"
20 #include "Panzer_Traits.hpp"
21 #include "Panzer_CellData.hpp"
22 #include "Panzer_EquationSet.hpp"
25 #include "Panzer_FieldLibrary.hpp"
27 #include "Panzer_WorksetNeeds.hpp"
28 
29 namespace Teuchos {
30  class ParameterList;
31 }
32 
33 namespace shards {
34  class CellTopology;
35 }
36 
37 namespace panzer {
38  class PureBasis;
39  class IntegrationRule;
40  struct EquationSetFactory;
41  struct GlobalData;
42  class PhysicsBlock;
43 }
44 
45 namespace panzer {
46 
47 
51  void buildPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
52  const std::map<std::string,Teuchos::RCP<const shards::CellTopology> >& block_ids_to_cell_topo,
53  const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
54  const int default_integration_order,
55  const std::size_t workset_size,
57  const Teuchos::RCP<panzer::GlobalData>& global_data,
58  const bool build_transient_support,
59  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
60  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
61 
68  void readPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
69  const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
70  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks);
71 
79  Teuchos::RCP<panzer::PhysicsBlock> findPhysicsBlock(const std::string element_block_id,
80  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physics_blocks,
81  bool throw_on_failure = true);
82 
85 
86  public:
88  explicit PhysicsBlock()
89  : m_build_transient_support(false), m_global_data(Teuchos::null),
90  m_active_evaluation_types(Sacado::mpl::size<panzer::Traits::EvalTypes>::value,true)
91  { std::cout << "WARNING: Default constructor for panzer::PhysicsBlock is for testing purposes only!" << std::endl; }
92 
95  PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
96  const std::string & element_block_id,
97  const int default_integration_order,
98  const panzer::CellData & cell_data,
100  const Teuchos::RCP<panzer::GlobalData>& global_data,
101  const bool build_transient_support,
102  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
103 
109  PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
110  const std::string & element_block_id);
111 
113  const panzer::CellData & cell_data);
114 
119  PhysicsBlock(const std::string & element_block_id,
120  const std::string & physics_block_id,
121  const int integration_order,
122  const panzer::CellData & cell_data,
123  const Teuchos::RCP<panzer::GlobalData>& global_data,
124  const Teuchos::RCP<panzer::PureBasis> & fields);
125 
129  void initialize(const int default_integration_order,
130  const bool build_transient_support,
131  const panzer::CellData & cell_data,
133  const Teuchos::RCP<panzer::GlobalData>& global_data,
134  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
135 
137  void setActiveEvaluationTypes(const std::vector<bool>& aet);
138 
141 
143  const Teuchos::ParameterList& user_data) const;
144 
147  const Teuchos::ParameterList& user_data) const;
148 
151  const Teuchos::ParameterList& user_data) const;
152 
155  const Teuchos::ParameterList& user_data) const;
156 
159  const Teuchos::ParameterList& models,
160  const Teuchos::ParameterList& user_data) const;
161 
164  const std::string& model_name,
165  const Teuchos::ParameterList& models,
167  const Teuchos::ParameterList& user_data) const;
168 
171  const std::string& model_name,
172  const Teuchos::ParameterList& models,
173  const Teuchos::ParameterList& user_data) const;
174 
175  template<typename EvalT>
177  const Teuchos::ParameterList& user_data) const;
178 
179  template<typename EvalT>
182  const Teuchos::ParameterList& user_data) const;
183 
184  template<typename EvalT>
187  const Teuchos::ParameterList& user_data) const;
188 
189  template<typename EvalT>
192  const Teuchos::ParameterList& user_data) const;
193 
194  template<typename EvalT>
197  const Teuchos::ParameterList& models,
198  const Teuchos::ParameterList& user_data) const;
199 
200  template<typename EvalT>
203  const std::string& model_name,
204  const Teuchos::ParameterList& models,
206  const Teuchos::ParameterList& user_data) const;
207 
208  const std::vector<std::string>& getDOFNames() const;
209  const std::vector<StrPureBasisPair>& getProvidedDOFs() const;
210 
211  const std::vector<std::vector<std::string> > & getCoordinateDOFs() const;
212 
214  const std::vector<StrPureBasisPair>& getTangentFields() const;
215 
219 
221  const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >& getBases() const;
222 
224  const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >& getIntegrationRules() const;
225 
226  const shards::CellTopology getBaseCellTopology() const;
227 
228  std::string physicsBlockID() const;
229  std::string elementBlockID() const;
230 
231  const panzer::CellData & cellData() const;
232 
238 
240 
242  { return m_field_lib.getConst(); }
243 
245  { return m_field_lib.getConst(); }
246 
247  // return the Physics Block parameter list
249  { return m_input_parameters; }
250 
251  protected:
252  void initialize(const Teuchos::RCP<Teuchos::ParameterList>& input_parameters,
253  const int& default_integration_order,
254  const std::string & element_block_id,
255  const panzer::CellData & cell_data,
256  const bool build_transient_support,
257  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
258 
259  std::string m_physics_id;
260  std::string m_element_block_id;
267 
268  std::vector<std::string> m_dof_names;
269  std::vector<StrPureBasisPair> m_provided_dofs;
270  std::vector<StrPureBasisPair> m_tangent_fields;
271  std::vector<std::vector<std::string> > m_coordinate_dofs; // coordinate DOFs (defines them)
272 
274  std::map<std::string,Teuchos::RCP<panzer::PureBasis> > m_bases;
276  std::map<int,Teuchos::RCP<panzer::IntegrationRule> > m_integration_rules;
277 
278  std::vector< Teuchos::RCP<panzer::EquationSet_TemplateManager<panzer::Traits> > > m_equation_sets;
281 
283  std::vector<bool> m_active_evaluation_types;
284  };
285 
286 }
287 
288 // ************************************************************
289 // template implementations
290 // ************************************************************
291 
292 template<typename EvalT>
294  const Teuchos::ParameterList& user_data) const
295 {
296  using std::vector;
297  using Teuchos::RCP;
299 
300  // Loop over equation set template managers
301  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
302  eq_set = m_equation_sets.begin();
303  int idx = 0;
304  for (;eq_set != m_equation_sets.end(); ++eq_set,++idx) {
305  if (m_active_evaluation_types[idx]) {
307 
308  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
309  eqstm.getAsObject<EvalT>()->buildAndRegisterEquationSetEvaluators(fm, *m_field_lib, user_data);
310  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
311  }
312  }
313 }
314 
315 template<typename EvalT>
318  const Teuchos::ParameterList& user_data) const
319 {
320  using std::vector;
321  using Teuchos::RCP;
323 
324  // Loop over equation set template managers
325  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
326  eq_set = m_equation_sets.begin();
327  int idx = 0;
328  for (;eq_set != m_equation_sets.end(); ++eq_set,++idx) {
329  if (m_active_evaluation_types[idx]) {
330 
332 
333  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
334  eqstm.getAsObject<EvalT>()->buildAndRegisterGatherAndOrientationEvaluators(fm,*m_field_lib,lof,user_data);
335  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
336  }
337  }
338 }
339 
340 template<typename EvalT>
343  const Teuchos::ParameterList& user_data) const
344 {
345  using std::vector;
346  using Teuchos::RCP;
348 
349  // Loop over equation set template managers
350  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
351  eq_set = m_equation_sets.begin();
352  for (;eq_set != m_equation_sets.end(); ++eq_set) {
354 
355  // Loop over integration rules
356  for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
357  ir_iter != m_integration_rules.end(); ++ ir_iter) {
358 
359  Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
360 
361  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
362  eqstm.getAsObject<EvalT>()->buildAndRegisterDOFProjectionsToIPEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,lof,user_data);
363  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
364  }
365 
366  }
367 }
368 
369 template<typename EvalT>
372  const Teuchos::ParameterList& user_data) const
373 {
374  using std::vector;
375  using Teuchos::RCP;
377 
378  // Loop over equation set template managers
379  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
380  eq_set = m_equation_sets.begin();
381  for (;eq_set != m_equation_sets.end(); ++eq_set) {
382 
384 
385  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
386  eqstm.getAsObject<EvalT>()->buildAndRegisterScatterEvaluators(fm,*m_field_lib,lof,user_data);
387  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
388  }
389 }
390 
391 template<typename EvalT>
394  const Teuchos::ParameterList& models,
395  const Teuchos::ParameterList& user_data) const
396 {
397  using std::vector;
398  using Teuchos::RCP;
400 
401  // Loop over equation set template managers
402  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
403  eq_set = m_equation_sets.begin();
404  for (;eq_set != m_equation_sets.end(); ++eq_set) {
405 
407 
408  // Loop over integration rules
409  for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
410  ir_iter != m_integration_rules.end(); ++ ir_iter) {
411 
412  Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
413 
414  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
415  eqstm.getAsObject<EvalT>()->buildAndRegisterClosureModelEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,factory,models,user_data);
416  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
417  }
418 
419  }
420 }
421 
422 template<typename EvalT>
425  const std::string& model_name,
426  const Teuchos::ParameterList& models,
428  const Teuchos::ParameterList& user_data) const
429 {
430  using std::vector;
431  using Teuchos::RCP;
433 
434  // Loop over equation set template managers
435  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
436  eq_set = m_equation_sets.begin();
437  for (;eq_set != m_equation_sets.end(); ++eq_set) {
438  std::vector<StrBasisPair> providedDOFs;
439 
441 
442  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
443  eqstm.getAsObject<EvalT>()->buildAndRegisterInitialConditionEvaluators(fm, *m_field_lib, factory, model_name, models, lof, user_data);
444  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
445  }
446 }
447 
448 #endif
Teuchos::RCP< PhysicsBlock > copyWithCellData(const panzer::CellData &cell_data) const
const std::vector< std::string > & getDOFNames() const
std::vector< StrPureBasisPair > m_provided_dofs
Teuchos::RCP< panzer::GlobalData > m_global_data
Object that contains information on the physics and discretization of a block of elements with the SA...
Teuchos::RCP< typename Sacado::mpl::apply< panzer::EquationSet< _ >, ScalarT >::type > getAsObject()
const std::map< std::string, Teuchos::RCP< panzer::PureBasis > > & getBases() const
Returns the unique set of bases, key is the unique panzer::PureBasis::name() of the basis...
int setDetailsIndex(const int details_index)
Teuchos::RCP< const panzer::EquationSetFactory > m_eqset_factory
const panzer::CellData & cellData() const
void buildAndRegisterClosureModelEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const Teuchos::ParameterList &models, const Teuchos::ParameterList &user_data) const
void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
int getDetailsIndex() const
Get the WorksetDetails index.
void buildAndRegisterClosureModelEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const Teuchos::ParameterList &models, const Teuchos::ParameterList &user_data) const
std::string physicsBlockID() const
void buildAndRegisterInitialConditionEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const std::string &model_name, const Teuchos::ParameterList &models, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
PHX::TemplateManager< TypeSeq, BaseT, ObjectT >::iterator begin()
Teuchos::RCP< panzer::GlobalData > globalData() const
void setActiveEvaluationTypes(const std::vector< bool > &aet)
Used to save memory by disabling unneeded evaluation types.
std::vector< Teuchos::RCP< panzer::EquationSet_TemplateManager< panzer::Traits > > > m_equation_sets
void buildAndRegisterDOFProjectionsToIPEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
std::vector< std::vector< std::string > > m_coordinate_dofs
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
Data for determining cell topology and dimensionality.
panzer::CellData m_cell_data
std::string elementBlockID() const
const std::vector< std::vector< std::string > > & getCoordinateDOFs() const
std::map< std::string, Teuchos::RCP< panzer::PureBasis > > m_bases
map of unique bases, key is the panzer::PureBasis::name() corresponding to its value ...
void buildAndRegisterGatherAndOrientationEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
Teuchos::RCP< Teuchos::ParameterList > m_input_parameters
store the input parameter list for copy ctors
void buildAndRegisterEquationSetEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
std::map< int, Teuchos::RCP< panzer::IntegrationRule > > m_integration_rules
map of unique integration rules, key is panzer::IntegrationRule::order() corresponding to its value ...
void buildAndRegisterInitialConditionEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const std::string &model_name, const Teuchos::ParameterList &models, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
const shards::CellTopology getBaseCellTopology() const
const std::vector< StrPureBasisPair > & getTangentFields() const
Returns list of tangent fields from DOFs and tangent param names.
Teuchos::RCP< const FieldLibrary > getFieldLibrary() const
WorksetNeeds getWorksetNeeds() const
Teuchos::RCP< const FieldLibraryBase > getFieldLibraryBase() const
void activateAllEvaluationTypes()
Used to reactivate all evaluation types if some were temporarily disabled with a call to setActiveEva...
const std::map< int, Teuchos::RCP< panzer::IntegrationRule > > & getIntegrationRules() const
Returns the unique set of point rules, key is the unique panzer::PointRule::name() ...
void initialize(const int default_integration_order, const bool build_transient_support, const panzer::CellData &cell_data, const Teuchos::RCP< const panzer::EquationSetFactory > &factory, const Teuchos::RCP< panzer::GlobalData > &global_data, const std::vector< std::string > &tangent_param_names=std::vector< std::string >())
Teuchos::RCP< FieldLibrary > m_field_lib
std::vector< bool > m_active_evaluation_types
Returns true for evaluation types that are active.
std::vector< std::string > m_dof_names
void buildAndRegisterDOFProjectionsToIPEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
void buildAndRegisterScatterEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
std::vector< StrPureBasisPair > m_tangent_fields
void buildAndRegisterEquationSetEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const