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"
59 #include "Panzer_DOFManagerFactory.hpp"
61 #include "Panzer_BlockedDOFManagerFactory.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<int> >(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)
225 stk_conn_mgr->associateElementsInSideset(bcit->sidesetID());
232 std::vector<std::string> sidesets = stk_conn_mgr->checkAssociateElementsInSidesets(*comm);
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);
423 m_conn_manager = conn_manager;
431 std::string loadBalanceString =
"";
432 bool blockedAssembly =
false;
439 blockedAssembly =
true;
445 = globalIndexerFactory.
buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_int,field_order);
446 globalIndexer = dofManager;
453 const std::string excludedBlocks = assembly_params.
get<std::string>(
"Excluded Blocks");
454 std::vector<std::string> stringPairs;
456 for(std::size_t i=0;i<stringPairs.size();i++) {
457 std::vector<std::string> sPair;
458 std::vector<int> iPair;
463 "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
464 " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
465 "Failure on string pair " << stringPairs[i] <<
"!");
467 bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
470 linObjFactory = bloLinObjFactory;
480 blockedAssembly =
true;
487 = globalIndexerFactory.
buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_long,field_order);
488 globalIndexer = dofManager;
495 const std::string excludedBlocks = assembly_params.
get<std::string>(
"Excluded Blocks");
496 std::vector<std::string> stringPairs;
498 for(std::size_t i=0;i<stringPairs.size();i++) {
499 std::vector<std::string> sPair;
500 std::vector<int> iPair;
505 "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
506 " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
507 "Failure on string pair " << stringPairs[i] <<
"!");
509 bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
512 linObjFactory = bloLinObjFactory;
528 = globalIndexerFactory.
buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_long,field_order);
529 globalIndexer = dofManager;
538 const bool has_interface_condition = hasInterfaceCondition(bcs);
539 if (has_interface_condition)
540 buildInterfaceConnections(bcs, conn_manager);
548 globalIndexerFactory.setUseTieBreak(use_load_balance);
549 globalIndexerFactory.setUseNeighbors(has_interface_condition);
551 = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_int,
553 globalIndexer = dofManager;
555 if (has_interface_condition)
556 checkInterfaceConnections(conn_manager, dofManager->getComm());
566 m_global_indexer = globalIndexer;
567 m_lin_obj_factory = linObjFactory;
568 m_blockedAssembly = blockedAssembly;
571 fout <<
"Degree of freedom load balancing: " << loadBalanceString << std::endl;
577 std::map<std::string,panzer::WorksetNeeds> needs;
578 for(std::size_t i=0;i<physicsBlocks.size();i++)
579 needs[physicsBlocks[i]->elementBlockID()] = physicsBlocks[i]->getWorksetNeeds();
587 m_wkstContainer = wkstContainer;
590 std::size_t max_wksets = 0;
591 for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
594 max_wksets = std::max(max_wksets,works->size());
596 user_data_params.
set<std::size_t>(
"Max Worksets",max_wksets);
597 wkstContainer->
clear();
604 useDynamicCoordinates_ =
false;
605 for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
606 if(physicsBlocks[pb]->getCoordinateDOFs().size()>0) {
608 useDynamicCoordinates_ =
true;
609 wkstContainer->
clear();
618 panzer_data_params.
set(
"STK Mesh", mesh);
619 panzer_data_params.
set(
"DOF Manager", globalIndexer);
620 panzer_data_params.
set(
"Linear Object Factory", linObjFactory);
625 if(!meConstructionOn)
631 std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names;
632 std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values;
636 int num_param_vecs = active_params.
get<
int>(
"Number of Parameter Vectors",0);
637 p_names.resize(num_param_vecs);
638 p_values.resize(num_param_vecs);
639 for (
int i=0; i<num_param_vecs; i++) {
640 std::stringstream ss;
641 ss <<
"Parameter Vector " << i;
643 int numParameters = pList.
get<
int>(
"Number");
646 std::endl <<
"Error! panzer::ModelEvaluator::ModelEvaluator(): " <<
647 "Parameter vector " << i <<
" has zero parameters!" << std::endl);
652 for (
int j=0; j<numParameters; j++) {
653 std::stringstream ss2;
654 ss2 <<
"Parameter " << j;
655 (*p_names[i])[j] = pList.
get<std::string>(ss2.str());
658 ss2 <<
"Initial Value " << j;
659 (*p_values[i])[j] = pList.
get<
double>(ss2.str());
672 cm_factory.buildObjects(io_cm_builder);
679 bool write_dot_files = p.
sublist(
"Options").
get(
"Write Volume Assembly Graphs",
false);
680 std::string dot_file_prefix = p.
sublist(
"Options").
get(
"Volume Assembly Graph Prefix",
"Panzer_AssemblyGraph");
681 bool write_fm_files = p.
sublist(
"Options").
get(
"Write Field Manager Files",
false);
682 std::string fm_file_prefix = p.
sublist(
"Options").
get(
"Field Manager File Prefix",
"Panzer_AssemblyGraph");
684 fmb = buildFieldManagerBuilder(wkstContainer,physicsBlocks,bcs,*eqset_factory,bc_factory,cm_factory,
685 user_cm_factory,p.
sublist(
"Closure Models"),*linObjFactory,user_data_params,
686 write_dot_files,dot_file_prefix,
687 write_fm_files,fm_file_prefix);
696 bool write_dot_files =
false;
697 std::string prefix =
"Panzer_ResponseGraph_";
698 write_dot_files = p.
sublist(
"Options").
get(
"Write Volume Response Graphs",write_dot_files);
699 prefix = p.
sublist(
"Options").
get(
"Volume Response Graph Prefix",prefix);
702 user_data.
set<
int>(
"Workset Size",workset_size);
716 t_init = this->getInitialTime(p.
sublist(
"Initial Conditions").
sublist(
"Transient Parameters"), *mesh);
718 if(blockedAssembly || useTpetra)
722 = buildPhysicsModelEvaluator(useThyraME,
742 model_it!=models.
end(); ++model_it) {
743 std::string key = model_it->first;
744 if (model_it->first !=
"Global MMS Parameters")
745 cl_models.
setEntry(key,model_it->second);
747 bool write_dot_files =
false;
748 std::string prefix =
"Panzer_AssemblyGraph_";
749 setupInitialConditions(*thyra_me,*wkstContainer,physicsBlocks,user_cm_factory,*linObjFactory,
751 p.
sublist(
"Initial Conditions"),
753 p.
sublist(
"Options").
get(
"Write Volume Assembly Graphs",write_dot_files),
754 p.
sublist(
"Options").
get(
"Volume Assembly Graph Prefix",prefix));
759 writeInitialConditions(*thyra_me,physicsBlocks,wkstContainer,globalIndexer,linObjFactory,mesh,user_cm_factory,
761 p.
sublist(
"User Data"),workset_size);
763 m_physics_me = thyra_me;
766 template<
typename ScalarT>
773 itr!=cellAvgQuants.
end();++itr) {
774 const std::string & blockId = itr->first;
775 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
776 std::vector<std::string> tokens;
781 for(std::size_t i=0;i<tokens.size();i++)
790 itr != cellAvgVectors.
end(); ++itr) {
791 const std::string & blockId = itr->first;
792 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
793 std::vector<std::string> tokens;
798 for(std::size_t i = 0; i < tokens.size(); i++) {
799 std::string d_mod[3] = {
"X",
"Y",
"Z"};
808 itr!=cellQuants.
end();++itr) {
809 const std::string & blockId = itr->first;
810 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
811 std::vector<std::string> tokens;
816 for(std::size_t i=0;i<tokens.size();i++)
823 itr!=nodalQuants.
end();++itr) {
824 const std::string & blockId = itr->first;
825 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
826 std::vector<std::string> tokens;
831 for(std::size_t i=0;i<tokens.size();i++)
837 itr!=allocNodalQuants.
end();++itr) {
838 const std::string & blockId = itr->first;
839 const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
840 std::vector<std::string> tokens;
845 for(std::size_t i=0;i<tokens.size();i++)
850 template<
typename ScalarT>
860 bool write_dot_files,
const std::string & dot_file_prefix)
const
864 Thyra::ModelEvaluatorBase::InArgs<double> nomValues = model.getNominalValues();
867 if(initial_cond_pl.
get<
bool>(
"Zero Initial Conditions")) {
869 Thyra::assign(x_vec.
ptr(),0.0);
871 else if(!initial_cond_pl.
sublist(
"Vector File").
get<
bool>(
"Enabled")) {
874 std::map<std::string, Teuchos::RCP< PHX::FieldManager<panzer::Traits> > > phx_ic_field_managers;
885 phx_ic_field_managers);
901 tloc->set_x_th(x_vec);
906 const std::string & vectorFile = initial_cond_pl.
sublist(
"Vector File").
get<std::string>(
"File Name");
908 "If \"Read From Vector File\" is true, then parameter \"Vector File\" cannot be the empty string.");
913 tloc->set_x_th(x_vec);
920 template<
typename ScalarT>
931 int workset_size)
const
938 = initializeSolnWriterResponseLibrary(wc,ugi,lof,mesh);
942 user_data.
set<
int>(
"Workset Size",workset_size);
944 finalizeSolnWriterResponseLibrary(*solnWriter,physicsBlocks,cm_factory,closure_model_pl,workset_size,user_data);
951 ae_inargs.
alpha = 0.0;
952 ae_inargs.
beta = 1.0;
967 template<
typename ScalarT>
973 if (mesh_params.
get<std::string>(
"Source") ==
"Exodus File") {
974 mesh_factory =
Teuchos::rcp(
new panzer_stk::STK_ExodusReaderFactory());
977 else if (mesh_params.
get<std::string>(
"Source") ==
"Pamgen Mesh") {
978 mesh_factory =
Teuchos::rcp(
new panzer_stk::STK_PamgenReaderFactory());
981 else if (mesh_params.
get<std::string>(
"Source") ==
"Inline Mesh") {
983 int dimension = mesh_params.
sublist(
"Inline Mesh").
get<
int>(
"Mesh Dimension");
984 std::string typeStr =
"";
986 typeStr = mesh_params.
sublist(
"Inline Mesh").
get<std::string>(
"Type");
988 if (dimension == 1) {
991 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
994 else if (dimension == 2 && typeStr==
"Tri") {
997 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1000 else if (dimension == 2) {
1003 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1006 else if (dimension == 3 && typeStr==
"Tet") {
1009 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1012 else if(dimension == 3) {
1015 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1018 else if(dimension==4) {
1021 *in_mesh = mesh_params.
sublist(
"Inline Mesh").
sublist(
"Mesh Factory Parameter List");
1025 else if (mesh_params.
get<std::string>(
"Source") ==
"Custom Mesh") {
1035 if(mesh_params.
isSublist(
"Rebalance")) {
1039 bool enabled =
false;
1040 if(rebalance.
isType<
bool>(
"Enabled"))
1041 enabled = rebalance.
get<
bool>(
"Enabled");
1045 if(enabled && rebalance.
isSublist(
"Cycles"))
1052 return mesh_factory;
1055 template<
typename ScalarT>
1063 std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
1064 for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
1066 double blockWeight = 0.0;
1069 const std::vector<panzer::StrPureBasisPair> & blockFields = pb->
getProvidedDOFs();
1070 const std::vector<std::vector<std::string> > & coordinateDOFs = pb->
getCoordinateDOFs();
1074 std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp> fieldNames;
1075 fieldNames.insert(blockFields.begin(),blockFields.end());
1080 std::set<std::string> fields_to_remove;
1084 for(std::size_t i=0;i<coordinateDOFs.size();i++) {
1086 for(std::size_t j=0;j<coordinateDOFs[i].size();j++)
1087 fields_to_remove.insert(coordinateDOFs[i][j]);
1091 std::set<std::string>::const_iterator rmItr;
1092 for (rmItr=fields_to_remove.begin();rmItr!=fields_to_remove.end();++rmItr)
1097 std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp>::const_iterator fieldItr;
1098 for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
1100 if(fieldItr->second->isScalarBasis() &&
1104 else if(fieldItr->second->isScalarBasis()) {
1107 else if(fieldItr->second->isVectorBasis()) {
1108 std::string d_mod[3] = {
"X",
"Y",
"Z"};
1109 for(
int d=0;d<fieldItr->second->dimension();d++)
1114 blockWeight += double(fieldItr->second->cardinality());
1127 template<
typename ScalarT>
1131 "Objects are not built yet! Please call buildObjects() member function.");
1132 return m_physics_me;
1135 template<
typename ScalarT>
1138 m_nox_observer_factory = nox_observer_factory;
1141 template<
typename ScalarT>
1144 m_rythmos_observer_factory = rythmos_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>
1175 "Objects are not built yet! Please call buildObjects() member function.");
1177 "Objects are not built yet! Please call buildObjects() member function.");
1179 "Objects are not built yet! Please call buildObjects() member function.");
1181 =
is_null(in_nox_observer_factory) ? m_nox_observer_factory.ptr() : in_nox_observer_factory;
1183 =
is_null(in_rythmos_observer_factory) ? m_rythmos_observer_factory.ptr() : in_rythmos_observer_factory;
1190 std::string solver = solncntl_params.
get<std::string>(
"Piro Solver");
1192 = Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me);
1193 if ( (solver==
"NOX") || (solver ==
"LOCA") ) {
1196 "No NOX obersver built! Please call setNOXObserverFactory() member function if you plan to use a NOX solver.");
1199 piro_params->
sublist(
"NOX").
sublist(
"Solver Options").
set(
"User Defined Pre/Post Operator", ppo);
1202 piro =
Teuchos::rcp(
new Piro::NOXSolver<double>(piro_params,
1203 Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db)));
1204 else if (solver ==
"LOCA")
1205 piro =
Teuchos::rcp(
new Piro::LOCASolver<double>(piro_params,
1206 Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db),
1215 else if (solver==
"Rythmos") {
1218 "No NOX obersver built! Please call setrythmosObserverFactory() member function if you plan to use a Rythmos solver.");
1223 piro_params->
sublist(
"NOX").
sublist(
"Solver Options").
set(
"User Defined Pre/Post Operator", ppo);
1233 if(rythmosSolver==Teuchos::null)
1236 piro_rythmos = rythmosSolver;
1240 const std::string stepper_type = piro_params->
sublist(
"Rythmos").
get<std::string>(
"Stepper Type");
1241 if(stepper_type==
"Explicit RK" || stepper_type==
"Forward Euler") {
1243 bool lumpExplicitMass = assembly_params.
get<
bool>(
"Lump Explicit Mass");
1247 piro_rythmos->initialize(piro_params, rythmos_me, rythmos_observer_factory->
buildRythmosObserver(m_mesh,m_global_indexer,m_lin_obj_factory));
1249 piro = piro_rythmos;
1253 "Error: Unknown Piro Solver : " << solver);
1258 template<
typename ScalarT>
1262 "Objects are not built yet! Please call buildObjects() member function.");
1264 return m_response_library;
1267 template<
typename ScalarT>
1271 "Objects are not built yet! Please call buildObjects() member function.");
1273 return m_physics_blocks;
1276 template<
typename ScalarT>
1281 const std::vector<panzer::BC> & bcs,
1289 bool writeGraph,
const std::string & graphPrefix,
1290 bool write_field_managers,
const std::string & field_manager_prefix)
const
1295 fmb->
setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,lo_factory,user_data);
1302 if (write_field_managers){
1310 template<
typename ScalarT>
1318 bool is_transient,
bool is_explicit,
1329 std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
1334 std::map<std::string,std::string> block_ids_to_physics_ids;
1338 std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
1339 for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
1340 itr!=block_ids_to_physics_ids.end();++itr) {
1341 block_ids_to_cell_topo[itr->first] = m_mesh->getCellTopology(itr->first);
1342 TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
1345 std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.
get<
int>(
"Workset Size"));
1347 panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
1348 block_ids_to_cell_topo,
1349 physics_block_plist,
1350 assembly_params.
get<
int>(
"Default Integration Order"),
1363 bool write_dot_files =
false;
1364 std::string prefix =
"Cloned_";
1366 std::vector<panzer::BC> bcs;
1367 if(bc_list==Teuchos::null) {
1368 panzer::buildBCs(bcs, p.
sublist(
"Boundary Conditions"), m_global_data);
1371 panzer::buildBCs(bcs, *bc_list, m_global_data);
1374 fmb = buildFieldManagerBuilder(
1387 write_dot_files,prefix,
1388 write_dot_files,prefix);
1394 m_lin_obj_factory));
1402 Thyra::ModelEvaluatorBase::InArgs<ScalarT> nomVals = physics_me->getNominalValues();
1407 bool useThyra =
true;
1408 if(ep_thyra_me!=Teuchos::null)
1412 std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names(physics_me->Np());
1413 std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values(physics_me->Np());
1414 for(std::size_t i=0;i<p_names.size();i++) {
1420 = buildPhysicsModelEvaluator(useThyra,
1432 thyra_me->getNominalValues() = nomVals;
1437 bool lumpExplicitMass = assembly_params.
get<
bool>(
"Lump Explicit Mass");
1445 template<
typename ScalarT>
1456 bool is_transient,
double t_init)
const
1467 thyra_me = Thyra::epetraModelEvaluator(ep_me,solverFactory);
1471 (fmb,rLibrary,lof,p_names,p_values,solverFactory,global_data,is_transient,t_init));
1477 template<
typename ScalarT>
1484 Teuchos::setStringToIntegralParameter<int>(
1487 "Set the start time",
1488 Teuchos::tuple<std::string>(
"From Input File",
"From Exodus File"),
1492 validPL.
set<
double>(
"Start Time",0.0);
1497 std::string t_init_type = p.
get<std::string>(
"Start Time Type");
1498 double t_init = 10.0;
1500 if (t_init_type ==
"From Input File")
1501 t_init = p.
get<
double>(
"Start Time");
1503 if (t_init_type ==
"From Exodus File")
1511 template<
typename ScalarT>
1521 std::vector<std::string> eBlocks;
1525 builder.
mesh = mesh;
1526 stkIOResponseLibrary->addResponse(
"Main Field Output",eBlocks,builder);
1528 return stkIOResponseLibrary;
1531 template<
typename ScalarT>
1539 user_data.
set<
int>(
"Workset Size",workset_size);
1543 template<
typename ScalarT>
1550 #ifdef PANZER_HAVE_TEKO
1561 sublist(
"Newton").
sublist(
"Stratimikos Linear Solver").
sublist(
"Stratimikos")));
1563 bool writeCoordinates =
false;
1565 writeCoordinates = p.
sublist(
"Options").
get<
bool>(
"Write Coordinates");
1567 bool writeTopo =
false;
1569 writeTopo = p.
sublist(
"Options").
get<
bool>(
"Write Topology");
1573 blockedAssembly,globalIndexer,conn_manager,
1574 Teuchos::as<int>(mesh->
getDimension()), mpi_comm, strat_params,
1575 #ifdef PANZER_HAVE_TEKO
1583 template<
typename ScalarT>
1586 const bool write_graphviz_file,
1587 const std::string& graphviz_file_prefix)
1599 if(thyra_me!=Teuchos::null && panzer_me==Teuchos::null) {
1602 thyra_me->uninitialize(&const_ep_me,&solveFactory);
1608 ep_panzer_me->
buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1611 thyra_me->initialize(ep_me,solveFactory);
1615 else if(panzer_me!=Teuchos::null && thyra_me==Teuchos::null) {
1616 panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< double > > buildLOWSFactory(bool blockedAssembly, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &globalIndexer, const Teuchos::RCP< panzer::ConnManagerBase< int > > &conn_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::UniqueGlobalIndexerBase > &auxGlobalIndexer, bool useCoordinates)
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::UniqueGlobalIndexerBase > &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.
const std::string & name() 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 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()
Teuchos::RCP< panzer::ParamLib > pl
Sacado scalar parameter library.
ParameterList & disableRecursiveValidation()
virtual Teuchos::RCP< Rythmos::IntegrationObserverBase< double > > buildRythmosObserver(const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &dof_manager, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof) const =0
void setGlobalIndexer(const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &ugi)
void getElementBlockNames(std::vector< std::string > &names) const
void setUseDOFManagerFEI(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
#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
Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< double > > buildLOWSFactory(bool blockedAssembly, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &globalIndexer, const Teuchos::RCP< panzer::ConnManagerBase< int > > &conn_manager, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const Teuchos::MpiComm< int > > &mpi_comm) 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)
void setUseTieBreak(bool flag)
Teuchos::RCP< panzer::LinearObjContainer > ghostedContainer_
Teuchos::RCP< panzer_stk::STK_Interface > mesh
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
virtual Teuchos::RCP< panzer::UniqueGlobalIndexer< LO, GO > > buildUniqueGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager< LO, GO > > &connMngr, const std::string &fieldOrder="") 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
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
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< panzer::ResponseLibrary< panzer::Traits > > initializeSolnWriterResponseLibrary(const Teuchos::RCP< panzer::WorksetContainer > &wc, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &ugi, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh) const
void setUseDOFManagerFEI(bool flag)
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)
std::string printUGILoadBalancingInformation(const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi)
ConstIterator begin() const
int getOutputToRootOnly() const
void setBlockWeight(const std::string &blockId, double weight)
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.
virtual Teuchos::RCP< panzer::UniqueGlobalIndexer< LO, std::pair< int, GO > > > buildUniqueGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager< LO, GO > > &connMngr, const std::string &fieldOrder="") const
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 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.
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)
#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)
virtual Teuchos::RCP< NOX::Abstract::PrePostOperator > buildNOXObserver(const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &dof_manager, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof) const =0
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.
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
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