13 #include "Teuchos_Assert.hpp"
15 #include "Phalanx_FieldManager.hpp"
16 #include "Phalanx_Evaluator_Factory.hpp"
22 #include "Shards_CellTopology.hpp"
26 void panzer::buildPhysicsBlocks(
const std::map<std::string,std::string>& block_ids_to_physics_ids,
29 const int default_integration_order,
30 const std::size_t workset_size,
33 const bool build_transient_support,
35 const std::vector<std::string>& tangent_param_names)
45 map<string,string>::const_iterator itr;
46 for (itr = block_ids_to_physics_ids.begin(); itr!=block_ids_to_physics_ids.end();++itr) {
47 string element_block_id = itr->first;
48 string physics_block_id = itr->second;
50 map<string,RCP<const shards::CellTopology> >::const_iterator ct_itr =
51 block_ids_to_cell_topo.find(element_block_id);
54 "Falied to find CellTopology for element block id: \""
55 << element_block_id <<
"\"!");
56 RCP<const shards::CellTopology> cellTopo = ct_itr->second;
63 "Failed to find physics id: \""
65 <<
"\" requested by element block: \""
66 << element_block_id <<
"\"!");
68 RCP<panzer::PhysicsBlock> pb =
rcp(
new panzer::PhysicsBlock(Teuchos::sublist(physics_blocks_plist,physics_block_id,
true),
70 default_integration_order,
74 build_transient_support,
77 physicsBlocks.push_back(pb);
81 void panzer::readPhysicsBlocks(
const std::map<std::string,std::string>& block_ids_to_physics_ids,
93 map<string,string>::const_iterator itr;
94 for (itr = block_ids_to_physics_ids.begin(); itr!=block_ids_to_physics_ids.end();++itr) {
95 string element_block_id = itr->first;
96 string physics_block_id = itr->second;
101 "Failed to find physics id: \""
103 <<
"\" requested by element block: \""
104 << element_block_id <<
"\"!");
106 RCP<panzer::PhysicsBlock> pb =
rcp(
new panzer::PhysicsBlock(Teuchos::sublist(physics_blocks_plist,physics_block_id,
true),
108 physicsBlocks.push_back(pb);
115 bool throw_on_failure)
117 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator pb = physics_blocks.begin();
119 while (pb != physics_blocks.end()) {
120 if ((*pb)->elementBlockID() == element_block_id)
126 TEUCHOS_TEST_FOR_EXCEPTION(throw_on_failure,std::runtime_error,
"Error: panzer::findPhysicsBlock(): The requested physics block for element block\"" << element_block_id <<
"\" was not found in the vecotr of physics blocks!");
135 const std::string & element_block_id,
136 const int default_integration_order,
140 const bool build_transient_support,
141 const std::vector<std::string>& tangent_param_names) :
142 m_element_block_id(element_block_id),
143 m_default_integration_order(default_integration_order),
144 m_cell_data(cell_data),
145 m_input_parameters(physics_block_plist),
146 m_build_transient_support(build_transient_support),
147 m_global_data(global_data),
148 m_eqset_factory(factory),
149 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
161 build_transient_support,
162 tangent_param_names);
168 const std::string & element_block_id) :
169 m_element_block_id(element_block_id),
170 m_default_integration_order(1),
171 m_input_parameters(physics_block_plist),
172 m_build_transient_support(false),
173 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
180 const std::string & physics_block_id,
181 const int integration_order,
185 m_physics_id(physics_block_id),
186 m_element_block_id(element_block_id),
187 m_default_integration_order(integration_order),
188 m_cell_data(cell_data),
189 m_input_parameters(Teuchos::null),
190 m_build_transient_support(false),
191 m_global_data(global_data),
192 m_eqset_factory(Teuchos::null),
193 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
222 for(std::vector<StrPureBasisPair>::const_iterator itr=
m_provided_dofs.begin();
224 m_field_lib->addFieldAndBasis(itr->first,itr->second);
231 m_physics_id(pb.m_physics_id),
232 m_element_block_id(pb.m_element_block_id),
233 m_default_integration_order(pb.m_default_integration_order),
234 m_cell_data(cell_data),
235 m_input_parameters(pb.m_input_parameters),
236 m_build_transient_support(pb.m_build_transient_support),
237 m_global_data(pb.m_global_data),
238 m_eqset_factory(pb.m_eqset_factory),
239 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
250 const bool build_transient_support,
254 const std::vector<std::string>& tangent_param_names)
256 m_default_integration_order = default_integration_order;
257 m_build_transient_support = build_transient_support;
258 m_cell_data = cell_data;
259 m_global_data = global_data;
260 m_eqset_factory = eqset_factory;
262 initialize(m_input_parameters,
263 m_default_integration_order,
266 m_build_transient_support,
267 tangent_param_names);
272 const int& default_integration_order,
273 const std::string & element_block_id,
275 const bool build_transient_support,
276 const std::vector<std::string>& tangent_param_names)
282 "The physics block \"" << input_parameters->
name()
283 <<
"\" required by element block \"" << element_block_id
284 <<
"\" does not have any equation sets associated with it."
285 <<
" Please add at least one equation set to this physics block!");
287 m_equation_sets.clear();
290 typedef ParameterList::ConstIterator pl_iter;
291 for (pl_iter eq = input_parameters->
begin(); eq != input_parameters->
end(); ++eq) {
294 "All entries in the physics block \"" << m_physics_id
295 <<
"\" must be an equation set sublist!" );
300 = m_eqset_factory->buildEquationSet(eq_set_pl, default_integration_order, cell_data, m_global_data, build_transient_support);
303 for (
auto eq_it = eq_set->begin(); eq_it != eq_set->end(); ++eq_it) {
304 eq_it->setTangentParamNames(tangent_param_names);
308 m_equation_sets.push_back(eq_set);
311 const std::vector<StrPureBasisPair> & sbNames = eq_set->begin()->getProvidedDOFs();
312 for(std::size_t j=0;j<sbNames.size();j++) {
315 m_dof_names.push_back(sbNames[j].first);
318 m_provided_dofs.push_back(sbNames[j]);
321 m_bases[sbNames[j].second->name()] = sbNames[j].second;
324 for (std::size_t k=0; k<tangent_param_names.size(); ++k)
325 m_tangent_fields.push_back(
StrPureBasisPair( sbNames[j].first +
" SENSITIVITY " + tangent_param_names[k],
326 sbNames[j].second ) );
331 const std::vector<std::vector<std::string> > & coord_dofs = eq_set->begin()->getCoordinateDOFs();
332 m_coordinate_dofs.insert(m_coordinate_dofs.begin(),coord_dofs.begin(),coord_dofs.end());
341 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> > & ir_map = eq_set->begin()->getIntegrationRules();
343 ir != ir_map.end(); ++ir)
344 m_integration_rules[ir->second->order()] = ir->second;
350 for(std::vector<StrPureBasisPair>::const_iterator itr=m_provided_dofs.begin();
351 itr!=m_provided_dofs.end();++itr)
352 m_field_lib->addFieldAndBasis(itr->first,itr->second);
355 for(std::size_t eq_i=0;eq_i<m_equation_sets.size();eq_i++) {
358 itr!=eq_set->end();++itr) {
359 itr->setElementBlockId(element_block_id);
368 TEUCHOS_ASSERT(aet.size() == std::size_t(Sacado::mpl::size<panzer::Traits::EvalTypes>::value));
369 m_active_evaluation_types = aet;
375 for (
auto&& t : m_active_evaluation_types)
385 using namespace panzer;
386 using namespace Teuchos;
389 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
390 eq_set = m_equation_sets.begin();
391 for (;eq_set != m_equation_sets.end(); ++eq_set) {
398 for (; eval_type != eqstm.
end(); ++eval_type,++idx) {
399 if (m_active_evaluation_types[idx]) {
404 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
405 eval_type->buildAndRegisterEquationSetEvaluators(fm, *m_field_lib, user_data);
406 eval_type->setDetailsIndex(di);
419 using namespace panzer;
420 using namespace Teuchos;
423 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
424 eq_set = m_equation_sets.begin();
425 for (;eq_set != m_equation_sets.end(); ++eq_set) {
432 for (; eval_type != eqstm.
end(); ++eval_type,++idx) {
433 if (m_active_evaluation_types[idx]) {
434 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
435 eval_type->buildAndRegisterGatherAndOrientationEvaluators(fm, *m_field_lib, lof, user_data);
436 eval_type->setDetailsIndex(di);
449 using namespace panzer;
450 using namespace Teuchos;
453 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
454 eq_set = m_equation_sets.begin();
455 for (;eq_set != m_equation_sets.end(); ++eq_set) {
462 for (; eval_type != eqstm.
end(); ++eval_type,++idx) {
463 if (m_active_evaluation_types[idx]) {
467 ir_iter != m_integration_rules.end(); ++ ir_iter) {
471 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
472 eval_type->buildAndRegisterDOFProjectionsToIPEvaluators(fm, *m_field_lib->buildFieldLayoutLibrary(*ir), ir, lof, user_data);
473 eval_type->setDetailsIndex(di);
487 using namespace panzer;
488 using namespace Teuchos;
491 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
492 eq_set = m_equation_sets.begin();
493 for (;eq_set != m_equation_sets.end(); ++eq_set) {
500 for (; eval_type != eqstm.
end(); ++eval_type,++idx) {
501 if (m_active_evaluation_types[idx]) {
502 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
503 eval_type->buildAndRegisterScatterEvaluators(fm, *m_field_lib, lof, user_data);
504 eval_type->setDetailsIndex(di);
518 using namespace panzer;
519 using namespace Teuchos;
522 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
523 eq_set = m_equation_sets.begin();
524 for (;eq_set != m_equation_sets.end(); ++eq_set) {
531 for (; eval_type != eqstm.
end(); ++eval_type,++idx) {
532 if (m_active_evaluation_types[idx]) {
536 ir_iter != m_integration_rules.end(); ++ ir_iter) {
540 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
541 eval_type->buildAndRegisterClosureModelEvaluators(fm, *m_field_lib->buildFieldLayoutLibrary(*ir), ir, factory, models, user_data);
542 eval_type->setDetailsIndex(di);
554 const std::string& model_name,
559 using namespace panzer;
560 using namespace Teuchos;
563 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
564 eq_set = m_equation_sets.begin();
565 for (;eq_set != m_equation_sets.end(); ++eq_set) {
572 for (; eval_type != eqstm.
end(); ++eval_type,++idx) {
573 if (m_active_evaluation_types[idx]) {
577 ir_iter != m_integration_rules.end(); ++ ir_iter) {
580 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
581 eval_type->buildAndRegisterClosureModelEvaluators(fm, *m_field_lib->buildFieldLayoutLibrary(*ir), ir, factory, model_name, models, user_data);
582 eval_type->setDetailsIndex(di);
589 if(m_equation_sets.size()==0) {
592 for (;eval_type != factory.
end(); ++eval_type,++idx) {
593 if (m_active_evaluation_types[idx]) {
600 ir_iter != m_integration_rules.end(); ++ ir_iter) {
606 eval_type->buildClosureModels(model_name,
608 *m_field_lib->buildFieldLayoutLibrary(*ir),
616 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
617 eval_type->registerEvaluators(*evaluators,fm);
618 eval_type->setDetailsIndex(di);
629 const std::string& model_name,
635 using namespace panzer;
636 using namespace Teuchos;
639 this->buildAndRegisterInitialConditionEvaluatorsForType<panzer::Traits::Residual>(fm, factory, model_name, models, lof, user_data);
652 return m_provided_dofs;
658 return m_coordinate_dofs;
664 return m_tangent_fields;
673 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >& int_rules = this->getIntegrationRules();
675 ir_itr != int_rules.end(); ++ir_itr)
676 needs.
int_rules.push_back(ir_itr->second);
678 const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >& bases= this->getBases();
679 const std::vector<StrPureBasisPair>& fieldToBasis = getProvidedDOFs();
681 b_itr != bases.end(); ++b_itr) {
683 needs.
bases.push_back(b_itr->second);
686 for(std::size_t d=0;d<fieldToBasis.size();d++) {
687 if(fieldToBasis[d].second->name()==b_itr->second->name()) {
704 const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >&
711 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >&
714 return m_integration_rules;
721 "Cannot return a basis since none exist in this physics block.");
722 return m_bases.begin()->second->getIntrepid2Basis()->getBaseCellTopology();
734 return m_element_block_id;
752 return m_global_data;
std::string name() const
A unique key that is the combination of the basis type and basis order.
Teuchos::RCP< PhysicsBlock > copyWithCellData(const panzer::CellData &cell_data) const
const std::string & name() const
std::vector< Teuchos::RCP< const PureBasis > > bases
const std::vector< std::string > & getDOFNames() const
ConstIterator end() const
std::vector< StrPureBasisPair > m_provided_dofs
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...
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
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
Ordinal numParams() const
std::vector< Teuchos::RCP< const IntegrationRule > > int_rules
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
std::vector< std::string > rep_field_name
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
PHX::TemplateManager< Traits::EvalTypes, panzer::EquationSetBase, panzer::EquationSet< _ > >::iterator begin()
Teuchos::RCP< panzer::GlobalData > globalData() const
int m_default_integration_order
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
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Data for determining cell topology and dimensionality.
panzer::CellData m_cell_data
bool isSublist(const std::string &name) const
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 ...
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 ...
ConstIterator begin() const
const shards::CellTopology getBaseCellTopology() const
const std::vector< StrPureBasisPair > & getTangentFields() const
Returns list of tangent fields from DOFs and tangent param names.
PHX::TemplateManager< Traits::EvalTypes, panzer::EquationSetBase, panzer::EquationSet< _ > >::iterator end()
WorksetNeeds getWorksetNeeds() const
bool nonnull(const boost::shared_ptr< T > &p)
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 >())
std::pair< std::string, Teuchos::RCP< panzer::PureBasis > > StrPureBasisPair
bool m_build_transient_support
Teuchos::RCP< FieldLibrary > m_field_lib
std::string m_element_block_id
#define TEUCHOS_ASSERT(assertion_test)
std::vector< std::string > m_dof_names
void buildAndRegisterEquationSetEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const