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)
125 "panzer::FMB::setupVolumeFieldManagers: method function getWorksetContainer() returns null. "
126 "Plase call setWorksetContainer() before calling this method");
128 "panzer::FMB::setupVolumeFieldManagers: physics block count must match workset descriptor count.");
130 phx_volume_field_managers_.clear();
134 for (std::size_t blkInd=0;blkInd<physicsBlocks.size();++blkInd) {
139 setupData.
worksets_ = getWorksetContainer()->getWorksets(wd);
140 setupData.
orientations_ = getWorksetContainer()->getOrientations();
154 if(!physicsBlockGatherDisabled())
157 if(!physicsBlockScatterDisabled())
160 if(closureModelByEBlock)
172 setKokkosExtendedDataTypeDimensions(wd.
getElementBlock(),*globalIndexer,user_data,*fm);
175 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,*fm,setupData));
178 volume_workset_desc_.push_back(wd);
179 phx_volume_field_managers_.push_back(fm);
191 std::vector<WorksetDescriptor> wkstDesc;
192 for(std::size_t i=0;i<physicsBlocks.size();i++)
193 wkstDesc.push_back(
blockDescriptor(physicsBlocks[i]->elementBlockID()));
196 setupVolumeFieldManagers(physicsBlocks,wkstDesc,cm_factory,closure_models,lo_factory,user_data,eef);
212 "panzer::FMB::setupBCFieldManagers: method function getWorksetContainer() returns null. "
213 "Plase call setWorksetContainer() before calling this method");
218 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks_map;
220 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
221 for(blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr) {
226 physicsBlocks_map.insert(std::make_pair(blockId,pb));
233 std::vector<panzer::BC>::const_iterator bc;
234 for (bc=bcs.begin(); bc != bcs.end(); ++bc) {
237 currentWkst = getWorksetContainer()->getSideWorksets(wd);
238 if (currentWkst.
is_null())
continue;
240 BCType bc_type = bc->bcType();
244 for (std::map<unsigned,panzer::Workset>::const_iterator wkst = currentWkst->begin();
245 wkst != currentWkst->end(); ++wkst) {
247 std::map<unsigned,PHX::FieldManager<panzer::Traits> >& field_managers =
248 bc_field_managers_[*bc];
253 for (
int block_id_index = 0; block_id_index < 2; ++block_id_index) {
254 const std::string element_block_id = block_id_index == 0 ? bc->elementBlockID() : bc->elementBlockID2();
256 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator
257 volume_pb_itr = physicsBlocks_map.find(element_block_id);
260 "panzer::FMB::setupBCFieldManagers: Cannot find physics block corresponding to element block \""
261 << element_block_id <<
"\"");
268 wkst->second.details(block_id_index).subcell_index,
269 volume_cell_topology);
280 bcs_type = bcstm->begin(); bcs_type != bcstm->end(); ++bcs_type,++i) {
281 if (active_evaluation_types_[i]) {
282 bcs_type->setDetailsIndex(block_id_index);
283 side_pb->setDetailsIndex(block_id_index);
284 bcs_type->setup(*side_pb, user_data);
285 bcs_type->buildAndRegisterEvaluators(fm, *side_pb, cm_factory, closure_models, user_data);
286 bcs_type->buildAndRegisterGatherAndOrientationEvaluators(fm, *side_pb, lo_factory, user_data);
287 if ( ! physicsBlockScatterDisabled())
288 bcs_type->buildAndRegisterScatterEvaluators(fm, *side_pb, lo_factory, user_data);
296 std::vector<PHX::index_size_type> derivative_dimensions;
297 derivative_dimensions.push_back(gid_count);
300 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
304 derivative_dimensions[0] = 1;
305 if (user_data.
isType<
int>(
"Tangent Dimension"))
306 derivative_dimensions[0] = user_data.
get<
int>(
"Tangent Dimension");
313 worksets->push_back(wkst->second);
315 setupData.
orientations_ = getWorksetContainer()->getOrientations();
317 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,fm,setupData));
321 const std::string element_block_id = bc->elementBlockID();
323 std::map<std::string,Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator volume_pb_itr
324 = physicsBlocks_map.find(element_block_id);
327 "panzer::FMB::setupBCFieldManagers: Cannot find physics block corresponding to element block \"" << element_block_id <<
"\"");
333 std::map<unsigned,PHX::FieldManager<panzer::Traits> >& field_managers =
334 bc_field_managers_[*bc];
337 for (std::map<unsigned,panzer::Workset>::const_iterator wkst =
338 currentWkst->begin(); wkst != currentWkst->end();
345 wkst->first,volume_cell_topology);
356 bcs_type = bcstm->begin(); bcs_type != bcstm->end(); ++bcs_type,++i) {
357 if (active_evaluation_types_[i]) {
358 bcs_type->setup(*side_pb,user_data);
359 bcs_type->buildAndRegisterEvaluators(fm,*side_pb,cm_factory,closure_models,user_data);
360 bcs_type->buildAndRegisterGatherAndOrientationEvaluators(fm,*side_pb,lo_factory,user_data);
361 if(!physicsBlockScatterDisabled())
362 bcs_type->buildAndRegisterScatterEvaluators(fm,*side_pb,lo_factory,user_data);
370 worksets->push_back(wkst->second);
372 setupData.
orientations_ = getWorksetContainer()->getOrientations();
375 setKokkosExtendedDataTypeDimensions(element_block_id,*globalIndexer,user_data,fm);
377 Sacado::mpl::for_each_no_kokkos<panzer::Traits::EvalTypes>(PostRegistrationFunctor(active_evaluation_types_,fm,setupData));
389 if(phx_volume_field_managers_.size()<1)
392 TEUCHOS_ASSERT(phx_volume_field_managers_.size()==physicsBlocks.size());
394 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
396 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr,++index) {
397 std::string blockId = (*blkItr)->elementBlockID();
398 phx_volume_field_managers_[index]->writeGraphvizFile(filename_prefix+
"_VOLUME_"+blockId);
408 typedef std::map<panzer::BC,std::map<unsigned,PHX::FieldManager<panzer::Traits> >,
panzer::LessBC> FMMap;
410 FMMap::const_iterator blkItr;
412 for (blkItr=bc_field_managers_.begin();blkItr!=bc_field_managers_.end();++blkItr,++bc_index) {
419 type =
"_Dirichlet_";
423 type =
"_Interface_";
429 fm.writeGraphvizFile(filename_prefix+
"_BC_"+std::to_string(bc_index)+type+sideId+
"_"+blockId);
440 if(phx_volume_field_managers_.size()<1)
443 TEUCHOS_ASSERT(phx_volume_field_managers_.size()==physicsBlocks.size());
445 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
447 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr,++index) {
449 std::string blockId = (*blkItr)->elementBlockID();
451 std::string filename = filename_prefix+
"_VOLUME_"+blockId+
".txt";
453 ofs.open(filename.c_str());
455 ofs << *(phx_volume_field_managers_[index]) << std::endl;
467 typedef std::map<panzer::BC,std::map<unsigned,PHX::FieldManager<panzer::Traits> >,
panzer::LessBC> FMMap;
469 FMMap::const_iterator blkItr;
471 for (blkItr=bc_field_managers_.begin();blkItr!=bc_field_managers_.end();++blkItr,++bc_index) {
478 type =
"_Dirichlet_";
482 type =
"_Interface_";
489 std::string filename = filename_prefix+
"_BC_"+std::to_string(bc_index)+type+sideId+
"_"+blockId+
".txt";
491 ofs.open(filename.c_str());
493 ofs << fm << std::endl;
510 std::vector<PHX::index_size_type> derivative_dimensions;
517 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
519 std::vector<PHX::index_size_type> derivative_dimensions;
527 std::vector<PHX::index_size_type> derivative_dimensions;
528 derivative_dimensions.push_back(1);
529 if (user_data.
isType<
int>(
"Tangent Dimension"))
530 derivative_dimensions[0] = user_data.
get<
int>(
"Tangent Dimension");
536 {active_evaluation_types_ = aet;}
542 phx_volume_field_managers_.clear();
543 volume_workset_desc_.clear();
544 if (clearVolumeWorksets)
545 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)
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 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 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_