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