18 #include "Phalanx_DataLayout_MDALayout.hpp"
19 #include "Phalanx_FieldManager.hpp"
21 #include "Teuchos_FancyOStream.hpp"
23 #include "Shards_CellTopology.hpp"
27 #include "Panzer_Workset_Builder.hpp"
44 os <<
"panzer::FieldManagerBuilder output: Not implemented yet!";
50 bool disablePhysicsBlockGather)
51 : disablePhysicsBlockScatter_(disablePhysicsBlockScatter)
52 , disablePhysicsBlockGather_(disablePhysicsBlockGather)
53 , active_evaluation_types_(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value, true)
58 struct PostRegistrationFunctor {
60 const std::vector<bool>& active_;
64 PostRegistrationFunctor(
const std::vector<bool>& active,
67 : active_(active),fm_(fm),setup_data_(setup_data) {}
70 void operator()(T)
const {
71 auto index = Sacado::mpl::find<panzer::Traits::EvalTypes,T>::value;
73 fm_.postRegistrationSetupForType<T>(setup_data_);
81 const std::vector<WorksetDescriptor> & wkstDesc,
87 bool closureModelByEBlock)
92 PANZER_FUNC_TIME_MONITOR_DIFF(
"panzer::FieldManagerBuilder::setupVolumeFieldManagers",setup_field_managers);
95 "panzer::FMB::setupVolumeFieldManagers: method function getWorksetContainer() returns null. "
96 "Plase call setWorksetContainer() before calling this method");
98 "panzer::FMB::setupVolumeFieldManagers: physics block count must match workset descriptor count.");
100 phx_volume_field_managers_.clear();
104 for (std::size_t blkInd=0;blkInd<physicsBlocks.size();++blkInd) {
110 PANZER_FUNC_TIME_MONITOR_DIFF(
"getWorksets()",get_worksets);
111 { setupData.
worksets_ = getWorksetContainer()->getWorksets(wd); }
114 PANZER_FUNC_TIME_MONITOR_DIFF(
"getOrientations()",get_orientations);
115 { setupData.
orientations_ = getWorksetContainer()->getOrientations(); }
131 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterEquationSetEvaluators()",build_and_reg_eq_set_eval);
135 if(!physicsBlockGatherDisabled()) {
136 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterGatherAndOrientationEvaluators()",build_and_reg_gath_and_orient_eval);
141 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterDOFProjectionsToIPEvaluators()",build_and_reg_dof_proj_eval);
145 if(!physicsBlockScatterDisabled()) {
146 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterScatterEvaluators()",build_and_reg_scatter_eval);
150 if(closureModelByEBlock) {
151 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterClosureModelEvaluators(): closureModelByEBlock==true",build_and_reg_closure_model_eval_if);
155 PANZER_FUNC_TIME_MONITOR_DIFF(
"pb->buildAndRegisterClosureModelEvaluators(): closureModelByEBlock==false",build_and_reg_closure_model_eval_else);
166 setKokkosExtendedDataTypeDimensions(wd.
getElementBlock(),*globalIndexer,user_data,*fm);
169 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,*fm,setupData));
172 volume_workset_desc_.push_back(wd);
173 phx_volume_field_managers_.push_back(fm);
185 std::vector<WorksetDescriptor> wkstDesc;
186 for(std::size_t i=0;i<physicsBlocks.size();i++)
187 wkstDesc.push_back(
blockDescriptor(physicsBlocks[i]->elementBlockID()));
190 setupVolumeFieldManagers(physicsBlocks,wkstDesc,cm_factory,closure_models,lo_factory,user_data,eef);
206 "panzer::FMB::setupBCFieldManagers: method function getWorksetContainer() returns null. "
207 "Plase call setWorksetContainer() before calling this method");
212 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks_map;
214 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
215 for(blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr) {
220 physicsBlocks_map.insert(std::make_pair(blockId,pb));
227 std::vector<panzer::BC>::const_iterator bc;
228 for (bc=bcs.begin(); bc != bcs.end(); ++bc) {
231 currentWkst = getWorksetContainer()->getSideWorksets(wd);
232 if (currentWkst.
is_null())
continue;
234 BCType bc_type = bc->bcType();
238 for (std::map<unsigned,panzer::Workset>::const_iterator wkst = currentWkst->begin();
239 wkst != currentWkst->end(); ++wkst) {
241 std::map<unsigned,PHX::FieldManager<panzer::Traits> >& field_managers =
242 bc_field_managers_[*bc];
247 for (
int block_id_index = 0; block_id_index < 2; ++block_id_index) {
248 const std::string element_block_id = block_id_index == 0 ? bc->elementBlockID() : bc->elementBlockID2();
250 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator
251 volume_pb_itr = physicsBlocks_map.find(element_block_id);
254 "panzer::FMB::setupBCFieldManagers: Cannot find physics block corresponding to element block \""
255 << element_block_id <<
"\"");
262 wkst->second.details(block_id_index).subcell_index,
263 volume_cell_topology);
274 bcs_type = bcstm->begin(); bcs_type != bcstm->end(); ++bcs_type,++i) {
275 if (active_evaluation_types_[i]) {
276 bcs_type->setDetailsIndex(block_id_index);
277 side_pb->setDetailsIndex(block_id_index);
278 bcs_type->setup(*side_pb, user_data);
279 bcs_type->buildAndRegisterEvaluators(fm, *side_pb, cm_factory, closure_models, user_data);
280 bcs_type->buildAndRegisterGatherAndOrientationEvaluators(fm, *side_pb, lo_factory, user_data);
281 if ( ! physicsBlockScatterDisabled())
282 bcs_type->buildAndRegisterScatterEvaluators(fm, *side_pb, lo_factory, user_data);
290 std::vector<PHX::index_size_type> derivative_dimensions;
291 derivative_dimensions.push_back(gid_count);
294 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
298 derivative_dimensions[0] = 1;
299 if (user_data.
isType<
int>(
"Tangent Dimension"))
300 derivative_dimensions[0] = user_data.
get<
int>(
"Tangent Dimension");
307 worksets->push_back(wkst->second);
309 setupData.
orientations_ = getWorksetContainer()->getOrientations();
311 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,fm,setupData));
315 const std::string element_block_id = bc->elementBlockID();
317 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator volume_pb_itr
318 = physicsBlocks_map.find(element_block_id);
321 "panzer::FMB::setupBCFieldManagers: Cannot find physics block corresponding to element block \"" << element_block_id <<
"\"");
327 std::map<unsigned,PHX::FieldManager<panzer::Traits> >& field_managers =
328 bc_field_managers_[*bc];
331 for (std::map<unsigned,panzer::Workset>::const_iterator wkst =
332 currentWkst->begin(); wkst != currentWkst->end();
339 wkst->first,volume_cell_topology);
350 bcs_type = bcstm->begin(); bcs_type != bcstm->end(); ++bcs_type,++i) {
351 if (active_evaluation_types_[i]) {
352 bcs_type->setup(*side_pb,user_data);
353 bcs_type->buildAndRegisterEvaluators(fm,*side_pb,cm_factory,closure_models,user_data);
354 bcs_type->buildAndRegisterGatherAndOrientationEvaluators(fm,*side_pb,lo_factory,user_data);
355 if(!physicsBlockScatterDisabled())
356 bcs_type->buildAndRegisterScatterEvaluators(fm,*side_pb,lo_factory,user_data);
364 worksets->push_back(wkst->second);
366 setupData.
orientations_ = getWorksetContainer()->getOrientations();
369 setKokkosExtendedDataTypeDimensions(element_block_id,*globalIndexer,user_data,fm);
371 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,fm,setupData));
383 if(phx_volume_field_managers_.size()<1)
386 TEUCHOS_ASSERT(phx_volume_field_managers_.size()==physicsBlocks.size());
388 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
390 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr,++index) {
391 std::string blockId = (*blkItr)->elementBlockID();
392 phx_volume_field_managers_[index]->writeGraphvizFile(filename_prefix+
"_VOLUME_"+blockId);
402 typedef std::map<panzer::BC,std::map<unsigned,PHX::FieldManager<panzer::Traits> >,
panzer::LessBC> FMMap;
404 FMMap::const_iterator blkItr;
406 for (blkItr=bc_field_managers_.begin();blkItr!=bc_field_managers_.end();++blkItr,++bc_index) {
413 type =
"_Dirichlet_";
417 type =
"_Interface_";
423 fm.
writeGraphvizFile(filename_prefix+
"_BC_"+std::to_string(bc_index)+type+sideId+
"_"+blockId);
434 if(phx_volume_field_managers_.size()<1)
437 TEUCHOS_ASSERT(phx_volume_field_managers_.size()==physicsBlocks.size());
439 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
441 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr,++index) {
443 std::string blockId = (*blkItr)->elementBlockID();
445 std::string filename = filename_prefix+
"_VOLUME_"+blockId+
".txt";
447 ofs.open(filename.c_str());
449 ofs << *(phx_volume_field_managers_[index]) << std::endl;
461 typedef std::map<panzer::BC,std::map<unsigned,PHX::FieldManager<panzer::Traits> >,
panzer::LessBC> FMMap;
463 FMMap::const_iterator blkItr;
465 for (blkItr=bc_field_managers_.begin();blkItr!=bc_field_managers_.end();++blkItr,++bc_index) {
472 type =
"_Dirichlet_";
476 type =
"_Interface_";
483 std::string filename = filename_prefix+
"_BC_"+std::to_string(bc_index)+type+sideId+
"_"+blockId+
".txt";
485 ofs.open(filename.c_str());
487 ofs << fm << std::endl;
504 std::vector<PHX::index_size_type> derivative_dimensions;
511 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
513 std::vector<PHX::index_size_type> derivative_dimensions;
521 std::vector<PHX::index_size_type> derivative_dimensions;
522 derivative_dimensions.push_back(1);
523 if (user_data.
isType<
int>(
"Tangent Dimension"))
524 derivative_dimensions[0] = user_data.
get<
int>(
"Tangent Dimension");
530 {active_evaluation_types_ = aet;}
536 phx_volume_field_managers_.clear();
537 volume_workset_desc_.clear();
538 if (clearVolumeWorksets)
539 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_