43 #ifndef PANZER_STK_MODEL_EVALUATOR_FACTORY_T_HPP
44 #define PANZER_STK_MODEL_EVALUATOR_FACTORY_T_HPP
46 #include "Thyra_ModelEvaluator.hpp"
47 #include "Teuchos_Assert.hpp"
50 #include "Teuchos_AbstractFactoryStd.hpp"
52 #include "PanzerAdaptersSTK_config.hpp"
63 #include "Panzer_TpetraLinearObjFactory.hpp"
105 #include "Thyra_EpetraModelEvaluator.hpp"
106 #include "Piro_ConfigDefs.hpp"
107 #include "Piro_NOXSolver.hpp"
108 #include "Piro_LOCASolver.hpp"
109 #include "Piro_RythmosSolver.hpp"
113 namespace panzer_stk {
115 template<
typename ScalarT>
122 if(!paramList->
sublist(
"Initial Conditions").
isType<
bool>(
"Zero Initial Conditions"))
123 paramList->
sublist(
"Initial Conditions").
set<
bool>(
"Zero Initial Conditions",
false);
126 getValidParameters()->sublist(
"Initial Conditions").sublist(
"Vector File"));
128 this->setMyParamList(paramList);
131 template<
typename ScalarT>
142 pl->
set<
bool>(
"Use Discrete Adjoint",
false);
146 pl->
sublist(
"Initial Conditions").
set<
bool>(
"Zero Initial Conditions",
false);
150 pl->
sublist(
"Initial Conditions").
sublist(
"Vector File").
set<
bool>(
"Enabled",
false);
153 pl->
sublist(
"Output").
set(
"File Name",
"panzer.exo");
154 pl->
sublist(
"Output").
set(
"Write to Exodus",
true);
164 p.
set<
int>(
"Workset Size", 1);
165 p.
set<
int>(
"Default Integration Order",-1);
166 p.
set<std::string>(
"Field Order",
"");
167 p.
set<std::string>(
"Auxiliary Field Order",
"");
168 p.
set<
bool>(
"Use DOFManager FEI",
false);
169 p.
set<
bool>(
"Load Balance DOFs",
false);
170 p.
set<
bool>(
"Use Tpetra",
false);
171 p.
set<
bool>(
"Use Epetra ME",
true);
172 p.
set<
bool>(
"Lump Explicit Mass",
false);
173 p.
set<
bool>(
"Constant Mass Matrix",
true);
174 p.
set<
bool>(
"Apply Mass Matrix Inverse in Explicit Evaluator",
true);
175 p.
set<
bool>(
"Use Conservative IMEX",
false);
176 p.
set<
bool>(
"Compute Real Time Derivative",
false);
177 p.
set<
bool>(
"Use Time Derivative in Explicit Model",
false);
178 p.
set<
bool>(
"Compute Time Derivative at Time Step",
false);
182 p.
set<std::string>(
"Excluded Blocks",
"");
200 bool hasInterfaceCondition(
const std::vector<panzer::BC>& bcs)
202 for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
212 Teuchos::rcp_dynamic_cast<STKConnManager>(conn_mgr);
214 "There are interface conditions, but the connection manager"
215 " does not support the necessary connections.");
219 void buildInterfaceConnections(
const std::vector<panzer::BC>& bcs,
223 for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
233 if ( ! sidesets.empty()) {
234 std::stringstream ss;
236 for (std::size_t i = 0; i < sidesets.size(); ++i)
237 ss <<
" " << sidesets[i];
238 ss <<
" did not yield associations, but these sidesets correspond to BCT_Interface BCs.";
244 template<
typename ScalarT>
250 bool meConstructionOn)
253 "ParameterList must be set before objects can be built!");
261 m_global_data = global_data;
287 std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.
get<
int>(
"Workset Size"));
288 std::string field_order = assembly_params.
get<std::string>(
"Field Order");
290 bool use_dofmanager_fei = assembly_params.
get<
bool>(
"Use DOFManager FEI");
291 bool use_load_balance = assembly_params.
get<
bool>(
"Load Balance DOFs");
292 bool useTpetra = assembly_params.
get<
bool>(
"Use Tpetra");
293 bool useThyraME = !assembly_params.
get<
bool>(
"Use Epetra ME");
297 bool is_transient = solncntl_params.
get<std::string>(
"Piro Solver") ==
"Rythmos" ?
true :
false;
299 if (solncntl_params.
get<std::string>(
"Piro Solver") ==
"NOX") {
300 if (solncntl_params.
sublist(
"NOX").
get<std::string>(
"Nonlinear Solver") ==
"Pseudo-Transient")
305 if (solncntl_params.
get<std::string>(
"Piro Solver") ==
"LOCA") {
306 if (solncntl_params.
sublist(
"LOCA").
sublist(
"Stepper").
get<
bool>(
"Compute Eigenvalues"))
309 m_is_transient = is_transient;
311 useDiscreteAdjoint = p.
get<
bool>(
"Use Discrete Adjoint");
332 m_eqset_factory = eqset_factory;
337 std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
340 std::map<std::string,std::string> block_ids_to_physics_ids;
344 std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
345 for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
346 itr!=block_ids_to_physics_ids.end();++itr) {
347 block_ids_to_cell_topo[itr->first] = mesh->
getCellTopology(itr->first);
348 TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
353 panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
354 block_ids_to_cell_topo,
356 assembly_params.
get<
int>(
"Default Integration Order"),
362 m_physics_blocks = physicsBlocks;
367 addUserFieldsToMesh(*mesh,output_list);
374 this->finalizeMeshConstruction(*mesh_factory,physicsBlocks,*mpi_comm,*mesh);
376 fout <<
"*****************************************\n\n";
377 fout <<
"Element block exception, could not finalize the mesh, printing block and sideset information:\n";
385 fout <<
"*****************************************\n\n";
386 fout <<
"Sideset exception, could not finalize the mesh, printing block and sideset information:\n";
396 if(p.
sublist(
"Output").
get<
bool>(
"Write to Exodus"))
402 if(m_user_wkst_factory==Teuchos::null)
405 wkstFactory = m_user_wkst_factory;
412 std::vector<panzer::BC> bcs;
413 panzer::buildBCs(bcs, p.
sublist(
"Boundary Conditions"), global_data);
418 m_conn_manager = conn_manager;
426 std::string loadBalanceString =
"";
427 bool blockedAssembly =
false;
432 blockedAssembly =
true;
438 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
439 globalIndexer = dofManager;
443 Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager>(dofManager)));
446 const std::string excludedBlocks = assembly_params.
get<std::string>(
"Excluded Blocks");
447 std::vector<std::string> stringPairs;
449 for(std::size_t i=0;i<stringPairs.size();i++) {
450 std::vector<std::string> sPair;
451 std::vector<int> iPair;
456 "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
457 " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
458 "Failure on string pair " << stringPairs[i] <<
"!");
460 bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
463 linObjFactory = bloLinObjFactory;
471 blockedAssembly =
true;
478 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
479 globalIndexer = dofManager;
483 Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager>(dofManager)));
486 const std::string excludedBlocks = assembly_params.
get<std::string>(
"Excluded Blocks");
487 std::vector<std::string> stringPairs;
489 for(std::size_t i=0;i<stringPairs.size();i++) {
490 std::vector<std::string> sPair;
491 std::vector<int> iPair;
496 "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
497 " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
498 "Failure on string pair " << stringPairs[i] <<
"!");
500 bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
503 linObjFactory = bloLinObjFactory;
516 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
517 globalIndexer = dofManager;
526 const bool has_interface_condition = hasInterfaceCondition(bcs);
527 if (has_interface_condition)
528 buildInterfaceConnections(bcs, conn_manager);
536 = globalIndexerFactory.
buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,
538 globalIndexer = dofManager;
540 if (has_interface_condition)
541 checkInterfaceConnections(conn_manager, dofManager->
getComm());
551 m_global_indexer = globalIndexer;
552 m_lin_obj_factory = linObjFactory;
553 m_blockedAssembly = blockedAssembly;
556 fout <<
"Degree of freedom load balancing: " << loadBalanceString << std::endl;
562 std::map<std::string,panzer::WorksetNeeds> needs;
563 for(std::size_t i=0;i<physicsBlocks.size();i++)
564 needs[physicsBlocks[i]->elementBlockID()] = physicsBlocks[i]->getWorksetNeeds();
572 m_wkstContainer = wkstContainer;
575 std::size_t max_wksets = 0;
576 for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
579 max_wksets = std::max(max_wksets,works->size());
581 user_data_params.
set<std::size_t>(
"Max Worksets",max_wksets);
582 wkstContainer->
clear();
589 useDynamicCoordinates_ =
false;
590 for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
591 if(physicsBlocks[pb]->getCoordinateDOFs().size()>0) {
593 useDynamicCoordinates_ =
true;
594 wkstContainer->
clear();
603 panzer_data_params.
set(
"STK Mesh", mesh);
604 panzer_data_params.
set(
"DOF Manager", globalIndexer);
605 panzer_data_params.
set(
"Linear Object Factory", linObjFactory);
610 if(!meConstructionOn)
616 std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names;
617 std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values;
621 int num_param_vecs = active_params.
get<
int>(
"Number of Parameter Vectors",0);
622 p_names.resize(num_param_vecs);
623 p_values.resize(num_param_vecs);
624 for (
int i=0; i<num_param_vecs; i++) {
625 std::stringstream ss;
626 ss <<
"Parameter Vector " << i;
628 int numParameters = pList.
get<
int>(
"Number");
631 std::endl <<
"Error! panzer::ModelEvaluator::ModelEvaluator(): " <<
632 "Parameter vector " << i <<
" has zero parameters!" << std::endl);
637 for (
int j=0; j<numParameters; j++) {
638 std::stringstream ss2;
639 ss2 <<
"Parameter " << j;
640 (*p_names[i])[j] = pList.
get<std::string>(ss2.str());
643 ss2 <<
"Initial Value " << j;
644 (*p_values[i])[j] = pList.
get<
double>(ss2.str());
657 cm_factory.buildObjects(io_cm_builder);
664 bool write_dot_files = p.
sublist(
"Options").
get(
"Write Volume Assembly Graphs",
false);
665 std::string dot_file_prefix = p.
sublist(
"Options").
get(
"Volume Assembly Graph Prefix",
"Panzer_AssemblyGraph");
666 bool write_fm_files = p.
sublist(
"Options").
get(
"Write Field Manager Files",
false);
667 std::string fm_file_prefix = p.
sublist(
"Options").
get(
"Field Manager File Prefix",
"Panzer_AssemblyGraph");
671 auto check_write_dag = std::getenv(
"PANZER_WRITE_DAG");
672 if (check_write_dag !=
nullptr) {
673 write_dot_files =
true;
674 write_fm_files =
true;
678 fmb = buildFieldManagerBuilder(wkstContainer,physicsBlocks,bcs,*eqset_factory,bc_factory,cm_factory,
679 user_cm_factory,p.
sublist(
"Closure Models"),*linObjFactory,user_data_params,
680 write_dot_files,dot_file_prefix,
681 write_fm_files,fm_file_prefix);
690 bool write_dot_files =
false;
691 std::string prefix =
"Panzer_ResponseGraph_";
692 write_dot_files = p.
sublist(
"Options").
get(
"Write Volume Response Graphs",write_dot_files);
693 prefix = p.
sublist(
"Options").
get(
"Volume Response Graph Prefix",prefix);
696 user_data.
set<
int>(
"Workset Size",workset_size);
710 t_init = this->getInitialTime(p.
sublist(
"Initial Conditions").
sublist(
"Transient Parameters"), *mesh);
712 if(blockedAssembly || useTpetra)
716 = buildPhysicsModelEvaluator(useThyraME,
736 model_it!=models.
end(); ++model_it) {
737 std::string key = model_it->first;
738 if (model_it->first !=
"Global MMS Parameters")
739 cl_models.
setEntry(key,model_it->second);
741 bool write_dot_files =
false;
742 std::string prefix =
"Panzer_AssemblyGraph_";
743 setupInitialConditions(*thyra_me,*wkstContainer,physicsBlocks,user_cm_factory,*linObjFactory,
745 p.
sublist(
"Initial Conditions"),
747 p.
sublist(
"Options").
get(
"Write Volume Assembly Graphs",write_dot_files),
748 p.
sublist(
"Options").
get(
"Volume Assembly Graph Prefix",prefix));
753 writeInitialConditions(*thyra_me,physicsBlocks,wkstContainer,globalIndexer,linObjFactory,mesh,user_cm_factory,
755 p.
sublist(
"User Data"),workset_size);
757 m_physics_me = thyra_me;
760 template<
typename ScalarT>
767 itr!=cellAvgQuants.
end();++itr) {
768 const std::string & blockId = itr->first;
769 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
770 std::vector<std::string> tokens;
775 for(std::size_t i=0;i<tokens.size();i++)
784 itr != cellAvgVectors.
end(); ++itr) {
785 const std::string & blockId = itr->first;
786 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
787 std::vector<std::string> tokens;
792 for(std::size_t i = 0; i < tokens.size(); i++) {
793 std::string d_mod[3] = {
"X",
"Y",
"Z"};
802 itr!=cellQuants.
end();++itr) {
803 const std::string & blockId = itr->first;
804 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
805 std::vector<std::string> tokens;
810 for(std::size_t i=0;i<tokens.size();i++)
817 itr!=nodalQuants.
end();++itr) {
818 const std::string & blockId = itr->first;
819 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
820 std::vector<std::string> tokens;
825 for(std::size_t i=0;i<tokens.size();i++)
831 itr!=allocNodalQuants.
end();++itr) {
832 const std::string & blockId = itr->first;
833 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
834 std::vector<std::string> tokens;
839 for(std::size_t i=0;i<tokens.size();i++)
844 template<
typename ScalarT>
854 bool write_dot_files,
const std::string & dot_file_prefix)
const
858 Thyra::ModelEvaluatorBase::InArgs<double> nomValues = model.getNominalValues();
861 if(initial_cond_pl.
get<
bool>(
"Zero Initial Conditions")) {
863 Thyra::assign(x_vec.
ptr(),0.0);
865 else if(!initial_cond_pl.
sublist(
"Vector File").
get<
bool>(
"Enabled")) {
868 std::map<std::string, Teuchos::RCP< PHX::FieldManager<panzer::Traits> > > phx_ic_field_managers;
879 phx_ic_field_managers);
895 tloc->set_x_th(x_vec);
900 const std::string & vectorFile = initial_cond_pl.
sublist(
"Vector File").
get<std::string>(
"File Name");
902 "If \"Read From Vector File\" is true, then parameter \"Vector File\" cannot be the empty string.");
907 tloc->set_x_th(x_vec);
914 template<
typename ScalarT>
925 int workset_size)
const
932 = initializeSolnWriterResponseLibrary(wc,ugi,lof,mesh);
936 user_data.
set<
int>(
"Workset Size",workset_size);
938 finalizeSolnWriterResponseLibrary(*solnWriter,physicsBlocks,cm_factory,closure_model_pl,workset_size,user_data);
945 ae_inargs.
alpha = 0.0;
946 ae_inargs.
beta = 1.0;
961 template<
typename ScalarT>
967 if (mesh_params.
get<std::string>(
"Source") ==
"Exodus File") {
968 mesh_factory =
Teuchos::rcp(
new panzer_stk::STK_ExodusReaderFactory());
971 else if (mesh_params.
get<std::string>(
"Source") ==
"Pamgen Mesh") {
972 mesh_factory =
Teuchos::rcp(
new panzer_stk::STK_ExodusReaderFactory());
974 pamgenList->
set(
"File Type",
"Pamgen");
977 else if (mesh_params.
get<std::string>(
"Source") ==
"Inline Mesh") {
979 int dimension = mesh_params.
sublist(
"Inline Mesh").
get<
int>(
"Mesh Dimension");
980 std::string typeStr =
"";
982 typeStr = mesh_params.
sublist(
"Inline Mesh").
get<std::string>(
"Type");
984 if (dimension == 1) {
987 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
990 else if (dimension == 2 && typeStr==
"Tri") {
993 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
996 else if (dimension == 2) {
999 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1002 else if (dimension == 3 && typeStr==
"Tet") {
1005 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1008 else if(dimension == 3) {
1011 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1014 else if(dimension==4) {
1017 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1021 else if (mesh_params.
get<std::string>(
"Source") ==
"Custom Mesh") {
1031 if(mesh_params.
isSublist(
"Rebalance")) {
1035 bool enabled =
false;
1036 if(rebalance.
isType<
bool>(
"Enabled"))
1037 enabled = rebalance.
get<
bool>(
"Enabled");
1041 if(enabled && rebalance.
isSublist(
"Cycles"))
1048 return mesh_factory;
1051 template<
typename ScalarT>
1059 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
1060 for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
1062 double blockWeight = 0.0;
1065 const std::vector<panzer::StrPureBasisPair> & blockFields = pb->
getProvidedDOFs();
1066 const std::vector<std::vector<std::string> > & coordinateDOFs = pb->
getCoordinateDOFs();
1070 std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp> fieldNames;
1071 fieldNames.insert(blockFields.begin(),blockFields.end());
1076 std::set<std::string> fields_to_remove;
1080 for(std::size_t i=0;i<coordinateDOFs.size();i++) {
1082 for(std::size_t j=0;j<coordinateDOFs[i].size();j++)
1083 fields_to_remove.insert(coordinateDOFs[i][j]);
1087 std::set<std::string>::const_iterator rmItr;
1088 for (rmItr=fields_to_remove.begin();rmItr!=fields_to_remove.end();++rmItr)
1093 std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp>::const_iterator fieldItr;
1094 for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
1096 if(fieldItr->second->isScalarBasis() &&
1100 else if(fieldItr->second->isScalarBasis()) {
1103 else if(fieldItr->second->isVectorBasis()) {
1104 std::string d_mod[3] = {
"X",
"Y",
"Z"};
1105 for(
int d=0;d<fieldItr->second->dimension();d++)
1110 blockWeight += double(fieldItr->second->cardinality());
1123 template<
typename ScalarT>
1127 "Objects are not built yet! Please call buildObjects() member function.");
1128 return m_physics_me;
1131 template<
typename ScalarT>
1134 m_nox_observer_factory = nox_observer_factory;
1137 template<
typename ScalarT>
1140 m_rythmos_observer_factory = rythmos_observer_factory;
1143 template<
typename ScalarT>
1146 m_user_wkst_factory = user_wkst_factory;
1149 template<
typename ScalarT>
1152 if(m_rome_me==Teuchos::null)
1153 m_rome_me = buildResponseOnlyModelEvaluator(m_physics_me,m_global_data);
1158 template<
typename ScalarT>
1171 "Objects are not built yet! Please call buildObjects() member function.");
1173 "Objects are not built yet! Please call buildObjects() member function.");
1175 "Objects are not built yet! Please call buildObjects() member function.");
1177 =
is_null(in_nox_observer_factory) ? m_nox_observer_factory.ptr() : in_nox_observer_factory;
1179 =
is_null(in_rythmos_observer_factory) ? m_rythmos_observer_factory.ptr() : in_rythmos_observer_factory;
1186 std::string solver = solncntl_params.
get<std::string>(
"Piro Solver");
1188 = Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me);
1189 if ( (solver==
"NOX") || (solver ==
"LOCA") ) {
1192 "No NOX obersver built! Please call setNOXObserverFactory() member function if you plan to use a NOX solver.");
1195 piro_params->
sublist(
"NOX").
sublist(
"Solver Options").
set(
"User Defined Pre/Post Operator", ppo);
1198 piro =
Teuchos::rcp(
new Piro::NOXSolver<double>(piro_params,
1199 Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db)));
1200 else if (solver ==
"LOCA")
1201 piro =
Teuchos::rcp(
new Piro::LOCASolver<double>(piro_params,
1202 Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db),
1211 else if (solver==
"Rythmos") {
1214 "No NOX obersver built! Please call setrythmosObserverFactory() member function if you plan to use a Rythmos solver.");
1219 piro_params->
sublist(
"NOX").
sublist(
"Solver Options").
set(
"User Defined Pre/Post Operator", ppo);
1229 if(rythmosSolver==Teuchos::null)
1232 piro_rythmos = rythmosSolver;
1236 const std::string stepper_type = piro_params->
sublist(
"Rythmos").
get<std::string>(
"Stepper Type");
1237 if(stepper_type==
"Explicit RK" || stepper_type==
"Forward Euler") {
1239 bool lumpExplicitMass = assembly_params.
get<
bool>(
"Lump Explicit Mass");
1243 piro_rythmos->initialize(piro_params, rythmos_me, rythmos_observer_factory->
buildRythmosObserver(m_mesh,m_global_indexer,m_lin_obj_factory));
1245 piro = piro_rythmos;
1249 "Error: Unknown Piro Solver : " << solver);
1254 template<
typename ScalarT>
1258 "Objects are not built yet! Please call buildObjects() member function.");
1260 return m_response_library;
1263 template<
typename ScalarT>
1267 "Objects are not built yet! Please call buildObjects() member function.");
1269 return m_physics_blocks;
1272 template<
typename ScalarT>
1277 const std::vector<panzer::BC> & bcs,
1285 bool writeGraph,
const std::string & graphPrefix,
1286 bool write_field_managers,
const std::string & field_manager_prefix)
const
1291 fmb->
setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,lo_factory,user_data);
1298 if (write_field_managers){
1306 template<
typename ScalarT>
1314 bool is_transient,
bool is_explicit,
1325 std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
1330 std::map<std::string,std::string> block_ids_to_physics_ids;
1334 std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
1335 for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
1336 itr!=block_ids_to_physics_ids.end();++itr) {
1337 block_ids_to_cell_topo[itr->first] = m_mesh->getCellTopology(itr->first);
1338 TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
1341 std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.
get<
int>(
"Workset Size"));
1343 panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
1344 block_ids_to_cell_topo,
1345 physics_block_plist,
1346 assembly_params.
get<
int>(
"Default Integration Order"),
1359 bool write_dot_files =
false;
1360 std::string prefix =
"Cloned_";
1362 std::vector<panzer::BC> bcs;
1363 if(bc_list==Teuchos::null) {
1364 panzer::buildBCs(bcs, p.
sublist(
"Boundary Conditions"), m_global_data);
1367 panzer::buildBCs(bcs, *bc_list, m_global_data);
1370 fmb = buildFieldManagerBuilder(
1383 write_dot_files,prefix,
1384 write_dot_files,prefix);
1390 m_lin_obj_factory));
1398 Thyra::ModelEvaluatorBase::InArgs<ScalarT> nomVals = physics_me->getNominalValues();
1403 bool useThyra =
true;
1404 if(ep_thyra_me!=Teuchos::null)
1408 std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names(physics_me->Np());
1409 std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values(physics_me->Np());
1410 for(std::size_t i=0;i<p_names.size();i++) {
1416 = buildPhysicsModelEvaluator(useThyra,
1428 thyra_me->getNominalValues() = nomVals;
1433 bool lumpExplicitMass = assembly_params.
get<
bool>(
"Lump Explicit Mass");
1441 template<
typename ScalarT>
1452 bool is_transient,
double t_init)
const
1463 thyra_me = Thyra::epetraModelEvaluator(ep_me,solverFactory);
1467 (fmb,rLibrary,lof,p_names,p_values,solverFactory,global_data,is_transient,t_init));
1473 template<
typename ScalarT>
1480 Teuchos::setStringToIntegralParameter<int>(
1483 "Set the start time",
1484 Teuchos::tuple<std::string>(
"From Input File",
"From Exodus File"),
1488 validPL.
set<
double>(
"Start Time",0.0);
1493 std::string t_init_type = p.
get<std::string>(
"Start Time Type");
1494 double t_init = 10.0;
1496 if (t_init_type ==
"From Input File")
1497 t_init = p.
get<
double>(
"Start Time");
1499 if (t_init_type ==
"From Exodus File")
1507 template<
typename ScalarT>
1517 std::vector<std::string> eBlocks;
1521 builder.
mesh = mesh;
1522 stkIOResponseLibrary->addResponse(
"Main Field Output",eBlocks,builder);
1524 return stkIOResponseLibrary;
1527 template<
typename ScalarT>
1535 user_data.
set<
int>(
"Workset Size",workset_size);
1539 template<
typename ScalarT>
1546 #ifdef PANZER_HAVE_TEKO
1557 sublist(
"Newton").
sublist(
"Stratimikos Linear Solver").
sublist(
"Stratimikos")));
1559 bool writeCoordinates =
false;
1561 writeCoordinates = p.
sublist(
"Options").
get<
bool>(
"Write Coordinates");
1563 bool writeTopo =
false;
1565 writeTopo = p.
sublist(
"Options").
get<
bool>(
"Write Topology");
1569 blockedAssembly,globalIndexer,conn_manager,
1570 Teuchos::as<int>(mesh->
getDimension()), mpi_comm, strat_params,
1571 #ifdef PANZER_HAVE_TEKO
1579 template<
typename ScalarT>
1582 const bool write_graphviz_file,
1583 const std::string& graphviz_file_prefix)
1595 if(thyra_me!=Teuchos::null && panzer_me==Teuchos::null) {
1598 thyra_me->uninitialize(&const_ep_me,&solveFactory);
1604 ep_panzer_me->
buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1607 thyra_me->initialize(ep_me,solveFactory);
1611 else if(panzer_me!=Teuchos::null && thyra_me==Teuchos::null) {
1612 panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
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.
void setRythmosObserverFactory(const Teuchos::RCP< const panzer_stk::RythmosObserverFactory > &rythmos_observer_factory)
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
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)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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
virtual bool useNOXObserver() const =0
Use the NOX observer as well?
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)
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_
ParameterList & setEntry(const std::string &name, const ParameterEntry &entry)
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="")
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > buildResponseOnlyModelEvaluator(const Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > &thyra_me, const Teuchos::RCP< panzer::GlobalData > &global_data, const Teuchos::RCP< Piro::RythmosSolver< ScalarT > > rythmosSolver=Teuchos::null, const Teuchos::Ptr< const panzer_stk::NOXObserverFactory > &in_nox_observer_factory=Teuchos::null, const Teuchos::Ptr< const panzer_stk::RythmosObserverFactory > &in_rythmos_observer_factory=Teuchos::null)
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()
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)
double getInitialStateTime() const
virtual void readVector(const std::string &identifier, LinearObjContainer &loc, int id) const =0
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
virtual Teuchos::RCP< Rythmos::IntegrationObserverBase< double > > buildRythmosObserver(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 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.
void setupExodusFile(const std::string &filename)
Set up an output Exodus file for writing results.
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)
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