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