43 #ifndef PANZER_BCSTRATEGY_DIRICHLET_DEFAULT_IMPL_IMPL_HPP 44 #define PANZER_BCSTRATEGY_DIRICHLET_DEFAULT_IMPL_IMPL_HPP 46 #include "Teuchos_ParameterList.hpp" 47 #include "Teuchos_RCP.hpp" 48 #include "Teuchos_Assert.hpp" 50 #include "Phalanx_DataLayout_MDALayout.hpp" 51 #include "Phalanx_FieldManager.hpp" 53 #include "Phalanx_MDField.hpp" 54 #include "Phalanx_DataLayout.hpp" 55 #include "Phalanx_DataLayout_MDALayout.hpp" 60 #include "Panzer_Dirichlet_Residual.hpp" 63 #include "Panzer_GatherSolution_Epetra.hpp" 64 #include "Panzer_GatherBasisCoordinates.hpp" 65 #include "Panzer_ScatterDirichletResidual_Epetra.hpp" 66 #include "Panzer_BasisValues_Evaluator.hpp" 67 #include "Panzer_PointValues_Evaluator.hpp" 72 template <
typename EvalT>
75 const Teuchos::RCP<panzer::GlobalData>& global_data,
76 const bool in_check_apply_bc) :
79 check_apply_bc(in_check_apply_bc),
80 descriptor_map_built(false)
86 template <
typename EvalT>
94 template <
typename EvalT>
99 const Teuchos::ParameterList& user_data)
const 102 buildDescriptorMapFromVectors();
104 buildAndRegisterGatherAndOrientationEvaluators(fm,pb,lof,user_data);
105 buildAndRegisterScatterEvaluators(fm,pb,lof,user_data);
110 template <
typename EvalT>
115 const Teuchos::ParameterList& )
const 117 using Teuchos::ParameterList;
126 buildDescriptorMapFromVectors();
132 itr!=m_provided_dofs_desc.end(); ++itr) {
142 std::string dofName = desc.
dofName;
145 ParameterList p(
"Scatter: "+residualName +
" to " + dofName);
148 string scatter_field_name =
"Dummy Scatter: " + this->m_bc.identifier() + residualName;
149 p.set(
"Scatter Name", scatter_field_name);
152 const vector<pair<string,RCP<panzer::PureBasis> > >& dofBasisPair = pb.
getProvidedDOFs();
153 RCP<panzer::PureBasis> basis;
154 for (vector<pair<
string,RCP<panzer::PureBasis> > >::const_iterator it =
155 dofBasisPair.begin(); it != dofBasisPair.end(); ++it) {
156 if (it->first == dofName)
160 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(basis), std::runtime_error,
161 "Error the name \"" << dofName
162 <<
"\" is not a valid DOF for the boundary condition:\n" 163 << this->m_bc <<
"\n");
165 p.set(
"Basis", basis);
167 RCP<vector<string> > residual_names = rcp(
new vector<string>);
168 residual_names->push_back(residualName);
169 p.set(
"Dependent Names", residual_names);
171 RCP<map<string,string> > names_map = rcp(
new map<string,string>);
172 names_map->insert(std::make_pair(residualName,dofName));
173 p.set(
"Dependent Map", names_map);
175 TEUCHOS_TEST_FOR_EXCEPTION(!pb.
cellData().
isSide(), std::logic_error,
176 "Error - physics block is not a side set!");
178 p.set<
int>(
"Side Subcell Dimension",
182 p.set(
"Check Apply BC",check_apply_bc);
186 this->
template registerEvaluator<EvalT>(fm, op);
191 PHX::Tag<typename EvalT::ScalarT> tag(scatter_field_name,
192 rcp(
new PHX::MDALayout<Dummy>(0)));
193 fm.template requireField<EvalT>(tag);
201 template <
typename EvalT>
206 const Teuchos::ParameterList& )
const 208 using Teuchos::ParameterList;
217 buildDescriptorMapFromVectors();
226 const std::map<std::string,Teuchos::RCP<panzer::PureBasis> > & bases = pb.
getBases();
227 for (std::map<std::string,Teuchos::RCP<panzer::PureBasis> >::const_iterator it=bases.begin();
228 it!=bases.end();it++) {
230 Teuchos::RCP<panzer::PureBasis> basis = it->second;
234 RCP< PHX::Evaluator<panzer::Traits> > basis_op
236 this->
template registerEvaluator<EvalT>(fm, basis_op);
240 if(basis->isVectorBasis()) {
241 RCP<const panzer::PointRule> pointRule = rcp(
new panzer::PointRule(basis->name()+
":BasisPoints",basis->cardinality(),cellData));
244 RCP< PHX::Evaluator<panzer::Traits> > eval
247 this->
template registerEvaluator<EvalT>(fm, eval);
251 RCP< PHX::Evaluator<panzer::Traits> > eval
254 this->
template registerEvaluator<EvalT>(fm, eval);
262 itr!=m_provided_dofs_desc.end(); ++itr) {
265 std::string dofName = itr->second.dofName;
266 std::string fieldDof = !itr->second.timeDerivative.first
267 ? itr->second.dofName : itr->second.timeDerivative.second;
269 const vector<pair<string,RCP<panzer::PureBasis> > >& dofBasisPair = pb.
getProvidedDOFs();
270 RCP<panzer::PureBasis> basis;
271 for (vector<pair<
string,RCP<panzer::PureBasis> > >::const_iterator it =
272 dofBasisPair.begin(); it != dofBasisPair.end(); ++it) {
273 if (it->first == dofName)
277 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(basis), std::runtime_error,
278 "Error the name \"" << dofName
279 <<
"\" is not a valid DOF for the boundary condition:\n" 280 << this->m_bc <<
"\n");
283 ParameterList p(
"BC Gather");
284 RCP<vector<string> > gather_field_names_vec = rcp(
new vector<string>);
285 RCP<vector<string> > gather_names_vec = rcp(
new vector<string>);
286 gather_field_names_vec->push_back(fieldDof);
287 gather_names_vec->push_back(dofName);
289 p.set(
"DOF Names", gather_field_names_vec);
290 p.set(
"Indexer Names", gather_names_vec);
291 p.set(
"Basis", basis);
292 p.set(
"Use Time Derivative Solution Vector",itr->second.timeDerivative.first);
294 RCP< PHX::Evaluator<panzer::Traits> > op = lof.
buildGather<EvalT>(p);
295 this->
template registerEvaluator<EvalT>(fm, op);
298 if(basis->requiresOrientations()) {
299 ParameterList p(
"Gather Orientation");
300 RCP<vector<string> > gather_field_names_vec = rcp(
new vector<string>);
301 RCP<vector<string> > gather_names_vec = rcp(
new vector<string>);
302 gather_field_names_vec->push_back(fieldDof);
303 gather_names_vec->push_back(dofName);
305 p.set(
"DOF Names", gather_field_names_vec);
306 p.set(
"Indexer Names", gather_names_vec);
307 p.set(
"Basis", basis);
311 this->
template registerEvaluator<EvalT>(fm, op);
315 if(basis->isVectorBasis()) {
316 RCP<const panzer::PointRule> pointRule = rcp(
new panzer::PointRule(basis->name()+
":BasisPoints",basis->cardinality(),cellData));
319 p.set(
"Name",fieldDof);
320 p.set(
"Basis",basis.getConst());
321 p.set(
"Point Rule",pointRule);
323 RCP< PHX::Evaluator<panzer::Traits> > eval
325 this->
template registerEvaluator<EvalT>(fm, eval);
332 itr!=m_provided_dofs_desc.end(); ++itr) {
342 ? itr->second.dofName : itr->second.timeDerivative.second;
344 std::string targetName = desc.
targetName.second;
346 const vector<pair<string,RCP<panzer::PureBasis> > >& dofBasisPair = pb.
getProvidedDOFs();
347 RCP<panzer::PureBasis> basis;
348 for (vector<pair<
string,RCP<panzer::PureBasis> > >::const_iterator it =
349 dofBasisPair.begin(); it != dofBasisPair.end(); ++it) {
350 if (it->first == itr->second.dofName)
354 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(basis), std::runtime_error,
355 "Error the name \"" << itr->second.dofName
356 <<
"\" is not a valid DOF for the boundary condition:\n" 357 << this->m_bc <<
"\n");
360 ParameterList p(
"Dirichlet Residual: "+residualName +
" to " + dofName);
361 p.set(
"Residual Name", residualName);
362 p.set(
"DOF Name", dofName);
363 p.set(
"Value Name", targetName);
364 p.set(
"Data Layout", basis->functional);
366 RCP< PHX::Evaluator<panzer::Traits> > op =
369 this->
template registerEvaluator<EvalT>(fm, op);
372 else if(basis->isVectorBasis()&&basis->supportsDiv()) {
373 RCP<const panzer::PointRule> pointRule = rcp(
new panzer::PointRule(basis->name()+
":BasisPoints",basis->cardinality(),cellData));
376 p.set(
"Residual Name", residualName);
377 p.set(
"DOF Name", dofName);
378 p.set(
"Value Name", targetName);
379 p.set(
"Basis", basis.getConst());
380 p.set(
"Point Rule", pointRule);
382 RCP< PHX::Evaluator<panzer::Traits> > op =
385 this->
template registerEvaluator<EvalT>(fm, op);
387 else if(basis->isVectorBasis()) {
388 RCP<const panzer::PointRule> pointRule = rcp(
new panzer::PointRule(basis->name()+
":BasisPoints",basis->cardinality(),cellData));
391 p.set(
"Residual Name", residualName);
392 p.set(
"DOF Name", dofName);
393 p.set(
"Value Name", targetName);
394 p.set(
"Basis", basis.getConst());
395 p.set(
"Point Rule", pointRule);
397 RCP< PHX::Evaluator<panzer::Traits> > op =
400 this->
template registerEvaluator<EvalT>(fm, op);
408 template <
typename EvalT>
412 if(descriptor_map_built)
416 std::map<std::string,std::string> dof_names_to_residual_map;
417 for(std::map<std::string,std::string>::const_iterator itr=residual_to_dof_names_map.begin();
418 itr!=residual_to_dof_names_map.end();++itr) {
419 dof_names_to_residual_map[itr->second] = itr->first;
422 for(std::size_t i=0;i<required_dof_names.size();i++) {
423 std::string dof_name = required_dof_names[i];
429 if(dof_names_to_residual_map.find(dof_name)!=dof_names_to_residual_map.end()) {
430 std::string residual_name = dof_names_to_residual_map[dof_name];
431 std::string target_name = residual_to_target_field_map.find(residual_name)->second;
436 addTarget(target_name,
442 descriptor_map_built =
true;
447 template <
typename EvalT>
452 TEUCHOS_ASSERT(itr==m_provided_dofs_desc.end());
460 template <
typename EvalT>
463 const std::string & dofName,
464 const std::string & residualName)
466 typename std::map<std::string,DOFDescriptor>::iterator itr = m_provided_dofs_desc.find(dofName);
467 TEUCHOS_ASSERT(itr!=m_provided_dofs_desc.end());
471 desc.coefficientResidual =
false;
472 desc.targetName = std::make_pair(
true,targetName);
473 desc.residualName = (residualName==
"") ? std::make_pair(
true,
"RESIDUAL_"+dofName)
474 : std::make_pair(
true,residualName);
477 template <
typename EvalT>
480 const std::string & dofName,
481 const std::string & residualName)
483 typename std::map<std::string,DOFDescriptor>::iterator itr = m_provided_dofs_desc.find(dofName);
484 TEUCHOS_ASSERT(itr!=m_provided_dofs_desc.end());
488 desc.coefficientResidual =
true;
489 desc.targetName = std::make_pair(
true,targetName);
490 desc.residualName = (residualName==
"") ? std::make_pair(
true,
"RESIDUAL_"+dofName)
491 : std::make_pair(
true,residualName);
496 template <
typename EvalT>
499 const std::string & dofName,
500 const std::string & dotName,
501 const std::string & residualName)
503 typename std::map<std::string,DOFDescriptor>::iterator itr = m_provided_dofs_desc.find(dofName);
504 TEUCHOS_ASSERT(itr!=m_provided_dofs_desc.end());
508 desc.targetName = std::make_pair(
true,targetName);
509 desc.timeDerivative = (dotName==
"") ? std::make_pair(
true,
"DXDT_"+dofName)
510 : std::make_pair(
true,dotName);
511 desc.residualName = (residualName==
"") ? std::make_pair(
true,
"RESIDUAL_"+dofName)
512 : std::make_pair(
true,residualName);
Teuchos::RCP< PHX::Evaluator< Traits > > buildScatterDirichlet(const Teuchos::ParameterList &pl) const
Use preconstructed dirichlet scatter evaluators.
Object that contains information on the physics and discretization of a block of elements with the SA...
Default implementation for accessing the GlobalData object.
std::pair< bool, std::string > timeDerivative
Interpolates basis DOF values to IP DOF values.
Teuchos::RCP< PHX::Evaluator< Traits > > buildGather(const Teuchos::ParameterList &pl) const
Use preconstructed gather evaluators.
BCStrategy_Dirichlet_DefaultImpl(const panzer::BC &bc, const Teuchos::RCP< panzer::GlobalData > &global_data, const bool check_apply_bc=false)
Interpolates basis DOF values to IP DOF Curl values.
virtual void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
Teuchos::RCP< const shards::CellTopology > getCellTopology() const
Get CellTopology for the base cell.
std::map< std::string, DOFDescriptor >::const_iterator DescriptorIterator
For convenience, declare the DOFDescriptor iterator.
std::pair< bool, std::string > residualName
Data for determining cell topology and dimensionality.
void addDOF(const std::string &dofName)
virtual ~BCStrategy_Dirichlet_DefaultImpl()
void addTarget(const std::string &targetName, const std::string &dofName, const std::string &residualName="")
void buildDescriptorMapFromVectors() const
void addDotTarget(const std::string &targetName, const std::string &dofName, const std::string &dotName="", const std::string &residualName="")
const panzer::CellData & cellData() const
void addCoefficientTarget(const std::string &targetName, const std::string &dofName, const std::string &residualName="")
virtual void buildAndRegisterGatherScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &pb, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const
std::pair< bool, std::string > targetName
const std::map< std::string, Teuchos::RCP< panzer::PureBasis > > & getBases() const
Returns the unique set of bases, key is the unique panzer::PureBasis::name() of the basis...
Stores input information for a boundary condition.
Evaluates a Dirichlet BC residual corresponding to a field value.
Gathers coordinates for the basis function from the workset and stores them in the field manager...
const shards::CellTopology getBaseCellTopology() const
Interpolates basis DOF values to IP DOF values.
std::size_t numCells() const
virtual void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
Teuchos::RCP< PHX::Evaluator< Traits > > buildGatherOrientation(const Teuchos::ParameterList &pl) const
Use preconstructed gather evaluators.