45 #include "Teuchos_Assert.hpp"
47 #include "Panzer_EquationSet_DefaultImpl.hpp"
62 const bool write_graphviz_file,
63 const std::string& graphviz_file_prefix,
66 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
67 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr) {
76 std::string closure_model_name =
"";
77 if (ic_block_closure_models.
isSublist(blockId))
78 closure_model_name = blockId;
79 else if (ic_block_closure_models.
isSublist(
"Default"))
80 closure_model_name =
"Default";
83 <<
"\". You must provide an initial condition for each element block or set a default!"
84 << ic_block_closure_models);
87 std::vector<bool> active_evaluation_types(Sacado::mpl::size<panzer::Traits::EvalTypes>::value,
false);
88 int residual_index = Sacado::mpl::find<panzer::Traits::EvalTypes,panzer::Traits::Residual>::value;
89 active_evaluation_types[residual_index] =
true;
104 for (
auto eval_type=fm->begin(); eval_type != fm->end(); ++eval_type,++i) {
105 if (active_evaluation_types[i])
106 eval_type->postRegistrationSetup(setupData,*fm,
false,
false,
nullptr);
109 phx_ic_field_managers[blockId] = fm;
111 if (write_graphviz_file)
112 fm->writeGraphvizFile(graphviz_file_prefix+
"_IC_"+blockId);
124 const bool write_graphviz_file,
125 const std::string& graphviz_file_prefix,
128 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator blkItr;
129 for (blkItr=physicsBlocks.begin();blkItr!=physicsBlocks.end();++blkItr) {
138 std::string closure_model_name =
"";
139 if (ic_block_closure_models.
isSublist(blockId))
140 closure_model_name = blockId;
141 else if (ic_block_closure_models.
isSublist(
"Default"))
142 closure_model_name =
"Default";
145 <<
"\". You must provide an initial condition for each element block or set a default!"
146 << ic_block_closure_models);
149 std::vector<bool> active_evaluation_types(Sacado::mpl::size<panzer::Traits::EvalTypes>::value,
false);
150 int residual_index = Sacado::mpl::find<panzer::Traits::EvalTypes,panzer::Traits::Residual>::value;
151 active_evaluation_types[residual_index] =
true;
169 for (
auto eval_type=fm->begin(); eval_type != fm->end(); ++eval_type,++i) {
170 if (active_evaluation_types[i])
171 eval_type->postRegistrationSetup(setupData,*fm,
false,
false,
nullptr);
174 phx_ic_field_managers[blockId] = fm;
176 if (write_graphviz_file)
177 fm->writeGraphvizFile(graphviz_file_prefix+
"_IC_"+blockId);
186 const double time_stamp)
201 localCounter->initialize();
203 ped.
gedc->addDataObject(
"Residual Scatter Container",ghostedloc);
204 ped.
gedc->addDataObject(
"Dirichlet Counter",localCounter);
208 itr!=phx_ic_field_managers.end();++itr) {
209 std::string blockId = itr->first;
216 std::vector<panzer::Workset>& w = *wkstContainer.
getWorksets(wd);
217 for (std::size_t i = 0; i < w.size(); ++i) {
221 workset.
time = time_stamp;
228 summedGhostedCounter->initialize();
233 globalCounter->initialize();
250 if(loc2!=Teuchos::null) {
251 bool zeroVectorRows =
false;
266 template <
typename EvalT>
267 class EquationSet_IC :
public EquationSet_DefaultImpl<EvalT> {
274 const int& default_integration_order,
275 const CellData& cell_data,
277 const bool build_transient_support);
282 const FieldLibrary& ,
288 template <
typename EvalT>
289 EquationSet_IC<EvalT>::
291 const int& default_integration_order,
292 const CellData& cell_data,
294 const bool build_transient_support) :
295 EquationSet_DefaultImpl<EvalT>(params, default_integration_order, cell_data, global_data, build_transient_support )
301 valid_parameters_sublist.
set(
"Basis Type",
"HGrad",
"Type of Basis to use");
302 valid_parameters_sublist.
set(
"Basis Order",1,
"Order of the basis");
304 for(
auto itr=params->
begin();itr!=params->
end();++itr) {
306 const std::string
field = params->
name(itr);
310 if(!entry.
isList())
continue;
315 std::string basis_type = basisPL.
get<std::string>(
"Basis Type");
316 int basis_order = basisPL.
get<
int>(
"Basis Order");
318 this->addDOF(field,basis_type,basis_order,default_integration_order);
321 this->addClosureModel(
"");
330 class IC_EquationSetFactory : public EquationSetFactory {
335 const int& default_integration_order,
336 const CellData& cell_data,
338 const bool build_transient_support)
const
350 std::string msg =
"Error - the \"Equation Set\" called \"" + params->
get<std::string>(
"Type") +
351 "\" is not a valid equation set identifier. Please supply the correct factory.\n";
364 const std::map<std::string,std::vector<ICFieldDescriptor> > & block_ids_to_fields,
374 std::vector<Teuchos::RCP<PhysicsBlock> > physics_blocks;
377 std::map<std::string, Teuchos::RCP< PHX::FieldManager<Traits> > > phx_ic_field_managers;
385 "initial_condition_control_test",
386 phx_ic_field_managers);
398 const std::map<std::string,std::vector<ICFieldDescriptor> > & block_ids_to_fields,
405 std::map<std::string,std::string> block_ids_to_physics_ids;
409 for(
auto itr=block_ids_to_cell_topo.begin();itr!=block_ids_to_cell_topo.end();++itr) {
410 std::string eblock = itr->first;
414 auto fds_itr = block_ids_to_fields.find(eblock);
417 const std::vector<ICFieldDescriptor> & fd_vec = fds_itr->second;
419 std::string physics_id =
"ic_"+eblock;
420 block_ids_to_physics_ids[eblock] = physics_id;
424 physics_block.
set(
"Type",
"IC");
426 for(std::size_t i=0;i<fd_vec.size();i++) {
439 block_ids_to_cell_topo,
440 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
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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
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_