13 #include "Teuchos_Assert.hpp"
15 #include "Panzer_EquationSet_DefaultImpl.hpp"
30 const bool write_graphviz_file,
31 const std::string& graphviz_file_prefix,
34 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
35 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr) {
44 std::string closure_model_name =
"";
45 if (ic_block_closure_models.
isSublist(blockId))
46 closure_model_name = blockId;
47 else if (ic_block_closure_models.
isSublist(
"Default"))
48 closure_model_name =
"Default";
51 <<
"\". You must provide an initial condition for each element block or set a default!"
52 << ic_block_closure_models);
55 std::vector<bool> active_evaluation_types(Sacado::mpl::size<panzer::Traits::EvalTypes>::value,
false);
56 int residual_index = Sacado::mpl::find<panzer::Traits::EvalTypes,panzer::Traits::Residual>::value;
57 active_evaluation_types[residual_index] =
true;
72 for (
auto eval_type=fm->begin(); eval_type != fm->end(); ++eval_type,++i) {
73 if (active_evaluation_types[i])
74 eval_type->postRegistrationSetup(setupData,*fm,
false,
false,
nullptr);
77 phx_ic_field_managers[blockId] = fm;
79 if (write_graphviz_file)
80 fm->writeGraphvizFile(graphviz_file_prefix+
"_IC_"+blockId);
92 const bool write_graphviz_file,
93 const std::string& graphviz_file_prefix,
96 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
97 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr) {
106 std::string closure_model_name =
"";
107 if (ic_block_closure_models.
isSublist(blockId))
108 closure_model_name = blockId;
109 else if (ic_block_closure_models.
isSublist(
"Default"))
110 closure_model_name =
"Default";
113 <<
"\". You must provide an initial condition for each element block or set a default!"
114 << ic_block_closure_models);
117 std::vector<bool> active_evaluation_types(Sacado::mpl::size<panzer::Traits::EvalTypes>::value,
false);
118 int residual_index = Sacado::mpl::find<panzer::Traits::EvalTypes,panzer::Traits::Residual>::value;
119 active_evaluation_types[residual_index] =
true;
137 for (
auto eval_type=fm->begin(); eval_type != fm->end(); ++eval_type,++i) {
138 if (active_evaluation_types[i])
139 eval_type->postRegistrationSetup(setupData,*fm,
false,
false,
nullptr);
142 phx_ic_field_managers[blockId] = fm;
144 if (write_graphviz_file)
145 fm->writeGraphvizFile(graphviz_file_prefix+
"_IC_"+blockId);
154 const double time_stamp)
169 localCounter->initialize();
171 ped.
gedc->addDataObject(
"Residual Scatter Container",ghostedloc);
172 ped.
gedc->addDataObject(
"Dirichlet Counter",localCounter);
176 itr!=phx_ic_field_managers.end();++itr) {
177 std::string blockId = itr->first;
184 std::vector<panzer::Workset>& w = *wkstContainer.
getWorksets(wd);
185 for (std::size_t i = 0; i < w.size(); ++i) {
187 workset.
time = time_stamp;
194 summedGhostedCounter->initialize();
199 globalCounter->initialize();
216 if(loc2!=Teuchos::null) {
217 bool zeroVectorRows =
false;
232 template <
typename EvalT>
233 class EquationSet_IC :
public EquationSet_DefaultImpl<EvalT> {
240 const int& default_integration_order,
241 const CellData& cell_data,
243 const bool build_transient_support);
248 const FieldLibrary& ,
254 template <
typename EvalT>
255 EquationSet_IC<EvalT>::
257 const int& default_integration_order,
258 const CellData& cell_data,
260 const bool build_transient_support) :
261 EquationSet_DefaultImpl<EvalT>(params, default_integration_order, cell_data, global_data, build_transient_support )
267 valid_parameters_sublist.
set(
"Basis Type",
"HGrad",
"Type of Basis to use");
268 valid_parameters_sublist.
set(
"Basis Order",1,
"Order of the basis");
270 for(
auto itr=params->
begin();itr!=params->
end();++itr) {
272 const std::string
field = params->
name(itr);
276 if(!entry.
isList())
continue;
281 std::string basis_type = basisPL.
get<std::string>(
"Basis Type");
282 int basis_order = basisPL.
get<
int>(
"Basis Order");
284 this->addDOF(field,basis_type,basis_order,default_integration_order);
287 this->addClosureModel(
"");
296 class IC_EquationSetFactory : public EquationSetFactory {
301 const int& default_integration_order,
302 const CellData& cell_data,
304 const bool build_transient_support)
const
316 std::string msg =
"Error - the \"Equation Set\" called \"" + params->
get<std::string>(
"Type") +
317 "\" is not a valid equation set identifier. Please supply the correct factory.\n";
330 const std::map<std::string,std::vector<ICFieldDescriptor> > & block_ids_to_fields,
340 std::vector<Teuchos::RCP<PhysicsBlock> > physics_blocks;
343 std::map<std::string, Teuchos::RCP< PHX::FieldManager<Traits> > > phx_ic_field_managers;
351 "initial_condition_control_test",
352 phx_ic_field_managers);
364 const std::map<std::string,std::vector<ICFieldDescriptor> > & block_ids_to_fields,
371 std::map<std::string,std::string> block_ids_to_physics_ids;
375 for(
auto itr=block_ids_to_cell_topo.begin();itr!=block_ids_to_cell_topo.end();++itr) {
376 std::string eblock = itr->first;
380 auto fds_itr = block_ids_to_fields.find(eblock);
383 const std::vector<ICFieldDescriptor> & fd_vec = fds_itr->second;
385 std::string physics_id =
"ic_"+eblock;
386 block_ids_to_physics_ids[eblock] = physics_id;
390 physics_block.
set(
"Type",
"IC");
392 for(std::size_t i=0;i<fd_vec.size();i++) {
405 block_ids_to_cell_topo,
406 ipb,1,workset_size,eqset_factory,gd,
false,physics_blocks);
void buildICPhysicsBlocks(const std::map< std::string, Teuchos::RCP< const shards::CellTopology > > &block_ids_to_cell_topo, const std::map< std::string, std::vector< ICFieldDescriptor > > &block_ids_to_fields, int workset_size, std::vector< Teuchos::RCP< PhysicsBlock > > &physics_blocks)
Teuchos::RCP< GlobalEvaluationDataContainer > gedc
const std::string & name() const
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_
ConstIterator end() const
void addDataObject(const std::string &key, const Teuchos::RCP< GlobalEvaluationData > &ged)
std::unordered_map< std::string, Teuchos::RCP< GlobalEvaluationData > >::iterator iterator
T & get(const std::string &name, T def_value)
const_iterator begin() const
FieldManager::iterator begin()
void setupControlInitialCondition(const std::map< std::string, Teuchos::RCP< const shards::CellTopology > > &block_ids_to_cell_topo, const std::map< std::string, std::vector< ICFieldDescriptor > > &block_ids_to_fields, WorksetContainer &wkstContainer, const LinearObjFactory< Traits > &lof, const ClosureModelFactory_TemplateManager< Traits > &cm_factory, const Teuchos::ParameterList &ic_closure_models, const Teuchos::ParameterList &user_data, int workset_size, double t0, const Teuchos::RCP< Thyra::VectorBase< double > > &vec)
#define PANZER_BUILD_EQSET_OBJECTS(key, fType)
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)
virtual void adjustForDirichletConditions(const LinearObjContainer &localBCRows, const LinearObjContainer &globalBCRows, LinearObjContainer &ghostedObjs, bool zeroVectorRows=false, bool adjustX=false) const =0
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > getOrientations() const
T & getValue(T *ptr) const
Class that provides access to worksets on each element block and side set.
virtual Teuchos::RCP< LinearObjContainer > buildPrimitiveGhostedLinearObjContainer() const =0
void setActiveEvaluationTypes(const std::vector< bool > &aet)
Used to save memory by disabling unneeded evaluation types.
std::string first_sensitivities_name
virtual void initializeContainer(int, LinearObjContainer &loc) const =0
const_iterator end() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool isSublist(const std::string &name) const
std::string elementBlockID() const
void buildPhysicsBlocks(const std::map< std::string, std::string > &block_ids_to_physics_ids, const std::map< std::string, Teuchos::RCP< const shards::CellTopology > > &block_ids_to_cell_topo, const Teuchos::RCP< Teuchos::ParameterList > &physics_blocks_plist, const int default_integration_order, const std::size_t workset_size, const Teuchos::RCP< const panzer::EquationSetFactory > &eqset_factory, const Teuchos::RCP< panzer::GlobalData > &global_data, const bool build_transient_support, std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const std::vector< std::string > &tangent_param_names=std::vector< std::string >())
Nonmember function for building the physics blocks from a Teuchos::ParameterList for a given list of ...
Teuchos::RCP< panzer::GlobalData > createGlobalData(bool build_default_os=true, int print_process=0)
Nonmember constructor.
Teuchos::RCP< std::vector< Workset > > getWorksets(const WorksetDescriptor &wd)
Access to volume worksets.
virtual Teuchos::RCP< LinearObjContainer > buildLinearObjContainer() const =0
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
ConstIterator begin() const
#define PANZER_DECLARE_EQSET_TEMPLATE_BUILDER(fClass, fType)
const ParameterEntry & entry(ConstIterator i) const
void activateAllEvaluationTypes()
Used to reactivate all evaluation types if some were temporarily disabled with a call to setActiveEva...
void setupInitialConditionFieldManagers(WorksetContainer &wkstContainer, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &ic_block_closure_models, const panzer::LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data, const bool write_graphviz_file, const std::string &graphviz_file_prefix, std::map< std::string, Teuchos::RCP< PHX::FieldManager< panzer::Traits > > > &phx_ic_field_managers)
Builds PHX::FieldManager objects for inital conditions and registers evaluators.
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral...
virtual Teuchos::RCP< LinearObjContainer > buildPrimitiveLinearObjContainer() const =0
virtual void globalToGhostContainer(const LinearObjContainer &container, LinearObjContainer &ghostContainer, int) const =0
virtual void initializeGhostedContainer(int, LinearObjContainer &loc) const =0
WorksetDescriptor blockDescriptor(const std::string &eBlock)
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
virtual Teuchos::RCP< LinearObjContainer > buildGhostedLinearObjContainer() const =0
#define TEUCHOS_ASSERT(assertion_test)
void evaluateInitialCondition(WorksetContainer &wkstContainer, const std::map< std::string, Teuchos::RCP< PHX::FieldManager< panzer::Traits > > > &phx_ic_field_managers, Teuchos::RCP< panzer::LinearObjContainer > loc, const panzer::LinearObjFactory< panzer::Traits > &lo_factory, const double time_stamp)
virtual void ghostToGlobalContainer(const LinearObjContainer &ghostContainer, LinearObjContainer &container, int) const =0
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_