Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STK_ModelEvaluatorFactory_impl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef PANZER_STK_MODEL_EVALUATOR_FACTORY_T_HPP
12 #define PANZER_STK_MODEL_EVALUATOR_FACTORY_T_HPP
13 
14 #include "Thyra_ModelEvaluator.hpp"
15 #include "Teuchos_Assert.hpp"
16 #include "Teuchos_as.hpp"
18 #include "Teuchos_AbstractFactoryStd.hpp"
19 
20 #include "PanzerAdaptersSTK_config.hpp"
21 #include "Panzer_Traits.hpp"
22 #include "Panzer_GlobalData.hpp"
23 #include "Panzer_BC.hpp"
25 #include "Panzer_BasisIRLayout.hpp"
26 #include "Panzer_DOFManager.hpp"
31 #include "Panzer_TpetraLinearObjFactory.hpp"
42 
43 #include "Panzer_STK_Interface.hpp"
53 #include "Panzer_STK_Utilities.hpp"
57 #ifdef PANZER_HAVE_TEMPUS
59 #endif
65 
66 #include <vector>
67 #include <iostream>
68 #include <fstream>
69 #include <cstdlib> // for std::getenv
70 
71 // Piro solver objects
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"
77 #endif
78 
79 #ifdef PANZER_HAVE_EPETRA_STACK
81 #include "Thyra_EpetraModelEvaluator.hpp"
84 #endif
85 
86 #include <Panzer_NodeType.hpp>
87 
88 namespace panzer_stk {
89 
90  template<typename ScalarT>
92  {
93  paramList->validateParametersAndSetDefaults(*this->getValidParameters());
94 
95  // add in some addtional defaults that are hard to validate externally (this is because of the "disableRecursiveValidation" calls)
96 
97  if(!paramList->sublist("Initial Conditions").isType<bool>("Zero Initial Conditions"))
98  paramList->sublist("Initial Conditions").set<bool>("Zero Initial Conditions",false);
99 
100  paramList->sublist("Initial Conditions").sublist("Vector File").validateParametersAndSetDefaults(
101  getValidParameters()->sublist("Initial Conditions").sublist("Vector File"));
102 
103  this->setMyParamList(paramList);
104  }
105 
106  template<typename ScalarT>
108  {
109  m_stratimikos_params = paramList;
110  }
111 
112  template<typename ScalarT>
114  {
116  if (is_null(validPL)) {
118 
119  pl->sublist("Physics Blocks").disableRecursiveValidation();
120  pl->sublist("Closure Models").disableRecursiveValidation();
121  pl->sublist("Boundary Conditions").disableRecursiveValidation();
122  pl->sublist("Solution Control").disableRecursiveValidation();
123  pl->set<bool>("Use Discrete Adjoint",false);
124 
125  pl->sublist("Mesh").disableRecursiveValidation();
126 
127  pl->sublist("Initial Conditions").set<bool>("Zero Initial Conditions",false);
128  pl->sublist("Initial Conditions").sublist("Transient Parameters").disableRecursiveValidation();
129  pl->sublist("Initial Conditions").sublist("Vector File");
130  pl->sublist("Initial Conditions").sublist("Vector File").set("File Name","");
131  pl->sublist("Initial Conditions").sublist("Vector File").set<bool>("Enabled",false);
132  pl->sublist("Initial Conditions").disableRecursiveValidation();
133 
134  pl->sublist("Output").set("File Name","panzer.exo");
135  pl->sublist("Output").set("Write to Exodus",true);
136  pl->sublist("Output").sublist("Cell Average Quantities").disableRecursiveValidation();
137  pl->sublist("Output").sublist("Cell Quantities").disableRecursiveValidation();
138  pl->sublist("Output").sublist("Cell Average Vectors").disableRecursiveValidation();
139  pl->sublist("Output").sublist("Nodal Quantities").disableRecursiveValidation();
140  pl->sublist("Output").sublist("Allocate Nodal Quantities").disableRecursiveValidation();
141 
142  // Assembly sublist
143  {
144  Teuchos::ParameterList& p = pl->sublist("Assembly");
145  p.set<int>("Workset Size", 1);
146  p.set<int>("Default Integration Order",-1);
147  p.set<std::string>("Field Order","");
148  p.set<std::string>("Auxiliary Field Order","");
149  p.set<bool>("Use DOFManager FEI",false);
150  p.set<bool>("Load Balance DOFs",false);
151  p.set<bool>("Use Tpetra",false);
152  p.set<bool>("Use Epetra ME",true);
153  p.set<bool>("Lump Explicit Mass",false);
154  p.set<bool>("Constant Mass Matrix",true);
155  p.set<bool>("Apply Mass Matrix Inverse in Explicit Evaluator",true);
156  p.set<bool>("Use Conservative IMEX",false);
157  p.set<bool>("Compute Real Time Derivative",false);
158  p.set<bool>("Use Time Derivative in Explicit Model",false);
159  p.set<bool>("Compute Time Derivative at Time Step",false);
160  p.set<Teuchos::RCP<const panzer::EquationSetFactory> >("Equation Set Factory", Teuchos::null);
161  p.set<Teuchos::RCP<const panzer::ClosureModelFactory_TemplateManager<panzer::Traits> > >("Closure Model Factory", Teuchos::null);
162  p.set<Teuchos::RCP<const panzer::BCStrategyFactory> >("BC Factory",Teuchos::null);
163  p.set<std::string>("Excluded Blocks","");
165  }
166 
167  pl->sublist("Block ID to Physics ID Mapping").disableRecursiveValidation();
168  pl->sublist("Options").disableRecursiveValidation();
169  pl->sublist("Active Parameters").disableRecursiveValidation();
170  pl->sublist("Controls").disableRecursiveValidation();
171  pl->sublist("ALE").disableRecursiveValidation(); // this sucks
172  pl->sublist("User Data").disableRecursiveValidation();
173  pl->sublist("User Data").sublist("Panzer Data").disableRecursiveValidation();
174 
175  validPL = pl;
176  }
177  return validPL;
178  }
179 
180  namespace {
181  bool hasInterfaceCondition(const std::vector<panzer::BC>& bcs)
182  {
183  for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
184  if (bcit->bcType() == panzer::BCT_Interface)
185  return true;
186  return false;
187  }
188 
190  getSTKConnManager(const Teuchos::RCP<panzer::ConnManager>& conn_mgr)
191  {
192  const Teuchos::RCP<STKConnManager> stk_conn_mgr =
193  Teuchos::rcp_dynamic_cast<STKConnManager>(conn_mgr);
194  TEUCHOS_TEST_FOR_EXCEPTION(stk_conn_mgr.is_null(), std::logic_error,
195  "There are interface conditions, but the connection manager"
196  " does not support the necessary connections.");
197  return stk_conn_mgr;
198  }
199 
200  void buildInterfaceConnections(const std::vector<panzer::BC>& bcs,
201  const Teuchos::RCP<panzer::ConnManager>& conn_mgr)
202  {
203  const Teuchos::RCP<STKConnManager> stk_conn_mgr = getSTKConnManager(conn_mgr);
204  for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
205  if (bcit->bcType() == panzer::BCT_Interface)
206  stk_conn_mgr->associateElementsInSideset(bcit->sidesetID());
207  }
208 
209  void checkInterfaceConnections(const Teuchos::RCP<panzer::ConnManager>& conn_mgr,
210  const Teuchos::RCP<Teuchos::Comm<int> >& comm)
211  {
212  const Teuchos::RCP<STKConnManager> stk_conn_mgr = getSTKConnManager(conn_mgr);
213  std::vector<std::string> sidesets = stk_conn_mgr->checkAssociateElementsInSidesets(*comm);
214  if ( ! sidesets.empty()) {
215  std::stringstream ss;
216  ss << "Sideset IDs";
217  for (std::size_t i = 0; i < sidesets.size(); ++i)
218  ss << " " << sidesets[i];
219  ss << " did not yield associations, but these sidesets correspond to BCT_Interface BCs.";
220  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, ss.str());
221  }
222  }
223  } // namespace
224 
225  template<typename ScalarT>
227  const Teuchos::RCP<panzer::GlobalData>& global_data,
229  const panzer::BCStrategyFactory & bc_factory,
231  bool meConstructionOn)
232  {
233  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(this->getParameterList()), std::runtime_error,
234  "ParameterList must be set before objects can be built!");
235 
236  TEUCHOS_ASSERT(nonnull(comm));
237  TEUCHOS_ASSERT(nonnull(global_data));
238  TEUCHOS_ASSERT(nonnull(global_data->os));
239  TEUCHOS_ASSERT(nonnull(global_data->pl));
240 
241  // begin at the beginning...
242  m_global_data = global_data;
243 
246  // Parse input file, setup parameters
249 
250  // this function will need to be broken up eventually and probably
251  // have parts moved back into panzer. Just need to get something
252  // running.
253 
254  Teuchos::ParameterList& p = *this->getNonconstParameterList();
255 
256  // "parse" parameter list
257  Teuchos::ParameterList & mesh_params = p.sublist("Mesh");
258  Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
259  Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
260  Teuchos::ParameterList & output_list = p.sublist("Output");
261 
262  Teuchos::ParameterList & user_data_params = p.sublist("User Data");
263  Teuchos::ParameterList & panzer_data_params = user_data_params.sublist("Panzer Data");
264 
265  Teuchos::RCP<Teuchos::ParameterList> physics_block_plist = Teuchos::sublist(this->getMyNonconstParamList(),"Physics Blocks");
266 
267  // extract assembly information
268  std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.get<int>("Workset Size"));
269  std::string field_order = assembly_params.get<std::string>("Field Order"); // control nodal ordering of unknown
270  // global IDs in linear system
271  bool use_dofmanager_fei = assembly_params.get<bool>("Use DOFManager FEI"); // use FEI if true, otherwise use internal dof manager
272  bool use_load_balance = assembly_params.get<bool>("Load Balance DOFs");
273  bool useTpetra = assembly_params.get<bool>("Use Tpetra");
274  bool useThyraME = !assembly_params.get<bool>("Use Epetra ME");
275 
276  // this is weird...we are accessing the solution control to determine if things are transient
277  // it is backwards!
278  bool is_transient = (solncntl_params.get<std::string>("Piro Solver") == "Tempus") ? true : false;
279  // for pseudo-transient, we need to enable transient solver support to get time derivatives into fill
280  if (solncntl_params.get<std::string>("Piro Solver") == "NOX") {
281  if (solncntl_params.sublist("NOX").get<std::string>("Nonlinear Solver") == "Pseudo-Transient")
282  is_transient = true;
283  }
284  // for eigenvalues, we need to enable transient solver support to
285  // get time derivatives into generalized eigenvale problem
286  if (solncntl_params.get<std::string>("Piro Solver") == "LOCA") {
287  if (solncntl_params.sublist("LOCA").sublist("Stepper").get<bool>("Compute Eigenvalues"))
288  is_transient = true;
289  }
290  m_is_transient = is_transient;
291 
292  useDiscreteAdjoint = p.get<bool>("Use Discrete Adjoint");
293 
296  // Do stuff
299 
300  Teuchos::FancyOStream& fout = *global_data->os;
301 
302  // for convience cast to an MPI comm
304  Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >(comm);
305 
306  // Build mesh factory and uncommitted mesh
308 
309  Teuchos::RCP<panzer_stk::STK_MeshFactory> mesh_factory = this->buildSTKMeshFactory(mesh_params);
310  Teuchos::RCP<panzer_stk::STK_Interface> mesh = mesh_factory->buildUncommitedMesh(*(mpi_comm->getRawMpiComm()));
311  m_mesh = mesh;
312 
313  m_eqset_factory = eqset_factory;
314 
315  // setup the physcs blocks
317 
318  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
319  {
320  // setup physical mappings and boundary conditions
321  std::map<std::string,std::string> block_ids_to_physics_ids;
322  panzer::buildBlockIdToPhysicsIdMap(block_ids_to_physics_ids, p.sublist("Block ID to Physics ID Mapping"));
323 
324  // build cell ( block id -> cell topology ) mapping
325  std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
326  for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
327  itr!=block_ids_to_physics_ids.end();++itr) {
328  block_ids_to_cell_topo[itr->first] = mesh->getCellTopology(itr->first);
329  TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
330  }
331 
332  // build physics blocks
333 
334  panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
335  block_ids_to_cell_topo,
336  physics_block_plist,
337  assembly_params.get<int>("Default Integration Order"),
338  workset_size,
339  eqset_factory,
340  global_data,
341  is_transient,
342  physicsBlocks);
343  m_physics_blocks = physicsBlocks; // hold onto physics blocks for safe keeping
344  }
345 
346  // add fields automatically written through the closure model
348  addUserFieldsToMesh(*mesh,output_list);
349 
350  // finish building mesh, set required field variables and mesh bulk data
352 
353  try {
354  // this throws some exceptions, catch them as neccessary
355  this->finalizeMeshConstruction(*mesh_factory,physicsBlocks,*mpi_comm,*mesh);
356  } catch(const panzer_stk::STK_Interface::ElementBlockException & ebexp) {
357  fout << "*****************************************\n\n";
358  fout << "Element block exception, could not finalize the mesh, printing block and sideset information:\n";
359  fout.pushTab(3);
360  mesh->printMetaData(fout);
361  fout.popTab();
362  fout << std::endl;
363 
364  throw ebexp;
365  } catch(const panzer_stk::STK_Interface::SidesetException & ssexp) {
366  fout << "*****************************************\n\n";
367  fout << "Sideset exception, could not finalize the mesh, printing block and sideset information:\n";
368  fout.pushTab(3);
369  mesh->printMetaData(fout);
370  fout.popTab();
371  fout << std::endl;
372 
373  throw ssexp;
374  }
375 
376  mesh->print(fout);
377  if(p.sublist("Output").get<bool>("Write to Exodus"))
378  mesh->setupExodusFile(p.sublist("Output").get<std::string>("File Name"));
379 
380  // build a workset factory that depends on STK
383  if(m_user_wkst_factory==Teuchos::null)
384  wkstFactory = Teuchos::rcp(new panzer_stk::WorksetFactory()); // build STK workset factory
385  else
386  wkstFactory = m_user_wkst_factory;
387 
388  // set workset factory mesh
389  wkstFactory->setMesh(mesh);
390 
391  // handle boundary and interface conditions
393  std::vector<panzer::BC> bcs;
394  panzer::buildBCs(bcs, p.sublist("Boundary Conditions"), global_data);
395 
396  // build the connection manager
399  m_conn_manager = conn_manager;
400 
401  // build DOF Manager
403 
406 
407  std::string loadBalanceString = ""; // what is the load balancing information
408  bool blockedAssembly = false;
409 
410  const bool has_interface_condition = hasInterfaceCondition(bcs);
411 
412  if(panzer::BlockedDOFManagerFactory::requiresBlocking(field_order) && !useTpetra) {
413 
414 #ifdef PANZER_HAVE_EPETRA_STACK
415  // Can't yet handle interface conditions for this system
416  TEUCHOS_TEST_FOR_EXCEPTION(has_interface_condition,
418  "ERROR: Blocked Epetra systems cannot handle interface conditions.");
419 
420  // use a blocked DOF manager
421  blockedAssembly = true;
422 
423  panzer::BlockedDOFManagerFactory globalIndexerFactory;
424  globalIndexerFactory.setUseDOFManagerFEI(use_dofmanager_fei);
425 
427  = globalIndexerFactory.buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
428  globalIndexer = dofManager;
429 
432  Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager>(dofManager)));
433 
434  // parse any explicitly excluded pairs or blocks
435  const std::string excludedBlocks = assembly_params.get<std::string>("Excluded Blocks");
436  std::vector<std::string> stringPairs;
437  panzer::StringTokenizer(stringPairs,excludedBlocks,";",true);
438  for(std::size_t i=0;i<stringPairs.size();i++) {
439  std::vector<std::string> sPair;
440  std::vector<int> iPair;
441  panzer::StringTokenizer(sPair,stringPairs[i],",",true);
442  panzer::TokensToInts(iPair,sPair);
443 
444  TEUCHOS_TEST_FOR_EXCEPTION(iPair.size()!=2,std::logic_error,
445  "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
446  " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
447  "Failure on string pair " << stringPairs[i] << "!");
448 
449  bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
450  }
451 
452  linObjFactory = bloLinObjFactory;
453 
454  // build load balancing string for informative output
455  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
456 #else
457  TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: buildObjects() - Epetra support is NOT enabled in this build!");
458 #endif
459  }
460  else if(panzer::BlockedDOFManagerFactory::requiresBlocking(field_order) && useTpetra) {
461 
462  // Can't yet handle interface conditions for this system
463  TEUCHOS_TEST_FOR_EXCEPTION(has_interface_condition,
465  "ERROR: Blocked Tpetra system cannot handle interface conditions.");
466 
467  // use a blocked DOF manager
468  blockedAssembly = true;
469 
470  TEUCHOS_ASSERT(!use_dofmanager_fei);
471  panzer::BlockedDOFManagerFactory globalIndexerFactory;
472  globalIndexerFactory.setUseDOFManagerFEI(false);
473 
475  = globalIndexerFactory.buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
476  globalIndexer = dofManager;
477 
480  Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager>(dofManager)));
481 
482  // parse any explicitly excluded pairs or blocks
483  const std::string excludedBlocks = assembly_params.get<std::string>("Excluded Blocks");
484  std::vector<std::string> stringPairs;
485  panzer::StringTokenizer(stringPairs,excludedBlocks,";",true);
486  for(std::size_t i=0;i<stringPairs.size();i++) {
487  std::vector<std::string> sPair;
488  std::vector<int> iPair;
489  panzer::StringTokenizer(sPair,stringPairs[i],",",true);
490  panzer::TokensToInts(iPair,sPair);
491 
492  TEUCHOS_TEST_FOR_EXCEPTION(iPair.size()!=2,std::logic_error,
493  "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
494  " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
495  "Failure on string pair " << stringPairs[i] << "!");
496 
497  bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
498  }
499 
500  linObjFactory = bloLinObjFactory;
501 
502  // build load balancing string for informative output
503  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
504  }
505  else if(useTpetra) {
506 
507  if (has_interface_condition)
508  buildInterfaceConnections(bcs, conn_manager);
509 
510  // use a flat DOF manager
511 
512  TEUCHOS_ASSERT(!use_dofmanager_fei);
513  panzer::DOFManagerFactory globalIndexerFactory;
514  globalIndexerFactory.setUseDOFManagerFEI(false);
515  globalIndexerFactory.setUseTieBreak(use_load_balance);
517  = globalIndexerFactory.buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,field_order);
518  globalIndexer = dofManager;
519 
520  if (has_interface_condition)
521  checkInterfaceConnections(conn_manager, dofManager->getComm());
522 
523  TEUCHOS_ASSERT(!useDiscreteAdjoint); // safety check
525 
526  // build load balancing string for informative output
527  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
528  }
529  else {
530 
531 #ifdef PANZER_HAVE_EPETRA_STACK
532  if (has_interface_condition)
533  buildInterfaceConnections(bcs, conn_manager);
534 
535  // use a flat DOF manager
536  panzer::DOFManagerFactory globalIndexerFactory;
537  globalIndexerFactory.setUseDOFManagerFEI(use_dofmanager_fei);
538  globalIndexerFactory.setUseTieBreak(use_load_balance);
539  globalIndexerFactory.setUseNeighbors(has_interface_condition);
541  = globalIndexerFactory.buildGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager,
542  field_order);
543  globalIndexer = dofManager;
544 
545  if (has_interface_condition)
546  checkInterfaceConnections(conn_manager, dofManager->getComm());
547 
548  linObjFactory = Teuchos::rcp(new panzer::BlockedEpetraLinearObjFactory<panzer::Traits,int>(mpi_comm,dofManager,useDiscreteAdjoint));
549 
550  // build load balancing string for informative output
551  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
552 #else
553  TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: buildObjects() - Epetra support is NOT enabled in this build!");
554 #endif
555  }
556 
557  TEUCHOS_ASSERT(globalIndexer!=Teuchos::null);
558  TEUCHOS_ASSERT(linObjFactory!=Teuchos::null);
559  m_global_indexer = globalIndexer;
560  m_lin_obj_factory = linObjFactory;
561  m_blockedAssembly = blockedAssembly;
562 
563  // print out load balancing information
564  fout << "Degree of freedom load balancing: " << loadBalanceString << std::endl;
565 
566  // build worksets
568 
569  // build up needs array for workset container
570  std::map<std::string,panzer::WorksetNeeds> needs;
571  for(std::size_t i=0;i<physicsBlocks.size();i++)
572  needs[physicsBlocks[i]->elementBlockID()] = physicsBlocks[i]->getWorksetNeeds();
573 
574  Teuchos::RCP<panzer::WorksetContainer> wkstContainer // attach it to a workset container (uses lazy evaluation)
575  = Teuchos::rcp(new panzer::WorksetContainer(wkstFactory,needs));
576 
577  wkstContainer->setWorksetSize(workset_size);
578  wkstContainer->setGlobalIndexer(globalIndexer); // set the global indexer so the orientations are evaluated
579 
580  m_wkstContainer = wkstContainer;
581 
582  // find max number of worksets
583  std::size_t max_wksets = 0;
584  for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
585  const panzer::WorksetDescriptor wd = panzer::blockDescriptor(physicsBlocks[pb]->elementBlockID());
586  Teuchos::RCP< std::vector<panzer::Workset> >works = wkstContainer->getWorksets(wd);
587  max_wksets = std::max(max_wksets,works->size());
588  }
589  user_data_params.set<std::size_t>("Max Worksets",max_wksets);
590  wkstContainer->clear();
591 
592  // Setup lagrangian type coordinates
594 
595  // see if field coordinates are required, if so reset the workset container
596  // and set the coordinates to be associated with a field in the mesh
597  useDynamicCoordinates_ = false;
598  for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
599  if(physicsBlocks[pb]->getCoordinateDOFs().size()>0) {
600  mesh->setUseFieldCoordinates(true);
601  useDynamicCoordinates_ = true;
602  wkstContainer->clear(); // this serves to refresh the worksets
603  // and put in new coordinates
604  break;
605  }
606  }
607 
608  // Add mesh objects to user data to make available to user ctors
610 
611  panzer_data_params.set("STK Mesh", mesh);
612  panzer_data_params.set("DOF Manager", globalIndexer);
613  panzer_data_params.set("Linear Object Factory", linObjFactory);
614 
615  // If user requested it, short circuit model construction
617 
618  if(!meConstructionOn)
619  return;
620 
621  // Setup active parameters
623 
624  std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names;
625  std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values;
626  if (p.isSublist("Active Parameters")) {
627  Teuchos::ParameterList& active_params = p.sublist("Active Parameters");
628 
629  int num_param_vecs = active_params.get<int>("Number of Parameter Vectors",0);
630  p_names.resize(num_param_vecs);
631  p_values.resize(num_param_vecs);
632  for (int i=0; i<num_param_vecs; i++) {
633  std::stringstream ss;
634  ss << "Parameter Vector " << i;
635  Teuchos::ParameterList& pList = active_params.sublist(ss.str());
636  int numParameters = pList.get<int>("Number");
637  TEUCHOS_TEST_FOR_EXCEPTION(numParameters == 0,
639  std::endl << "Error! panzer::ModelEvaluator::ModelEvaluator(): " <<
640  "Parameter vector " << i << " has zero parameters!" << std::endl);
641  p_names[i] =
642  Teuchos::rcp(new Teuchos::Array<std::string>(numParameters));
643  p_values[i] =
644  Teuchos::rcp(new Teuchos::Array<double>(numParameters));
645  for (int j=0; j<numParameters; j++) {
646  std::stringstream ss2;
647  ss2 << "Parameter " << j;
648  (*p_names[i])[j] = pList.get<std::string>(ss2.str());
649  ss2.str("");
650 
651  ss2 << "Initial Value " << j;
652  (*p_values[i])[j] = pList.get<double>(ss2.str());
653 
654  // this is a band-aid/hack to make sure parameters are registered before they are accessed
655  panzer::registerScalarParameter((*p_names[i])[j],*global_data->pl,(*p_values[i])[j]);
656  }
657  }
658  }
659 
660  // setup the closure model for automatic writing (during residual/jacobian update)
662 
663  panzer_stk::IOClosureModelFactory_TemplateBuilder<panzer::Traits> io_cm_builder(user_cm_factory,mesh,output_list);
665  cm_factory.buildObjects(io_cm_builder);
666 
667  // setup field manager build
669 
671  {
672  bool write_dot_files = p.sublist("Options").get("Write Volume Assembly Graphs",false);
673  std::string dot_file_prefix = p.sublist("Options").get("Volume Assembly Graph Prefix","Panzer_AssemblyGraph");
674  bool write_fm_files = p.sublist("Options").get("Write Field Manager Files",false);
675  std::string fm_file_prefix = p.sublist("Options").get("Field Manager File Prefix","Panzer_AssemblyGraph");
676 
677  // Allow users to override inputs via runtime env
678  {
679  auto check_write_dag = std::getenv("PANZER_WRITE_DAG");
680  if (check_write_dag != nullptr) {
681  write_dot_files = true;
682  write_fm_files = true;
683  }
684  }
685 
686  fmb = buildFieldManagerBuilder(wkstContainer,physicsBlocks,bcs,*eqset_factory,bc_factory,cm_factory,
687  user_cm_factory,p.sublist("Closure Models"),*linObjFactory,user_data_params,
688  write_dot_files,dot_file_prefix,
689  write_fm_files,fm_file_prefix);
690  }
691 
692  // build response library
694 
695  m_response_library = Teuchos::rcp(new panzer::ResponseLibrary<panzer::Traits>(wkstContainer,globalIndexer,linObjFactory));
696 
697  {
698  bool write_dot_files = false;
699  std::string prefix = "Panzer_ResponseGraph_";
700  write_dot_files = p.sublist("Options").get("Write Volume Response Graphs",write_dot_files);
701  prefix = p.sublist("Options").get("Volume Response Graph Prefix",prefix);
702 
703  Teuchos::ParameterList user_data(p.sublist("User Data"));
704  user_data.set<int>("Workset Size",workset_size);
705  }
706 
707  // Setup solver factory
709 
711  buildLOWSFactory(blockedAssembly,globalIndexer,conn_manager,mesh,mpi_comm);
712 
713  // Setup physics model evaluator
715 
716  double t_init = 0.0;
717  if(is_transient)
718  t_init = this->getInitialTime(p.sublist("Initial Conditions").sublist("Transient Parameters"), *mesh);
719 
720  if(blockedAssembly || useTpetra) // override the user request
721  useThyraME = true;
722 
724  = buildPhysicsModelEvaluator(useThyraME, // blockedAssembly || useTpetra, // this determines if a Thyra or Epetra ME is used
725  fmb,
726  m_response_library,
727  linObjFactory,
728  p_names,
729  p_values,
730  lowsFactory,
731  global_data,
732  is_transient,
733  t_init);
734 
735  // Setup initial conditions
737 
738  {
739  // Create closure model list for use in defining initial conditions
740  // For now just remove Global MMS Parameters, if it exists
741  const Teuchos::ParameterList& models = p.sublist("Closure Models");
742  Teuchos::ParameterList cl_models(models.name());
743  for (Teuchos::ParameterList::ConstIterator model_it=models.begin();
744  model_it!=models.end(); ++model_it) {
745  std::string key = model_it->first;
746  if (model_it->first != "Global MMS Parameters")
747  cl_models.setEntry(key,model_it->second);
748  }
749  bool write_dot_files = false;
750  std::string prefix = "Panzer_AssemblyGraph_";
751  setupInitialConditions(*thyra_me,*wkstContainer,physicsBlocks,user_cm_factory,*linObjFactory,
752  cl_models,
753  p.sublist("Initial Conditions"),
754  p.sublist("User Data"),
755  p.sublist("Options").get("Write Volume Assembly Graphs",write_dot_files),
756  p.sublist("Options").get("Volume Assembly Graph Prefix",prefix));
757  }
758 
759  // Write the IC vector into the STK mesh: use response library
761  writeInitialConditions(*thyra_me,physicsBlocks,wkstContainer,globalIndexer,linObjFactory,mesh,user_cm_factory,
762  p.sublist("Closure Models"),
763  p.sublist("User Data"),workset_size);
764 
765  m_physics_me = thyra_me;
766  }
767 
768  template<typename ScalarT>
771  {
772  // register cell averaged scalar fields
773  const Teuchos::ParameterList & cellAvgQuants = output_list.sublist("Cell Average Quantities");
774  for(Teuchos::ParameterList::ConstIterator itr=cellAvgQuants.begin();
775  itr!=cellAvgQuants.end();++itr) {
776  const std::string & blockId = itr->first;
777  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
778  std::vector<std::string> tokens;
779 
780  // break up comma seperated fields
781  panzer::StringTokenizer(tokens,fields,",",true);
782 
783  for(std::size_t i=0;i<tokens.size();i++)
784  mesh.addCellField(tokens[i],blockId);
785  }
786 
787  // register cell averaged components of vector fields
788  // just allocate space for the fields here. The actual calculation and writing
789  // are done by panzer_stk::ScatterCellAvgVector.
790  const Teuchos::ParameterList & cellAvgVectors = output_list.sublist("Cell Average Vectors");
791  for(Teuchos::ParameterList::ConstIterator itr = cellAvgVectors.begin();
792  itr != cellAvgVectors.end(); ++itr) {
793  const std::string & blockId = itr->first;
794  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
795  std::vector<std::string> tokens;
796 
797  // break up comma seperated fields
798  panzer::StringTokenizer(tokens,fields,",",true);
799 
800  for(std::size_t i = 0; i < tokens.size(); i++) {
801  std::string d_mod[3] = {"X","Y","Z"};
802  for(std::size_t d = 0; d < mesh.getDimension(); d++)
803  mesh.addCellField(tokens[i]+d_mod[d],blockId);
804  }
805  }
806 
807  // register cell quantities
808  const Teuchos::ParameterList & cellQuants = output_list.sublist("Cell Quantities");
809  for(Teuchos::ParameterList::ConstIterator itr=cellQuants.begin();
810  itr!=cellQuants.end();++itr) {
811  const std::string & blockId = itr->first;
812  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
813  std::vector<std::string> tokens;
814 
815  // break up comma seperated fields
816  panzer::StringTokenizer(tokens,fields,",",true);
817 
818  for(std::size_t i=0;i<tokens.size();i++)
819  mesh.addCellField(tokens[i],blockId);
820  }
821 
822  // register ndoal quantities
823  const Teuchos::ParameterList & nodalQuants = output_list.sublist("Nodal Quantities");
824  for(Teuchos::ParameterList::ConstIterator itr=nodalQuants.begin();
825  itr!=nodalQuants.end();++itr) {
826  const std::string & blockId = itr->first;
827  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
828  std::vector<std::string> tokens;
829 
830  // break up comma seperated fields
831  panzer::StringTokenizer(tokens,fields,",",true);
832 
833  for(std::size_t i=0;i<tokens.size();i++)
834  mesh.addSolutionField(tokens[i],blockId);
835  }
836 
837  const Teuchos::ParameterList & allocNodalQuants = output_list.sublist("Allocate Nodal Quantities");
838  for(Teuchos::ParameterList::ConstIterator itr=allocNodalQuants.begin();
839  itr!=allocNodalQuants.end();++itr) {
840  const std::string & blockId = itr->first;
841  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
842  std::vector<std::string> tokens;
843 
844  // break up comma seperated fields
845  panzer::StringTokenizer(tokens,fields,",",true);
846 
847  for(std::size_t i=0;i<tokens.size();i++)
848  mesh.addSolutionField(tokens[i],blockId);
849  }
850  }
851 
852  template<typename ScalarT>
855  panzer::WorksetContainer & wkstContainer,
856  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
859  const Teuchos::ParameterList & closure_pl,
860  const Teuchos::ParameterList & initial_cond_pl,
861  const Teuchos::ParameterList & user_data_pl,
862  bool write_dot_files,const std::string & dot_file_prefix) const
863  {
864  using Teuchos::RCP;
865 
866  Thyra::ModelEvaluatorBase::InArgs<double> nomValues = model.getNominalValues();
867  Teuchos::RCP<Thyra::VectorBase<double> > x_vec = Teuchos::rcp_const_cast<Thyra::VectorBase<double> >(nomValues.get_x());
868 
869  if(initial_cond_pl.get<bool>("Zero Initial Conditions")) {
870  // zero out the x vector
871  Thyra::assign(x_vec.ptr(),0.0);
872  }
873  else if(!initial_cond_pl.sublist("Vector File").get<bool>("Enabled")) {
874  // read from exodus, or compute using field managers
875 
876  std::map<std::string, Teuchos::RCP< PHX::FieldManager<panzer::Traits> > > phx_ic_field_managers;
877 
879  physicsBlocks,
880  cm_factory,
881  closure_pl,
882  initial_cond_pl,
883  lof,
884  user_data_pl,
885  write_dot_files,
886  dot_file_prefix,
887  phx_ic_field_managers);
888 /*
889  panzer::setupInitialConditionFieldManagers(wkstContainer,
890  physicsBlocks,
891  cm_factory,
892  initial_cond_pl,
893  lof,
894  user_data_pl,
895  write_dot_files,
896  dot_file_prefix,
897  phx_ic_field_managers);
898 */
899 
900  // set the vector to be filled
903  tloc->set_x_th(x_vec);
904 
905  panzer::evaluateInitialCondition(wkstContainer, phx_ic_field_managers, loc, lof, 0.0);
906  }
907  else {
908  const std::string & vectorFile = initial_cond_pl.sublist("Vector File").get<std::string>("File Name");
909  TEUCHOS_TEST_FOR_EXCEPTION(vectorFile=="",std::runtime_error,
910  "If \"Read From Vector File\" is true, then parameter \"Vector File\" cannot be the empty string.");
911 
912  // set the vector to be filled
915  tloc->set_x_th(x_vec);
916 
917  // read the vector
918  lof.readVector(vectorFile,*loc,panzer::LinearObjContainer::X);
919  }
920  }
921 
922  template<typename ScalarT>
925  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
931  const Teuchos::ParameterList & closure_model_pl,
932  const Teuchos::ParameterList & user_data_pl,
933  int workset_size) const
934  {
935  Teuchos::RCP<panzer::LinearObjContainer> loc = lof->buildLinearObjContainer();
937  tloc->set_x_th(Teuchos::rcp_const_cast<Thyra::VectorBase<double> >(model.getNominalValues().get_x()));
938 
940  = initializeSolnWriterResponseLibrary(wc,ugi,lof,mesh);
941 
942  {
943  Teuchos::ParameterList user_data(user_data_pl);
944  user_data.set<int>("Workset Size",workset_size);
945 
946  finalizeSolnWriterResponseLibrary(*solnWriter,physicsBlocks,cm_factory,closure_model_pl,workset_size,user_data);
947  }
948 
949  // initialize the assembly container
951  ae_inargs.container_ = loc;
952  ae_inargs.ghostedContainer_ = lof->buildGhostedLinearObjContainer();
953  ae_inargs.alpha = 0.0;
954  ae_inargs.beta = 1.0;
955  ae_inargs.evaluate_transient_terms = false;
956 
957  // initialize the ghosted container
958  lof->initializeGhostedContainer(panzer::LinearObjContainer::X,*ae_inargs.ghostedContainer_);
959 
960  // do import
961  lof->globalToGhostContainer(*ae_inargs.container_,*ae_inargs.ghostedContainer_,panzer::LinearObjContainer::X);
962 
963  // fill STK mesh objects
964  solnWriter->addResponsesToInArgs<panzer::Traits::Residual>(ae_inargs);
965  solnWriter->evaluate<panzer::Traits::Residual>(ae_inargs);
966  }
967 
969  template<typename ScalarT>
971  {
973 
974  // first contruct the mesh factory
975  if (mesh_params.get<std::string>("Source") == "Exodus File") {
976  mesh_factory = Teuchos::rcp(new panzer_stk::STK_ExodusReaderFactory());
977  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Exodus File"))));
978  }
979  else if (mesh_params.get<std::string>("Source") == "Pamgen Mesh") {
980  mesh_factory = Teuchos::rcp(new panzer_stk::STK_ExodusReaderFactory());
981  Teuchos::RCP<Teuchos::ParameterList> pamgenList = Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Pamgen Mesh")));
982  pamgenList->set("File Type","Pamgen"); // For backwards compatibility when pamgen had separate factory from exodus
983  mesh_factory->setParameterList(pamgenList);
984  }
985  else if (mesh_params.get<std::string>("Source") == "Inline Mesh") {
986 
987  int dimension = mesh_params.sublist("Inline Mesh").get<int>("Mesh Dimension");
988  std::string typeStr = "";
989  if(mesh_params.sublist("Inline Mesh").isParameter("Type"))
990  typeStr = mesh_params.sublist("Inline Mesh").get<std::string>("Type");
991 
992  if (dimension == 1) {
993  mesh_factory = Teuchos::rcp(new panzer_stk::LineMeshFactory);
995  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
996  mesh_factory->setParameterList(in_mesh);
997  }
998  else if (dimension == 2 && typeStr=="Tri") {
1001  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1002  mesh_factory->setParameterList(in_mesh);
1003  }
1004  else if (dimension == 2) {
1005  mesh_factory = Teuchos::rcp(new panzer_stk::SquareQuadMeshFactory);
1007  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1008  mesh_factory->setParameterList(in_mesh);
1009  }
1010  else if (dimension == 3 && typeStr=="Tet") {
1011  mesh_factory = Teuchos::rcp(new panzer_stk::CubeTetMeshFactory);
1013  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1014  mesh_factory->setParameterList(in_mesh);
1015  }
1016  else if(dimension == 3) {
1017  mesh_factory = Teuchos::rcp(new panzer_stk::CubeHexMeshFactory);
1019  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1020  mesh_factory->setParameterList(in_mesh);
1021  }
1022  else if(dimension==4) { // not really "dimension==4" simply a flag to try this other mesh for testing
1023  mesh_factory = Teuchos::rcp(new panzer_stk::MultiBlockMeshFactory);
1025  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1026  mesh_factory->setParameterList(in_mesh);
1027  }
1028  }
1029  else if (mesh_params.get<std::string>("Source") == "Custom Mesh") {
1030  mesh_factory = Teuchos::rcp(new panzer_stk::CustomMeshFactory());
1031  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Custom Mesh"))));
1032  }
1033  else {
1034  // throw a runtime exception for invalid parameter values
1035  }
1036 
1037 
1038  // get rebalancing parameters
1039  if(mesh_params.isSublist("Rebalance")) {
1040  const Teuchos::ParameterList & rebalance = mesh_params.sublist("Rebalance");
1041 
1042  // check to see if its enabled
1043  bool enabled = false;
1044  if(rebalance.isType<bool>("Enabled"))
1045  enabled = rebalance.get<bool>("Enabled");
1046 
1047  // we can also use a list description of what to load balance
1048  Teuchos::RCP<Teuchos::ParameterList> rebalanceCycles;
1049  if(enabled && rebalance.isSublist("Cycles"))
1050  rebalanceCycles = Teuchos::rcp(new Teuchos::ParameterList(rebalance.sublist("Cycles")));
1051 
1052  // setup rebalancing as neccessary
1053  mesh_factory->enableRebalance(enabled,rebalanceCycles);
1054  }
1055 
1056  return mesh_factory;
1057  }
1058 
1059  template<typename ScalarT>
1061  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
1062  const Teuchos::MpiComm<int> mpi_comm,
1063  STK_Interface & mesh) const
1064  {
1065  // finish building mesh, set required field variables and mesh bulk data
1066  {
1067  std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
1068  for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
1069  // what is the block weight for this element block?
1070  double blockWeight = 0.0;
1071 
1073  const std::vector<panzer::StrPureBasisPair> & blockFields = pb->getProvidedDOFs();
1074  const std::vector<std::vector<std::string> > & coordinateDOFs = pb->getCoordinateDOFs();
1075  // these are treated specially
1076 
1077  // insert all fields into a set
1078  std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp> fieldNames;
1079  fieldNames.insert(blockFields.begin(),blockFields.end());
1080 
1081  // Now we will set up the coordinate fields (make sure to remove
1082  // the DOF fields)
1083  {
1084  std::set<std::string> fields_to_remove;
1085 
1086  // add mesh coordinate fields, setup their removal from fieldNames
1087  // set to prevent duplication
1088  for(std::size_t i=0;i<coordinateDOFs.size();i++) {
1089  mesh.addMeshCoordFields(pb->elementBlockID(),coordinateDOFs[i],"DISPL");
1090  for(std::size_t j=0;j<coordinateDOFs[i].size();j++)
1091  fields_to_remove.insert(coordinateDOFs[i][j]);
1092  }
1093 
1094  // remove the already added coordinate fields
1095  std::set<std::string>::const_iterator rmItr;
1096  for (rmItr=fields_to_remove.begin();rmItr!=fields_to_remove.end();++rmItr)
1097  fieldNames.erase(fieldNames.find(panzer::StrPureBasisPair(*rmItr,Teuchos::null)));
1098  }
1099 
1100  // add basis to DOF manager: block specific
1101  std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp>::const_iterator fieldItr;
1102  for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
1103 
1104  if(fieldItr->second->isScalarBasis() &&
1105  fieldItr->second->getElementSpace()==panzer::PureBasis::CONST) {
1106  mesh.addCellField(fieldItr->first,pb->elementBlockID());
1107  }
1108  else if(fieldItr->second->isScalarBasis()) {
1109  mesh.addSolutionField(fieldItr->first,pb->elementBlockID());
1110  }
1111  else if(fieldItr->second->isVectorBasis()) {
1112  std::string d_mod[3] = {"X","Y","Z"};
1113  for(int d=0;d<fieldItr->second->dimension();d++)
1114  mesh.addCellField(fieldItr->first+d_mod[d],pb->elementBlockID());
1115  }
1116  else { TEUCHOS_ASSERT(false); }
1117 
1118  blockWeight += double(fieldItr->second->cardinality());
1119  }
1120 
1121  // set the compute block weight (this is the sum of the cardinality of all basis
1122  // functions on this block
1123  mesh.setBlockWeight(pb->elementBlockID(),blockWeight);
1124  }
1125 
1126  mesh_factory.completeMeshConstruction(mesh,*(mpi_comm.getRawMpiComm()));
1127  }
1128  }
1129 
1130 
1131  template<typename ScalarT>
1133  {
1134  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(m_physics_me), std::runtime_error,
1135  "Objects are not built yet! Please call buildObjects() member function.");
1136  return m_physics_me;
1137  }
1138 
1139  template<typename ScalarT>
1141  {
1142  m_nox_observer_factory = nox_observer_factory;
1143  }
1144 
1145 #ifdef PANZER_HAVE_TEMPUS
1146  template<typename ScalarT>
1148  {
1149  m_tempus_observer_factory = tempus_observer_factory;
1150  }
1151 #endif
1152 
1153  template<typename ScalarT>
1155  {
1156  m_user_wkst_factory = user_wkst_factory;
1157  }
1158 
1159  template<typename ScalarT>
1161  {
1162  if(m_rome_me==Teuchos::null)
1163  m_rome_me = buildResponseOnlyModelEvaluator(m_physics_me,m_global_data);
1164 
1165  return m_rome_me;
1166  }
1167 
1168  template<typename ScalarT>
1171  const Teuchos::RCP<panzer::GlobalData>& global_data,
1172 #ifdef PANZER_HAVE_TEMPUS
1173  const Teuchos::RCP<Piro::TempusSolverForwardOnly<ScalarT> > tempusSolver,
1174 #endif
1175  const Teuchos::Ptr<const panzer_stk::NOXObserverFactory> & in_nox_observer_factory
1176 #ifdef PANZER_HAVE_TEMPUS
1177  , const Teuchos::Ptr<const panzer_stk::TempusObserverFactory> & in_tempus_observer_factory
1178 #endif
1179  )
1180  {
1181  using Teuchos::is_null;
1182  using Teuchos::Ptr;
1183 
1184  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_lin_obj_factory), std::runtime_error,
1185  "Objects are not built yet! Please call buildObjects() member function.");
1186  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_global_indexer), std::runtime_error,
1187  "Objects are not built yet! Please call buildObjects() member function.");
1188  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_mesh), std::runtime_error,
1189  "Objects are not built yet! Please call buildObjects() member function.");
1191  = is_null(in_nox_observer_factory) ? m_nox_observer_factory.ptr() : in_nox_observer_factory;
1192 #ifdef PANZER_HAVE_TEMPUS
1194  = is_null(in_tempus_observer_factory) ? m_tempus_observer_factory.ptr() : in_tempus_observer_factory;
1195 #endif
1196 
1197  Teuchos::ParameterList& p = *this->getNonconstParameterList();
1198  Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
1199  Teuchos::RCP<Teuchos::ParameterList> piro_params = Teuchos::rcp(new Teuchos::ParameterList(solncntl_params));
1201 
1202  std::string solver = solncntl_params.get<std::string>("Piro Solver");
1204  = Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me);
1205  if ( (solver=="NOX") || (solver == "LOCA") ) {
1206 
1207  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(nox_observer_factory), std::runtime_error,
1208  "No NOX obersver built! Please call setNOXObserverFactory() member function if you plan to use a NOX solver.");
1209 
1210  Teuchos::RCP<NOX::Abstract::PrePostOperator> ppo = nox_observer_factory->buildNOXObserver(m_mesh,m_global_indexer,m_lin_obj_factory);
1211  piro_params->sublist("NOX").sublist("Solver Options").set("User Defined Pre/Post Operator", ppo);
1212 
1213  if (solver=="NOX")
1214  piro = Teuchos::rcp(new Piro::NOXSolver<double>(piro_params,
1215  Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db)));
1216  else if (solver == "LOCA")
1217  piro = Teuchos::rcp(new Piro::LOCASolver<double>(piro_params,
1218  Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db),
1219  Teuchos::null));
1220  TEUCHOS_ASSERT(nonnull(piro));
1221 
1222  // override printing to use panzer ostream
1223  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Output Stream",global_data->os);
1224  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Error Stream",global_data->os);
1225  piro_params->sublist("NOX").sublist("Printing").set<int>("Output Processor",global_data->os->getOutputToRootOnly());
1226  }
1227 #ifdef PANZER_HAVE_TEMPUS
1228  else if (solver=="Tempus") {
1229 
1230  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(tempus_observer_factory), std::runtime_error,
1231  "No Tempus observer built! Please call setTempusObserverFactory() member function if you plan to use a Tempus solver.");
1232 
1233  // install the nox observer
1234  if(tempus_observer_factory->useNOXObserver()) {
1235  Teuchos::RCP<NOX::Abstract::PrePostOperator> ppo = nox_observer_factory->buildNOXObserver(m_mesh,m_global_indexer,m_lin_obj_factory);
1236  piro_params->sublist("NOX").sublist("Solver Options").set("User Defined Pre/Post Operator", ppo);
1237  }
1238 
1239  // override printing to use panzer ostream
1240  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Output Stream",global_data->os);
1241  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Error Stream",global_data->os);
1242  piro_params->sublist("NOX").sublist("Printing").set<int>("Output Processor",global_data->os->getOutputToRootOnly());
1243 
1244  // use the user specfied tempus solver if they pass one in
1246 
1247  if(tempusSolver==Teuchos::null)
1248  {
1249  piro_tempus =
1250  Teuchos::rcp(new Piro::TempusSolverForwardOnly<double>(piro_params, thyra_me,
1251  tempus_observer_factory->buildTempusObserver(m_mesh,m_global_indexer,m_lin_obj_factory)));
1252  }
1253  else
1254  {
1255  piro_tempus = tempusSolver;
1256  piro_tempus->initialize(piro_params, thyra_me,
1257  tempus_observer_factory->buildTempusObserver(m_mesh,m_global_indexer,m_lin_obj_factory));
1258  }
1259 
1260  piro = piro_tempus;
1261  }
1262 #endif
1263  else {
1264  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
1265  "Error: Unknown Piro Solver : " << solver);
1266  }
1267  return piro;
1268  }
1269 
1270  template<typename ScalarT>
1272  {
1273  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(m_response_library), std::runtime_error,
1274  "Objects are not built yet! Please call buildObjects() member function.");
1275 
1276  return m_response_library;
1277  }
1278 
1279  template<typename ScalarT>
1280  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & ModelEvaluatorFactory<ScalarT>::getPhysicsBlocks() const
1281  {
1282  TEUCHOS_TEST_FOR_EXCEPTION(m_physics_blocks.size()==0, std::runtime_error,
1283  "Objects are not built yet! Please call buildObjects() member function.");
1284 
1285  return m_physics_blocks;
1286  }
1287 
1288  template<typename ScalarT>
1292  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
1293  const std::vector<panzer::BC> & bcs,
1294  const panzer::EquationSetFactory & eqset_factory,
1295  const panzer::BCStrategyFactory& bc_factory,
1298  const Teuchos::ParameterList& closure_models,
1299  const panzer::LinearObjFactory<panzer::Traits> & lo_factory,
1300  const Teuchos::ParameterList& user_data,
1301  bool writeGraph,const std::string & graphPrefix,
1302  bool write_field_managers,const std::string & field_manager_prefix) const
1303  {
1305  fmb->setWorksetContainer(wc);
1306  fmb->setupVolumeFieldManagers(physicsBlocks,volume_cm_factory,closure_models,lo_factory,user_data);
1307  fmb->setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,lo_factory,user_data);
1308 
1309  // Print Phalanx DAGs
1310  if (writeGraph){
1311  fmb->writeVolumeGraphvizDependencyFiles(graphPrefix, physicsBlocks);
1312  fmb->writeBCGraphvizDependencyFiles(graphPrefix);
1313  }
1314  if (write_field_managers){
1315  fmb->writeVolumeTextDependencyFiles(graphPrefix, physicsBlocks);
1316  fmb->writeBCTextDependencyFiles(field_manager_prefix);
1317  }
1318 
1319  return fmb;
1320  }
1321 
1322  template<typename ScalarT>
1326  const Teuchos::RCP<Teuchos::ParameterList> & physics_block_plist,
1328  const panzer::BCStrategyFactory & bc_factory,
1330  bool is_transient,bool is_explicit,
1332  const Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > & physics_me_in) const
1333  {
1334  typedef panzer::ModelEvaluator<ScalarT> PanzerME;
1335 
1336  Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > physics_me = physics_me_in==Teuchos::null ? m_physics_me : physics_me_in;
1337 
1338  const Teuchos::ParameterList& p = *this->getParameterList();
1339 
1340  // build PhysicsBlocks
1341  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
1342  {
1343  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1344 
1345  // setup physical mappings and boundary conditions
1346  std::map<std::string,std::string> block_ids_to_physics_ids;
1347  panzer::buildBlockIdToPhysicsIdMap(block_ids_to_physics_ids, p.sublist("Block ID to Physics ID Mapping"));
1348 
1349  // build cell ( block id -> cell topology ) mapping
1350  std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
1351  for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
1352  itr!=block_ids_to_physics_ids.end();++itr) {
1353  block_ids_to_cell_topo[itr->first] = m_mesh->getCellTopology(itr->first);
1354  TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
1355  }
1356 
1357  std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.get<int>("Workset Size"));
1358 
1359  panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
1360  block_ids_to_cell_topo,
1361  physics_block_plist,
1362  assembly_params.get<int>("Default Integration Order"),
1363  workset_size,
1364  eqset_factory,
1365  m_global_data,
1366  is_transient,
1367  physicsBlocks);
1368  }
1369 
1370  // build FMB
1372  {
1373  const Teuchos::ParameterList & user_data_params = p.sublist("User Data");
1374 
1375  bool write_dot_files = false;
1376  std::string prefix = "Cloned_";
1377 
1378  std::vector<panzer::BC> bcs;
1379  if(bc_list==Teuchos::null) {
1380  panzer::buildBCs(bcs, p.sublist("Boundary Conditions"), m_global_data);
1381  }
1382  else {
1383  panzer::buildBCs(bcs, *bc_list, m_global_data);
1384  }
1385 
1386  fmb = buildFieldManagerBuilder(// Teuchos::rcp_const_cast<panzer::WorksetContainer>(
1387  // m_response_library!=Teuchos::null ? m_response_library->getWorksetContainer()
1388  // : m_wkstContainer),
1389  m_wkstContainer,
1390  physicsBlocks,
1391  bcs,
1392  *eqset_factory,
1393  bc_factory,
1394  user_cm_factory,
1395  user_cm_factory,
1396  p.sublist("Closure Models"),
1397  *m_lin_obj_factory,
1398  user_data_params,
1399  write_dot_files,prefix,
1400  write_dot_files,prefix);
1401  }
1402 
1405  m_global_indexer,
1406  m_lin_obj_factory));
1407  // = Teuchos::rcp(new panzer::ResponseLibrary<panzer::Traits>(m_response_library->getWorksetContainer(),
1408  // m_response_library->getGlobalIndexer(),
1409  // m_response_library->getLinearObjFactory()));
1410 
1411  // using the FMB, build the model evaluator
1412  {
1413  // get nominal input values, make sure they match with internal me
1414  Thyra::ModelEvaluatorBase::InArgs<ScalarT> nomVals = physics_me->getNominalValues();
1415 
1416  // determine if this is a Epetra or Thyra ME
1417  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(physics_me);
1418 
1419  bool useThyra = true;
1420 #ifdef PANZER_HAVE_EPETRA_STACK
1421  Teuchos::RCP<Thyra::EpetraModelEvaluator> ep_thyra_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(physics_me);
1422  if(ep_thyra_me!=Teuchos::null)
1423  useThyra = false;
1424 #endif
1425 
1426  // get parameter names
1427  std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names(physics_me->Np());
1428  std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values(physics_me->Np());
1429  for(std::size_t i=0;i<p_names.size();i++) {
1430  p_names[i] = Teuchos::rcp(new Teuchos::Array<std::string>(*physics_me->get_p_names(i)));
1431  p_values[i] = Teuchos::rcp(new Teuchos::Array<double>(p_names[i]->size(),0.0));
1432  }
1433 
1435  = buildPhysicsModelEvaluator(useThyra,
1436  fmb,
1437  response_library,
1438  m_lin_obj_factory,
1439  p_names,
1440  p_values,
1441  solverFactory,
1442  m_global_data,
1443  is_transient,
1444  nomVals.get_t());
1445 
1446  // set the nominal values...does this work???
1447  thyra_me->getNominalValues() = nomVals;
1448 
1449  // build an explicit model evaluator
1450  if(is_explicit) {
1451  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1452  bool lumpExplicitMass = assembly_params.get<bool>("Lump Explicit Mass");
1453  thyra_me = Teuchos::rcp(new panzer::ExplicitModelEvaluator<ScalarT>(thyra_me,!useDynamicCoordinates_,lumpExplicitMass));
1454  }
1455 
1456  return thyra_me;
1457  }
1458  }
1459 
1460  template<typename ScalarT>
1467  const std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > & p_names,
1468  const std::vector<Teuchos::RCP<Teuchos::Array<double> > > & p_values,
1470  const Teuchos::RCP<panzer::GlobalData> & global_data,
1471  bool is_transient,double t_init) const
1472  {
1474  if(!buildThyraME) {
1475 #ifdef PANZER_HAVE_EPETRA_STACK
1477  = Teuchos::rcp(new panzer::ModelEvaluator_Epetra(fmb,rLibrary,lof, p_names,p_values, global_data, is_transient));
1478 
1479  if (is_transient)
1480  ep_me->set_t_init(t_init);
1481 
1482  // Build Thyra Model Evaluator
1483  thyra_me = Thyra::epetraModelEvaluator(ep_me,solverFactory);
1484 #else
1485  TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: buildPhysicsModelEvalautor() - Epetra stack is not enabled!");
1486 #endif
1487  }
1488  else {
1490  (fmb,rLibrary,lof,p_names,p_values,solverFactory,global_data,is_transient,t_init));
1491  }
1492 
1493  return thyra_me;
1494  }
1495 
1496  template<typename ScalarT>
1499  const panzer_stk::STK_Interface & mesh) const
1500  {
1501  Teuchos::ParameterList validPL;
1502  {
1503  validPL.set<std::string>("Start Time Type", "From Input File", "Set the start time",
1504  rcp(new Teuchos::StringValidator(Teuchos::tuple<std::string>("From Input File","From Exodus File"))));
1505 
1506  validPL.set<double>("Start Time",0.0);
1507  }
1508 
1510 
1511  std::string t_init_type = p.get<std::string>("Start Time Type");
1512  double t_init = 10.0;
1513 
1514  if (t_init_type == "From Input File")
1515  t_init = p.get<double>("Start Time");
1516 
1517  if (t_init_type == "From Exodus File")
1518  t_init = mesh.getInitialStateTime();
1519 
1520  return t_init;
1521  }
1522 
1523  // Setup STK response library for writing out the solution fields
1525  template<typename ScalarT>
1530  const Teuchos::RCP<panzer_stk::STK_Interface> & mesh) const
1531  {
1534 
1535  std::vector<std::string> eBlocks;
1536  mesh->getElementBlockNames(eBlocks);
1537 
1539  builder.mesh = mesh;
1540  stkIOResponseLibrary->addResponse("Main Field Output",eBlocks,builder);
1541 
1542  return stkIOResponseLibrary;
1543  }
1544 
1545  template<typename ScalarT>
1548  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
1550  const Teuchos::ParameterList & closure_models,
1551  int workset_size, Teuchos::ParameterList & user_data) const
1552  {
1553  user_data.set<int>("Workset Size",workset_size);
1554  rl.buildResponseEvaluators(physicsBlocks, cm_factory, closure_models, user_data);
1555  }
1556 
1557  template<typename ScalarT>
1559  buildLOWSFactory(bool blockedAssembly,
1560  const Teuchos::RCP<const panzer::GlobalIndexer> & globalIndexer,
1561  const Teuchos::RCP<panzer::ConnManager> & conn_manager,
1563  const Teuchos::RCP<const Teuchos::MpiComm<int> > & mpi_comm
1564  #ifdef PANZER_HAVE_TEKO
1565  , const Teuchos::RCP<Teko::RequestHandler> & reqHandler
1566  #endif
1567  ) const
1568  {
1569  const Teuchos::ParameterList & p = *this->getParameterList();
1570  const Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
1571 
1572  // Build stratimikos solver (note that this defaults to a hard
1573  // coded path to linear solver options in nox list!)
1575  if (nonnull(m_stratimikos_params)) {
1576  strat_params = m_stratimikos_params;
1577  }
1578  else {
1579  strat_params = Teuchos::rcp(new Teuchos::ParameterList(solncntl_params.sublist("NOX").sublist("Direction").
1580  sublist("Newton").sublist("Stratimikos Linear Solver").sublist("Stratimikos")));
1581  }
1582 
1583  bool writeCoordinates = false;
1584  if(p.sublist("Options").isType<bool>("Write Coordinates"))
1585  writeCoordinates = p.sublist("Options").get<bool>("Write Coordinates");
1586 
1587  bool writeTopo = false;
1588  if(p.sublist("Options").isType<bool>("Write Topology"))
1589  writeTopo = p.sublist("Options").get<bool>("Write Topology");
1590 
1591 
1593  blockedAssembly,globalIndexer,conn_manager,
1594  Teuchos::as<int>(mesh->getDimension()), mpi_comm, strat_params,
1595  #ifdef PANZER_HAVE_TEKO
1596  reqHandler,
1597  #endif
1598  writeCoordinates,
1599  writeTopo
1600  );
1601  }
1602 
1603  template<typename ScalarT>
1606  const bool write_graphviz_file,
1607  const std::string& graphviz_file_prefix)
1608  {
1609  Teuchos::ParameterList & p = *this->getNonconstParameterList();
1610  Teuchos::ParameterList & user_data = p.sublist("User Data");
1611  Teuchos::ParameterList & closure_models = p.sublist("Closure Models");
1612 
1613  // uninitialize the thyra model evaluator, and rebuild the
1614  // responses to get the correct response counts!
1615 
1616  using PanzerME = panzer::ModelEvaluator<double>;
1617  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(m_physics_me);
1618 
1619  if(nonnull(panzer_me)) {
1620  panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1621  return;
1622  }
1623 #ifdef PANZER_HAVE_EPETRA_STACK
1624  else {
1625  Teuchos::RCP<Thyra::EpetraModelEvaluator> epetra_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(m_physics_me);
1626 
1627  if(epetra_me!=Teuchos::null) {
1630  epetra_me->uninitialize(&const_ep_me,&solveFactory);
1631 
1632  Teuchos::RCP<EpetraExt::ModelEvaluator> ep_me = Teuchos::rcp_const_cast<EpetraExt::ModelEvaluator>(const_ep_me);
1633  Teuchos::RCP<panzer::ModelEvaluator_Epetra> ep_panzer_me = Teuchos::rcp_dynamic_cast<panzer::ModelEvaluator_Epetra>(ep_me);
1634  ep_panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1635 
1636  // reinitialize the thyra model evaluator, now with the correct responses
1637  epetra_me->initialize(ep_me,solveFactory);
1638 
1639  return;
1640  }
1641  }
1642 #endif
1643 
1644  TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: buildResponses() - could not cast Physics ME to PanzerME!");
1645  }
1646 }
1647 
1648 #endif
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)
void setStratimikosList(const Teuchos::RCP< Teuchos::ParameterList > &paramList)
Set the Stratimikos Linear Solver sublist used to create the LinearOpWithSolve factory.
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 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, const double step_size, const int stage_number)
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 &paramList)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Teuchos::RCP< panzer::LinearObjContainer > ghostedContainer_
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 > &paramList)=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
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)
Ptr< T > ptr() const
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)
virtual void readVector(const std::string &identifier, LinearObjContainer &loc, int id) const =0
virtual bool useNOXObserver() const =0
Use the NOX observer as well?
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)
#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
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.
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)
bool is_null() const
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