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 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef PANZER_PHYSICS_BLOCK_HPP
44 #define PANZER_PHYSICS_BLOCK_HPP
45 
46 #include <string>
47 #include <vector>
48 #include <map>
49 
50 #include "Teuchos_RCP.hpp"
51 #include "Phalanx_FieldManager.hpp"
52 #include "Panzer_Traits.hpp"
53 #include "Panzer_CellData.hpp"
54 #include "Panzer_EquationSet.hpp"
57 #include "Panzer_FieldLibrary.hpp"
59 #include "Panzer_WorksetNeeds.hpp"
60 
61 namespace Teuchos {
62  class ParameterList;
63 }
64 
65 namespace shards {
66  class CellTopology;
67 }
68 
69 namespace panzer {
70  class PureBasis;
71  class IntegrationRule;
72  struct EquationSetFactory;
73  struct GlobalData;
74  class PhysicsBlock;
75 }
76 
77 namespace panzer {
78 
79 
83  void buildPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
84  const std::map<std::string,Teuchos::RCP<const shards::CellTopology> >& block_ids_to_cell_topo,
85  const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
86  const int default_integration_order,
87  const std::size_t workset_size,
89  const Teuchos::RCP<panzer::GlobalData>& global_data,
90  const bool build_transient_support,
91  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
92  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
93 
100  void readPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
101  const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
102  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks);
103 
111  Teuchos::RCP<panzer::PhysicsBlock> findPhysicsBlock(const std::string element_block_id,
112  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physics_blocks,
113  bool throw_on_failure = true);
114 
117 
118  public:
120  explicit PhysicsBlock()
121  : m_build_transient_support(false), m_global_data(Teuchos::null)
122  { std::cout << "WARNING: Default constructor for panzer::PhysicsBlock is for testing purposes only!" << std::endl; }
123 
126  PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
127  const std::string & element_block_id,
128  const int default_integration_order,
129  const panzer::CellData & cell_data,
131  const Teuchos::RCP<panzer::GlobalData>& global_data,
132  const bool build_transient_support,
133  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
134 
140  PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
141  const std::string & element_block_id);
142 
144  const panzer::CellData & cell_data);
145 
150  PhysicsBlock(const std::string & element_block_id,
151  const std::string & physics_block_id,
152  const int integration_order,
153  const panzer::CellData & cell_data,
154  const Teuchos::RCP<panzer::GlobalData>& global_data,
155  const Teuchos::RCP<panzer::PureBasis> & fields);
156 
160  void initialize(const int default_integration_order,
161  const bool build_transient_support,
162  const panzer::CellData & cell_data,
164  const Teuchos::RCP<panzer::GlobalData>& global_data,
165  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
166 
168  const Teuchos::ParameterList& user_data) const;
169 
172  const Teuchos::ParameterList& user_data) const;
173 
176  const Teuchos::ParameterList& user_data) const;
177 
180  const Teuchos::ParameterList& user_data) const;
181 
184  const Teuchos::ParameterList& models,
185  const Teuchos::ParameterList& user_data) const;
186 
189  const std::string& model_name,
190  const Teuchos::ParameterList& models,
192  const Teuchos::ParameterList& user_data) const;
193 
196  const std::string& model_name,
197  const Teuchos::ParameterList& models,
198  const Teuchos::ParameterList& user_data) const;
199 
200  template<typename EvalT>
202  const Teuchos::ParameterList& user_data) const;
203 
204  template<typename EvalT>
207  const Teuchos::ParameterList& user_data) const;
208 
209  template<typename EvalT>
212  const Teuchos::ParameterList& user_data) const;
213 
214  template<typename EvalT>
217  const Teuchos::ParameterList& user_data) const;
218 
219  template<typename EvalT>
222  const Teuchos::ParameterList& models,
223  const Teuchos::ParameterList& user_data) const;
224 
225  template<typename EvalT>
228  const std::string& model_name,
229  const Teuchos::ParameterList& models,
231  const Teuchos::ParameterList& user_data) const;
232 
233  const std::vector<std::string>& getDOFNames() const;
234  const std::vector<StrPureBasisPair>& getProvidedDOFs() const;
235 
236  const std::vector<std::vector<std::string> > & getCoordinateDOFs() const;
237 
239  const std::vector<StrPureBasisPair>& getTangentFields() const;
240 
244 
246  const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >& getBases() const;
247 
249  const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >& getIntegrationRules() const;
250 
251  const shards::CellTopology getBaseCellTopology() const;
252 
253  std::string physicsBlockID() const;
254  std::string elementBlockID() const;
255 
256  const panzer::CellData & cellData() const;
257 
263 
265 
267  { return m_field_lib.getConst(); }
268 
270  { return m_field_lib.getConst(); }
271 
272  // return the Physics Block parameter list
274  { return m_input_parameters; }
275 
276  protected:
277  void initialize(const Teuchos::RCP<Teuchos::ParameterList>& input_parameters,
278  const int& default_integration_order,
279  const std::string & element_block_id,
280  const panzer::CellData & cell_data,
281  const bool build_transient_support,
282  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
283 
284  std::string m_physics_id;
285  std::string m_element_block_id;
292 
293  std::vector<std::string> m_dof_names;
294  std::vector<StrPureBasisPair> m_provided_dofs;
295  std::vector<StrPureBasisPair> m_tangent_fields;
296  std::vector<std::vector<std::string> > m_coordinate_dofs; // coordinate DOFs (defines them)
297 
299  std::map<std::string,Teuchos::RCP<panzer::PureBasis> > m_bases;
301  std::map<int,Teuchos::RCP<panzer::IntegrationRule> > m_integration_rules;
302 
303  std::vector< Teuchos::RCP<panzer::EquationSet_TemplateManager<panzer::Traits> > > m_equation_sets;
306  };
307 
308 }
309 
310 // ************************************************************
311 // template implementations
312 // ************************************************************
313 
314 template<typename EvalT>
316  const Teuchos::ParameterList& user_data) const
317 {
318  using std::vector;
319  using Teuchos::RCP;
321 
322  // Loop over equation set template managers
323  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
324  eq_set = m_equation_sets.begin();
325  for (;eq_set != m_equation_sets.end(); ++eq_set) {
326 
328 
329  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
330  eqstm.getAsObject<EvalT>()->buildAndRegisterEquationSetEvaluators(fm, *m_field_lib, user_data);
331  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
332  }
333 }
334 
335 template<typename EvalT>
338  const Teuchos::ParameterList& user_data) const
339 {
340  using std::vector;
341  using Teuchos::RCP;
343 
344  // Loop over equation set template managers
345  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
346  eq_set = m_equation_sets.begin();
347  for (;eq_set != m_equation_sets.end(); ++eq_set) {
348 
350 
351  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
352  eqstm.getAsObject<EvalT>()->buildAndRegisterGatherAndOrientationEvaluators(fm,*m_field_lib,lof,user_data);
353  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
354  }
355 }
356 
357 template<typename EvalT>
360  const Teuchos::ParameterList& user_data) const
361 {
362  using std::vector;
363  using Teuchos::RCP;
365 
366  // Loop over equation set template managers
367  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
368  eq_set = m_equation_sets.begin();
369  for (;eq_set != m_equation_sets.end(); ++eq_set) {
371 
372  // Loop over integration rules
373  for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
374  ir_iter != m_integration_rules.end(); ++ ir_iter) {
375 
376  Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
377 
378  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
379  eqstm.getAsObject<EvalT>()->buildAndRegisterDOFProjectionsToIPEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,lof,user_data);
380  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
381  }
382 
383  }
384 }
385 
386 template<typename EvalT>
389  const Teuchos::ParameterList& user_data) const
390 {
391  using std::vector;
392  using Teuchos::RCP;
394 
395  // Loop over equation set template managers
396  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
397  eq_set = m_equation_sets.begin();
398  for (;eq_set != m_equation_sets.end(); ++eq_set) {
399 
401 
402  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
403  eqstm.getAsObject<EvalT>()->buildAndRegisterScatterEvaluators(fm,*m_field_lib,lof,user_data);
404  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
405  }
406 }
407 
408 template<typename EvalT>
411  const Teuchos::ParameterList& models,
412  const Teuchos::ParameterList& user_data) const
413 {
414  using std::vector;
415  using Teuchos::RCP;
417 
418  // Loop over equation set template managers
419  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
420  eq_set = m_equation_sets.begin();
421  for (;eq_set != m_equation_sets.end(); ++eq_set) {
422 
424 
425  // Loop over integration rules
426  for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
427  ir_iter != m_integration_rules.end(); ++ ir_iter) {
428 
429  Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
430 
431  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
432  eqstm.getAsObject<EvalT>()->buildAndRegisterClosureModelEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,factory,models,user_data);
433  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
434  }
435 
436  }
437 }
438 
439 template<typename EvalT>
442  const std::string& model_name,
443  const Teuchos::ParameterList& models,
445  const Teuchos::ParameterList& user_data) const
446 {
447  using std::vector;
448  using Teuchos::RCP;
450 
451  // Loop over equation set template managers
452  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
453  eq_set = m_equation_sets.begin();
454  for (;eq_set != m_equation_sets.end(); ++eq_set) {
455  std::vector<StrBasisPair> providedDOFs;
456 
458 
459  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
460  eqstm.getAsObject<EvalT>()->buildAndRegisterInitialConditionEvaluators(fm, *m_field_lib, factory, model_name, models, lof, user_data);
461  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
462  }
463 }
464 
465 #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...
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
Teuchos::RCP< panzer::GlobalData > globalData() const
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
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< 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