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