50 #include "Phalanx_DataLayout_MDALayout.hpp"
51 #include "Phalanx_FieldManager.hpp"
53 #include "Teuchos_FancyOStream.hpp"
55 #include "Shards_CellTopology.hpp"
59 #include "Panzer_Workset_Builder.hpp"
76 os <<
"panzer::FieldManagerBuilder output: Not implemented yet!";
82 bool disablePhysicsBlockGather)
83 : disablePhysicsBlockScatter_(disablePhysicsBlockScatter)
84 , disablePhysicsBlockGather_(disablePhysicsBlockGather)
85 , active_evaluation_types_(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value, true)
90 struct PostRegistrationFunctor {
92 const std::vector<bool>& active_;
96 PostRegistrationFunctor(
const std::vector<bool>& active,
99 : active_(active),fm_(fm),setup_data_(setup_data) {}
102 void operator()(T)
const {
103 auto index = Sacado::mpl::find<panzer::Traits::EvalTypes,T>::value;
105 fm_.postRegistrationSetupForType<T>(setup_data_);
113 const std::vector<WorksetDescriptor> & wkstDesc,
119 bool closureModelByEBlock)
124 PANZER_FUNC_TIME_MONITOR_DIFF(
"panzer::FieldManagerBuilder::setupVolumeFieldManagers",setup_field_managers);
127 "panzer::FMB::setupVolumeFieldManagers: method function getWorksetContainer() returns null. "
128 "Plase call setWorksetContainer() before calling this method");
130 "panzer::FMB::setupVolumeFieldManagers: physics block count must match workset descriptor count.");
132 phx_volume_field_managers_.clear();
136 for (std::size_t blkInd=0;blkInd<physicsBlocks.size();++blkInd) {
142 PANZER_FUNC_TIME_MONITOR_DIFF(
"getWorksets()",get_worksets);
143 { setupData.
worksets_ = getWorksetContainer()->getWorksets(wd); }
146 PANZER_FUNC_TIME_MONITOR_DIFF(
"getOrientations()",get_orientations);
147 { setupData.
orientations_ = getWorksetContainer()->getOrientations(); }
163 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterEquationSetEvaluators()",build_and_reg_eq_set_eval);
167 if(!physicsBlockGatherDisabled()) {
168 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterGatherAndOrientationEvaluators()",build_and_reg_gath_and_orient_eval);
173 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterDOFProjectionsToIPEvaluators()",build_and_reg_dof_proj_eval);
177 if(!physicsBlockScatterDisabled()) {
178 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterScatterEvaluators()",build_and_reg_scatter_eval);
182 if(closureModelByEBlock) {
183 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterClosureModelEvaluators(): closureModelByEBlock==true",build_and_reg_closure_model_eval_if);
187 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterClosureModelEvaluators(): closureModelByEBlock==false",build_and_reg_closure_model_eval_else);
198 setKokkosExtendedDataTypeDimensions(wd.
getElementBlock(),*globalIndexer,user_data,*fm);
201 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,*fm,setupData));
204 volume_workset_desc_.push_back(wd);
205 phx_volume_field_managers_.push_back(fm);
217 std::vector<WorksetDescriptor> wkstDesc;
218 for(std::size_t i=0;i<physicsBlocks.size();i++)
219 wkstDesc.push_back(
blockDescriptor(physicsBlocks[i]->elementBlockID()));
222 setupVolumeFieldManagers(physicsBlocks,wkstDesc,cm_factory,closure_models,lo_factory,user_data,eef);
238 "panzer::FMB::setupBCFieldManagers: method function getWorksetContainer() returns null. "
239 "Plase call setWorksetContainer() before calling this method");
244 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks_map;
246 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
247 for(blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr) {
252 physicsBlocks_map.insert(std::make_pair(blockId,pb));
259 std::vector<panzer::BC>::const_iterator bc;
260 for (bc=bcs.begin(); bc != bcs.end(); ++bc) {
263 currentWkst = getWorksetContainer()->getSideWorksets(wd);
264 if (currentWkst.
is_null())
continue;
266 BCType bc_type = bc->bcType();
270 for (std::map<unsigned,panzer::Workset>::const_iterator wkst = currentWkst->begin();
271 wkst != currentWkst->end(); ++wkst) {
273 std::map<unsigned,PHX::FieldManager<panzer::Traits> >& field_managers =
274 bc_field_managers_[*bc];
279 for (
int block_id_index = 0; block_id_index < 2; ++block_id_index) {
280 const std::string element_block_id = block_id_index == 0 ? bc->elementBlockID() : bc->elementBlockID2();
282 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator
283 volume_pb_itr = physicsBlocks_map.find(element_block_id);
286 "panzer::FMB::setupBCFieldManagers: Cannot find physics block corresponding to element block \""
287 << element_block_id <<
"\"");
294 wkst->second.details(block_id_index).subcell_index,
295 volume_cell_topology);
306 bcs_type = bcstm->begin(); bcs_type != bcstm->end(); ++bcs_type,++i) {
307 if (active_evaluation_types_[i]) {
308 bcs_type->setDetailsIndex(block_id_index);
309 side_pb->setDetailsIndex(block_id_index);
310 bcs_type->setup(*side_pb, user_data);
311 bcs_type->buildAndRegisterEvaluators(fm, *side_pb, cm_factory, closure_models, user_data);
312 bcs_type->buildAndRegisterGatherAndOrientationEvaluators(fm, *side_pb, lo_factory, user_data);
313 if ( ! physicsBlockScatterDisabled())
314 bcs_type->buildAndRegisterScatterEvaluators(fm, *side_pb, lo_factory, user_data);
322 std::vector<PHX::index_size_type> derivative_dimensions;
323 derivative_dimensions.push_back(gid_count);
326 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
330 derivative_dimensions[0] = 1;
331 if (user_data.
isType<
int>(
"Tangent Dimension"))
332 derivative_dimensions[0] = user_data.
get<
int>(
"Tangent Dimension");
339 worksets->push_back(wkst->second);
341 setupData.
orientations_ = getWorksetContainer()->getOrientations();
343 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,fm,setupData));
347 const std::string element_block_id = bc->elementBlockID();
349 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator volume_pb_itr
350 = physicsBlocks_map.find(element_block_id);
353 "panzer::FMB::setupBCFieldManagers: Cannot find physics block corresponding to element block \"" << element_block_id <<
"\"");
359 std::map<unsigned,PHX::FieldManager<panzer::Traits> >& field_managers =
360 bc_field_managers_[*bc];
363 for (std::map<unsigned,panzer::Workset>::const_iterator wkst =
364 currentWkst->begin(); wkst != currentWkst->end();
371 wkst->first,volume_cell_topology);
382 bcs_type = bcstm->begin(); bcs_type != bcstm->end(); ++bcs_type,++i) {
383 if (active_evaluation_types_[i]) {
384 bcs_type->setup(*side_pb,user_data);
385 bcs_type->buildAndRegisterEvaluators(fm,*side_pb,cm_factory,closure_models,user_data);
386 bcs_type->buildAndRegisterGatherAndOrientationEvaluators(fm,*side_pb,lo_factory,user_data);
387 if(!physicsBlockScatterDisabled())
388 bcs_type->buildAndRegisterScatterEvaluators(fm,*side_pb,lo_factory,user_data);
396 worksets->push_back(wkst->second);
398 setupData.
orientations_ = getWorksetContainer()->getOrientations();
401 setKokkosExtendedDataTypeDimensions(element_block_id,*globalIndexer,user_data,fm);
403 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,fm,setupData));
415 if(phx_volume_field_managers_.size()<1)
418 TEUCHOS_ASSERT(phx_volume_field_managers_.size()==physicsBlocks.size());
420 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
422 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr,++index) {
423 std::string blockId = (*blkItr)->elementBlockID();
424 phx_volume_field_managers_[index]->writeGraphvizFile(filename_prefix+
"_VOLUME_"+blockId);
434 typedef std::map<panzer::BC,std::map<unsigned,PHX::FieldManager<panzer::Traits> >,
panzer::LessBC> FMMap;
436 FMMap::const_iterator blkItr;
438 for (blkItr=bc_field_managers_.begin();blkItr!=bc_field_managers_.end();++blkItr,++bc_index) {
445 type =
"_Dirichlet_";
449 type =
"_Interface_";
455 fm.
writeGraphvizFile(filename_prefix+
"_BC_"+std::to_string(bc_index)+type+sideId+
"_"+blockId);
466 if(phx_volume_field_managers_.size()<1)
469 TEUCHOS_ASSERT(phx_volume_field_managers_.size()==physicsBlocks.size());
471 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
473 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr,++index) {
475 std::string blockId = (*blkItr)->elementBlockID();
477 std::string filename = filename_prefix+
"_VOLUME_"+blockId+
".txt";
479 ofs.open(filename.c_str());
481 ofs << *(phx_volume_field_managers_[index]) << std::endl;
493 typedef std::map<panzer::BC,std::map<unsigned,PHX::FieldManager<panzer::Traits> >,
panzer::LessBC> FMMap;
495 FMMap::const_iterator blkItr;
497 for (blkItr=bc_field_managers_.begin();blkItr!=bc_field_managers_.end();++blkItr,++bc_index) {
504 type =
"_Dirichlet_";
508 type =
"_Interface_";
515 std::string filename = filename_prefix+
"_BC_"+std::to_string(bc_index)+type+sideId+
"_"+blockId+
".txt";
517 ofs.open(filename.c_str());
519 ofs << fm << std::endl;
536 std::vector<PHX::index_size_type> derivative_dimensions;
543 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
545 std::vector<PHX::index_size_type> derivative_dimensions;
553 std::vector<PHX::index_size_type> derivative_dimensions;
554 derivative_dimensions.push_back(1);
555 if (user_data.
isType<
int>(
"Tangent Dimension"))
556 derivative_dimensions[0] = user_data.
get<
int>(
"Tangent Dimension");
562 {active_evaluation_types_ = aet;}
568 phx_volume_field_managers_.clear();
569 volume_workset_desc_.clear();
570 if (clearVolumeWorksets)
571 worksetContainer_->clearVolumeWorksets();
Interface for constructing a BCStrategy_TemplateManager.
void setupVolumeFieldManagers(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data)
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_
BCType
Type of boundary condition.
std::string elementBlockID() const
Returns the element block id associated with this sideset.
virtual Teuchos::RCP< const panzer::GlobalIndexer > getRangeGlobalIndexer() const =0
Get the range global indexer object associated with this factory.
T & get(const std::string &name, T def_value)
FieldManager::iterator begin()
void writeVolumeGraphvizDependencyFiles(std::string filename_prefix, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks) const
virtual int getElementBlockGIDCount(const std::size_t &blockIndex) const =0
How any GIDs are associate with each element in a particular element block.
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
const std::string & getElementBlock(const int block=0) const
Get element block name.
void writeBCGraphvizDependencyFiles(std::string filename_prefix) const
void writeGraphvizFile(const std::string filename="graph.dot", bool writeEvaluatedFields=true, bool writeDependentFields=true, bool debugRegisteredEvaluators=false) const
void clearVolumeFieldManagers(bool clearVolumeWorksets=true)
Delete all volume field managers, retaining the BC ones.
void setKokkosExtendedDataTypeDimensions(const std::string &eblock, const panzer::GlobalIndexer &globalIndexer, const Teuchos::ParameterList &user_data, PHX::FieldManager< panzer::Traits > &fm) const
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
virtual Teuchos::RCP< panzer::BCStrategy_TemplateManager< panzer::Traits > > buildBCStrategy(const panzer::BC &bc, const Teuchos::RCP< panzer::GlobalData > &global_data) const =0
void writeBCTextDependencyFiles(std::string filename_prefix) const
Teuchos::RCP< panzer::GlobalData > globalData() const
void setActiveEvaluationTypes(const std::vector< bool > &aet)
Used to save memory by disabling unneeded evaluation types.
void buildAndRegisterDOFProjectionsToIPEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
void print(std::ostream &os) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Data for determining cell topology and dimensionality.
void writeVolumeTextDependencyFiles(std::string filename_prefix, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks) const
std::string elementBlockID() const
BCType bcType() const
Returns the boundary condition type (Dirichlet or Neumann or Interface).
virtual bool registerEvaluators(PHX::FieldManager< panzer::Traits > &fm, const WorksetDescriptor &wd, const PhysicsBlock &pb) const =0
void activateAllEvaluationTypes()
Used to reactivate all evaluation types if some were temporarily disabled with a call to setActiveEva...
std::string sidesetID() const
Returns the set id.
std::ostream & operator<<(std::ostream &os, const AssemblyEngineInArgs &in)
bool isType(const std::string &name) const
FieldManagerBuilder(bool disablePhysicsBlockScatter=false, bool disablePhysicsBlockGather=false)
WorksetDescriptor blockDescriptor(const std::string &eBlock)
WorksetDescriptor bcDescriptor(const panzer::BC &bc)
Stores input information for a boundary condition.
void setupBCFieldManagers(const std::vector< panzer::BC > &bcs, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::EquationSetFactory &eqset_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const panzer::BCStrategyFactory &bc_factory, const Teuchos::ParameterList &closure_models, const LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data)
#define TEUCHOS_ASSERT(assertion_test)
void setActiveEvaluationTypes(const std::vector< bool > &aet)
Set a vector of active evaluation types to allocate.
void buildAndRegisterEquationSetEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_