11 #ifndef PANZER_STK_MODEL_EVALUATOR_FACTORY_T_HPP
12 #define PANZER_STK_MODEL_EVALUATOR_FACTORY_T_HPP
14 #include "Thyra_ModelEvaluator.hpp"
15 #include "Teuchos_Assert.hpp"
18 #include "Teuchos_AbstractFactoryStd.hpp"
20 #include "PanzerAdaptersSTK_config.hpp"
31 #include "Panzer_TpetraLinearObjFactory.hpp"
57 #ifdef PANZER_HAVE_TEMPUS
72 #include "Piro_ConfigDefs.hpp"
73 #include "Piro_NOXSolver.hpp"
74 #include "Piro_LOCASolver.hpp"
75 #ifdef PANZER_HAVE_TEMPUS
76 #include "Piro_TempusSolverForwardOnly.hpp"
79 #ifdef PANZER_HAVE_EPETRA_STACK
81 #include "Thyra_EpetraModelEvaluator.hpp"
88 namespace panzer_stk {
90 template<
typename ScalarT>
97 if(!paramList->
sublist(
"Initial Conditions").
isType<
bool>(
"Zero Initial Conditions"))
98 paramList->
sublist(
"Initial Conditions").
set<
bool>(
"Zero Initial Conditions",
false);
101 getValidParameters()->sublist(
"Initial Conditions").sublist(
"Vector File"));
103 this->setMyParamList(paramList);
106 template<
typename ScalarT>
117 pl->
set<
bool>(
"Use Discrete Adjoint",
false);
121 pl->
sublist(
"Initial Conditions").
set<
bool>(
"Zero Initial Conditions",
false);
125 pl->
sublist(
"Initial Conditions").
sublist(
"Vector File").
set<
bool>(
"Enabled",
false);
128 pl->
sublist(
"Output").
set(
"File Name",
"panzer.exo");
129 pl->
sublist(
"Output").
set(
"Write to Exodus",
true);
139 p.
set<
int>(
"Workset Size", 1);
140 p.
set<
int>(
"Default Integration Order",-1);
141 p.
set<std::string>(
"Field Order",
"");
142 p.
set<std::string>(
"Auxiliary Field Order",
"");
143 p.
set<
bool>(
"Use DOFManager FEI",
false);
144 p.
set<
bool>(
"Load Balance DOFs",
false);
145 p.
set<
bool>(
"Use Tpetra",
false);
146 p.
set<
bool>(
"Use Epetra ME",
true);
147 p.
set<
bool>(
"Lump Explicit Mass",
false);
148 p.
set<
bool>(
"Constant Mass Matrix",
true);
149 p.
set<
bool>(
"Apply Mass Matrix Inverse in Explicit Evaluator",
true);
150 p.
set<
bool>(
"Use Conservative IMEX",
false);
151 p.
set<
bool>(
"Compute Real Time Derivative",
false);
152 p.
set<
bool>(
"Use Time Derivative in Explicit Model",
false);
153 p.
set<
bool>(
"Compute Time Derivative at Time Step",
false);
157 p.
set<std::string>(
"Excluded Blocks",
"");
175 bool hasInterfaceCondition(
const std::vector<panzer::BC>& bcs)
177 for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
187 Teuchos::rcp_dynamic_cast<STKConnManager>(conn_mgr);
189 "There are interface conditions, but the connection manager"
190 " does not support the necessary connections.");
194 void buildInterfaceConnections(
const std::vector<panzer::BC>& bcs,
198 for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
208 if ( ! sidesets.empty()) {
209 std::stringstream ss;
211 for (std::size_t i = 0; i < sidesets.size(); ++i)
212 ss <<
" " << sidesets[i];
213 ss <<
" did not yield associations, but these sidesets correspond to BCT_Interface BCs.";
219 template<
typename ScalarT>
225 bool meConstructionOn)
228 "ParameterList must be set before objects can be built!");
236 m_global_data = global_data;
262 std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.
get<
int>(
"Workset Size"));
263 std::string field_order = assembly_params.
get<std::string>(
"Field Order");
265 bool use_dofmanager_fei = assembly_params.
get<
bool>(
"Use DOFManager FEI");
266 bool use_load_balance = assembly_params.
get<
bool>(
"Load Balance DOFs");
267 bool useTpetra = assembly_params.
get<
bool>(
"Use Tpetra");
268 bool useThyraME = !assembly_params.
get<
bool>(
"Use Epetra ME");
272 bool is_transient = (solncntl_params.
get<std::string>(
"Piro Solver") ==
"Tempus") ?
true :
false;
274 if (solncntl_params.
get<std::string>(
"Piro Solver") ==
"NOX") {
275 if (solncntl_params.
sublist(
"NOX").
get<std::string>(
"Nonlinear Solver") ==
"Pseudo-Transient")
280 if (solncntl_params.
get<std::string>(
"Piro Solver") ==
"LOCA") {
281 if (solncntl_params.
sublist(
"LOCA").
sublist(
"Stepper").
get<
bool>(
"Compute Eigenvalues"))
284 m_is_transient = is_transient;
286 useDiscreteAdjoint = p.
get<
bool>(
"Use Discrete Adjoint");
307 m_eqset_factory = eqset_factory;
312 std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
315 std::map<std::string,std::string> block_ids_to_physics_ids;
319 std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
320 for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
321 itr!=block_ids_to_physics_ids.end();++itr) {
322 block_ids_to_cell_topo[itr->first] = mesh->
getCellTopology(itr->first);
323 TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
328 panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
329 block_ids_to_cell_topo,
331 assembly_params.
get<
int>(
"Default Integration Order"),
337 m_physics_blocks = physicsBlocks;
342 addUserFieldsToMesh(*mesh,output_list);
349 this->finalizeMeshConstruction(*mesh_factory,physicsBlocks,*mpi_comm,*mesh);
351 fout <<
"*****************************************\n\n";
352 fout <<
"Element block exception, could not finalize the mesh, printing block and sideset information:\n";
360 fout <<
"*****************************************\n\n";
361 fout <<
"Sideset exception, could not finalize the mesh, printing block and sideset information:\n";
371 if(p.
sublist(
"Output").
get<
bool>(
"Write to Exodus"))
377 if(m_user_wkst_factory==Teuchos::null)
380 wkstFactory = m_user_wkst_factory;
387 std::vector<panzer::BC> bcs;
388 panzer::buildBCs(bcs, p.
sublist(
"Boundary Conditions"), global_data);
393 m_conn_manager = conn_manager;
401 std::string loadBalanceString =
"";
402 bool blockedAssembly =
false;
404 const bool has_interface_condition = hasInterfaceCondition(bcs);
408 #ifdef PANZER_HAVE_EPETRA_STACK
412 "ERROR: Blocked Epetra systems cannot handle interface conditions.");
415 blockedAssembly =
true;
421 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
422 globalIndexer = dofManager;
426 Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager>(dofManager)));
429 const std::string excludedBlocks = assembly_params.
get<std::string>(
"Excluded Blocks");
430 std::vector<std::string> stringPairs;
432 for(std::size_t i=0;i<stringPairs.size();i++) {
433 std::vector<std::string> sPair;
434 std::vector<int> iPair;
439 "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
440 " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
441 "Failure on string pair " << stringPairs[i] <<
"!");
443 bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
446 linObjFactory = bloLinObjFactory;
459 "ERROR: Blocked Tpetra system cannot handle interface conditions.");
462 blockedAssembly =
true;
469 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
470 globalIndexer = dofManager;
474 Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager>(dofManager)));
477 const std::string excludedBlocks = assembly_params.
get<std::string>(
"Excluded Blocks");
478 std::vector<std::string> stringPairs;
480 for(std::size_t i=0;i<stringPairs.size();i++) {
481 std::vector<std::string> sPair;
482 std::vector<int> iPair;
487 "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
488 " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
489 "Failure on string pair " << stringPairs[i] <<
"!");
491 bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
494 linObjFactory = bloLinObjFactory;
501 if (has_interface_condition)
502 buildInterfaceConnections(bcs, conn_manager);
511 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
512 globalIndexer = dofManager;
514 if (has_interface_condition)
515 checkInterfaceConnections(conn_manager, dofManager->
getComm());
525 #ifdef PANZER_HAVE_EPETRA_STACK
526 if (has_interface_condition)
527 buildInterfaceConnections(bcs, conn_manager);
535 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,
537 globalIndexer = dofManager;
539 if (has_interface_condition)
540 checkInterfaceConnections(conn_manager, dofManager->
getComm());
553 m_global_indexer = globalIndexer;
554 m_lin_obj_factory = linObjFactory;
555 m_blockedAssembly = blockedAssembly;
558 fout <<
"Degree of freedom load balancing: " << loadBalanceString << std::endl;
564 std::map<std::string,panzer::WorksetNeeds> needs;
565 for(std::size_t i=0;i<physicsBlocks.size();i++)
566 needs[physicsBlocks[i]->elementBlockID()] = physicsBlocks[i]->getWorksetNeeds();
574 m_wkstContainer = wkstContainer;
577 std::size_t max_wksets = 0;
578 for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
581 max_wksets = std::max(max_wksets,works->size());
583 user_data_params.
set<std::size_t>(
"Max Worksets",max_wksets);
584 wkstContainer->
clear();
591 useDynamicCoordinates_ =
false;
592 for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
593 if(physicsBlocks[pb]->getCoordinateDOFs().size()>0) {
595 useDynamicCoordinates_ =
true;
596 wkstContainer->
clear();
605 panzer_data_params.
set(
"STK Mesh", mesh);
606 panzer_data_params.
set(
"DOF Manager", globalIndexer);
607 panzer_data_params.
set(
"Linear Object Factory", linObjFactory);
612 if(!meConstructionOn)
618 std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names;
619 std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values;
623 int num_param_vecs = active_params.
get<
int>(
"Number of Parameter Vectors",0);
624 p_names.resize(num_param_vecs);
625 p_values.resize(num_param_vecs);
626 for (
int i=0; i<num_param_vecs; i++) {
627 std::stringstream ss;
628 ss <<
"Parameter Vector " << i;
630 int numParameters = pList.
get<
int>(
"Number");
633 std::endl <<
"Error! panzer::ModelEvaluator::ModelEvaluator(): " <<
634 "Parameter vector " << i <<
" has zero parameters!" << std::endl);
639 for (
int j=0; j<numParameters; j++) {
640 std::stringstream ss2;
641 ss2 <<
"Parameter " << j;
642 (*p_names[i])[j] = pList.
get<std::string>(ss2.str());
645 ss2 <<
"Initial Value " << j;
646 (*p_values[i])[j] = pList.
get<
double>(ss2.str());
666 bool write_dot_files = p.
sublist(
"Options").
get(
"Write Volume Assembly Graphs",
false);
667 std::string dot_file_prefix = p.
sublist(
"Options").
get(
"Volume Assembly Graph Prefix",
"Panzer_AssemblyGraph");
668 bool write_fm_files = p.
sublist(
"Options").
get(
"Write Field Manager Files",
false);
669 std::string fm_file_prefix = p.
sublist(
"Options").
get(
"Field Manager File Prefix",
"Panzer_AssemblyGraph");
673 auto check_write_dag = std::getenv(
"PANZER_WRITE_DAG");
674 if (check_write_dag !=
nullptr) {
675 write_dot_files =
true;
676 write_fm_files =
true;
680 fmb = buildFieldManagerBuilder(wkstContainer,physicsBlocks,bcs,*eqset_factory,bc_factory,cm_factory,
681 user_cm_factory,p.
sublist(
"Closure Models"),*linObjFactory,user_data_params,
682 write_dot_files,dot_file_prefix,
683 write_fm_files,fm_file_prefix);
692 bool write_dot_files =
false;
693 std::string prefix =
"Panzer_ResponseGraph_";
694 write_dot_files = p.
sublist(
"Options").
get(
"Write Volume Response Graphs",write_dot_files);
695 prefix = p.
sublist(
"Options").
get(
"Volume Response Graph Prefix",prefix);
698 user_data.
set<
int>(
"Workset Size",workset_size);
712 t_init = this->getInitialTime(p.
sublist(
"Initial Conditions").
sublist(
"Transient Parameters"), *mesh);
714 if(blockedAssembly || useTpetra)
718 = buildPhysicsModelEvaluator(useThyraME,
738 model_it!=models.
end(); ++model_it) {
739 std::string key = model_it->first;
740 if (model_it->first !=
"Global MMS Parameters")
741 cl_models.
setEntry(key,model_it->second);
743 bool write_dot_files =
false;
744 std::string prefix =
"Panzer_AssemblyGraph_";
745 setupInitialConditions(*thyra_me,*wkstContainer,physicsBlocks,user_cm_factory,*linObjFactory,
747 p.
sublist(
"Initial Conditions"),
749 p.
sublist(
"Options").
get(
"Write Volume Assembly Graphs",write_dot_files),
750 p.
sublist(
"Options").
get(
"Volume Assembly Graph Prefix",prefix));
755 writeInitialConditions(*thyra_me,physicsBlocks,wkstContainer,globalIndexer,linObjFactory,mesh,user_cm_factory,
757 p.
sublist(
"User Data"),workset_size);
759 m_physics_me = thyra_me;
762 template<
typename ScalarT>
769 itr!=cellAvgQuants.
end();++itr) {
770 const std::string & blockId = itr->first;
771 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
772 std::vector<std::string> tokens;
777 for(std::size_t i=0;i<tokens.size();i++)
786 itr != cellAvgVectors.
end(); ++itr) {
787 const std::string & blockId = itr->first;
788 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
789 std::vector<std::string> tokens;
794 for(std::size_t i = 0; i < tokens.size(); i++) {
795 std::string d_mod[3] = {
"X",
"Y",
"Z"};
804 itr!=cellQuants.
end();++itr) {
805 const std::string & blockId = itr->first;
806 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
807 std::vector<std::string> tokens;
812 for(std::size_t i=0;i<tokens.size();i++)
819 itr!=nodalQuants.
end();++itr) {
820 const std::string & blockId = itr->first;
821 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
822 std::vector<std::string> tokens;
827 for(std::size_t i=0;i<tokens.size();i++)
833 itr!=allocNodalQuants.
end();++itr) {
834 const std::string & blockId = itr->first;
835 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
836 std::vector<std::string> tokens;
841 for(std::size_t i=0;i<tokens.size();i++)
846 template<
typename ScalarT>
856 bool write_dot_files,
const std::string & dot_file_prefix)
const
860 Thyra::ModelEvaluatorBase::InArgs<double> nomValues = model.getNominalValues();
863 if(initial_cond_pl.
get<
bool>(
"Zero Initial Conditions")) {
865 Thyra::assign(x_vec.
ptr(),0.0);
867 else if(!initial_cond_pl.
sublist(
"Vector File").
get<
bool>(
"Enabled")) {
870 std::map<std::string, Teuchos::RCP< PHX::FieldManager<panzer::Traits> > > phx_ic_field_managers;
881 phx_ic_field_managers);
897 tloc->set_x_th(x_vec);
902 const std::string & vectorFile = initial_cond_pl.
sublist(
"Vector File").
get<std::string>(
"File Name");
904 "If \"Read From Vector File\" is true, then parameter \"Vector File\" cannot be the empty string.");
909 tloc->set_x_th(x_vec);
916 template<
typename ScalarT>
927 int workset_size)
const
934 = initializeSolnWriterResponseLibrary(wc,ugi,lof,mesh);
938 user_data.
set<
int>(
"Workset Size",workset_size);
940 finalizeSolnWriterResponseLibrary(*solnWriter,physicsBlocks,cm_factory,closure_model_pl,workset_size,user_data);
947 ae_inargs.
alpha = 0.0;
948 ae_inargs.
beta = 1.0;
963 template<
typename ScalarT>
969 if (mesh_params.
get<std::string>(
"Source") ==
"Exodus File") {
970 mesh_factory =
Teuchos::rcp(
new panzer_stk::STK_ExodusReaderFactory());
973 else if (mesh_params.
get<std::string>(
"Source") ==
"Pamgen Mesh") {
974 mesh_factory =
Teuchos::rcp(
new panzer_stk::STK_ExodusReaderFactory());
976 pamgenList->
set(
"File Type",
"Pamgen");
979 else if (mesh_params.
get<std::string>(
"Source") ==
"Inline Mesh") {
981 int dimension = mesh_params.
sublist(
"Inline Mesh").
get<
int>(
"Mesh Dimension");
982 std::string typeStr =
"";
984 typeStr = mesh_params.
sublist(
"Inline Mesh").
get<std::string>(
"Type");
986 if (dimension == 1) {
989 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
992 else if (dimension == 2 && typeStr==
"Tri") {
995 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
998 else if (dimension == 2) {
1001 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1004 else if (dimension == 3 && typeStr==
"Tet") {
1007 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1010 else if(dimension == 3) {
1013 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1016 else if(dimension==4) {
1019 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1023 else if (mesh_params.
get<std::string>(
"Source") ==
"Custom Mesh") {
1033 if(mesh_params.
isSublist(
"Rebalance")) {
1037 bool enabled =
false;
1038 if(rebalance.
isType<
bool>(
"Enabled"))
1039 enabled = rebalance.
get<
bool>(
"Enabled");
1043 if(enabled && rebalance.
isSublist(
"Cycles"))
1050 return mesh_factory;
1053 template<
typename ScalarT>
1061 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
1062 for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
1064 double blockWeight = 0.0;
1067 const std::vector<panzer::StrPureBasisPair> & blockFields = pb->
getProvidedDOFs();
1068 const std::vector<std::vector<std::string> > & coordinateDOFs = pb->
getCoordinateDOFs();
1072 std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp> fieldNames;
1073 fieldNames.insert(blockFields.begin(),blockFields.end());
1078 std::set<std::string> fields_to_remove;
1082 for(std::size_t i=0;i<coordinateDOFs.size();i++) {
1084 for(std::size_t j=0;j<coordinateDOFs[i].size();j++)
1085 fields_to_remove.insert(coordinateDOFs[i][j]);
1089 std::set<std::string>::const_iterator rmItr;
1090 for (rmItr=fields_to_remove.begin();rmItr!=fields_to_remove.end();++rmItr)
1095 std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp>::const_iterator fieldItr;
1096 for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
1098 if(fieldItr->second->isScalarBasis() &&
1102 else if(fieldItr->second->isScalarBasis()) {
1105 else if(fieldItr->second->isVectorBasis()) {
1106 std::string d_mod[3] = {
"X",
"Y",
"Z"};
1107 for(
int d=0;d<fieldItr->second->dimension();d++)
1112 blockWeight += double(fieldItr->second->cardinality());
1125 template<
typename ScalarT>
1129 "Objects are not built yet! Please call buildObjects() member function.");
1130 return m_physics_me;
1133 template<
typename ScalarT>
1136 m_nox_observer_factory = nox_observer_factory;
1139 #ifdef PANZER_HAVE_TEMPUS
1140 template<
typename ScalarT>
1143 m_tempus_observer_factory = tempus_observer_factory;
1147 template<
typename ScalarT>
1150 m_user_wkst_factory = user_wkst_factory;
1153 template<
typename ScalarT>
1156 if(m_rome_me==Teuchos::null)
1157 m_rome_me = buildResponseOnlyModelEvaluator(m_physics_me,m_global_data);
1162 template<
typename ScalarT>
1166 #ifdef PANZER_HAVE_TEMPUS
1167 const Teuchos::RCP<Piro::TempusSolverForwardOnly<ScalarT> > tempusSolver,
1170 #ifdef PANZER_HAVE_TEMPUS
1179 "Objects are not built yet! Please call buildObjects() member function.");
1181 "Objects are not built yet! Please call buildObjects() member function.");
1183 "Objects are not built yet! Please call buildObjects() member function.");
1185 =
is_null(in_nox_observer_factory) ? m_nox_observer_factory.ptr() : in_nox_observer_factory;
1186 #ifdef PANZER_HAVE_TEMPUS
1188 =
is_null(in_tempus_observer_factory) ? m_tempus_observer_factory.ptr() : in_tempus_observer_factory;
1196 std::string solver = solncntl_params.
get<std::string>(
"Piro Solver");
1198 = Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me);
1199 if ( (solver==
"NOX") || (solver ==
"LOCA") ) {
1202 "No NOX obersver built! Please call setNOXObserverFactory() member function if you plan to use a NOX solver.");
1205 piro_params->
sublist(
"NOX").
sublist(
"Solver Options").
set(
"User Defined Pre/Post Operator", ppo);
1208 piro =
Teuchos::rcp(
new Piro::NOXSolver<double>(piro_params,
1209 Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db)));
1210 else if (solver ==
"LOCA")
1211 piro =
Teuchos::rcp(
new Piro::LOCASolver<double>(piro_params,
1212 Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db),
1221 #ifdef PANZER_HAVE_TEMPUS
1222 else if (solver==
"Tempus") {
1225 "No Tempus observer built! Please call setTempusObserverFactory() member function if you plan to use a Tempus solver.");
1230 piro_params->
sublist(
"NOX").
sublist(
"Solver Options").
set(
"User Defined Pre/Post Operator", ppo);
1241 if(tempusSolver==Teuchos::null)
1244 Teuchos::rcp(
new Piro::TempusSolverForwardOnly<double>(piro_params, thyra_me,
1245 tempus_observer_factory->
buildTempusObserver(m_mesh,m_global_indexer,m_lin_obj_factory)));
1249 piro_tempus = tempusSolver;
1250 piro_tempus->initialize(piro_params, thyra_me,
1259 "Error: Unknown Piro Solver : " << solver);
1264 template<
typename ScalarT>
1268 "Objects are not built yet! Please call buildObjects() member function.");
1270 return m_response_library;
1273 template<
typename ScalarT>
1277 "Objects are not built yet! Please call buildObjects() member function.");
1279 return m_physics_blocks;
1282 template<
typename ScalarT>
1287 const std::vector<panzer::BC> & bcs,
1295 bool writeGraph,
const std::string & graphPrefix,
1296 bool write_field_managers,
const std::string & field_manager_prefix)
const
1301 fmb->
setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,lo_factory,user_data);
1308 if (write_field_managers){
1316 template<
typename ScalarT>
1324 bool is_transient,
bool is_explicit,
1335 std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
1340 std::map<std::string,std::string> block_ids_to_physics_ids;
1344 std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
1345 for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
1346 itr!=block_ids_to_physics_ids.end();++itr) {
1347 block_ids_to_cell_topo[itr->first] = m_mesh->getCellTopology(itr->first);
1348 TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
1351 std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.
get<
int>(
"Workset Size"));
1353 panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
1354 block_ids_to_cell_topo,
1355 physics_block_plist,
1356 assembly_params.
get<
int>(
"Default Integration Order"),
1369 bool write_dot_files =
false;
1370 std::string prefix =
"Cloned_";
1372 std::vector<panzer::BC> bcs;
1373 if(bc_list==Teuchos::null) {
1374 panzer::buildBCs(bcs, p.
sublist(
"Boundary Conditions"), m_global_data);
1377 panzer::buildBCs(bcs, *bc_list, m_global_data);
1380 fmb = buildFieldManagerBuilder(
1393 write_dot_files,prefix,
1394 write_dot_files,prefix);
1400 m_lin_obj_factory));
1408 Thyra::ModelEvaluatorBase::InArgs<ScalarT> nomVals = physics_me->getNominalValues();
1413 bool useThyra =
true;
1414 #ifdef PANZER_HAVE_EPETRA_STACK
1416 if(ep_thyra_me!=Teuchos::null)
1421 std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names(physics_me->Np());
1422 std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values(physics_me->Np());
1423 for(std::size_t i=0;i<p_names.size();i++) {
1429 = buildPhysicsModelEvaluator(useThyra,
1441 thyra_me->getNominalValues() = nomVals;
1446 bool lumpExplicitMass = assembly_params.
get<
bool>(
"Lump Explicit Mass");
1454 template<
typename ScalarT>
1465 bool is_transient,
double t_init)
const
1469 #ifdef PANZER_HAVE_EPETRA_STACK
1477 thyra_me = Thyra::epetraModelEvaluator(ep_me,solverFactory);
1484 (fmb,rLibrary,lof,p_names,p_values,solverFactory,global_data,is_transient,t_init));
1490 template<
typename ScalarT>
1497 validPL.
set<std::string>(
"Start Time Type",
"From Input File",
"Set the start time",
1500 validPL.
set<
double>(
"Start Time",0.0);
1505 std::string t_init_type = p.
get<std::string>(
"Start Time Type");
1506 double t_init = 10.0;
1508 if (t_init_type ==
"From Input File")
1509 t_init = p.
get<
double>(
"Start Time");
1511 if (t_init_type ==
"From Exodus File")
1519 template<
typename ScalarT>
1529 std::vector<std::string> eBlocks;
1533 builder.
mesh = mesh;
1534 stkIOResponseLibrary->addResponse(
"Main Field Output",eBlocks,builder);
1536 return stkIOResponseLibrary;
1539 template<
typename ScalarT>
1547 user_data.
set<
int>(
"Workset Size",workset_size);
1551 template<
typename ScalarT>
1558 #ifdef PANZER_HAVE_TEKO
1569 sublist(
"Newton").
sublist(
"Stratimikos Linear Solver").
sublist(
"Stratimikos")));
1571 bool writeCoordinates =
false;
1573 writeCoordinates = p.
sublist(
"Options").
get<
bool>(
"Write Coordinates");
1575 bool writeTopo =
false;
1577 writeTopo = p.
sublist(
"Options").
get<
bool>(
"Write Topology");
1581 blockedAssembly,globalIndexer,conn_manager,
1582 Teuchos::as<int>(mesh->
getDimension()), mpi_comm, strat_params,
1583 #ifdef PANZER_HAVE_TEKO
1591 template<
typename ScalarT>
1594 const bool write_graphviz_file,
1595 const std::string& graphviz_file_prefix)
1608 panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1611 #ifdef PANZER_HAVE_EPETRA_STACK
1615 if(epetra_me!=Teuchos::null) {
1618 epetra_me->uninitialize(&const_ep_me,&solveFactory);
1622 ep_panzer_me->
buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1625 epetra_me->initialize(ep_me,solveFactory);
const std::string & name() const
virtual Teuchos::RCP< panzer::GlobalIndexer > buildGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager > &connMngr, const std::string &fieldOrder="") const
void TokensToInts(std::vector< int > &values, const std::vector< std::string > &tokens)
Turn a vector of tokens into a vector of ints.
Interface for constructing a BCStrategy_TemplateManager.
virtual Teuchos::RCP< Teuchos::Comm< int > > getComm() const =0
virtual void completeMeshConstruction(STK_Interface &mesh, stk::ParallelMachine parallelMach) const =0
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)
Allocates and initializes an equation set template manager.
void print(std::ostream &os) const
ParameterList & setEntry(const std::string &name, U &&entry)
bool evaluate_transient_terms
ConstIterator end() const
bool is_null(const boost::shared_ptr< T > &p)
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > getPhysicsModelEvaluator()
void setGlobalIndexer(const Teuchos::RCP< const panzer::GlobalIndexer > &ugi)
Teuchos::RCP< panzer::ParamLib > pl
Sacado scalar parameter library.
ParameterList & disableRecursiveValidation()
static bool requiresBlocking(const std::string &fieldorder)
void getElementBlockNames(std::vector< std::string > &names) const
void setUseTieBreak(bool flag)
T & get(const std::string &name, T def_value)
Teuchos::RCP< Teuchos::FancyOStream > os
ostream for redirecting all panzer output for a particular instantiation.
void buildBlockIdToPhysicsIdMap(std::map< std::string, std::string > &b_to_p, const Teuchos::ParameterList &p)
bool is_null(const std::shared_ptr< T > &p)
void writeVolumeGraphvizDependencyFiles(std::string filename_prefix, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks) const
Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< double > > buildLOWSFactory(bool blockedAssembly, const Teuchos::RCP< const panzer::GlobalIndexer > &globalIndexer, const Teuchos::RCP< panzer::ConnManager > &conn_manager, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const Teuchos::MpiComm< int > > &mpi_comm) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void finalizeSolnWriterResponseLibrary(panzer::ResponseLibrary< panzer::Traits > &rl, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, int workset_size, Teuchos::ParameterList &user_data) const
void printMetaData(std::ostream &os) const
void addSolutionField(const std::string &fieldName, const std::string &blockId)
Teuchos::RCP< STK_MeshFactory > buildSTKMeshFactory(const Teuchos::ParameterList &mesh_params) const
build STK mesh factory from a mesh parameter list
void writeBCGraphvizDependencyFiles(std::string filename_prefix) const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const ¶mList)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Teuchos::RCP< panzer::LinearObjContainer > ghostedContainer_
Teuchos::RCP< panzer_stk::STK_Interface > mesh
virtual Teuchos::RCP< NOX::Abstract::PrePostOperator > buildNOXObserver(const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const panzer::GlobalIndexer > &dof_manager, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof) const =0
std::vector< std::string > checkAssociateElementsInSidesets(const Teuchos::Comm< int > &comm) const
void setWorksetSize(std::size_t worksetSize)
set the workset size
Class that provides access to worksets on each element block and side set.
void set_t_init(double t)
Set initial time value.
void writeBCTextDependencyFiles(std::string filename_prefix) const
Teuchos::RCP< panzer::LinearObjContainer > container_
void setWorksetContainer(const Teuchos::RCP< WorksetContainer > &wc)
bool isParameter(const std::string &name) const
virtual void setParameterList(const RCP< ParameterList > ¶mList)=0
void buildResponseEvaluators(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
unsigned getDimension() const
get the dimension
void buildResponses(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::EquationSetFactory &eqset_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > getResponseOnlyModelEvaluator()
void setupExodusFile(const std::string &filename, const bool append=false, const bool append_after_restart_time=false, const double restart_time=0.0)
Set up an output Exodus file for writing results.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setUseFieldCoordinates(bool useFieldCoordinates)
void writeVolumeTextDependencyFiles(std::string filename_prefix, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks) const
Teuchos::RCP< Thyra::ModelEvaluator< double > > cloneWithNewPhysicsBlocks(const Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< ScalarT > > &solverFactory, const Teuchos::RCP< Teuchos::ParameterList > &physics_block_plist, const Teuchos::RCP< const panzer::EquationSetFactory > &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &user_cm_factory, bool is_transient, bool is_explicit, const Teuchos::Ptr< const Teuchos::ParameterList > &bc_list=Teuchos::null, const Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > &physics_me=Teuchos::null) const
bool isSublist(const std::string &name) const
void setUseNeighbors(bool flag)
std::string elementBlockID() const
const std::vector< std::vector< std::string > > & getCoordinateDOFs() const
void addUserFieldsToMesh(panzer_stk::STK_Interface &mesh, const Teuchos::ParameterList &output_list) const
Add the user fields specified by output_list to the mesh.
void setNOXObserverFactory(const Teuchos::RCP< const panzer_stk::NOXObserverFactory > &nox_observer_factory)
params_t::ConstIterator ConstIterator
virtual Teuchos::RCP< panzer::GlobalIndexer > buildGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager > &connMngr, const std::string &fieldOrder="") const
void buildObjects(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< panzer::GlobalData > &global_data, const Teuchos::RCP< const panzer::EquationSetFactory > &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, bool meConstructionOn=true)
Builds the model evaluators for a panzer assembly.
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
int getOutputToRootOnly() const
void setBlockWeight(const std::string &blockId, double weight)
Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< double > > buildLOWSFactory(bool blockedAssembly, const Teuchos::RCP< const panzer::GlobalIndexer > &globalIndexer, const Teuchos::RCP< panzer_stk::STKConnManager > &stkConn_manager, int spatialDim, const Teuchos::RCP< const Teuchos::MpiComm< int > > &mpi_comm, const Teuchos::RCP< Teuchos::ParameterList > &strat_params, bool writeCoordinates, bool writeTopo, const Teuchos::RCP< const panzer::GlobalIndexer > &auxGlobalIndexer, bool useCoordinates)
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > buildResponseOnlyModelEvaluator(const Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > &thyra_me, const Teuchos::RCP< panzer::GlobalData > &global_data, const Teuchos::Ptr< const panzer_stk::NOXObserverFactory > &in_nox_observer_factory=Teuchos::null)
double getInitialStateTime() const
virtual void readVector(const std::string &identifier, LinearObjContainer &loc, int id) const =0
virtual bool useNOXObserver() const =0
Use the NOX observer as well?
void buildObjects(const BuilderOpT &builder)
bool nonnull(const boost::shared_ptr< T > &p)
void addMeshCoordFields(const std::string &blockId, const std::vector< std::string > &coordField, const std::string &dispPrefix)
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.
void buildResponses(const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
virtual void setMesh(const Teuchos::RCP< const panzer_stk::STK_Interface > &mesh)
const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > & getPhysicsBlocks() const
bool isType(const std::string &name) const
void enableRebalance(bool enable, const Teuchos::RCP< const Teuchos::ParameterList > &rebalanceList=Teuchos::null)
std::pair< std::string, Teuchos::RCP< panzer::PureBasis > > StrPureBasisPair
void finalizeMeshConstruction(const STK_MeshFactory &mesh_factory, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::MpiComm< int > mpi_comm, STK_Interface &mesh) const
void writeInitialConditions(const Thyra::ModelEvaluator< ScalarT > &model, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< panzer::WorksetContainer > &wc, const Teuchos::RCP< const panzer::GlobalIndexer > &ugi, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_model_pl, const Teuchos::ParameterList &user_data_pl, int workset_size) const
Write the initial conditions to exodus. Note that this is entirely self contained.
WorksetDescriptor blockDescriptor(const std::string &eBlock)
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void StringTokenizer(std::vector< std::string > &tokens, const std::string &str, const std::string delimiters, bool trim)
Tokenize a string, put tokens in a vector.
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > initializeSolnWriterResponseLibrary(const Teuchos::RCP< panzer::WorksetContainer > &wc, const Teuchos::RCP< const panzer::GlobalIndexer > &ugi, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh) const
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)
void setUseDOFManagerFEI(bool flag)
#define TEUCHOS_ASSERT(assertion_test)
void setupInitialConditions(Thyra::ModelEvaluator< ScalarT > &model, panzer::WorksetContainer &wkstContainer, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &closure_pl, const Teuchos::ParameterList &initial_cond_pl, const Teuchos::ParameterList &user_data_pl, bool write_dot_files, const std::string &dot_file_prefix) const
Setup the initial conditions in a model evaluator. Note that this is entirely self contained...
void addCellField(const std::string &fieldName, const std::string &blockId)
Teuchos::RCP< panzer::FieldManagerBuilder > buildFieldManagerBuilder(const Teuchos::RCP< panzer::WorksetContainer > &wc, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const std::vector< panzer::BC > &bcs, const panzer::EquationSetFactory &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &volume_cm_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &bc_cm_factory, const Teuchos::ParameterList &closure_models, const panzer::LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data, bool writeGraph, const std::string &graphPrefix, bool write_field_managers, const std::string &field_manager_prefix) const
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)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void registerScalarParameter(const std::string name, panzer::ParamLib &pl, double realValue)
virtual Teuchos::RCP< Tempus::IntegratorObserver< double > > buildTempusObserver(const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const panzer::GlobalIndexer > &dof_manager, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof) const =0
void setUserWorksetFactory(Teuchos::RCP< panzer_stk::WorksetFactory > &user_wkst_factory)
Set user defined workset factory.
void setUseDOFManagerFEI(bool flag)
double getInitialTime(Teuchos::ParameterList &transient_ic_params, const panzer_stk::STK_Interface &mesh) const
Gets the initial time from either the input parameter list or an exodus file.
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > getResponseLibrary()
Teuchos::RCP< const shards::CellTopology > getCellTopology(const std::string &eBlock) const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const
void associateElementsInSideset(const std::string sideset_id)
std::string printUGILoadBalancingInformation(const GlobalIndexer &ugi)
Teuchos::RCP< Thyra::ModelEvaluatorDefaultBase< double > > buildPhysicsModelEvaluator(bool buildThyraME, const Teuchos::RCP< panzer::FieldManagerBuilder > &fmb, const Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > &rLibrary, const Teuchos::RCP< panzer::LinearObjFactory< panzer::Traits > > &lof, const std::vector< Teuchos::RCP< Teuchos::Array< std::string > > > &p_names, const std::vector< Teuchos::RCP< Teuchos::Array< double > > > &p_values, const Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< ScalarT > > &solverFactory, const Teuchos::RCP< panzer::GlobalData > &global_data, bool is_transient, double t_init) const