Panzer  Version of the Day
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"
59 #include "Panzer_DOFManagerFactory.hpp"
61 #include "Panzer_BlockedDOFManagerFactory.hpp"
63 #include "Panzer_EpetraLinearObjFactory.hpp"
64 #include "Panzer_TpetraLinearObjFactory.hpp"
78 
79 #include "Panzer_STK_Interface.hpp"
90 #include "Panzer_STK_Utilities.hpp"
100 
101 #include <vector>
102 #include <iostream>
103 #include <fstream>
104 
105 // Piro solver objects
106 #include "Thyra_EpetraModelEvaluator.hpp"
107 #include "Piro_ConfigDefs.hpp"
108 #include "Piro_NOXSolver.hpp"
109 #include "Piro_LOCASolver.hpp"
110 #include "Piro_RythmosSolver.hpp"
111 
112 #include <Panzer_NodeType.hpp>
113 
114 namespace panzer_stk {
115 
116  template<typename ScalarT>
118  {
120 
121  // add in some addtional defaults that are hard to validate externally (this is because of the "disableRecursiveValidation" calls)
122 
123  if(!paramList->sublist("Initial Conditions").isType<bool>("Zero Initial Conditions"))
124  paramList->sublist("Initial Conditions").set<bool>("Zero Initial Conditions",false);
125 
126  paramList->sublist("Initial Conditions").sublist("Vector File").validateParametersAndSetDefaults(
127  getValidParameters()->sublist("Initial Conditions").sublist("Vector File"));
128 
129  this->setMyParamList(paramList);
130  }
131 
132  template<typename ScalarT>
134  {
136  if (is_null(validPL)) {
138 
139  pl->sublist("Physics Blocks").disableRecursiveValidation();
140  pl->sublist("Closure Models").disableRecursiveValidation();
141  pl->sublist("Boundary Conditions").disableRecursiveValidation();
142  pl->sublist("Solution Control").disableRecursiveValidation();
143  pl->set<bool>("Use Discrete Adjoint",false);
144 
145  pl->sublist("Mesh").disableRecursiveValidation();
146 
147  pl->sublist("Initial Conditions").set<bool>("Zero Initial Conditions",false);
148  pl->sublist("Initial Conditions").sublist("Transient Parameters").disableRecursiveValidation();
149  pl->sublist("Initial Conditions").sublist("Vector File");
150  pl->sublist("Initial Conditions").sublist("Vector File").set("File Name","");
151  pl->sublist("Initial Conditions").sublist("Vector File").set<bool>("Enabled",false);
152  pl->sublist("Initial Conditions").disableRecursiveValidation();
153 
154  pl->sublist("Output").set("File Name","panzer.exo");
155  pl->sublist("Output").set("Write to Exodus",true);
156  pl->sublist("Output").sublist("Cell Average Quantities").disableRecursiveValidation();
157  pl->sublist("Output").sublist("Cell Quantities").disableRecursiveValidation();
158  pl->sublist("Output").sublist("Cell Average Vectors").disableRecursiveValidation();
159  pl->sublist("Output").sublist("Nodal Quantities").disableRecursiveValidation();
160  pl->sublist("Output").sublist("Allocate Nodal Quantities").disableRecursiveValidation();
161 
162  // Assembly sublist
163  {
164  Teuchos::ParameterList& p = pl->sublist("Assembly");
165  p.set<int>("Workset Size", 1);
166  p.set<int>("Default Integration Order",-1);
167  p.set<std::string>("Field Order","");
168  p.set<std::string>("Auxiliary Field Order","");
169  p.set<bool>("Use DOFManager FEI",false);
170  p.set<bool>("Load Balance DOFs",false);
171  p.set<bool>("Use Tpetra",false);
172  p.set<bool>("Use Epetra ME",true);
173  p.set<bool>("Lump Explicit Mass",false);
174  p.set<bool>("Constant Mass Matrix",true);
175  p.set<bool>("Apply Mass Matrix Inverse in Explicit Evaluator",true);
176  p.set<bool>("Use Conservative IMEX",false);
177  p.set<bool>("Compute Real Time Derivative",false);
178  p.set<bool>("Use Time Derivative in Explicit Model",false);
179  p.set<bool>("Compute Time Derivative at Time Step",false);
180  p.set<Teuchos::RCP<const panzer::EquationSetFactory> >("Equation Set Factory", Teuchos::null);
181  p.set<Teuchos::RCP<const panzer::ClosureModelFactory_TemplateManager<panzer::Traits> > >("Closure Model Factory", Teuchos::null);
182  p.set<Teuchos::RCP<const panzer::BCStrategyFactory> >("BC Factory",Teuchos::null);
183  p.set<std::string>("Excluded Blocks","");
185  }
186 
187  pl->sublist("Block ID to Physics ID Mapping").disableRecursiveValidation();
188  pl->sublist("Options").disableRecursiveValidation();
189  pl->sublist("Active Parameters").disableRecursiveValidation();
190  pl->sublist("Controls").disableRecursiveValidation();
191  pl->sublist("ALE").disableRecursiveValidation(); // this sucks
192  pl->sublist("User Data").disableRecursiveValidation();
193  pl->sublist("User Data").sublist("Panzer Data").disableRecursiveValidation();
194 
195  validPL = pl;
196  }
197  return validPL;
198  }
199 
200  namespace {
201  bool hasInterfaceCondition(const std::vector<panzer::BC>& bcs)
202  {
203  for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
204  if (bcit->bcType() == panzer::BCT_Interface)
205  return true;
206  return false;
207  }
208 
210  getSTKConnManager(const Teuchos::RCP<panzer::ConnManagerBase<int> >& conn_mgr)
211  {
212  const Teuchos::RCP<STKConnManager<int> > stk_conn_mgr =
213  Teuchos::rcp_dynamic_cast<STKConnManager<int> >(conn_mgr);
214  TEUCHOS_TEST_FOR_EXCEPTION(stk_conn_mgr.is_null(), std::logic_error,
215  "There are interface conditions, but the connection manager"
216  " does not support the necessary connections.");
217  return stk_conn_mgr;
218  }
219 
220  void buildInterfaceConnections(const std::vector<panzer::BC>& bcs,
221  const Teuchos::RCP<panzer::ConnManagerBase<int> >& conn_mgr)
222  {
223  const Teuchos::RCP<STKConnManager<int> > stk_conn_mgr = getSTKConnManager(conn_mgr);
224  for (std::vector<panzer::BC>::const_iterator bcit = bcs.begin(); bcit != bcs.end(); ++bcit)
225  if (bcit->bcType() == panzer::BCT_Interface)
226  stk_conn_mgr->associateElementsInSideset(bcit->sidesetID());
227  }
228 
229  void checkInterfaceConnections(const Teuchos::RCP<panzer::ConnManagerBase<int> >& conn_mgr,
231  {
232  const Teuchos::RCP<STKConnManager<int> > stk_conn_mgr = getSTKConnManager(conn_mgr);
233  std::vector<std::string> sidesets = stk_conn_mgr->checkAssociateElementsInSidesets(*comm);
234  if ( ! sidesets.empty()) {
235  std::stringstream ss;
236  ss << "Sideset IDs";
237  for (std::size_t i = 0; i < sidesets.size(); ++i)
238  ss << " " << sidesets[i];
239  ss << " did not yield associations, but these sidesets correspond to BCT_Interface BCs.";
240  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, ss.str());
241  }
242  }
243  } // namespace
244 
245  template<typename ScalarT>
249  const panzer::BCStrategyFactory & bc_factory,
251  bool meConstructionOn)
252  {
253  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(this->getParameterList()), std::runtime_error,
254  "ParameterList must be set before objects can be built!");
255 
260 
261  // begin at the beginning...
262  m_global_data = global_data;
263 
266  // Parse input file, setup parameters
269 
270  // this function will need to be broken up eventually and probably
271  // have parts moved back into panzer. Just need to get something
272  // running.
273 
274  Teuchos::ParameterList& p = *this->getNonconstParameterList();
275 
276  // "parse" parameter list
277  Teuchos::ParameterList & mesh_params = p.sublist("Mesh");
278  Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
279  Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
280  Teuchos::ParameterList & output_list = p.sublist("Output");
281 
282  Teuchos::ParameterList & user_data_params = p.sublist("User Data");
283  Teuchos::ParameterList & panzer_data_params = user_data_params.sublist("Panzer Data");
284 
285  Teuchos::RCP<Teuchos::ParameterList> physics_block_plist = Teuchos::sublist(this->getMyNonconstParamList(),"Physics Blocks");
286 
287  // extract assembly information
288  std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.get<int>("Workset Size"));
289  std::string field_order = assembly_params.get<std::string>("Field Order"); // control nodal ordering of unknown
290  // global IDs in linear system
291  bool use_dofmanager_fei = assembly_params.get<bool>("Use DOFManager FEI"); // use FEI if true, otherwise use internal dof manager
292  bool use_load_balance = assembly_params.get<bool>("Load Balance DOFs");
293  bool useTpetra = assembly_params.get<bool>("Use Tpetra");
294  bool useThyraME = !assembly_params.get<bool>("Use Epetra ME");
295 
296  // this is weird...we are accessing the solution control to determine if things are transient
297  // it is backwards!
298  bool is_transient = solncntl_params.get<std::string>("Piro Solver") == "Rythmos" ? true : false;
299  // for pseudo-transient, we need to enable transient solver support to get time derivatives into fill
300  if (solncntl_params.get<std::string>("Piro Solver") == "NOX") {
301  if (solncntl_params.sublist("NOX").get<std::string>("Nonlinear Solver") == "Pseudo-Transient")
302  is_transient = true;
303  }
304  // for eigenvalues, we need to enable transient solver support to
305  // get time derivatives into generalized eigenvale problem
306  if (solncntl_params.get<std::string>("Piro Solver") == "LOCA") {
307  if (solncntl_params.sublist("LOCA").sublist("Stepper").get<bool>("Compute Eigenvalues"))
308  is_transient = true;
309  }
310  m_is_transient = is_transient;
311 
312  bool useDiscreteAdjoint = p.get<bool>("Use Discrete Adjoint");
313 
316  // Do stuff
319 
321 
322  // for convience cast to an MPI comm
324  Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >(comm);
325 
326  // Build mesh factory and uncommitted mesh
328 
329  Teuchos::RCP<panzer_stk::STK_MeshFactory> mesh_factory = this->buildSTKMeshFactory(mesh_params);
330  Teuchos::RCP<panzer_stk::STK_Interface> mesh = mesh_factory->buildUncommitedMesh(*(mpi_comm->getRawMpiComm()));
331  m_mesh = mesh;
332 
333  m_eqset_factory = eqset_factory;
334 
335  // setup the physcs blocks
337 
338  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
339  {
340  // setup physical mappings and boundary conditions
341  std::map<std::string,std::string> block_ids_to_physics_ids;
342  panzer::buildBlockIdToPhysicsIdMap(block_ids_to_physics_ids, p.sublist("Block ID to Physics ID Mapping"));
343 
344  // build cell ( block id -> cell topology ) mapping
345  std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
346  for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
347  itr!=block_ids_to_physics_ids.end();++itr) {
348  block_ids_to_cell_topo[itr->first] = mesh->getCellTopology(itr->first);
349  TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
350  }
351 
352  // build physics blocks
353 
354  panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
355  block_ids_to_cell_topo,
356  physics_block_plist,
357  assembly_params.get<int>("Default Integration Order"),
358  workset_size,
359  eqset_factory,
360  global_data,
361  is_transient,
362  physicsBlocks);
363  m_physics_blocks = physicsBlocks; // hold onto physics blocks for safe keeping
364  }
365 
366  // add fields automatically written through the closure model
368  addUserFieldsToMesh(*mesh,output_list);
369 
370  // finish building mesh, set required field variables and mesh bulk data
372 
373  try {
374  // this throws some exceptions, catch them as neccessary
375  this->finalizeMeshConstruction(*mesh_factory,physicsBlocks,*mpi_comm,*mesh);
376  } catch(const panzer_stk::STK_Interface::ElementBlockException & ebexp) {
377  fout << "*****************************************\n\n";
378  fout << "Element block exception, could not finalize the mesh, printing block and sideset information:\n";
379  fout.pushTab(3);
380  mesh->printMetaData(fout);
381  fout.popTab();
382  fout << std::endl;
383 
384  throw ebexp;
385  } catch(const panzer_stk::STK_Interface::SidesetException & ssexp) {
386  fout << "*****************************************\n\n";
387  fout << "Sideset exception, could not finalize the mesh, printing block and sideset information:\n";
388  fout.pushTab(3);
389  mesh->printMetaData(fout);
390  fout.popTab();
391  fout << std::endl;
392 
393  throw ssexp;
394  }
395 
396  mesh->print(fout);
397  if(p.sublist("Output").get<bool>("Write to Exodus"))
398  mesh->setupTransientExodusFile(p.sublist("Output").get<std::string>("File Name"));
399 
400  // build a workset factory that depends on STK
403  if(m_user_wkst_factory==Teuchos::null)
404  wkstFactory = Teuchos::rcp(new panzer_stk::WorksetFactory()); // build STK workset factory
405  else
406  wkstFactory = m_user_wkst_factory;
407 
408  // set workset factory mesh
409  wkstFactory->setMesh(mesh);
410 
411  // handle boundary and interface conditions
413  std::vector<panzer::BC> bcs;
414  panzer::buildBCs(bcs, p.sublist("Boundary Conditions"), global_data);
415 
416  // build the connection manager
418 
420  if(useTpetra)
422  else
423  conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager<int>(mesh));
424  m_conn_manager = conn_manager;
425 
426  // build DOF Manager
428 
431 
432  std::string loadBalanceString = ""; // what is the load balancing information
433  bool blockedAssembly = false;
434 
435  if(panzer::BlockedDOFManagerFactory<int,int>::requiresBlocking(field_order) && !useTpetra) {
436  const Teuchos::RCP<panzer::ConnManager<int,int> > conn_manager_int
437  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,int> >(conn_manager,true);
438 
439  // use a blocked DOF manager
440  blockedAssembly = true;
441 
442  panzer::BlockedDOFManagerFactory<int,int> globalIndexerFactory;
443  globalIndexerFactory.setUseDOFManagerFEI(use_dofmanager_fei);
444 
446  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_int,field_order);
447  globalIndexer = dofManager;
448 
451  Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager<int,int> >(dofManager)));
452 
453  // parse any explicitly excluded pairs or blocks
454  const std::string excludedBlocks = assembly_params.get<std::string>("Excluded Blocks");
455  std::vector<std::string> stringPairs;
456  panzer::StringTokenizer(stringPairs,excludedBlocks,";",true);
457  for(std::size_t i=0;i<stringPairs.size();i++) {
458  std::vector<std::string> sPair;
459  std::vector<int> iPair;
460  panzer::StringTokenizer(sPair,stringPairs[i],",",true);
461  panzer::TokensToInts(iPair,sPair);
462 
463  TEUCHOS_TEST_FOR_EXCEPTION(iPair.size()!=2,std::logic_error,
464  "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
465  " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
466  "Failure on string pair " << stringPairs[i] << "!");
467 
468  bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
469  }
470 
471  linObjFactory = bloLinObjFactory;
472 
473  // build load balancing string for informative output
474  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
475  }
478  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,panzer::Ordinal64> >(conn_manager,true);
479 
480  // use a blocked DOF manager
481  blockedAssembly = true;
482 
483  TEUCHOS_ASSERT(!use_dofmanager_fei);
485  globalIndexerFactory.setUseDOFManagerFEI(false);
486 
488  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_long,field_order);
489  globalIndexer = dofManager;
490 
493  Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager<int,panzer::Ordinal64> >(dofManager)));
494 
495  // parse any explicitly excluded pairs or blocks
496  const std::string excludedBlocks = assembly_params.get<std::string>("Excluded Blocks");
497  std::vector<std::string> stringPairs;
498  panzer::StringTokenizer(stringPairs,excludedBlocks,";",true);
499  for(std::size_t i=0;i<stringPairs.size();i++) {
500  std::vector<std::string> sPair;
501  std::vector<int> iPair;
502  panzer::StringTokenizer(sPair,stringPairs[i],",",true);
503  panzer::TokensToInts(iPair,sPair);
504 
505  TEUCHOS_TEST_FOR_EXCEPTION(iPair.size()!=2,std::logic_error,
506  "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
507  " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
508  "Failure on string pair " << stringPairs[i] << "!");
509 
510  bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
511  }
512 
513  linObjFactory = bloLinObjFactory;
514 
515  // build load balancing string for informative output
516  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
517  }
518  else if(useTpetra) {
520  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,panzer::Ordinal64> >(conn_manager,true);
521 
522  // use a flat DOF manager
523 
524  TEUCHOS_ASSERT(!use_dofmanager_fei);
526  globalIndexerFactory.setUseDOFManagerFEI(false);
527  globalIndexerFactory.setUseTieBreak(use_load_balance);
529  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_long,field_order);
530  globalIndexer = dofManager;
531 
532  TEUCHOS_ASSERT(!useDiscreteAdjoint); // safety check
534 
535  // build load balancing string for informative output
536  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
537  }
538  else {
539  const bool has_interface_condition = hasInterfaceCondition(bcs);
540  if (has_interface_condition)
541  buildInterfaceConnections(bcs, conn_manager);
542 
543  const Teuchos::RCP<panzer::ConnManager<int,int> > conn_manager_int
544  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,int> >(conn_manager,true);
545 
546  // use a flat DOF manager
547  panzer::DOFManagerFactory<int,int> globalIndexerFactory;
548  globalIndexerFactory.setUseDOFManagerFEI(use_dofmanager_fei);
549  globalIndexerFactory.setUseTieBreak(use_load_balance);
550  globalIndexerFactory.setUseNeighbors(has_interface_condition);
552  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_int,
553  field_order);
554  globalIndexer = dofManager;
555 
556  if (has_interface_condition)
557  checkInterfaceConnections(conn_manager, dofManager->getComm());
558 
559  linObjFactory = Teuchos::rcp(new panzer::EpetraLinearObjFactory<panzer::Traits,int>(mpi_comm,dofManager,useDiscreteAdjoint));
560 
561  // build load balancing string for informative output
562  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
563  }
564 
565  TEUCHOS_ASSERT(globalIndexer!=Teuchos::null);
566  TEUCHOS_ASSERT(linObjFactory!=Teuchos::null);
567  m_global_indexer = globalIndexer;
568  m_lin_obj_factory = linObjFactory;
569  m_blockedAssembly = blockedAssembly;
570 
571  // print out load balancing information
572  fout << "Degree of freedom load balancing: " << loadBalanceString << std::endl;
573 
574  // build worksets
576 
577  Teuchos::RCP<panzer::WorksetContainer> wkstContainer // attach it to a workset container (uses lazy evaluation)
578  = Teuchos::rcp(new panzer::WorksetContainer(wkstFactory,physicsBlocks,workset_size));
579 
580  m_wkstContainer = wkstContainer;
581 
582  // set the global indexer so the orientations are evaluated
583  wkstContainer->setGlobalIndexer(globalIndexer);
584 
585  // Setup lagrangian type coordinates
587 
588  // see if field coordinates are required, if so reset the workset container
589  // and set the coordinates to be associated with a field in the mesh
590  useDynamicCoordinates_ = false;
591  for(std::size_t p=0;p<physicsBlocks.size();p++) {
592  if(physicsBlocks[p]->getCoordinateDOFs().size()>0) {
593  mesh->setUseFieldCoordinates(true);
594  useDynamicCoordinates_ = true;
595  wkstContainer->clear(); // this serves to refresh the worksets
596  // and put in new coordinates
597  break;
598  }
599  }
600 
601  // Add mesh objects to user data to make available to user ctors
603 
604  panzer_data_params.set("STK Mesh", mesh);
605  panzer_data_params.set("DOF Manager", globalIndexer);
606  panzer_data_params.set("Linear Object Factory", linObjFactory);
607 
608  // If user requested it, short circuit model construction
610 
611  if(!meConstructionOn)
612  return;
613 
614  // Setup active parameters
616 
617  std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names;
618  std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values;
619  if (p.isSublist("Active Parameters")) {
620  Teuchos::ParameterList& active_params = p.sublist("Active Parameters");
621 
622  int num_param_vecs = active_params.get<int>("Number of Parameter Vectors",0);
623  p_names.resize(num_param_vecs);
624  p_values.resize(num_param_vecs);
625  for (int i=0; i<num_param_vecs; i++) {
626  std::stringstream ss;
627  ss << "Parameter Vector " << i;
628  Teuchos::ParameterList& pList = active_params.sublist(ss.str());
629  int numParameters = pList.get<int>("Number");
630  TEUCHOS_TEST_FOR_EXCEPTION(numParameters == 0,
632  std::endl << "Error! panzer::ModelEvaluator::ModelEvaluator(): " <<
633  "Parameter vector " << i << " has zero parameters!" << std::endl);
634  p_names[i] =
635  Teuchos::rcp(new Teuchos::Array<std::string>(numParameters));
636  p_values[i] =
637  Teuchos::rcp(new Teuchos::Array<double>(numParameters));
638  for (int j=0; j<numParameters; j++) {
639  std::stringstream ss2;
640  ss2 << "Parameter " << j;
641  (*p_names[i])[j] = pList.get<std::string>(ss2.str());
642  ss2.str("");
643 
644  ss2 << "Initial Value " << j;
645  (*p_values[i])[j] = pList.get<double>(ss2.str());
646 
647  // this is a band-aid/hack to make sure parameters are registered before they are accessed
648  panzer::registerScalarParameter((*p_names[i])[j],*global_data->pl,(*p_values[i])[j]);
649  }
650  }
651  }
652 
653  // setup the closure model for automatic writing (during residual/jacobian update)
655 
656  panzer_stk::IOClosureModelFactory_TemplateBuilder<panzer::Traits> io_cm_builder(user_cm_factory,mesh,output_list);
658  cm_factory.buildObjects(io_cm_builder);
659 
660  // setup field manager build
662 
664  {
665  bool write_dot_files = p.sublist("Options").get("Write Volume Assembly Graphs",false);
666  std::string dot_file_prefix = p.sublist("Options").get("Volume Assembly Graph Prefix","Panzer_AssemblyGraph");
667  bool write_fm_files = p.sublist("Options").get("Write Field Manager Files",false);
668  std::string fm_file_prefix = p.sublist("Options").get("Field Manager File Prefix","Panzer_AssemblyGraph");
669 
670  fmb = buildFieldManagerBuilder(wkstContainer,physicsBlocks,bcs,*eqset_factory,bc_factory,cm_factory,
671  user_cm_factory,p.sublist("Closure Models"),*linObjFactory,user_data_params,
672  write_dot_files,dot_file_prefix,
673  write_fm_files,fm_file_prefix);
674  }
675 
676  // build response library
678 
679  m_response_library = Teuchos::rcp(new panzer::ResponseLibrary<panzer::Traits>(wkstContainer,globalIndexer,linObjFactory));
680 
681  {
682  bool write_dot_files = false;
683  std::string prefix = "Panzer_ResponseGraph_";
684  write_dot_files = p.sublist("Options").get("Write Volume Response Graphs",write_dot_files);
685  prefix = p.sublist("Options").get("Volume Response Graph Prefix",prefix);
686 
687  Teuchos::ParameterList user_data(p.sublist("User Data"));
688  user_data.set<int>("Workset Size",workset_size);
689  }
690 
691  // Setup solver factory
693 
695  buildLOWSFactory(blockedAssembly,globalIndexer,conn_manager,mesh,mpi_comm);
696 
697  // Setup physics model evaluator
699 
700  double t_init = 0.0;
701  if(is_transient)
702  t_init = this->getInitialTime(p.sublist("Initial Conditions").sublist("Transient Parameters"), *mesh);
703 
704  if(blockedAssembly || useTpetra) // override the user request
705  useThyraME = true;
706 
708  = buildPhysicsModelEvaluator(useThyraME, // blockedAssembly || useTpetra, // this determines if a Thyra or Epetra ME is used
709  fmb,
710  m_response_library,
711  linObjFactory,
712  p_names,
713  p_values,
714  lowsFactory,
715  global_data,
716  is_transient,
717  t_init);
718 
719  // Setup initial conditions
721 
722  {
723  bool write_dot_files = false;
724  std::string prefix = "Panzer_AssemblyGraph_";
725  setupInitialConditions(*thyra_me,*wkstContainer,physicsBlocks,user_cm_factory,*linObjFactory,
726  p.sublist("Initial Conditions"),
727  p.sublist("User Data"),
728  p.sublist("Options").get("Write Volume Assembly Graphs",write_dot_files),
729  p.sublist("Options").get("Volume Assembly Graph Prefix",prefix));
730  }
731 
732  // Write the IC vector into the STK mesh: use response library
734  writeInitialConditions(*thyra_me,physicsBlocks,wkstContainer,globalIndexer,linObjFactory,mesh,user_cm_factory,
735  p.sublist("Closure Models"),
736  p.sublist("User Data"),workset_size);
737 
738  m_physics_me = thyra_me;
739  }
740 
741  template<typename ScalarT>
744  {
745  // register cell averaged scalar fields
746  const Teuchos::ParameterList & cellAvgQuants = output_list.sublist("Cell Average Quantities");
747  for(Teuchos::ParameterList::ConstIterator itr=cellAvgQuants.begin();
748  itr!=cellAvgQuants.end();++itr) {
749  const std::string & blockId = itr->first;
750  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
751  std::vector<std::string> tokens;
752 
753  // break up comma seperated fields
754  panzer::StringTokenizer(tokens,fields,",",true);
755 
756  for(std::size_t i=0;i<tokens.size();i++)
757  mesh.addCellField(tokens[i],blockId);
758  }
759 
760  // register cell averaged components of vector fields
761  // just allocate space for the fields here. The actual calculation and writing
762  // are done by panzer_stk::ScatterCellAvgVector.
763  const Teuchos::ParameterList & cellAvgVectors = output_list.sublist("Cell Average Vectors");
764  for(Teuchos::ParameterList::ConstIterator itr = cellAvgVectors.begin();
765  itr != cellAvgVectors.end(); ++itr) {
766  const std::string & blockId = itr->first;
767  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
768  std::vector<std::string> tokens;
769 
770  // break up comma seperated fields
771  panzer::StringTokenizer(tokens,fields,",",true);
772 
773  for(std::size_t i = 0; i < tokens.size(); i++) {
774  std::string d_mod[3] = {"X","Y","Z"};
775  for(std::size_t d = 0; d < mesh.getDimension(); d++)
776  mesh.addCellField(tokens[i]+d_mod[d],blockId);
777  }
778  }
779 
780  // register cell quantities
781  const Teuchos::ParameterList & cellQuants = output_list.sublist("Cell Quantities");
782  for(Teuchos::ParameterList::ConstIterator itr=cellQuants.begin();
783  itr!=cellQuants.end();++itr) {
784  const std::string & blockId = itr->first;
785  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
786  std::vector<std::string> tokens;
787 
788  // break up comma seperated fields
789  panzer::StringTokenizer(tokens,fields,",",true);
790 
791  for(std::size_t i=0;i<tokens.size();i++)
792  mesh.addCellField(tokens[i],blockId);
793  }
794 
795  // register ndoal quantities
796  const Teuchos::ParameterList & nodalQuants = output_list.sublist("Nodal Quantities");
797  for(Teuchos::ParameterList::ConstIterator itr=nodalQuants.begin();
798  itr!=nodalQuants.end();++itr) {
799  const std::string & blockId = itr->first;
800  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
801  std::vector<std::string> tokens;
802 
803  // break up comma seperated fields
804  panzer::StringTokenizer(tokens,fields,",",true);
805 
806  for(std::size_t i=0;i<tokens.size();i++)
807  mesh.addSolutionField(tokens[i],blockId);
808  }
809 
810  const Teuchos::ParameterList & allocNodalQuants = output_list.sublist("Allocate Nodal Quantities");
811  for(Teuchos::ParameterList::ConstIterator itr=allocNodalQuants.begin();
812  itr!=allocNodalQuants.end();++itr) {
813  const std::string & blockId = itr->first;
814  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
815  std::vector<std::string> tokens;
816 
817  // break up comma seperated fields
818  panzer::StringTokenizer(tokens,fields,",",true);
819 
820  for(std::size_t i=0;i<tokens.size();i++)
821  mesh.addSolutionField(tokens[i],blockId);
822  }
823  }
824 
825  template<typename ScalarT>
828  panzer::WorksetContainer & wkstContainer,
829  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
832  const Teuchos::ParameterList & initial_cond_pl,
833  const Teuchos::ParameterList & user_data_pl,
834  bool write_dot_files,const std::string & dot_file_prefix) const
835  {
836  using Teuchos::RCP;
837 
838  Thyra::ModelEvaluatorBase::InArgs<double> nomValues = model.getNominalValues();
839  Teuchos::RCP<Thyra::VectorBase<double> > x_vec = Teuchos::rcp_const_cast<Thyra::VectorBase<double> >(nomValues.get_x());
840 
841  if(initial_cond_pl.get<bool>("Zero Initial Conditions")) {
842  // zero out the x vector
843  Thyra::assign(x_vec.ptr(),0.0);
844  }
845  else if(!initial_cond_pl.sublist("Vector File").get<bool>("Enabled")) {
846  // read from exodus, or compute using field managers
847 
848  std::map<std::string, Teuchos::RCP< PHX::FieldManager<panzer::Traits> > > phx_ic_field_managers;
850  physicsBlocks,
851  cm_factory,
852  initial_cond_pl,
853  lof,
854  user_data_pl,
855  write_dot_files,
856  dot_file_prefix,
857  phx_ic_field_managers);
858 
859  // set the vector to be filled
862  tloc->set_x_th(x_vec);
863 
864  panzer::evaluateInitialCondition(wkstContainer, phx_ic_field_managers, loc, lof, 0.0);
865  }
866  else {
867  const std::string & vectorFile = initial_cond_pl.sublist("Vector File").get<std::string>("File Name");
868  TEUCHOS_TEST_FOR_EXCEPTION(vectorFile=="",std::runtime_error,
869  "If \"Read From Vector File\" is true, then parameter \"Vector File\" cannot be the empty string.");
870 
871  // set the vector to be filled
874  tloc->set_x_th(x_vec);
875 
876  // read the vector
877  lof.readVector(vectorFile,*loc,panzer::LinearObjContainer::X);
878  }
879  }
880 
881  template<typename ScalarT>
884  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
890  const Teuchos::ParameterList & closure_model_pl,
891  const Teuchos::ParameterList & user_data_pl,
892  int workset_size) const
893  {
894  Teuchos::RCP<panzer::LinearObjContainer> loc = lof->buildLinearObjContainer();
896  tloc->set_x_th(Teuchos::rcp_const_cast<Thyra::VectorBase<double> >(model.getNominalValues().get_x()));
897 
899  = initializeSolnWriterResponseLibrary(wc,ugi,lof,mesh);
900 
901  {
902  Teuchos::ParameterList user_data(user_data_pl);
903  user_data.set<int>("Workset Size",workset_size);
904 
905  finalizeSolnWriterResponseLibrary(*solnWriter,physicsBlocks,cm_factory,closure_model_pl,workset_size,user_data);
906  }
907 
908  // initialize the assembly container
910  ae_inargs.container_ = loc;
911  ae_inargs.ghostedContainer_ = lof->buildGhostedLinearObjContainer();
912  ae_inargs.alpha = 0.0;
913  ae_inargs.beta = 1.0;
914  ae_inargs.evaluate_transient_terms = false;
915 
916  // initialize the ghosted container
917  lof->initializeGhostedContainer(panzer::LinearObjContainer::X,*ae_inargs.ghostedContainer_);
918 
919  // do import
920  lof->globalToGhostContainer(*ae_inargs.container_,*ae_inargs.ghostedContainer_,panzer::LinearObjContainer::X);
921 
922  // fill STK mesh objects
923  solnWriter->addResponsesToInArgs<panzer::Traits::Residual>(ae_inargs);
924  solnWriter->evaluate<panzer::Traits::Residual>(ae_inargs);
925  }
926 
928  template<typename ScalarT>
930  {
932 
933  // first contruct the mesh factory
934  if (mesh_params.get<std::string>("Source") == "Exodus File") {
935  mesh_factory = Teuchos::rcp(new panzer_stk::STK_ExodusReaderFactory());
936  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Exodus File"))));
937  }
938  else if (mesh_params.get<std::string>("Source") == "Pamgen Mesh") {
939  mesh_factory = Teuchos::rcp(new panzer_stk::STK_PamgenReaderFactory());
940  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Pamgen Mesh"))));
941  }
942  else if (mesh_params.get<std::string>("Source") == "Inline Mesh") {
943 
944  int dimension = mesh_params.sublist("Inline Mesh").get<int>("Mesh Dimension");
945  std::string typeStr = "";
946  if(mesh_params.sublist("Inline Mesh").isParameter("Type"))
947  typeStr = mesh_params.sublist("Inline Mesh").get<std::string>("Type");
948 
949  if (dimension == 1) {
950  mesh_factory = Teuchos::rcp(new panzer_stk::LineMeshFactory);
952  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
953  mesh_factory->setParameterList(in_mesh);
954  }
955  else if (dimension == 2 && typeStr=="Tri") {
958  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
959  mesh_factory->setParameterList(in_mesh);
960  }
961  else if (dimension == 2) {
964  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
965  mesh_factory->setParameterList(in_mesh);
966  }
967  else if (dimension == 3 && typeStr=="Tet") {
968  mesh_factory = Teuchos::rcp(new panzer_stk::CubeTetMeshFactory);
970  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
971  mesh_factory->setParameterList(in_mesh);
972  }
973  else if(dimension == 3) {
974  mesh_factory = Teuchos::rcp(new panzer_stk::CubeHexMeshFactory);
976  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
977  mesh_factory->setParameterList(in_mesh);
978  }
979  else if(dimension==4) { // not really "dimension==4" simply a flag to try this other mesh for testing
982  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
983  mesh_factory->setParameterList(in_mesh);
984  }
985  }
986  else if (mesh_params.get<std::string>("Source") == "Custom Mesh") {
987  mesh_factory = Teuchos::rcp(new panzer_stk::CustomMeshFactory());
988  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Custom Mesh"))));
989  }
990  else {
991  // throw a runtime exception for invalid parameter values
992  }
993 
994 
995  // get rebalancing parameters
996  if(mesh_params.isSublist("Rebalance")) {
997  const Teuchos::ParameterList & rebalance = mesh_params.sublist("Rebalance");
998 
999  // check to see if its enabled
1000  bool enabled = false;
1001  if(rebalance.isType<bool>("Enabled"))
1002  enabled = rebalance.get<bool>("Enabled");
1003 
1004  // we can also use a list description of what to load balance
1005  Teuchos::RCP<Teuchos::ParameterList> rebalanceCycles;
1006  if(enabled && rebalance.isSublist("Cycles"))
1007  rebalanceCycles = Teuchos::rcp(new Teuchos::ParameterList(rebalance.sublist("Cycles")));
1008 
1009  // setup rebalancing as neccessary
1010  mesh_factory->enableRebalance(enabled,rebalanceCycles);
1011  }
1012 
1013  return mesh_factory;
1014  }
1015 
1016  template<typename ScalarT>
1018  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
1019  const Teuchos::MpiComm<int> mpi_comm,
1020  STK_Interface & mesh) const
1021  {
1022  // finish building mesh, set required field variables and mesh bulk data
1023  {
1024  std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
1025  for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
1026  // what is the block weight for this element block?
1027  double blockWeight = 0.0;
1028 
1030  const std::vector<panzer::StrPureBasisPair> & blockFields = pb->getProvidedDOFs();
1031  const std::vector<std::vector<std::string> > & coordinateDOFs = pb->getCoordinateDOFs();
1032  // these are treated specially
1033 
1034  // insert all fields into a set
1035  std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp> fieldNames;
1036  fieldNames.insert(blockFields.begin(),blockFields.end());
1037 
1038  // Now we will set up the coordinate fields (make sure to remove
1039  // the DOF fields)
1040  {
1041  std::set<std::string> fields_to_remove;
1042 
1043  // add mesh coordinate fields, setup their removal from fieldNames
1044  // set to prevent duplication
1045  for(std::size_t i=0;i<coordinateDOFs.size();i++) {
1046  mesh.addMeshCoordFields(pb->elementBlockID(),coordinateDOFs[i],"DISPL");
1047  for(std::size_t j=0;j<coordinateDOFs[i].size();j++)
1048  fields_to_remove.insert(coordinateDOFs[i][j]);
1049  }
1050 
1051  // remove the already added coordinate fields
1052  std::set<std::string>::const_iterator rmItr;
1053  for (rmItr=fields_to_remove.begin();rmItr!=fields_to_remove.end();++rmItr)
1054  fieldNames.erase(fieldNames.find(panzer::StrPureBasisPair(*rmItr,Teuchos::null)));
1055  }
1056 
1057  // add basis to DOF manager: block specific
1058  std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp>::const_iterator fieldItr;
1059  for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
1060 
1061  if(fieldItr->second->isScalarBasis() &&
1062  fieldItr->second->getElementSpace()==panzer::PureBasis::CONST) {
1063  mesh.addCellField(fieldItr->first,pb->elementBlockID());
1064  }
1065  else if(fieldItr->second->isScalarBasis()) {
1066  mesh.addSolutionField(fieldItr->first,pb->elementBlockID());
1067  }
1068  else if(fieldItr->second->isVectorBasis()) {
1069  std::string d_mod[3] = {"X","Y","Z"};
1070  for(int d=0;d<fieldItr->second->dimension();d++)
1071  mesh.addCellField(fieldItr->first+d_mod[d],pb->elementBlockID());
1072  }
1073  else { TEUCHOS_ASSERT(false); }
1074 
1075  blockWeight += double(fieldItr->second->cardinality());
1076  }
1077 
1078  // set the compute block weight (this is the sum of the cardinality of all basis
1079  // functions on this block
1080  mesh.setBlockWeight(pb->elementBlockID(),blockWeight);
1081  }
1082 
1083  mesh_factory.completeMeshConstruction(mesh,*(mpi_comm.getRawMpiComm()));
1084  }
1085  }
1086 
1087 
1088  template<typename ScalarT>
1090  {
1091  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(m_physics_me), std::runtime_error,
1092  "Objects are not built yet! Please call buildObjects() member function.");
1093  return m_physics_me;
1094  }
1095 
1096  template<typename ScalarT>
1098  {
1099  m_nox_observer_factory = nox_observer_factory;
1100  }
1101 
1102  template<typename ScalarT>
1104  {
1105  m_rythmos_observer_factory = rythmos_observer_factory;
1106  }
1107 
1108  template<typename ScalarT>
1110  {
1111  m_user_wkst_factory = user_wkst_factory;
1112  }
1113 
1114  template<typename ScalarT>
1116  {
1117  if(m_rome_me==Teuchos::null)
1118  m_rome_me = buildResponseOnlyModelEvaluator(m_physics_me,m_global_data);
1119 
1120  return m_rome_me;
1121  }
1122 
1123  template<typename ScalarT>
1127  const Teuchos::RCP<Piro::RythmosSolver<ScalarT> > rythmosSolver,
1128  const Teuchos::Ptr<const panzer_stk::NOXObserverFactory> & in_nox_observer_factory,
1129  const Teuchos::Ptr<const panzer_stk::RythmosObserverFactory> & in_rythmos_observer_factory
1130  )
1131  {
1132  using Teuchos::is_null;
1133  using Teuchos::Ptr;
1134 
1135  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_lin_obj_factory), std::runtime_error,
1136  "Objects are not built yet! Please call buildObjects() member function.");
1137  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_global_indexer), std::runtime_error,
1138  "Objects are not built yet! Please call buildObjects() member function.");
1139  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_mesh), std::runtime_error,
1140  "Objects are not built yet! Please call buildObjects() member function.");
1142  = is_null(in_nox_observer_factory) ? m_nox_observer_factory.ptr() : in_nox_observer_factory;
1144  = is_null(in_rythmos_observer_factory) ? m_rythmos_observer_factory.ptr() : in_rythmos_observer_factory;
1145 
1146  Teuchos::ParameterList& p = *this->getNonconstParameterList();
1147  Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
1148  Teuchos::RCP<Teuchos::ParameterList> piro_params = Teuchos::rcp(new Teuchos::ParameterList(solncntl_params));
1150 
1151  std::string solver = solncntl_params.get<std::string>("Piro Solver");
1153  = Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me);
1154  if ( (solver=="NOX") || (solver == "LOCA") ) {
1155 
1156  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(nox_observer_factory), std::runtime_error,
1157  "No NOX obersver built! Please call setNOXObserverFactory() member function if you plan to use a NOX solver.");
1158 
1159  Teuchos::RCP<NOX::Abstract::PrePostOperator> ppo = nox_observer_factory->buildNOXObserver(m_mesh,m_global_indexer,m_lin_obj_factory);
1160  piro_params->sublist("NOX").sublist("Solver Options").set("User Defined Pre/Post Operator", ppo);
1161 
1162  if (solver=="NOX")
1163  piro = Teuchos::rcp(new Piro::NOXSolver<double>(piro_params,
1164  Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db)));
1165  else if (solver == "LOCA")
1166  piro = Teuchos::rcp(new Piro::LOCASolver<double>(piro_params,
1167  Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db),
1168  Teuchos::null));
1169  TEUCHOS_ASSERT(nonnull(piro));
1170 
1171  // override printing to use panzer ostream
1172  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Output Stream",global_data->os);
1173  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Error Stream",global_data->os);
1174  piro_params->sublist("NOX").sublist("Printing").set<int>("Output Processor",global_data->os->getOutputToRootOnly());
1175  }
1176  else if (solver=="Rythmos") {
1177 
1178  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(rythmos_observer_factory), std::runtime_error,
1179  "No NOX obersver built! Please call setrythmosObserverFactory() member function if you plan to use a Rythmos solver.");
1180 
1181  // install the nox observer
1182  if(rythmos_observer_factory->useNOXObserver()) {
1183  Teuchos::RCP<NOX::Abstract::PrePostOperator> ppo = nox_observer_factory->buildNOXObserver(m_mesh,m_global_indexer,m_lin_obj_factory);
1184  piro_params->sublist("NOX").sublist("Solver Options").set("User Defined Pre/Post Operator", ppo);
1185  }
1186 
1187  // override printing to use panzer ostream
1188  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Output Stream",global_data->os);
1189  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Error Stream",global_data->os);
1190  piro_params->sublist("NOX").sublist("Printing").set<int>("Output Processor",global_data->os->getOutputToRootOnly());
1191 
1192  // use the user specfied rythmos solver if they pass one in
1194  if(rythmosSolver==Teuchos::null)
1195  piro_rythmos = Teuchos::rcp(new Piro::RythmosSolver<double>());
1196  else
1197  piro_rythmos = rythmosSolver;
1198 
1199  // if you are using explicit RK, make sure to wrap the ME in an explicit model evaluator decorator
1200  Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > rythmos_me = thyra_me;
1201  const std::string stepper_type = piro_params->sublist("Rythmos").get<std::string>("Stepper Type");
1202  if(stepper_type=="Explicit RK" || stepper_type=="Forward Euler") {
1203  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1204  bool lumpExplicitMass = assembly_params.get<bool>("Lump Explicit Mass");
1205  rythmos_me = Teuchos::rcp(new panzer::ExplicitModelEvaluator<ScalarT>(thyra_me,!useDynamicCoordinates_,lumpExplicitMass));
1206  }
1207 
1208  piro_rythmos->initialize(piro_params, rythmos_me, rythmos_observer_factory->buildRythmosObserver(m_mesh,m_global_indexer,m_lin_obj_factory));
1209 
1210  piro = piro_rythmos;
1211  }
1212  else {
1213  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
1214  "Error: Unknown Piro Solver : " << solver);
1215  }
1216  return piro;
1217  }
1218 
1219  template<typename ScalarT>
1221  {
1222  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(m_response_library), std::runtime_error,
1223  "Objects are not built yet! Please call buildObjects() member function.");
1224 
1225  return m_response_library;
1226  }
1227 
1228  template<typename ScalarT>
1229  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & ModelEvaluatorFactory<ScalarT>::getPhysicsBlocks() const
1230  {
1231  TEUCHOS_TEST_FOR_EXCEPTION(m_physics_blocks.size()==0, std::runtime_error,
1232  "Objects are not built yet! Please call buildObjects() member function.");
1233 
1234  return m_physics_blocks;
1235  }
1236 
1237  template<typename ScalarT>
1241  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
1242  const std::vector<panzer::BC> & bcs,
1243  const panzer::EquationSetFactory & eqset_factory,
1244  const panzer::BCStrategyFactory& bc_factory,
1247  const Teuchos::ParameterList& closure_models,
1248  const panzer::LinearObjFactory<panzer::Traits> & lo_factory,
1249  const Teuchos::ParameterList& user_data,
1250  bool writeGraph,const std::string & graphPrefix,
1251  bool write_field_managers,const std::string & field_manager_prefix) const
1252  {
1254  fmb->setWorksetContainer(wc);
1255  fmb->setupVolumeFieldManagers(physicsBlocks,volume_cm_factory,closure_models,lo_factory,user_data);
1256  fmb->setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,lo_factory,user_data);
1257 
1258  // Print Phalanx DAGs
1259  if (writeGraph){
1260  fmb->writeVolumeGraphvizDependencyFiles(graphPrefix, physicsBlocks);
1261  fmb->writeBCGraphvizDependencyFiles(graphPrefix);
1262  }
1263  if (write_field_managers){
1264  fmb->writeVolumeTextDependencyFiles(graphPrefix, physicsBlocks);
1265  fmb->writeBCTextDependencyFiles(field_manager_prefix);
1266  }
1267 
1268  return fmb;
1269  }
1270 
1271  template<typename ScalarT>
1275  const Teuchos::RCP<Teuchos::ParameterList> & physics_block_plist,
1277  const panzer::BCStrategyFactory & bc_factory,
1279  bool is_transient,bool is_explicit,
1281  const Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > & physics_me_in) const
1282  {
1283  typedef panzer::ModelEvaluator<ScalarT> PanzerME;
1284 
1285  Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > physics_me = physics_me_in==Teuchos::null ? m_physics_me : physics_me_in;
1286 
1287  const Teuchos::ParameterList& p = *this->getParameterList();
1288 
1289  // build PhysicsBlocks
1290  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
1291  {
1292  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1293 
1294  // setup physical mappings and boundary conditions
1295  std::map<std::string,std::string> block_ids_to_physics_ids;
1296  panzer::buildBlockIdToPhysicsIdMap(block_ids_to_physics_ids, p.sublist("Block ID to Physics ID Mapping"));
1297 
1298  // build cell ( block id -> cell topology ) mapping
1299  std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
1300  for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
1301  itr!=block_ids_to_physics_ids.end();++itr) {
1302  block_ids_to_cell_topo[itr->first] = m_mesh->getCellTopology(itr->first);
1303  TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
1304  }
1305 
1306  std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.get<int>("Workset Size"));
1307 
1308  panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
1309  block_ids_to_cell_topo,
1310  physics_block_plist,
1311  assembly_params.get<int>("Default Integration Order"),
1312  workset_size,
1313  eqset_factory,
1314  m_global_data,
1315  is_transient,
1316  physicsBlocks);
1317  }
1318 
1319  // build FMB
1321  {
1322  const Teuchos::ParameterList & user_data_params = p.sublist("User Data");
1323 
1324  bool write_dot_files = false;
1325  std::string prefix = "Cloned_";
1326 
1327  std::vector<panzer::BC> bcs;
1328  if(bc_list==Teuchos::null) {
1329  panzer::buildBCs(bcs, p.sublist("Boundary Conditions"), m_global_data);
1330  }
1331  else {
1332  panzer::buildBCs(bcs, *bc_list, m_global_data);
1333  }
1334 
1335  fmb = buildFieldManagerBuilder(// Teuchos::rcp_const_cast<panzer::WorksetContainer>(
1336  // m_response_library!=Teuchos::null ? m_response_library->getWorksetContainer()
1337  // : m_wkstContainer),
1338  m_wkstContainer,
1339  physicsBlocks,
1340  bcs,
1341  *eqset_factory,
1342  bc_factory,
1343  user_cm_factory,
1344  user_cm_factory,
1345  p.sublist("Closure Models"),
1346  *m_lin_obj_factory,
1347  user_data_params,
1348  write_dot_files,prefix,
1349  write_dot_files,prefix);
1350  }
1351 
1354  m_global_indexer,
1355  m_lin_obj_factory));
1356  // = Teuchos::rcp(new panzer::ResponseLibrary<panzer::Traits>(m_response_library->getWorksetContainer(),
1357  // m_response_library->getGlobalIndexer(),
1358  // m_response_library->getLinearObjFactory()));
1359 
1360  // using the FMB, build the model evaluator
1361  {
1362  // get nominal input values, make sure they match with internal me
1363  Thyra::ModelEvaluatorBase::InArgs<ScalarT> nomVals = physics_me->getNominalValues();
1364 
1365  // determine if this is a Epetra or Thyra ME
1366  Teuchos::RCP<Thyra::EpetraModelEvaluator> ep_thyra_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(physics_me);
1367  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(physics_me);
1368  bool useThyra = true;
1369  if(ep_thyra_me!=Teuchos::null)
1370  useThyra = false;
1371 
1372  // get parameter names
1373  std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names(physics_me->Np());
1374  std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values(physics_me->Np());
1375  for(std::size_t i=0;i<p_names.size();i++) {
1376  p_names[i] = Teuchos::rcp(new Teuchos::Array<std::string>(*physics_me->get_p_names(i)));
1377  p_values[i] = Teuchos::rcp(new Teuchos::Array<double>(p_names[i]->size(),0.0));
1378  }
1379 
1381  = buildPhysicsModelEvaluator(useThyra,
1382  fmb,
1383  response_library,
1384  m_lin_obj_factory,
1385  p_names,
1386  p_values,
1387  solverFactory,
1388  m_global_data,
1389  is_transient,
1390  nomVals.get_t());
1391 
1392  // set the nominal values...does this work???
1393  thyra_me->getNominalValues() = nomVals;
1394 
1395  // build an explicit model evaluator
1396  if(is_explicit) {
1397  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1398  bool lumpExplicitMass = assembly_params.get<bool>("Lump Explicit Mass");
1399  thyra_me = Teuchos::rcp(new panzer::ExplicitModelEvaluator<ScalarT>(thyra_me,!useDynamicCoordinates_,lumpExplicitMass));
1400  }
1401 
1402  return thyra_me;
1403  }
1404  }
1405 
1406  template<typename ScalarT>
1414  const std::vector<Teuchos::RCP<Teuchos::Array<double> > > & p_values,
1417  bool is_transient,double t_init) const
1418  {
1420  if(!buildThyraME) {
1422  = Teuchos::rcp(new panzer::ModelEvaluator_Epetra(fmb,rLibrary,lof, p_names,p_values, global_data, is_transient));
1423 
1424  if (is_transient)
1425  ep_me->set_t_init(t_init);
1426 
1427  // Build Thyra Model Evaluator
1428  thyra_me = Thyra::epetraModelEvaluator(ep_me,solverFactory);
1429  }
1430  else {
1432  (fmb,rLibrary,lof,p_names,p_values,solverFactory,global_data,is_transient,t_init));
1433  }
1434 
1435  return thyra_me;
1436  }
1437 
1438  template<typename ScalarT>
1441  const panzer_stk::STK_Interface & mesh) const
1442  {
1443  Teuchos::ParameterList validPL;
1444  {
1445  Teuchos::setStringToIntegralParameter<int>(
1446  "Start Time Type",
1447  "From Input File",
1448  "Set the start time",
1449  Teuchos::tuple<std::string>("From Input File","From Exodus File"),
1450  &validPL
1451  );
1452 
1453  validPL.set<double>("Start Time",0.0);
1454  }
1455 
1457 
1458  std::string t_init_type = p.get<std::string>("Start Time Type");
1459  double t_init = 10.0;
1460 
1461  if (t_init_type == "From Input File")
1462  t_init = p.get<double>("Start Time");
1463 
1464  if (t_init_type == "From Exodus File")
1465  t_init = mesh.getInitialStateTime();
1466 
1467  return t_init;
1468  }
1469 
1470  // Setup STK response library for writing out the solution fields
1472  template<typename ScalarT>
1477  const Teuchos::RCP<panzer_stk::STK_Interface> & mesh) const
1478  {
1481 
1482  std::vector<std::string> eBlocks;
1483  mesh->getElementBlockNames(eBlocks);
1484 
1486  builder.mesh = mesh;
1487  stkIOResponseLibrary->addResponse("Main Field Output",eBlocks,builder);
1488 
1489  return stkIOResponseLibrary;
1490  }
1491 
1492  template<typename ScalarT>
1495  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
1497  const Teuchos::ParameterList & closure_models,
1498  int workset_size, Teuchos::ParameterList & user_data) const
1499  {
1500  user_data.set<int>("Workset Size",workset_size);
1501  rl.buildResponseEvaluators(physicsBlocks, cm_factory, closure_models, user_data);
1502  }
1503 
1504  template<typename ScalarT>
1506  buildLOWSFactory(bool blockedAssembly,
1508  const Teuchos::RCP<panzer::ConnManagerBase<int> > & conn_manager,
1510  const Teuchos::RCP<const Teuchos::MpiComm<int> > & mpi_comm
1511  #ifdef PANZER_HAVE_TEKO
1512  , const Teuchos::RCP<Teko::RequestHandler> & reqHandler
1513  #endif
1514  ) const
1515  {
1516  const Teuchos::ParameterList & p = *this->getParameterList();
1517  const Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
1518 
1519  // Build stratimikos solver (note that this is a hard coded path to linear solver options in nox list!)
1521  = Teuchos::rcp(new Teuchos::ParameterList(solncntl_params.sublist("NOX").sublist("Direction").
1522  sublist("Newton").sublist("Stratimikos Linear Solver").sublist("Stratimikos")));
1523 
1524  bool writeCoordinates = false;
1525  if(p.sublist("Options").isType<bool>("Write Coordinates"))
1526  writeCoordinates = p.sublist("Options").get<bool>("Write Coordinates");
1527 
1528  bool writeTopo = false;
1529  if(p.sublist("Options").isType<bool>("Write Topology"))
1530  writeTopo = p.sublist("Options").get<bool>("Write Topology");
1531 
1532 
1534  blockedAssembly,globalIndexer,conn_manager,
1535  Teuchos::as<int>(mesh->getDimension()), mpi_comm, strat_params,
1536  #ifdef PANZER_HAVE_TEKO
1537  reqHandler,
1538  #endif
1539  writeCoordinates,
1540  writeTopo
1541  );
1542  }
1543 
1544  template<typename ScalarT>
1547  const bool write_graphviz_file,
1548  const std::string& graphviz_file_prefix)
1549  {
1550  typedef panzer::ModelEvaluator<double> PanzerME;
1551 
1552  Teuchos::ParameterList & p = *this->getNonconstParameterList();
1553  Teuchos::ParameterList & user_data = p.sublist("User Data");
1554  Teuchos::ParameterList & closure_models = p.sublist("Closure Models");
1555 
1556  // uninitialize the thyra model evaluator, its respone counts are wrong!
1557  Teuchos::RCP<Thyra::EpetraModelEvaluator> thyra_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(m_physics_me);
1558  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(m_physics_me);
1559 
1560  if(thyra_me!=Teuchos::null && panzer_me==Teuchos::null) {
1563  thyra_me->uninitialize(&const_ep_me,&solveFactory); // this seems dangerous!
1564 
1565  // I don't need no const-ness!
1566  Teuchos::RCP<EpetraExt::ModelEvaluator> ep_me = Teuchos::rcp_const_cast<EpetraExt::ModelEvaluator>(const_ep_me);
1567  Teuchos::RCP<panzer::ModelEvaluator_Epetra> ep_panzer_me = Teuchos::rcp_dynamic_cast<panzer::ModelEvaluator_Epetra>(ep_me);
1568 
1569  ep_panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1570 
1571  // reinitialize the thyra model evaluator, now with the correct responses
1572  thyra_me->initialize(ep_me,solveFactory);
1573 
1574  return;
1575  }
1576  else if(panzer_me!=Teuchos::null && thyra_me==Teuchos::null) {
1577  panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1578 
1579  return;
1580  }
1581 
1582  TEUCHOS_ASSERT(false);
1583  }
1584 }
1585 
1586 #endif
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > initializeSolnWriterResponseLibrary(const Teuchos::RCP< panzer::WorksetContainer > &wc, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &ugi, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh) const
void writeVolumeTextDependencyFiles(std::string filename_prefix, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks) 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::UniqueGlobalIndexerBase > &ugi, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_model_pl, const Teuchos::ParameterList &user_data_pl, int workset_size) const
Write the initial conditions to exodus. Note that this is entirely self contained.
void TokensToInts(std::vector< int > &values, const std::vector< std::string > &tokens)
Turn a vector of tokens into a vector of ints.
void setRythmosObserverFactory(const Teuchos::RCP< const panzer_stk::RythmosObserverFactory > &rythmos_observer_factory)
Interface for constructing a BCStrategy_TemplateManager.
virtual void completeMeshConstruction(STK_Interface &mesh, stk::ParallelMachine parallelMach) const =0
void setupVolumeFieldManagers(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data)
Allocates and initializes an equation set template manager.
void finalizeMeshConstruction(const STK_MeshFactory &mesh_factory, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::MpiComm< int > mpi_comm, STK_Interface &mesh) const
bool is_null(const boost::shared_ptr< T > &p)
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > getPhysicsModelEvaluator()
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
Teuchos::RCP< panzer::ParamLib > pl
Sacado scalar parameter library.
ParameterList & disableRecursiveValidation()
virtual Teuchos::RCP< Rythmos::IntegrationObserverBase< double > > buildRythmosObserver(const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &dof_manager, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof) const =0
void setGlobalIndexer(const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &ugi)
void writeVolumeGraphvizDependencyFiles(std::string filename_prefix, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks) const
ConstIterator begin() 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)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual bool useNOXObserver() const =0
Use the NOX observer as well?
bool isSublist(const std::string &name) const
std::string elementBlockID() const
void addSolutionField(const std::string &fieldName, const std::string &blockId)
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
Teuchos::RCP< panzer::LinearObjContainer > ghostedContainer_
Class that provides access to worksets on each element block and side set.
PHX::MDField< ScalarT > vector
Teuchos::RCP< panzer::GlobalData > global_data
bool is_null() const
void set_t_init(double t)
Set initial time value.
void getElementBlockNames(std::vector< std::string > &names) const
virtual Teuchos::RCP< panzer::UniqueGlobalIndexer< LO, std::pair< int, GO > > > buildUniqueGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager< LO, GO > > &connMngr, const std::string &fieldOrder="") const
void 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 &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...
Teuchos::RCP< panzer::LinearObjContainer > container_
void writeBCTextDependencyFiles(std::string filename_prefix) const
ConstIterator end() const
void setWorksetContainer(const Teuchos::RCP< WorksetContainer > &wc)
virtual void setParameterList(const RCP< ParameterList > &paramList)=0
Teuchos::RCP< panzer::FieldManagerBuilder > buildFieldManagerBuilder(const Teuchos::RCP< panzer::WorksetContainer > &wc, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const std::vector< panzer::BC > &bcs, const panzer::EquationSetFactory &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &volume_cm_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &bc_cm_factory, const Teuchos::ParameterList &closure_models, const panzer::LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data, bool writeGraph, const std::string &graphPrefix, bool write_field_managers, const std::string &field_manager_prefix) const
unsigned getDimension() const
get the dimension
void buildResponseEvaluators(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > buildResponseOnlyModelEvaluator(const Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > &thyra_me, const Teuchos::RCP< panzer::GlobalData > &global_data, const Teuchos::RCP< Piro::RythmosSolver< ScalarT > > rythmosSolver=Teuchos::null, const Teuchos::Ptr< const panzer_stk::NOXObserverFactory > &in_nox_observer_factory=Teuchos::null, const Teuchos::Ptr< const panzer_stk::RythmosObserverFactory > &in_rythmos_observer_factory=Teuchos::null)
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="")
void addUserFieldsToMesh(panzer_stk::STK_Interface &mesh, const Teuchos::ParameterList &output_list) const
Add the user fields specified by output_list to the mesh.
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > getResponseOnlyModelEvaluator()
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
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setUseFieldCoordinates(bool useFieldCoordinates)
void writeBCGraphvizDependencyFiles(std::string filename_prefix) const
void setNOXObserverFactory(const Teuchos::RCP< const panzer_stk::NOXObserverFactory > &nox_observer_factory)
params_t::ConstIterator ConstIterator
Teuchos::RCP< STK_MeshFactory > buildSTKMeshFactory(const Teuchos::ParameterList &mesh_params) const
build STK mesh factory from a mesh parameter list
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.
void setupTransientExodusFile(const std::string &filename)
virtual Teuchos::RCP< LinearObjContainer > buildLinearObjContainer() const =0
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
std::string printUGILoadBalancingInformation(const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi)
bool isType(const std::string &name) const
void printMetaData(std::ostream &os) const
const std::vector< std::vector< std::string > > & getCoordinateDOFs() const
void setBlockWeight(const std::string &blockId, double weight)
Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< double > > buildLOWSFactory(bool blockedAssembly, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &globalIndexer, const Teuchos::RCP< panzer::ConnManagerBase< int > > &conn_manager, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const Teuchos::MpiComm< int > > &mpi_comm) const
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.
virtual void readVector(const std::string &identifier, LinearObjContainer &loc, int id) const =0
bool nonnull(const boost::shared_ptr< T > &p)
void addMeshCoordFields(const std::string &blockId, const std::vector< std::string > &coordField, const std::string &dispPrefix)
const std::vector< StrPureBasisPair > & getProvidedDOFs() const
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.
Teuchos::RCP< const shards::CellTopology > getCellTopology(const std::string &eBlock) const
void buildResponses(const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
Teuchos::RCP< const Teuchos::Comm< int > > comm
virtual void setMesh(const Teuchos::RCP< const panzer_stk::STK_Interface > &mesh)
const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > & getPhysicsBlocks() const
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 enableRebalance(bool enable, const Teuchos::RCP< const Teuchos::ParameterList > &rebalanceList=Teuchos::null)
std::pair< std::string, Teuchos::RCP< panzer::PureBasis > > StrPureBasisPair
bool isParameter(const std::string &name) const
virtual Teuchos::RCP< panzer::UniqueGlobalIndexer< LO, GO > > buildUniqueGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager< LO, GO > > &connMngr, const std::string &fieldOrder="") const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void StringTokenizer(std::vector< std::string > &tokens, const std::string &str, const std::string delimiters, bool trim)
Tokenize a string, put tokens in a vector.
void print(std::ostream &os) 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 addCellField(const std::string &fieldName, const std::string &blockId)
virtual Teuchos::RCP< NOX::Abstract::PrePostOperator > buildNOXObserver(const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &dof_manager, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof) const =0
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)
void registerScalarParameter(const std::string name, panzer::ParamLib &pl, double realValue)
void setUserWorksetFactory(Teuchos::RCP< panzer_stk::WorksetFactory > &user_wkst_factory)
Set user defined workset factory.
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > getResponseLibrary()
Ptr< T > ptr() const
Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< double > > buildLOWSFactory(bool blockedAssembly, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &globalIndexer, const Teuchos::RCP< panzer::ConnManagerBase< int > > &conn_manager, int spatialDim, const Teuchos::RCP< const Teuchos::MpiComm< int > > &mpi_comm, const Teuchos::RCP< Teuchos::ParameterList > &strat_params, bool writeCoordinates, bool writeTopo)