Panzer  Version of the Day
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 
60 namespace Teuchos {
61  class ParameterList;
62 }
63 
64 namespace shards {
65  class CellTopology;
66 }
67 
68 namespace panzer {
69  class RegionFillData;
70  class MaterialModel;
71  class PureBasis;
72  class IntegrationRule;
73  struct EquationSetFactory;
74  struct GlobalData;
75  class PhysicsBlock;
76 }
77 
78 namespace panzer {
79 
80 
84  void buildPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
85  const std::map<std::string,Teuchos::RCP<const shards::CellTopology> >& block_ids_to_cell_topo,
86  const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
87  const int default_integration_order,
88  const std::size_t workset_size,
89  const Teuchos::RCP<const panzer::EquationSetFactory>& eqset_factory,
90  const Teuchos::RCP<panzer::GlobalData>& global_data,
91  const bool build_transient_support,
92  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
93  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
94 
101  void readPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
102  const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
103  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks);
104 
112  Teuchos::RCP<panzer::PhysicsBlock> findPhysicsBlock(const std::string element_block_id,
113  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physics_blocks,
114  bool throw_on_failure = true);
115 
118 
119  public:
121  explicit PhysicsBlock()
123  { std::cout << "WARNING: Default constructor for panzer::PhysicsBlock is for testing purposes only!" << std::endl; }
124 
127  PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
128  const std::string & element_block_id,
129  const int default_integration_order,
130  const panzer::CellData & cell_data,
131  const Teuchos::RCP<const panzer::EquationSetFactory>& factory,
132  const Teuchos::RCP<panzer::GlobalData>& global_data,
133  const bool build_transient_support,
134  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
135 
141  PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
142  const std::string & element_block_id);
143 
145  const panzer::CellData & cell_data);
146 
151  PhysicsBlock(const std::string & element_block_id,
152  const std::string & physics_block_id,
153  const int integration_order,
154  const panzer::CellData & cell_data,
155  const Teuchos::RCP<panzer::GlobalData>& global_data,
156  const Teuchos::RCP<panzer::PureBasis> & fields);
157 
161  void initialize(const int default_integration_order,
162  const bool build_transient_support,
163  const panzer::CellData & cell_data,
164  const Teuchos::RCP<const panzer::EquationSetFactory>& factory,
165  const Teuchos::RCP<panzer::GlobalData>& global_data,
166  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
167 
169  const Teuchos::ParameterList& user_data) const;
170 
173  const Teuchos::ParameterList& user_data) const;
174 
176  const Teuchos::Ptr<const panzer::LinearObjFactory<panzer::Traits> > & lof,
177  const Teuchos::ParameterList& user_data) const;
178 
181  const Teuchos::ParameterList& user_data) const;
182 
185  const Teuchos::ParameterList& models,
186  const Teuchos::ParameterList& user_data) const;
187 
190  const std::string& model_name,
191  const Teuchos::ParameterList& models,
193  const Teuchos::ParameterList& user_data) const;
194 
197  const std::string& model_name,
198  const Teuchos::ParameterList& models,
199  const Teuchos::ParameterList& user_data) const;
200 
201  template<typename EvalT>
203  const Teuchos::ParameterList& user_data) const;
204 
205  template<typename EvalT>
208  const Teuchos::ParameterList& user_data) const;
209 
210  template<typename EvalT>
212  const Teuchos::Ptr<const panzer::LinearObjFactory<panzer::Traits> > & lof,
213  const Teuchos::ParameterList& user_data) const;
214 
215  template<typename EvalT>
218  const Teuchos::ParameterList& user_data) const;
219 
220  template<typename EvalT>
223  const Teuchos::ParameterList& models,
224  const Teuchos::ParameterList& user_data) const;
225 
226  template<typename EvalT>
229  const std::string& model_name,
230  const Teuchos::ParameterList& models,
232  const Teuchos::ParameterList& user_data) const;
233 
234  const std::vector<std::string>& getDOFNames() const;
235  const std::vector<StrPureBasisPair>& getProvidedDOFs() const;
236 
237  const std::vector<std::vector<std::string> > & getCoordinateDOFs() const;
238 
240  const std::vector<StrPureBasisPair>& getTangentFields() const;
241 
243  const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >& getBases() const;
244 
246  const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >& getIntegrationRules() const;
247 
248  const shards::CellTopology getBaseCellTopology() const;
249 
250  std::string physicsBlockID() const;
251  std::string elementBlockID() const;
252 
253  const panzer::CellData & cellData() const;
254 
259  Teuchos::RCP<PhysicsBlock> copyWithCellData(const panzer::CellData & cell_data) const;
260 
261  Teuchos::RCP<panzer::GlobalData> globalData() const;
262 
263  Teuchos::RCP<const FieldLibrary> getFieldLibrary() const
264  { return m_field_lib.getConst(); }
265 
266  Teuchos::RCP<const FieldLibraryBase> getFieldLibraryBase() const
267  { return m_field_lib.getConst(); }
268 
269  // return the Physics Block parameter list
270  Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const
271  { return m_input_parameters; }
272 
273  protected:
274  void initialize(const Teuchos::RCP<Teuchos::ParameterList>& input_parameters,
275  const int& default_integration_order,
276  const std::string & element_block_id,
277  const panzer::CellData & cell_data,
278  const bool build_transient_support,
279  const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
280 
281  std::string m_physics_id;
282  std::string m_element_block_id;
286  Teuchos::RCP<Teuchos::ParameterList> m_input_parameters;
288  Teuchos::RCP<panzer::GlobalData> m_global_data;
289 
290  std::vector<std::string> m_dof_names;
291  std::vector<StrPureBasisPair> m_provided_dofs;
292  std::vector<StrPureBasisPair> m_tangent_fields;
293  std::vector<std::vector<std::string> > m_coordinate_dofs; // coordinate DOFs (defines them)
294 
296  std::map<std::string,Teuchos::RCP<panzer::PureBasis> > m_bases;
298  std::map<int,Teuchos::RCP<panzer::IntegrationRule> > m_integration_rules;
299 
300  std::vector< Teuchos::RCP<panzer::EquationSet_TemplateManager<panzer::Traits> > > m_equation_sets;
301  Teuchos::RCP<FieldLibrary> m_field_lib;
302  Teuchos::RCP<const panzer::EquationSetFactory> m_eqset_factory;
303  };
304 
305 }
306 
307 // ************************************************************
308 // template implementations
309 // ************************************************************
310 
311 template<typename EvalT>
313  const Teuchos::ParameterList& user_data) const
314 {
315  using std::vector;
316  using Teuchos::RCP;
318 
319  // Loop over equation set template managers
320  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
321  eq_set = m_equation_sets.begin();
322  for (;eq_set != m_equation_sets.end(); ++eq_set) {
323 
325 
326  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
327  eqstm.getAsObject<EvalT>()->buildAndRegisterEquationSetEvaluators(fm, *m_field_lib, user_data);
328  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
329  }
330 }
331 
332 template<typename EvalT>
335  const Teuchos::ParameterList& user_data) const
336 {
337  using std::vector;
338  using Teuchos::RCP;
340 
341  // Loop over equation set template managers
342  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
343  eq_set = m_equation_sets.begin();
344  for (;eq_set != m_equation_sets.end(); ++eq_set) {
345 
347 
348  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
349  eqstm.getAsObject<EvalT>()->buildAndRegisterGatherAndOrientationEvaluators(fm,*m_field_lib,lof,user_data);
350  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
351  }
352 }
353 
354 template<typename EvalT>
356  const Teuchos::Ptr<const panzer::LinearObjFactory<panzer::Traits> > & lof,
357  const Teuchos::ParameterList& user_data) const
358 {
359  using std::vector;
360  using Teuchos::RCP;
362 
363  // Loop over equation set template managers
364  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
365  eq_set = m_equation_sets.begin();
366  for (;eq_set != m_equation_sets.end(); ++eq_set) {
368 
369  // Loop over integration rules
370  for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
371  ir_iter != m_integration_rules.end(); ++ ir_iter) {
372 
373  Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
374 
375  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
376  eqstm.getAsObject<EvalT>()->buildAndRegisterDOFProjectionsToIPEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,lof,user_data);
377  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
378  }
379 
380  }
381 }
382 
383 template<typename EvalT>
386  const Teuchos::ParameterList& user_data) const
387 {
388  using std::vector;
389  using Teuchos::RCP;
391 
392  // Loop over equation set template managers
393  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
394  eq_set = m_equation_sets.begin();
395  for (;eq_set != m_equation_sets.end(); ++eq_set) {
396 
398 
399  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
400  eqstm.getAsObject<EvalT>()->buildAndRegisterScatterEvaluators(fm,*m_field_lib,lof,user_data);
401  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
402  }
403 }
404 
405 template<typename EvalT>
408  const Teuchos::ParameterList& models,
409  const Teuchos::ParameterList& user_data) const
410 {
411  using std::vector;
412  using Teuchos::RCP;
414 
415  // Loop over equation set template managers
416  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
417  eq_set = m_equation_sets.begin();
418  for (;eq_set != m_equation_sets.end(); ++eq_set) {
419 
421 
422  // Loop over integration rules
423  for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
424  ir_iter != m_integration_rules.end(); ++ ir_iter) {
425 
426  Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
427 
428  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
429  eqstm.getAsObject<EvalT>()->buildAndRegisterClosureModelEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,factory,models,user_data);
430  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
431  }
432 
433  }
434 }
435 
436 template<typename EvalT>
439  const std::string& model_name,
440  const Teuchos::ParameterList& models,
442  const Teuchos::ParameterList& user_data) const
443 {
444  using std::vector;
445  using Teuchos::RCP;
447 
448  // Loop over equation set template managers
449  vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
450  eq_set = m_equation_sets.begin();
451  for (;eq_set != m_equation_sets.end(); ++eq_set) {
452  std::vector<StrBasisPair> providedDOFs;
453 
455 
456  const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
457  eqstm.getAsObject<EvalT>()->buildAndRegisterInitialConditionEvaluators(fm, *m_field_lib, factory, model_name, models, lof, user_data);
458  eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
459  }
460 }
461 
462 #endif
std::vector< StrPureBasisPair > m_provided_dofs
Teuchos::RCP< panzer::GlobalData > m_global_data
void buildAndRegisterDOFProjectionsToIPEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
Object that contains information on the physics and discretization of a block of elements with the SA...
Teuchos::RCP< panzer::GlobalData > globalData() const
int getDetailsIndex() const
Get the WorksetDetails index.
Teuchos::RCP< PhysicsBlock > copyWithCellData(const panzer::CellData &cell_data) const
int setDetailsIndex(const int details_index)
Teuchos::RCP< const panzer::EquationSetFactory > m_eqset_factory
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 elementBlockID() 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 buildAndRegisterGatherAndOrientationEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
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 std::vector< std::string > & getDOFNames() const
PHX::MDField< ScalarT > vector
Teuchos::RCP< panzer::GlobalData > global_data
void buildAndRegisterScatterEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
std::vector< Teuchos::RCP< panzer::EquationSet_TemplateManager< panzer::Traits > > > m_equation_sets
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
std::vector< std::vector< std::string > > m_coordinate_dofs
Data for determining cell topology and dimensionality.
panzer::CellData m_cell_data
std::string physicsBlockID() const
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) 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 ...
Teuchos::RCP< const FieldLibraryBase > getFieldLibraryBase() const
Teuchos::RCP< Teuchos::ParameterList > m_input_parameters
store the input parameter list for copy ctors
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 buildAndRegisterDOFProjectionsToIPEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
const std::vector< std::vector< std::string > > & getCoordinateDOFs() const
const panzer::CellData & cellData() const
Teuchos::RCP< const FieldLibrary > getFieldLibrary() const
void buildAndRegisterEquationSetEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
void buildAndRegisterEquationSetEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const
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...
void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
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
const std::vector< StrPureBasisPair > & getTangentFields() const
Returns list of tangent fields from DOFs and tangent param names.
std::vector< std::string > m_dof_names
const std::map< int, Teuchos::RCP< panzer::IntegrationRule > > & getIntegrationRules() const
Returns the unique set of point rules, key is the unique panzer::PointRule::name() ...
const shards::CellTopology getBaseCellTopology() const
std::vector< StrPureBasisPair > m_tangent_fields
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const