43 #ifndef PANZER_EQUATIONSET_DEFAULT_IMPL_IMPL_HPP
44 #define PANZER_EQUATIONSET_DEFAULT_IMPL_IMPL_HPP
51 #include "Panzer_GatherBasisCoordinates.hpp"
52 #include "Panzer_GatherIntegrationCoordinates.hpp"
53 #include "Panzer_GatherOrientation.hpp"
56 #include "Phalanx_MDField.hpp"
57 #include "Phalanx_DataLayout.hpp"
58 #include "Phalanx_DataLayout_MDALayout.hpp"
65 template <
typename EvalT>
68 const int& default_integration_order,
71 const bool build_transient_support) :
73 m_input_params(params),
74 m_default_integration_order(default_integration_order),
75 m_cell_data(cell_data),
76 m_build_transient_support(build_transient_support)
84 template <
typename EvalT>
89 m_type = m_input_params->get<std::string>(
"Type");
96 this->m_provided_dofs.clear();
97 this->m_int_rules.clear();
100 for(
typename std::map<std::string,DOFDescriptor>::iterator itr=m_provided_dofs_desc.begin();
101 itr!=m_provided_dofs_desc.end();++itr) {
105 this->m_provided_dofs.push_back(std::make_pair(itr->first, itr->second.basis));
116 m_int_rules[itr->second.intRule->order()] = itr->second.intRule;
121 for (
DescriptorIterator dof_iter = m_provided_dofs_desc.begin(); dof_iter != m_provided_dofs_desc.end(); ++dof_iter) {
123 std::string basis_name = dof_iter->second.basis->name();
125 std::string dof_name = dof_iter->first;
127 if (
is_null(m_basis_to_dofs[basis_name].first)) {
128 m_basis_to_dofs[basis_name].first = basis;
129 m_basis_to_dofs[basis_name].second =
Teuchos::rcp(
new std::vector<std::string>);
132 m_basis_to_dofs[basis_name].second->push_back(dof_name);
136 for (
DescriptorIterator dof_iter = m_provided_dofs_desc.begin(); dof_iter != m_provided_dofs_desc.end(); ++dof_iter) {
137 m_unique_bases[dof_iter->second.basis->name()] = dof_iter->second.basis;
141 this->m_eval_plist->set(
"Block ID", getElementBlockId());
142 this->setupDeprecatedDOFsSupport();
146 template <
typename EvalT>
158 this->m_eval_plist->set(
"Basis", basis);
159 this->m_eval_plist->set(
"IR", int_rule);
163 template <
typename EvalT>
179 for (
BasisIterator basis_it = m_basis_to_dofs.begin(); basis_it != m_basis_to_dofs.end(); ++basis_it) {
183 if (m_tangent_param_names.size() > 0) {
184 tangent_field_names =
rcp(
new std::vector< std::vector<std::string> >(basis_it->second.second->size()));
185 for (std::size_t i=0; i<basis_it->second.second->size(); ++i) {
186 for (std::size_t j=0; j<m_tangent_param_names.size(); ++j) {
187 const std::string tname =
188 (*(basis_it->second.second))[i] +
" SENSITIVITY " + m_tangent_param_names[j];
189 (*tangent_field_names)[i].push_back(tname);
195 ParameterList p(
"Gather");
196 p.set(
"Basis", basis_it->second.first);
197 p.set(
"DOF Names", basis_it->second.second);
198 p.set(
"Indexer Names", basis_it->second.second);
199 p.set(
"Sensitivities Name",
"");
200 p.set(
"First Sensitivities Available",
true);
201 p.set(
"Second Sensitivities Available",
true);
204 if (tangent_field_names != Teuchos::null)
205 p.set(
"Tangent Names", tangent_field_names);
209 this->
template registerEvaluator<EvalT>(fm, op);
214 if (tangent_field_names != Teuchos::null) {
215 for (std::size_t i=0; i<m_tangent_param_names.size(); ++i) {
218 for (std::size_t j=0; j<basis_it->second.second->size(); ++j)
219 names->push_back((*tangent_field_names)[j][i]);
221 ParameterList p(std::string(
"Gather Tangent ") + this->m_tangent_param_names[i]);
222 p.set(
"Basis", basis_it->second.first);
223 p.set(
"DOF Names", names);
224 p.set(
"Indexer Names", basis_it->second.second);
225 p.set(
"Sensitivities Name",
"");
226 p.set(
"First Sensitivities Available",
false);
227 p.set(
"Second Sensitivities Available",
false);
228 p.set(
"Global Data Key",
"X TANGENT GATHER CONTAINER: " + this->m_tangent_param_names[i]);
232 this->
template registerEvaluator<EvalT>(fm, op);
243 basis != m_unique_bases.end(); ++ basis) {
246 this->
template registerEvaluator<EvalT>(fm, basis_op);
251 ir != m_int_rules.end(); ++ir) {
254 this->
template registerEvaluator<EvalT>(fm, quad_op);
267 for (
BasisIterator basis_it = m_basis_to_dofs.begin(); basis_it != m_basis_to_dofs.end(); ++basis_it) {
274 for (
typename std::vector<std::string>::const_iterator dof_name = basis_it->second.second->begin();
275 dof_name != basis_it->second.second->end(); ++dof_name) {
281 if(desc->second.timeDerivative.first) {
283 t_dof_names->push_back(*dof_name);
284 t_field_names->push_back(desc->second.timeDerivative.second);
287 if (m_tangent_param_names.size() > 0) {
288 std::vector<std::string> tfn;
289 for (std::size_t j=0; j<m_tangent_param_names.size(); ++j) {
290 const std::string tname =
291 desc->second.timeDerivative.second +
" SENSITIVITY " + m_tangent_param_names[j];
292 tfn.push_back(tname);
294 tangent_field_names->push_back(tfn);
300 ParameterList p(
"Gather");
301 p.set(
"Basis", basis_it->second.first);
302 p.set(
"DOF Names", t_field_names);
303 p.set(
"Indexer Names", t_dof_names);
304 p.set(
"Use Time Derivative Solution Vector",
true);
307 if (m_tangent_param_names.size() > 0)
308 p.set(
"Tangent Names", tangent_field_names);
312 this->
template registerEvaluator<EvalT>(fm, op);
317 if (m_tangent_param_names.size() > 0) {
318 for (std::size_t i=0; i<m_tangent_param_names.size(); ++i) {
321 rcp(
new std::vector<std::string>);
322 for (std::size_t j=0; j<tangent_field_names->size(); ++j)
323 names->push_back((*tangent_field_names)[j][i]);
325 ParameterList p(std::string(
"Gather Tangent ") + this->m_tangent_param_names[i]);
326 p.set(
"Basis", basis_it->second.first);
327 p.set(
"DOF Names", names);
328 p.set(
"Indexer Names", t_dof_names);
329 p.set(
"Use Time Derivative Solution Vector",
true);
330 p.set(
"Global Data Key",
"DXDT TANGENT GATHER CONTAINER: " + this->m_tangent_param_names[i]);
334 this->
template registerEvaluator<EvalT>(fm, op);
343 for (
BasisIterator basis_it = m_basis_to_dofs.begin(); basis_it != m_basis_to_dofs.end(); ++basis_it) {
344 if(basis_it->second.first->requiresOrientations()) {
345 ParameterList p(
"Gather Orientation");
346 p.set(
"Basis", basis_it->second.first);
347 p.set(
"DOF Names", basis_it->second.second);
348 p.set(
"Indexer Names", basis_it->second.second);
352 this->
template registerEvaluator<EvalT>(fm, op);
359 template <
typename EvalT>
372 if(lof!=Teuchos::null)
373 globalIndexer = lof->getRangeGlobalIndexer();
376 for (
DescriptorIterator dof_iter = m_provided_dofs_desc.begin(); dof_iter != m_provided_dofs_desc.end(); ++dof_iter) {
379 p.set(
"Name", dof_iter->first);
383 if(globalIndexer!=Teuchos::null) {
385 int fieldNum = globalIndexer->
getFieldNum(dof_iter->first);
388 p.set(
"Jacobian Offsets Vector",
offsets);
395 this->
template registerEvaluator<EvalT>(fm, op);
400 for(
typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin();
401 itr!=m_provided_dofs_desc.end();++itr) {
403 if(itr->second.basis->supportsGrad()) {
406 if(!itr->second.grad.first)
409 const std::string dof_name = itr->first;
410 const std::string dof_grad_name = itr->second.grad.second;
413 p.set(
"Name", dof_name);
414 p.set(
"Gradient Name", dof_grad_name);
421 this->
template registerEvaluator<EvalT>(fm, op);
427 for(
typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin();
428 itr!=m_provided_dofs_desc.end();++itr) {
430 if(itr->second.basis->supportsCurl()) {
433 if(!itr->second.curl.first)
436 const std::string dof_name = itr->first;
437 const std::string dof_curl_name = itr->second.curl.second;
440 p.set(
"Name", dof_name);
441 p.set(
"Curl Name", dof_curl_name);
446 if(globalIndexer!=Teuchos::null) {
448 int fieldNum = globalIndexer->
getFieldNum(dof_name);
451 p.set(
"Jacobian Offsets Vector",
offsets);
459 this->
template registerEvaluator<EvalT>(fm, op);
466 for(
typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin();
467 itr!=m_provided_dofs_desc.end();++itr) {
469 if(itr->second.basis->supportsDiv()) {
472 if(!itr->second.div.first)
475 const std::string dof_name = itr->first;
476 const std::string dof_div_name = itr->second.div.second;
479 p.set(
"Name", dof_name);
480 p.set(
"Div Name", dof_div_name);
485 if(globalIndexer!=Teuchos::null) {
487 int fieldNum = globalIndexer->
getFieldNum(dof_name);
490 p.set(
"Jacobian Offsets Vector",
offsets);
498 this->
template registerEvaluator<EvalT>(fm, op);
503 for(
typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin();
504 itr!=m_provided_dofs_desc.end();++itr) {
506 if(!itr->second.timeDerivative.first)
509 const std::string td_name = itr->second.timeDerivative.second;
512 p.set(
"Name", td_name);
516 if(globalIndexer!=Teuchos::null) {
518 int fieldNum = globalIndexer->
getFieldNum(itr->first);
521 p.set(
"Jacobian Offsets Vector",
offsets);
527 if(itr->second.basis->requiresOrientations())
528 p.set(
"Orientation Field Name", itr->first+
" Orientation");
533 this->
template registerEvaluator<EvalT>(fm, op);
539 template <
typename EvalT>
552 bool ignoreScatter =
false;
554 ignoreScatter = user_data.
get<
bool>(
"Ignore Scatter");
558 for(
typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin();
559 itr!=m_provided_dofs_desc.end();++itr) {
567 names_map->insert(std::make_pair(itr->second.residualName.second,itr->first));
568 residual_names->push_back(itr->second.residualName.second);
571 ParameterList p(
"Scatter");
572 p.set(
"Scatter Name", itr->second.scatterName);
573 p.set(
"Basis", itr->second.basis.getConst());
574 p.set(
"Dependent Names", residual_names);
575 p.set(
"Dependent Map", names_map);
579 this->
template registerEvaluator<EvalT>(fm, op);
584 PHX::Tag<typename EvalT::ScalarT> tag(itr->second.scatterName,
586 fm.template requireField<EvalT>(tag);
597 template <
typename EvalT>
606 for (std::vector<std::string>::const_iterator model_name = m_closure_model_ids.begin();
607 model_name != m_closure_model_ids.end(); ++model_name) {
609 this->buildAndRegisterClosureModelEvaluators(fm,fl,ir,factory,*model_name,models,user_data);
615 template <
typename EvalT>
621 const std::string& model_name,
626 factory.getAsObject<EvalT>()->buildClosureModels(model_name,
630 *(this->m_eval_plist),
632 this->getGlobalData(),
635 for (std::vector<
Teuchos::RCP<PHX::Evaluator<panzer::Traits> > >::size_type i=0; i < evaluators->size(); ++i)
636 this->
template registerEvaluator<EvalT>(fm, (*evaluators)[i]);
640 template <
typename EvalT>
645 const std::string& model_name,
652 basis != m_unique_bases.end(); ++ basis) {
655 this->
template registerEvaluator<EvalT>(fm, basis_op);
658 for(
typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin();
659 itr!=m_provided_dofs_desc.end();++itr) {
662 p.
set(
"Scatter Name", itr->second.scatterName);
663 p.
set(
"Basis", itr->second.basis.getConst());
665 name->push_back(itr->first);
666 p.
set(
"Dependent Names", name);
670 names_map->insert(std::make_pair(itr->first,itr->first));
671 p.
set(
"Dependent Map", names_map);
674 p.
set(
"Scatter Initial Condition",
true);
679 this->
template registerEvaluator<EvalT>(fm, op);
683 PHX::Tag<typename EvalT::ScalarT> tag(itr->second.scatterName,
Teuchos::rcp(
new PHX::MDALayout<Dummy>(0)));
684 fm.template requireField<EvalT>(tag);
698 if (m_int_rules.size() > 0)
699 dummy_ir = m_int_rules.begin()->second;
703 factory.getAsObject<EvalT>()->buildClosureModels(model_name, models, *fll, dummy_ir, *(this->m_eval_plist), user_data, this->getGlobalData(), fm);
705 for (std::vector<
Teuchos::RCP<PHX::Evaluator<panzer::Traits> > >::size_type i=0; i < evaluators->size(); ++i)
706 this->
template registerEvaluator<EvalT>(fm, (*evaluators)[i]);
713 for (
BasisIterator basis_it = m_basis_to_dofs.begin(); basis_it != m_basis_to_dofs.end(); ++basis_it) {
714 if(basis_it->second.first->requiresOrientations()) {
716 p.
set(
"Basis", basis_it->second.first);
717 p.
set(
"DOF Names", basis_it->second.second);
718 p.
set(
"Indexer Names", basis_it->second.second);
722 this->
template registerEvaluator<EvalT>(fm, op);
729 template <
typename EvalT>
737 template <
typename EvalT>
738 const std::vector<std::pair<std::string,Teuchos::RCP<panzer::PureBasis> > >&
741 return m_provided_dofs;
745 template <
typename EvalT>
746 const std::vector<std::vector<std::string> > &
749 return m_coordinate_dofs;
753 template <
typename EvalT>
754 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> > &
761 template <
typename EvalT>
766 m_block_id = blockId;
767 this->m_eval_plist->set(
"Block ID", getElementBlockId());
772 template <
typename EvalT>
780 template <
typename EvalT>
787 template <
typename EvalT>
790 m_tangent_param_names = tangent_param_names;
794 template <
typename EvalT>
797 return m_build_transient_support;
801 template <
typename EvalT>
806 for(
typename std::map<std::string,DOFDescriptor>::const_iterator itr=m_provided_dofs_desc.begin();
807 itr!=m_provided_dofs_desc.end();++itr)
808 dofNames.push_back(itr->first);
812 template <
typename EvalT>
816 int integrationOrder)
818 typename std::map<std::string,DOFDescriptor>::const_iterator itr = m_provided_dofs_desc.find(dofName);
821 "EquationSet_DefaultImpl::updateDOF: DOF \"" << dofName <<
"\" has not been specified "
822 "by derived equation set \"" << this->getType() <<
"\".");
829 if (integrationOrder == -1)
830 desc.integrationOrder = m_default_integration_order;
832 desc.integrationOrder = integrationOrder;
838 template <
typename EvalT>
842 typename std::map<std::string,DOFDescriptor>::const_iterator itr = m_provided_dofs_desc.find(dofName);
845 "EquationSet_DefaultImpl::getBasisOrder: DOF \"" << dofName <<
"\" has not been specified "
846 "by derived equation set \"" << this->getType() <<
"\".");
848 return itr->second.basisOrder;
852 template <
typename EvalT>
856 typename std::map<std::string,DOFDescriptor>::const_iterator itr = m_provided_dofs_desc.find(dofName);
859 "EquationSet_DefaultImpl::getIntegrationOrder: DOF \"" << dofName <<
"\" has not been specified "
860 "by derived equation set \"" << this->getType() <<
"\".");
862 return itr->second.integrationOrder;
866 template <
typename EvalT>
869 const std::string & basisType,
870 const int & basisOrder,
871 const int integrationOrder,
872 const std::string residualName,
873 const std::string scatterName)
875 typename std::map<std::string,DOFDescriptor>::const_iterator itr = m_provided_dofs_desc.find(dofName);
878 "EquationSet_DefaultImpl::addProvidedDOF: DOF \"" << dofName <<
"\" was previously specified "
879 "by derived equation set \"" << this->getType() <<
"\".");
884 desc.basisType = basisType;
885 desc.basisOrder = basisOrder;
888 if (integrationOrder == -1)
889 desc.integrationOrder = m_default_integration_order;
891 desc.integrationOrder = integrationOrder;
896 desc.residualName.first =
true;
898 if (residualName ==
"")
899 desc.residualName.second =
"RESIDUAL_" + dofName;
901 desc.residualName.second = residualName;
903 if (scatterName ==
"")
904 desc.scatterName =
"SCATTER_" + dofName;
906 desc.scatterName = scatterName;
911 template <
typename EvalT>
914 const std::string & gradName)
916 typename std::map<std::string,DOFDescriptor>::iterator itr = m_provided_dofs_desc.find(dofName);
919 "EquationSet_DefaultImpl::addDOFGrad: DOF \"" << dofName <<
"\" has not been specified as a DOF "
920 "by derived equation set \"" << this->getType() <<
"\".");
927 desc.grad = std::make_pair(
true,std::string(
"GRAD_")+dofName);
929 desc.grad = std::make_pair(
true,gradName);
933 template <
typename EvalT>
936 const std::string & curlName)
938 typename std::map<std::string,DOFDescriptor>::iterator itr = m_provided_dofs_desc.find(dofName);
941 "EquationSet_DefaultImpl::addDOFCurl: DOF \"" << dofName <<
"\" has not been specified as a DOF "
942 "by derived equation set \"" << this->getType() <<
"\".");
949 desc.curl = std::make_pair(
true,std::string(
"CURL_")+dofName);
951 desc.curl = std::make_pair(
true,curlName);
955 template <
typename EvalT>
958 const std::string & divName)
960 typename std::map<std::string,DOFDescriptor>::iterator itr = m_provided_dofs_desc.find(dofName);
963 "EquationSet_DefaultImpl::addDOFDiv: DOF \"" << dofName <<
"\" has not been specified as a DOF "
964 "by derived equation set \"" << this->getType() <<
"\".");
971 desc.div = std::make_pair(
true,std::string(
"DIV_")+dofName);
973 desc.div = std::make_pair(
true,divName);
977 template <
typename EvalT>
980 const std::string & dotName)
982 typename std::map<std::string,DOFDescriptor>::iterator itr = m_provided_dofs_desc.find(dofName);
985 "EquationSet_DefaultImpl::addDOFTimeDerivative: DOF \"" << dofName <<
"\" has not been specified as a DOF "
986 "by derived equation set \"" << this->getType() <<
"\".");
993 desc.timeDerivative = std::make_pair(
true,std::string(
"DXDT_")+dofName);
995 desc.timeDerivative = std::make_pair(
true,dotName);
999 template <
typename EvalT>
1004 "EquationSet_DefaultImpl::setCoordinateDOFs: Size of vector is not equal to the "
1005 "spatial dimension.");
1007 for(std::size_t d=0;d<dofNames.size();d++) {
1008 typename std::map<std::string,DOFDescriptor>::const_iterator desc_it = m_provided_dofs_desc.find(dofNames[d]);
1010 "EquationSet_DefaultImpl::setCoordinateDOFs: DOF of name \"" + dofNames[d] +
"\" "
1011 "has not been added, thus cannot be set as a coordinate DOF.");
1014 m_coordinate_dofs.push_back(dofNames);
1018 template <
typename EvalT>
1022 std::string default_type =
"";
1023 valid_parameters.
set(
"Type",default_type,
"The equation set type. This must corespond to the type keyword used to build the equation set in the equation set factory.");
1027 template <
typename EvalT>
1031 typename std::map<std::string,DOFDescriptor>::const_iterator desc_it = m_provided_dofs_desc.find(dof_name);
1033 return desc_it->second.basis;
1037 template <
typename EvalT>
1041 typename std::map<std::string,DOFDescriptor>::const_iterator desc_it = m_provided_dofs_desc.find(dof_name);
1043 "EquationSet_DefaultImpl::getIntRuleForDOF: Failed to find degree of freedom "
1044 "with name \"" << dof_name <<
"\".");
1045 return desc_it->second.intRule;
1049 template <
typename EvalT>
1053 typename std::map<std::string,DOFDescriptor>::const_iterator desc_it = m_provided_dofs_desc.find(dof_name);
1055 "EquationSet_DefaultImpl::getBasisIRLayoutForDOF: Failed to find degree of freedom "
1056 "with name \"" << dof_name <<
"\".");
1062 template <
typename EvalT>
1065 const std::string dof_name,
1066 const std::vector<std::string>& residual_contributions,
1067 const std::string residual_field_name)
const
1074 if (residual_field_name !=
"")
1075 p.
set(
"Sum Name", residual_field_name);
1077 p.
set(
"Sum Name",
"RESIDUAL_" + dof_name);
1080 *rcp_residual_contributions = residual_contributions;
1082 p.
set(
"Values Names", rcp_residual_contributions);
1087 p.
set(
"Data Layout", desc_it->second.basis->functional);
1091 this->
template registerEvaluator<EvalT>(fm, op);
1095 template <
typename EvalT>
1098 const std::string dof_name,
1099 const std::vector<std::string>& residual_contributions,
1100 const std::vector<double>& scale_contributions,
1101 const std::string residual_field_name)
const
1108 if (residual_field_name !=
"")
1109 p.
set(
"Sum Name", residual_field_name);
1111 p.
set(
"Sum Name",
"RESIDUAL_" + dof_name);
1114 *rcp_residual_contributions = residual_contributions;
1115 p.
set(
"Values Names", rcp_residual_contributions);
1118 p.
set(
"Scalars", rcp_scale_contributions);
1123 p.
set(
"Data Layout", desc_it->second.basis->functional);
1127 this->
template registerEvaluator<EvalT>(fm, op);
1131 template <
typename EvalT>
1134 m_closure_model_ids.push_back(closure_model);
1138 template <
typename EvalT>
1142 return m_input_params;