45 #include "Teuchos_Assert.hpp"
47 #include "Phalanx_FieldManager.hpp"
48 #include "Phalanx_Evaluator_Factory.hpp"
54 #include "Shards_CellTopology.hpp"
58 void panzer::buildPhysicsBlocks(
const std::map<std::string,std::string>& block_ids_to_physics_ids,
61 const int default_integration_order,
62 const std::size_t workset_size,
65 const bool build_transient_support,
67 const std::vector<std::string>& tangent_param_names)
77 map<string,string>::const_iterator itr;
78 for (itr = block_ids_to_physics_ids.begin(); itr!=block_ids_to_physics_ids.end();++itr) {
79 string element_block_id = itr->first;
80 string physics_block_id = itr->second;
82 map<string,RCP<const shards::CellTopology> >::const_iterator ct_itr =
83 block_ids_to_cell_topo.find(element_block_id);
86 "Falied to find CellTopology for element block id: \""
87 << element_block_id <<
"\"!");
88 RCP<const shards::CellTopology> cellTopo = ct_itr->second;
95 "Failed to find physics id: \""
97 <<
"\" requested by element block: \""
98 << element_block_id <<
"\"!");
100 RCP<panzer::PhysicsBlock> pb =
rcp(
new panzer::PhysicsBlock(Teuchos::sublist(physics_blocks_plist,physics_block_id,
true),
102 default_integration_order,
106 build_transient_support,
109 physicsBlocks.push_back(pb);
113 void panzer::readPhysicsBlocks(
const std::map<std::string,std::string>& block_ids_to_physics_ids,
125 map<string,string>::const_iterator itr;
126 for (itr = block_ids_to_physics_ids.begin(); itr!=block_ids_to_physics_ids.end();++itr) {
127 string element_block_id = itr->first;
128 string physics_block_id = itr->second;
133 "Failed to find physics id: \""
135 <<
"\" requested by element block: \""
136 << element_block_id <<
"\"!");
138 RCP<panzer::PhysicsBlock> pb =
rcp(
new panzer::PhysicsBlock(Teuchos::sublist(physics_blocks_plist,physics_block_id,
true),
140 physicsBlocks.push_back(pb);
147 bool throw_on_failure)
149 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator pb = physics_blocks.begin();
151 while (pb != physics_blocks.end()) {
152 if ((*pb)->elementBlockID() == element_block_id)
158 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!");
167 const std::string & element_block_id,
168 const int default_integration_order,
172 const bool build_transient_support,
173 const std::vector<std::string>& tangent_param_names) :
174 m_element_block_id(element_block_id),
175 m_default_integration_order(default_integration_order),
176 m_cell_data(cell_data),
177 m_input_parameters(physics_block_plist),
178 m_build_transient_support(build_transient_support),
179 m_global_data(global_data),
180 m_eqset_factory(factory),
181 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
193 build_transient_support,
194 tangent_param_names);
200 const std::string & element_block_id) :
201 m_element_block_id(element_block_id),
202 m_default_integration_order(1),
203 m_input_parameters(physics_block_plist),
204 m_build_transient_support(false),
205 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
212 const std::string & physics_block_id,
213 const int integration_order,
217 m_physics_id(physics_block_id),
218 m_element_block_id(element_block_id),
219 m_default_integration_order(integration_order),
220 m_cell_data(cell_data),
221 m_input_parameters(Teuchos::null),
222 m_build_transient_support(false),
223 m_global_data(global_data),
224 m_eqset_factory(Teuchos::null),
225 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
254 for(std::vector<StrPureBasisPair>::const_iterator itr=
m_provided_dofs.begin();
256 m_field_lib->addFieldAndBasis(itr->first,itr->second);
263 m_physics_id(pb.m_physics_id),
264 m_element_block_id(pb.m_element_block_id),
265 m_default_integration_order(pb.m_default_integration_order),
266 m_cell_data(cell_data),
267 m_input_parameters(pb.m_input_parameters),
268 m_build_transient_support(pb.m_build_transient_support),
269 m_global_data(pb.m_global_data),
270 m_eqset_factory(pb.m_eqset_factory),
271 m_active_evaluation_types(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value,true)
282 const bool build_transient_support,
286 const std::vector<std::string>& tangent_param_names)
288 m_default_integration_order = default_integration_order;
289 m_build_transient_support = build_transient_support;
290 m_cell_data = cell_data;
291 m_global_data = global_data;
292 m_eqset_factory = eqset_factory;
294 initialize(m_input_parameters,
295 m_default_integration_order,
298 m_build_transient_support,
299 tangent_param_names);
304 const int& default_integration_order,
305 const std::string & element_block_id,
307 const bool build_transient_support,
308 const std::vector<std::string>& tangent_param_names)
314 "The physics block \"" << input_parameters->
name()
315 <<
"\" required by element block \"" << element_block_id
316 <<
"\" does not have any equation sets associated with it."
317 <<
" Please add at least one equation set to this physics block!");
319 m_equation_sets.clear();
322 typedef ParameterList::ConstIterator pl_iter;
323 for (pl_iter eq = input_parameters->
begin(); eq != input_parameters->
end(); ++eq) {
326 "All entries in the physics block \"" << m_physics_id
327 <<
"\" must be an equation set sublist!" );
332 = m_eqset_factory->buildEquationSet(eq_set_pl, default_integration_order, cell_data, m_global_data, build_transient_support);
335 for (
auto eq_it = eq_set->begin(); eq_it != eq_set->end(); ++eq_it) {
336 eq_it->setTangentParamNames(tangent_param_names);
340 m_equation_sets.push_back(eq_set);
343 const std::vector<StrPureBasisPair> & sbNames = eq_set->begin()->getProvidedDOFs();
344 for(std::size_t j=0;j<sbNames.size();j++) {
347 m_dof_names.push_back(sbNames[j].first);
350 m_provided_dofs.push_back(sbNames[j]);
353 m_bases[sbNames[j].second->name()] = sbNames[j].second;
356 for (std::size_t k=0; k<tangent_param_names.size(); ++k)
357 m_tangent_fields.push_back(
StrPureBasisPair( sbNames[j].first +
" SENSITIVITY " + tangent_param_names[k],
358 sbNames[j].second ) );
363 const std::vector<std::vector<std::string> > & coord_dofs = eq_set->begin()->getCoordinateDOFs();
364 m_coordinate_dofs.insert(m_coordinate_dofs.begin(),coord_dofs.begin(),coord_dofs.end());
373 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> > & ir_map = eq_set->begin()->getIntegrationRules();
375 ir != ir_map.end(); ++ir)
376 m_integration_rules[ir->second->order()] = ir->second;
382 for(std::vector<StrPureBasisPair>::const_iterator itr=m_provided_dofs.begin();
383 itr!=m_provided_dofs.end();++itr)
384 m_field_lib->addFieldAndBasis(itr->first,itr->second);
387 for(std::size_t eq_i=0;eq_i<m_equation_sets.size();eq_i++) {
390 itr!=eq_set->end();++itr) {
391 itr->setElementBlockId(element_block_id);
400 TEUCHOS_ASSERT(aet.size() == std::size_t(Sacado::mpl::size<panzer::Traits::EvalTypes>::value));
401 m_active_evaluation_types = aet;
407 for (
auto&& t : m_active_evaluation_types)
417 using namespace panzer;
418 using namespace Teuchos;
421 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
422 eq_set = m_equation_sets.begin();
423 for (;eq_set != m_equation_sets.end(); ++eq_set) {
430 for (; eval_type != eqstm.end(); ++eval_type,++idx) {
431 if (m_active_evaluation_types[idx]) {
436 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
437 eval_type->buildAndRegisterEquationSetEvaluators(fm, *m_field_lib, user_data);
438 eval_type->setDetailsIndex(di);
451 using namespace panzer;
452 using namespace Teuchos;
455 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
456 eq_set = m_equation_sets.begin();
457 for (;eq_set != m_equation_sets.end(); ++eq_set) {
464 for (; eval_type != eqstm.end(); ++eval_type,++idx) {
465 if (m_active_evaluation_types[idx]) {
466 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
467 eval_type->buildAndRegisterGatherAndOrientationEvaluators(fm, *m_field_lib, lof, user_data);
468 eval_type->setDetailsIndex(di);
481 using namespace panzer;
482 using namespace Teuchos;
485 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
486 eq_set = m_equation_sets.begin();
487 for (;eq_set != m_equation_sets.end(); ++eq_set) {
494 for (; eval_type != eqstm.end(); ++eval_type,++idx) {
495 if (m_active_evaluation_types[idx]) {
499 ir_iter != m_integration_rules.end(); ++ ir_iter) {
503 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
504 eval_type->buildAndRegisterDOFProjectionsToIPEvaluators(fm, *m_field_lib->buildFieldLayoutLibrary(*ir), ir, lof, user_data);
505 eval_type->setDetailsIndex(di);
519 using namespace panzer;
520 using namespace Teuchos;
523 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
524 eq_set = m_equation_sets.begin();
525 for (;eq_set != m_equation_sets.end(); ++eq_set) {
532 for (; eval_type != eqstm.end(); ++eval_type,++idx) {
533 if (m_active_evaluation_types[idx]) {
534 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
535 eval_type->buildAndRegisterScatterEvaluators(fm, *m_field_lib, lof, user_data);
536 eval_type->setDetailsIndex(di);
550 using namespace panzer;
551 using namespace Teuchos;
554 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
555 eq_set = m_equation_sets.begin();
556 for (;eq_set != m_equation_sets.end(); ++eq_set) {
563 for (; eval_type != eqstm.end(); ++eval_type,++idx) {
564 if (m_active_evaluation_types[idx]) {
568 ir_iter != m_integration_rules.end(); ++ ir_iter) {
572 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
573 eval_type->buildAndRegisterClosureModelEvaluators(fm, *m_field_lib->buildFieldLayoutLibrary(*ir), ir, factory, models, user_data);
574 eval_type->setDetailsIndex(di);
586 const std::string& model_name,
591 using namespace panzer;
592 using namespace Teuchos;
595 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
596 eq_set = m_equation_sets.begin();
597 for (;eq_set != m_equation_sets.end(); ++eq_set) {
604 for (; eval_type != eqstm.end(); ++eval_type,++idx) {
605 if (m_active_evaluation_types[idx]) {
609 ir_iter != m_integration_rules.end(); ++ ir_iter) {
612 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
613 eval_type->buildAndRegisterClosureModelEvaluators(fm, *m_field_lib->buildFieldLayoutLibrary(*ir), ir, factory, model_name, models, user_data);
614 eval_type->setDetailsIndex(di);
621 if(m_equation_sets.size()==0) {
624 for (;eval_type != factory.end(); ++eval_type,++idx) {
625 if (m_active_evaluation_types[idx]) {
632 ir_iter != m_integration_rules.end(); ++ ir_iter) {
638 eval_type->buildClosureModels(model_name,
640 *m_field_lib->buildFieldLayoutLibrary(*ir),
648 const int di = eval_type->setDetailsIndex(this->getDetailsIndex());
649 eval_type->registerEvaluators(*evaluators,fm);
650 eval_type->setDetailsIndex(di);
661 const std::string& model_name,
667 using namespace panzer;
668 using namespace Teuchos;
671 this->buildAndRegisterInitialConditionEvaluatorsForType<panzer::Traits::Residual>(fm, factory, model_name, models, lof, user_data);
684 return m_provided_dofs;
690 return m_coordinate_dofs;
696 return m_tangent_fields;
705 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >& int_rules = this->getIntegrationRules();
707 ir_itr != int_rules.end(); ++ir_itr)
708 needs.
int_rules.push_back(ir_itr->second);
710 const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >& bases= this->getBases();
711 const std::vector<StrPureBasisPair>& fieldToBasis = getProvidedDOFs();
713 b_itr != bases.end(); ++b_itr) {
715 needs.
bases.push_back(b_itr->second);
718 for(std::size_t d=0;d<fieldToBasis.size();d++) {
719 if(fieldToBasis[d].second->name()==b_itr->second->name()) {
736 const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >&
743 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >&
746 return m_integration_rules;
753 "Cannot return a basis since none exist in this physics block.");
754 return m_bases.begin()->second->getIntrepid2Basis()->getBaseCellTopology();
766 return m_element_block_id;
784 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
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.
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