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"
59 #include "Panzer_DOFManagerFactory.hpp"
61 #include "Panzer_BlockedDOFManagerFactory.hpp"
63 #include "Panzer_TpetraLinearObjFactory.hpp"
77 
78 #include "Panzer_STK_Interface.hpp"
89 #include "Panzer_STK_Utilities.hpp"
99 
100 #include <vector>
101 #include <iostream>
102 #include <fstream>
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::ConnManagerBase<int> >& conn_mgr)
210  {
211  const Teuchos::RCP<STKConnManager<int> > stk_conn_mgr =
212  Teuchos::rcp_dynamic_cast<STKConnManager<int> >(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::ConnManagerBase<int> >& conn_mgr)
221  {
222  const Teuchos::RCP<STKConnManager<int> > 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::ConnManagerBase<int> >& conn_mgr,
229  const Teuchos::RCP<Teuchos::Comm<int> >& comm)
230  {
231  const Teuchos::RCP<STKConnManager<int> > 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
417 
419  if(useTpetra)
421  else
422  conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager<int>(mesh));
423  m_conn_manager = conn_manager;
424 
425  // build DOF Manager
427 
430 
431  std::string loadBalanceString = ""; // what is the load balancing information
432  bool blockedAssembly = false;
433 
434  if(panzer::BlockedDOFManagerFactory<int,int>::requiresBlocking(field_order) && !useTpetra) {
435  const Teuchos::RCP<panzer::ConnManager<int,int> > conn_manager_int
436  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,int> >(conn_manager,true);
437 
438  // use a blocked DOF manager
439  blockedAssembly = true;
440 
441  panzer::BlockedDOFManagerFactory<int,int> globalIndexerFactory;
442  globalIndexerFactory.setUseDOFManagerFEI(use_dofmanager_fei);
443 
445  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_int,field_order);
446  globalIndexer = dofManager;
447 
450  Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager<int,int> >(dofManager)));
451 
452  // parse any explicitly excluded pairs or blocks
453  const std::string excludedBlocks = assembly_params.get<std::string>("Excluded Blocks");
454  std::vector<std::string> stringPairs;
455  panzer::StringTokenizer(stringPairs,excludedBlocks,";",true);
456  for(std::size_t i=0;i<stringPairs.size();i++) {
457  std::vector<std::string> sPair;
458  std::vector<int> iPair;
459  panzer::StringTokenizer(sPair,stringPairs[i],",",true);
460  panzer::TokensToInts(iPair,sPair);
461 
462  TEUCHOS_TEST_FOR_EXCEPTION(iPair.size()!=2,std::logic_error,
463  "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
464  " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
465  "Failure on string pair " << stringPairs[i] << "!");
466 
467  bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
468  }
469 
470  linObjFactory = bloLinObjFactory;
471 
472  // build load balancing string for informative output
473  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
474  }
477  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,panzer::Ordinal64> >(conn_manager,true);
478 
479  // use a blocked DOF manager
480  blockedAssembly = true;
481 
482  TEUCHOS_ASSERT(!use_dofmanager_fei);
484  globalIndexerFactory.setUseDOFManagerFEI(false);
485 
487  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_long,field_order);
488  globalIndexer = dofManager;
489 
492  Teuchos::rcp_dynamic_cast<panzer::BlockedDOFManager<int,panzer::Ordinal64> >(dofManager)));
493 
494  // parse any explicitly excluded pairs or blocks
495  const std::string excludedBlocks = assembly_params.get<std::string>("Excluded Blocks");
496  std::vector<std::string> stringPairs;
497  panzer::StringTokenizer(stringPairs,excludedBlocks,";",true);
498  for(std::size_t i=0;i<stringPairs.size();i++) {
499  std::vector<std::string> sPair;
500  std::vector<int> iPair;
501  panzer::StringTokenizer(sPair,stringPairs[i],",",true);
502  panzer::TokensToInts(iPair,sPair);
503 
504  TEUCHOS_TEST_FOR_EXCEPTION(iPair.size()!=2,std::logic_error,
505  "Input Error: The correct format for \"Excluded Blocks\" parameter in \"Assembly\" sub list is:\n"
506  " <int>,<int>; <int>,<int>; ...; <int>,<int>\n"
507  "Failure on string pair " << stringPairs[i] << "!");
508 
509  bloLinObjFactory->addExcludedPair(iPair[0],iPair[1]);
510  }
511 
512  linObjFactory = bloLinObjFactory;
513 
514  // build load balancing string for informative output
515  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
516  }
517  else if(useTpetra) {
519  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,panzer::Ordinal64> >(conn_manager,true);
520 
521  // use a flat DOF manager
522 
523  TEUCHOS_ASSERT(!use_dofmanager_fei);
525  globalIndexerFactory.setUseDOFManagerFEI(false);
526  globalIndexerFactory.setUseTieBreak(use_load_balance);
528  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_long,field_order);
529  globalIndexer = dofManager;
530 
531  TEUCHOS_ASSERT(!useDiscreteAdjoint); // safety check
533 
534  // build load balancing string for informative output
535  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
536  }
537  else {
538  const bool has_interface_condition = hasInterfaceCondition(bcs);
539  if (has_interface_condition)
540  buildInterfaceConnections(bcs, conn_manager);
541 
542  const Teuchos::RCP<panzer::ConnManager<int,int> > conn_manager_int
543  = Teuchos::rcp_dynamic_cast<panzer::ConnManager<int,int> >(conn_manager,true);
544 
545  // use a flat DOF manager
546  panzer::DOFManagerFactory<int,int> globalIndexerFactory;
547  globalIndexerFactory.setUseDOFManagerFEI(use_dofmanager_fei);
548  globalIndexerFactory.setUseTieBreak(use_load_balance);
549  globalIndexerFactory.setUseNeighbors(has_interface_condition);
551  = globalIndexerFactory.buildUniqueGlobalIndexer(mpi_comm->getRawMpiComm(),physicsBlocks,conn_manager_int,
552  field_order);
553  globalIndexer = dofManager;
554 
555  if (has_interface_condition)
556  checkInterfaceConnections(conn_manager, dofManager->getComm());
557 
558  linObjFactory = Teuchos::rcp(new panzer::BlockedEpetraLinearObjFactory<panzer::Traits,int>(mpi_comm,dofManager,useDiscreteAdjoint));
559 
560  // build load balancing string for informative output
561  loadBalanceString = printUGILoadBalancingInformation(*dofManager);
562  }
563 
564  TEUCHOS_ASSERT(globalIndexer!=Teuchos::null);
565  TEUCHOS_ASSERT(linObjFactory!=Teuchos::null);
566  m_global_indexer = globalIndexer;
567  m_lin_obj_factory = linObjFactory;
568  m_blockedAssembly = blockedAssembly;
569 
570  // print out load balancing information
571  fout << "Degree of freedom load balancing: " << loadBalanceString << std::endl;
572 
573  // build worksets
575 
576  // build up needs array for workset container
577  std::map<std::string,panzer::WorksetNeeds> needs;
578  for(std::size_t i=0;i<physicsBlocks.size();i++)
579  needs[physicsBlocks[i]->elementBlockID()] = physicsBlocks[i]->getWorksetNeeds();
580 
581  Teuchos::RCP<panzer::WorksetContainer> wkstContainer // attach it to a workset container (uses lazy evaluation)
582  = Teuchos::rcp(new panzer::WorksetContainer(wkstFactory,needs));
583 
584  wkstContainer->setWorksetSize(workset_size);
585  wkstContainer->setGlobalIndexer(globalIndexer); // set the global indexer so the orientations are evaluated
586 
587  m_wkstContainer = wkstContainer;
588 
589  // find max number of worksets
590  std::size_t max_wksets = 0;
591  for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
592  const panzer::WorksetDescriptor wd = panzer::blockDescriptor(physicsBlocks[pb]->elementBlockID());
593  Teuchos::RCP< std::vector<panzer::Workset> >works = wkstContainer->getWorksets(wd);
594  max_wksets = std::max(max_wksets,works->size());
595  }
596  user_data_params.set<std::size_t>("Max Worksets",max_wksets);
597  wkstContainer->clear();
598 
599  // Setup lagrangian type coordinates
601 
602  // see if field coordinates are required, if so reset the workset container
603  // and set the coordinates to be associated with a field in the mesh
604  useDynamicCoordinates_ = false;
605  for(std::size_t pb=0;pb<physicsBlocks.size();pb++) {
606  if(physicsBlocks[pb]->getCoordinateDOFs().size()>0) {
607  mesh->setUseFieldCoordinates(true);
608  useDynamicCoordinates_ = true;
609  wkstContainer->clear(); // this serves to refresh the worksets
610  // and put in new coordinates
611  break;
612  }
613  }
614 
615  // Add mesh objects to user data to make available to user ctors
617 
618  panzer_data_params.set("STK Mesh", mesh);
619  panzer_data_params.set("DOF Manager", globalIndexer);
620  panzer_data_params.set("Linear Object Factory", linObjFactory);
621 
622  // If user requested it, short circuit model construction
624 
625  if(!meConstructionOn)
626  return;
627 
628  // Setup active parameters
630 
631  std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names;
632  std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values;
633  if (p.isSublist("Active Parameters")) {
634  Teuchos::ParameterList& active_params = p.sublist("Active Parameters");
635 
636  int num_param_vecs = active_params.get<int>("Number of Parameter Vectors",0);
637  p_names.resize(num_param_vecs);
638  p_values.resize(num_param_vecs);
639  for (int i=0; i<num_param_vecs; i++) {
640  std::stringstream ss;
641  ss << "Parameter Vector " << i;
642  Teuchos::ParameterList& pList = active_params.sublist(ss.str());
643  int numParameters = pList.get<int>("Number");
644  TEUCHOS_TEST_FOR_EXCEPTION(numParameters == 0,
646  std::endl << "Error! panzer::ModelEvaluator::ModelEvaluator(): " <<
647  "Parameter vector " << i << " has zero parameters!" << std::endl);
648  p_names[i] =
649  Teuchos::rcp(new Teuchos::Array<std::string>(numParameters));
650  p_values[i] =
651  Teuchos::rcp(new Teuchos::Array<double>(numParameters));
652  for (int j=0; j<numParameters; j++) {
653  std::stringstream ss2;
654  ss2 << "Parameter " << j;
655  (*p_names[i])[j] = pList.get<std::string>(ss2.str());
656  ss2.str("");
657 
658  ss2 << "Initial Value " << j;
659  (*p_values[i])[j] = pList.get<double>(ss2.str());
660 
661  // this is a band-aid/hack to make sure parameters are registered before they are accessed
662  panzer::registerScalarParameter((*p_names[i])[j],*global_data->pl,(*p_values[i])[j]);
663  }
664  }
665  }
666 
667  // setup the closure model for automatic writing (during residual/jacobian update)
669 
670  panzer_stk::IOClosureModelFactory_TemplateBuilder<panzer::Traits> io_cm_builder(user_cm_factory,mesh,output_list);
672  cm_factory.buildObjects(io_cm_builder);
673 
674  // setup field manager build
676 
678  {
679  bool write_dot_files = p.sublist("Options").get("Write Volume Assembly Graphs",false);
680  std::string dot_file_prefix = p.sublist("Options").get("Volume Assembly Graph Prefix","Panzer_AssemblyGraph");
681  bool write_fm_files = p.sublist("Options").get("Write Field Manager Files",false);
682  std::string fm_file_prefix = p.sublist("Options").get("Field Manager File Prefix","Panzer_AssemblyGraph");
683 
684  fmb = buildFieldManagerBuilder(wkstContainer,physicsBlocks,bcs,*eqset_factory,bc_factory,cm_factory,
685  user_cm_factory,p.sublist("Closure Models"),*linObjFactory,user_data_params,
686  write_dot_files,dot_file_prefix,
687  write_fm_files,fm_file_prefix);
688  }
689 
690  // build response library
692 
693  m_response_library = Teuchos::rcp(new panzer::ResponseLibrary<panzer::Traits>(wkstContainer,globalIndexer,linObjFactory));
694 
695  {
696  bool write_dot_files = false;
697  std::string prefix = "Panzer_ResponseGraph_";
698  write_dot_files = p.sublist("Options").get("Write Volume Response Graphs",write_dot_files);
699  prefix = p.sublist("Options").get("Volume Response Graph Prefix",prefix);
700 
701  Teuchos::ParameterList user_data(p.sublist("User Data"));
702  user_data.set<int>("Workset Size",workset_size);
703  }
704 
705  // Setup solver factory
707 
709  buildLOWSFactory(blockedAssembly,globalIndexer,conn_manager,mesh,mpi_comm);
710 
711  // Setup physics model evaluator
713 
714  double t_init = 0.0;
715  if(is_transient)
716  t_init = this->getInitialTime(p.sublist("Initial Conditions").sublist("Transient Parameters"), *mesh);
717 
718  if(blockedAssembly || useTpetra) // override the user request
719  useThyraME = true;
720 
722  = buildPhysicsModelEvaluator(useThyraME, // blockedAssembly || useTpetra, // this determines if a Thyra or Epetra ME is used
723  fmb,
724  m_response_library,
725  linObjFactory,
726  p_names,
727  p_values,
728  lowsFactory,
729  global_data,
730  is_transient,
731  t_init);
732 
733  // Setup initial conditions
735 
736  {
737  // Create closure model list for use in defining initial conditions
738  // For now just remove Global MMS Parameters, if it exists
739  const Teuchos::ParameterList& models = p.sublist("Closure Models");
740  Teuchos::ParameterList cl_models(models.name());
741  for (Teuchos::ParameterList::ConstIterator model_it=models.begin();
742  model_it!=models.end(); ++model_it) {
743  std::string key = model_it->first;
744  if (model_it->first != "Global MMS Parameters")
745  cl_models.setEntry(key,model_it->second);
746  }
747  bool write_dot_files = false;
748  std::string prefix = "Panzer_AssemblyGraph_";
749  setupInitialConditions(*thyra_me,*wkstContainer,physicsBlocks,user_cm_factory,*linObjFactory,
750  cl_models,
751  p.sublist("Initial Conditions"),
752  p.sublist("User Data"),
753  p.sublist("Options").get("Write Volume Assembly Graphs",write_dot_files),
754  p.sublist("Options").get("Volume Assembly Graph Prefix",prefix));
755  }
756 
757  // Write the IC vector into the STK mesh: use response library
759  writeInitialConditions(*thyra_me,physicsBlocks,wkstContainer,globalIndexer,linObjFactory,mesh,user_cm_factory,
760  p.sublist("Closure Models"),
761  p.sublist("User Data"),workset_size);
762 
763  m_physics_me = thyra_me;
764  }
765 
766  template<typename ScalarT>
769  {
770  // register cell averaged scalar fields
771  const Teuchos::ParameterList & cellAvgQuants = output_list.sublist("Cell Average Quantities");
772  for(Teuchos::ParameterList::ConstIterator itr=cellAvgQuants.begin();
773  itr!=cellAvgQuants.end();++itr) {
774  const std::string & blockId = itr->first;
775  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
776  std::vector<std::string> tokens;
777 
778  // break up comma seperated fields
779  panzer::StringTokenizer(tokens,fields,",",true);
780 
781  for(std::size_t i=0;i<tokens.size();i++)
782  mesh.addCellField(tokens[i],blockId);
783  }
784 
785  // register cell averaged components of vector fields
786  // just allocate space for the fields here. The actual calculation and writing
787  // are done by panzer_stk::ScatterCellAvgVector.
788  const Teuchos::ParameterList & cellAvgVectors = output_list.sublist("Cell Average Vectors");
789  for(Teuchos::ParameterList::ConstIterator itr = cellAvgVectors.begin();
790  itr != cellAvgVectors.end(); ++itr) {
791  const std::string & blockId = itr->first;
792  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
793  std::vector<std::string> tokens;
794 
795  // break up comma seperated fields
796  panzer::StringTokenizer(tokens,fields,",",true);
797 
798  for(std::size_t i = 0; i < tokens.size(); i++) {
799  std::string d_mod[3] = {"X","Y","Z"};
800  for(std::size_t d = 0; d < mesh.getDimension(); d++)
801  mesh.addCellField(tokens[i]+d_mod[d],blockId);
802  }
803  }
804 
805  // register cell quantities
806  const Teuchos::ParameterList & cellQuants = output_list.sublist("Cell Quantities");
807  for(Teuchos::ParameterList::ConstIterator itr=cellQuants.begin();
808  itr!=cellQuants.end();++itr) {
809  const std::string & blockId = itr->first;
810  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
811  std::vector<std::string> tokens;
812 
813  // break up comma seperated fields
814  panzer::StringTokenizer(tokens,fields,",",true);
815 
816  for(std::size_t i=0;i<tokens.size();i++)
817  mesh.addCellField(tokens[i],blockId);
818  }
819 
820  // register ndoal quantities
821  const Teuchos::ParameterList & nodalQuants = output_list.sublist("Nodal Quantities");
822  for(Teuchos::ParameterList::ConstIterator itr=nodalQuants.begin();
823  itr!=nodalQuants.end();++itr) {
824  const std::string & blockId = itr->first;
825  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
826  std::vector<std::string> tokens;
827 
828  // break up comma seperated fields
829  panzer::StringTokenizer(tokens,fields,",",true);
830 
831  for(std::size_t i=0;i<tokens.size();i++)
832  mesh.addSolutionField(tokens[i],blockId);
833  }
834 
835  const Teuchos::ParameterList & allocNodalQuants = output_list.sublist("Allocate Nodal Quantities");
836  for(Teuchos::ParameterList::ConstIterator itr=allocNodalQuants.begin();
837  itr!=allocNodalQuants.end();++itr) {
838  const std::string & blockId = itr->first;
839  const std::string & fields = Teuchos::any_cast<std::string>(itr->second.getAny());
840  std::vector<std::string> tokens;
841 
842  // break up comma seperated fields
843  panzer::StringTokenizer(tokens,fields,",",true);
844 
845  for(std::size_t i=0;i<tokens.size();i++)
846  mesh.addSolutionField(tokens[i],blockId);
847  }
848  }
849 
850  template<typename ScalarT>
853  panzer::WorksetContainer & wkstContainer,
854  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
857  const Teuchos::ParameterList & closure_pl,
858  const Teuchos::ParameterList & initial_cond_pl,
859  const Teuchos::ParameterList & user_data_pl,
860  bool write_dot_files,const std::string & dot_file_prefix) const
861  {
862  using Teuchos::RCP;
863 
864  Thyra::ModelEvaluatorBase::InArgs<double> nomValues = model.getNominalValues();
865  Teuchos::RCP<Thyra::VectorBase<double> > x_vec = Teuchos::rcp_const_cast<Thyra::VectorBase<double> >(nomValues.get_x());
866 
867  if(initial_cond_pl.get<bool>("Zero Initial Conditions")) {
868  // zero out the x vector
869  Thyra::assign(x_vec.ptr(),0.0);
870  }
871  else if(!initial_cond_pl.sublist("Vector File").get<bool>("Enabled")) {
872  // read from exodus, or compute using field managers
873 
874  std::map<std::string, Teuchos::RCP< PHX::FieldManager<panzer::Traits> > > phx_ic_field_managers;
875 
877  physicsBlocks,
878  cm_factory,
879  closure_pl,
880  initial_cond_pl,
881  lof,
882  user_data_pl,
883  write_dot_files,
884  dot_file_prefix,
885  phx_ic_field_managers);
886 /*
887  panzer::setupInitialConditionFieldManagers(wkstContainer,
888  physicsBlocks,
889  cm_factory,
890  initial_cond_pl,
891  lof,
892  user_data_pl,
893  write_dot_files,
894  dot_file_prefix,
895  phx_ic_field_managers);
896 */
897 
898  // set the vector to be filled
901  tloc->set_x_th(x_vec);
902 
903  panzer::evaluateInitialCondition(wkstContainer, phx_ic_field_managers, loc, lof, 0.0);
904  }
905  else {
906  const std::string & vectorFile = initial_cond_pl.sublist("Vector File").get<std::string>("File Name");
907  TEUCHOS_TEST_FOR_EXCEPTION(vectorFile=="",std::runtime_error,
908  "If \"Read From Vector File\" is true, then parameter \"Vector File\" cannot be the empty string.");
909 
910  // set the vector to be filled
913  tloc->set_x_th(x_vec);
914 
915  // read the vector
916  lof.readVector(vectorFile,*loc,panzer::LinearObjContainer::X);
917  }
918  }
919 
920  template<typename ScalarT>
923  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
929  const Teuchos::ParameterList & closure_model_pl,
930  const Teuchos::ParameterList & user_data_pl,
931  int workset_size) const
932  {
933  Teuchos::RCP<panzer::LinearObjContainer> loc = lof->buildLinearObjContainer();
935  tloc->set_x_th(Teuchos::rcp_const_cast<Thyra::VectorBase<double> >(model.getNominalValues().get_x()));
936 
938  = initializeSolnWriterResponseLibrary(wc,ugi,lof,mesh);
939 
940  {
941  Teuchos::ParameterList user_data(user_data_pl);
942  user_data.set<int>("Workset Size",workset_size);
943 
944  finalizeSolnWriterResponseLibrary(*solnWriter,physicsBlocks,cm_factory,closure_model_pl,workset_size,user_data);
945  }
946 
947  // initialize the assembly container
949  ae_inargs.container_ = loc;
950  ae_inargs.ghostedContainer_ = lof->buildGhostedLinearObjContainer();
951  ae_inargs.alpha = 0.0;
952  ae_inargs.beta = 1.0;
953  ae_inargs.evaluate_transient_terms = false;
954 
955  // initialize the ghosted container
956  lof->initializeGhostedContainer(panzer::LinearObjContainer::X,*ae_inargs.ghostedContainer_);
957 
958  // do import
959  lof->globalToGhostContainer(*ae_inargs.container_,*ae_inargs.ghostedContainer_,panzer::LinearObjContainer::X);
960 
961  // fill STK mesh objects
962  solnWriter->addResponsesToInArgs<panzer::Traits::Residual>(ae_inargs);
963  solnWriter->evaluate<panzer::Traits::Residual>(ae_inargs);
964  }
965 
967  template<typename ScalarT>
969  {
971 
972  // first contruct the mesh factory
973  if (mesh_params.get<std::string>("Source") == "Exodus File") {
974  mesh_factory = Teuchos::rcp(new panzer_stk::STK_ExodusReaderFactory());
975  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Exodus File"))));
976  }
977  else if (mesh_params.get<std::string>("Source") == "Pamgen Mesh") {
978  mesh_factory = Teuchos::rcp(new panzer_stk::STK_PamgenReaderFactory());
979  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Pamgen Mesh"))));
980  }
981  else if (mesh_params.get<std::string>("Source") == "Inline Mesh") {
982 
983  int dimension = mesh_params.sublist("Inline Mesh").get<int>("Mesh Dimension");
984  std::string typeStr = "";
985  if(mesh_params.sublist("Inline Mesh").isParameter("Type"))
986  typeStr = mesh_params.sublist("Inline Mesh").get<std::string>("Type");
987 
988  if (dimension == 1) {
989  mesh_factory = Teuchos::rcp(new panzer_stk::LineMeshFactory);
991  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
992  mesh_factory->setParameterList(in_mesh);
993  }
994  else if (dimension == 2 && typeStr=="Tri") {
997  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
998  mesh_factory->setParameterList(in_mesh);
999  }
1000  else if (dimension == 2) {
1001  mesh_factory = Teuchos::rcp(new panzer_stk::SquareQuadMeshFactory);
1003  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1004  mesh_factory->setParameterList(in_mesh);
1005  }
1006  else if (dimension == 3 && typeStr=="Tet") {
1007  mesh_factory = Teuchos::rcp(new panzer_stk::CubeTetMeshFactory);
1009  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1010  mesh_factory->setParameterList(in_mesh);
1011  }
1012  else if(dimension == 3) {
1013  mesh_factory = Teuchos::rcp(new panzer_stk::CubeHexMeshFactory);
1015  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1016  mesh_factory->setParameterList(in_mesh);
1017  }
1018  else if(dimension==4) { // not really "dimension==4" simply a flag to try this other mesh for testing
1019  mesh_factory = Teuchos::rcp(new panzer_stk::MultiBlockMeshFactory);
1021  *in_mesh = mesh_params.sublist("Inline Mesh").sublist("Mesh Factory Parameter List");
1022  mesh_factory->setParameterList(in_mesh);
1023  }
1024  }
1025  else if (mesh_params.get<std::string>("Source") == "Custom Mesh") {
1026  mesh_factory = Teuchos::rcp(new panzer_stk::CustomMeshFactory());
1027  mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(mesh_params.sublist("Custom Mesh"))));
1028  }
1029  else {
1030  // throw a runtime exception for invalid parameter values
1031  }
1032 
1033 
1034  // get rebalancing parameters
1035  if(mesh_params.isSublist("Rebalance")) {
1036  const Teuchos::ParameterList & rebalance = mesh_params.sublist("Rebalance");
1037 
1038  // check to see if its enabled
1039  bool enabled = false;
1040  if(rebalance.isType<bool>("Enabled"))
1041  enabled = rebalance.get<bool>("Enabled");
1042 
1043  // we can also use a list description of what to load balance
1044  Teuchos::RCP<Teuchos::ParameterList> rebalanceCycles;
1045  if(enabled && rebalance.isSublist("Cycles"))
1046  rebalanceCycles = Teuchos::rcp(new Teuchos::ParameterList(rebalance.sublist("Cycles")));
1047 
1048  // setup rebalancing as neccessary
1049  mesh_factory->enableRebalance(enabled,rebalanceCycles);
1050  }
1051 
1052  return mesh_factory;
1053  }
1054 
1055  template<typename ScalarT>
1057  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
1058  const Teuchos::MpiComm<int> mpi_comm,
1059  STK_Interface & mesh) const
1060  {
1061  // finish building mesh, set required field variables and mesh bulk data
1062  {
1063  std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
1064  for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
1065  // what is the block weight for this element block?
1066  double blockWeight = 0.0;
1067 
1069  const std::vector<panzer::StrPureBasisPair> & blockFields = pb->getProvidedDOFs();
1070  const std::vector<std::vector<std::string> > & coordinateDOFs = pb->getCoordinateDOFs();
1071  // these are treated specially
1072 
1073  // insert all fields into a set
1074  std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp> fieldNames;
1075  fieldNames.insert(blockFields.begin(),blockFields.end());
1076 
1077  // Now we will set up the coordinate fields (make sure to remove
1078  // the DOF fields)
1079  {
1080  std::set<std::string> fields_to_remove;
1081 
1082  // add mesh coordinate fields, setup their removal from fieldNames
1083  // set to prevent duplication
1084  for(std::size_t i=0;i<coordinateDOFs.size();i++) {
1085  mesh.addMeshCoordFields(pb->elementBlockID(),coordinateDOFs[i],"DISPL");
1086  for(std::size_t j=0;j<coordinateDOFs[i].size();j++)
1087  fields_to_remove.insert(coordinateDOFs[i][j]);
1088  }
1089 
1090  // remove the already added coordinate fields
1091  std::set<std::string>::const_iterator rmItr;
1092  for (rmItr=fields_to_remove.begin();rmItr!=fields_to_remove.end();++rmItr)
1093  fieldNames.erase(fieldNames.find(panzer::StrPureBasisPair(*rmItr,Teuchos::null)));
1094  }
1095 
1096  // add basis to DOF manager: block specific
1097  std::set<panzer::StrPureBasisPair,panzer::StrPureBasisComp>::const_iterator fieldItr;
1098  for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
1099 
1100  if(fieldItr->second->isScalarBasis() &&
1101  fieldItr->second->getElementSpace()==panzer::PureBasis::CONST) {
1102  mesh.addCellField(fieldItr->first,pb->elementBlockID());
1103  }
1104  else if(fieldItr->second->isScalarBasis()) {
1105  mesh.addSolutionField(fieldItr->first,pb->elementBlockID());
1106  }
1107  else if(fieldItr->second->isVectorBasis()) {
1108  std::string d_mod[3] = {"X","Y","Z"};
1109  for(int d=0;d<fieldItr->second->dimension();d++)
1110  mesh.addCellField(fieldItr->first+d_mod[d],pb->elementBlockID());
1111  }
1112  else { TEUCHOS_ASSERT(false); }
1113 
1114  blockWeight += double(fieldItr->second->cardinality());
1115  }
1116 
1117  // set the compute block weight (this is the sum of the cardinality of all basis
1118  // functions on this block
1119  mesh.setBlockWeight(pb->elementBlockID(),blockWeight);
1120  }
1121 
1122  mesh_factory.completeMeshConstruction(mesh,*(mpi_comm.getRawMpiComm()));
1123  }
1124  }
1125 
1126 
1127  template<typename ScalarT>
1129  {
1130  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(m_physics_me), std::runtime_error,
1131  "Objects are not built yet! Please call buildObjects() member function.");
1132  return m_physics_me;
1133  }
1134 
1135  template<typename ScalarT>
1137  {
1138  m_nox_observer_factory = nox_observer_factory;
1139  }
1140 
1141  template<typename ScalarT>
1143  {
1144  m_rythmos_observer_factory = rythmos_observer_factory;
1145  }
1146 
1147  template<typename ScalarT>
1149  {
1150  m_user_wkst_factory = user_wkst_factory;
1151  }
1152 
1153  template<typename ScalarT>
1155  {
1156  if(m_rome_me==Teuchos::null)
1157  m_rome_me = buildResponseOnlyModelEvaluator(m_physics_me,m_global_data);
1158 
1159  return m_rome_me;
1160  }
1161 
1162  template<typename ScalarT>
1165  const Teuchos::RCP<panzer::GlobalData>& global_data,
1166  const Teuchos::RCP<Piro::RythmosSolver<ScalarT> > rythmosSolver,
1167  const Teuchos::Ptr<const panzer_stk::NOXObserverFactory> & in_nox_observer_factory,
1168  const Teuchos::Ptr<const panzer_stk::RythmosObserverFactory> & in_rythmos_observer_factory
1169  )
1170  {
1171  using Teuchos::is_null;
1172  using Teuchos::Ptr;
1173 
1174  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_lin_obj_factory), std::runtime_error,
1175  "Objects are not built yet! Please call buildObjects() member function.");
1176  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_global_indexer), std::runtime_error,
1177  "Objects are not built yet! Please call buildObjects() member function.");
1178  TEUCHOS_TEST_FOR_EXCEPTION(is_null(m_mesh), std::runtime_error,
1179  "Objects are not built yet! Please call buildObjects() member function.");
1181  = is_null(in_nox_observer_factory) ? m_nox_observer_factory.ptr() : in_nox_observer_factory;
1183  = is_null(in_rythmos_observer_factory) ? m_rythmos_observer_factory.ptr() : in_rythmos_observer_factory;
1184 
1185  Teuchos::ParameterList& p = *this->getNonconstParameterList();
1186  Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
1187  Teuchos::RCP<Teuchos::ParameterList> piro_params = Teuchos::rcp(new Teuchos::ParameterList(solncntl_params));
1189 
1190  std::string solver = solncntl_params.get<std::string>("Piro Solver");
1192  = Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me);
1193  if ( (solver=="NOX") || (solver == "LOCA") ) {
1194 
1195  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(nox_observer_factory), std::runtime_error,
1196  "No NOX obersver built! Please call setNOXObserverFactory() member function if you plan to use a NOX solver.");
1197 
1198  Teuchos::RCP<NOX::Abstract::PrePostOperator> ppo = nox_observer_factory->buildNOXObserver(m_mesh,m_global_indexer,m_lin_obj_factory);
1199  piro_params->sublist("NOX").sublist("Solver Options").set("User Defined Pre/Post Operator", ppo);
1200 
1201  if (solver=="NOX")
1202  piro = Teuchos::rcp(new Piro::NOXSolver<double>(piro_params,
1203  Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db)));
1204  else if (solver == "LOCA")
1205  piro = Teuchos::rcp(new Piro::LOCASolver<double>(piro_params,
1206  Teuchos::rcp_dynamic_cast<Thyra::ModelEvaluatorDefaultBase<double> >(thyra_me_db),
1207  Teuchos::null));
1208  TEUCHOS_ASSERT(nonnull(piro));
1209 
1210  // override printing to use panzer ostream
1211  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Output Stream",global_data->os);
1212  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Error Stream",global_data->os);
1213  piro_params->sublist("NOX").sublist("Printing").set<int>("Output Processor",global_data->os->getOutputToRootOnly());
1214  }
1215  else if (solver=="Rythmos") {
1216 
1217  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(rythmos_observer_factory), std::runtime_error,
1218  "No NOX obersver built! Please call setrythmosObserverFactory() member function if you plan to use a Rythmos solver.");
1219 
1220  // install the nox observer
1221  if(rythmos_observer_factory->useNOXObserver()) {
1222  Teuchos::RCP<NOX::Abstract::PrePostOperator> ppo = nox_observer_factory->buildNOXObserver(m_mesh,m_global_indexer,m_lin_obj_factory);
1223  piro_params->sublist("NOX").sublist("Solver Options").set("User Defined Pre/Post Operator", ppo);
1224  }
1225 
1226  // override printing to use panzer ostream
1227  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Output Stream",global_data->os);
1228  piro_params->sublist("NOX").sublist("Printing").set<Teuchos::RCP<std::ostream> >("Error Stream",global_data->os);
1229  piro_params->sublist("NOX").sublist("Printing").set<int>("Output Processor",global_data->os->getOutputToRootOnly());
1230 
1231  // use the user specfied rythmos solver if they pass one in
1233  if(rythmosSolver==Teuchos::null)
1234  piro_rythmos = Teuchos::rcp(new Piro::RythmosSolver<double>());
1235  else
1236  piro_rythmos = rythmosSolver;
1237 
1238  // if you are using explicit RK, make sure to wrap the ME in an explicit model evaluator decorator
1239  Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > rythmos_me = thyra_me;
1240  const std::string stepper_type = piro_params->sublist("Rythmos").get<std::string>("Stepper Type");
1241  if(stepper_type=="Explicit RK" || stepper_type=="Forward Euler") {
1242  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1243  bool lumpExplicitMass = assembly_params.get<bool>("Lump Explicit Mass");
1244  rythmos_me = Teuchos::rcp(new panzer::ExplicitModelEvaluator<ScalarT>(thyra_me,!useDynamicCoordinates_,lumpExplicitMass));
1245  }
1246 
1247  piro_rythmos->initialize(piro_params, rythmos_me, rythmos_observer_factory->buildRythmosObserver(m_mesh,m_global_indexer,m_lin_obj_factory));
1248 
1249  piro = piro_rythmos;
1250  }
1251  else {
1252  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
1253  "Error: Unknown Piro Solver : " << solver);
1254  }
1255  return piro;
1256  }
1257 
1258  template<typename ScalarT>
1260  {
1261  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(m_response_library), std::runtime_error,
1262  "Objects are not built yet! Please call buildObjects() member function.");
1263 
1264  return m_response_library;
1265  }
1266 
1267  template<typename ScalarT>
1268  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & ModelEvaluatorFactory<ScalarT>::getPhysicsBlocks() const
1269  {
1270  TEUCHOS_TEST_FOR_EXCEPTION(m_physics_blocks.size()==0, std::runtime_error,
1271  "Objects are not built yet! Please call buildObjects() member function.");
1272 
1273  return m_physics_blocks;
1274  }
1275 
1276  template<typename ScalarT>
1280  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
1281  const std::vector<panzer::BC> & bcs,
1282  const panzer::EquationSetFactory & eqset_factory,
1283  const panzer::BCStrategyFactory& bc_factory,
1286  const Teuchos::ParameterList& closure_models,
1287  const panzer::LinearObjFactory<panzer::Traits> & lo_factory,
1288  const Teuchos::ParameterList& user_data,
1289  bool writeGraph,const std::string & graphPrefix,
1290  bool write_field_managers,const std::string & field_manager_prefix) const
1291  {
1293  fmb->setWorksetContainer(wc);
1294  fmb->setupVolumeFieldManagers(physicsBlocks,volume_cm_factory,closure_models,lo_factory,user_data);
1295  fmb->setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,lo_factory,user_data);
1296 
1297  // Print Phalanx DAGs
1298  if (writeGraph){
1299  fmb->writeVolumeGraphvizDependencyFiles(graphPrefix, physicsBlocks);
1300  fmb->writeBCGraphvizDependencyFiles(graphPrefix);
1301  }
1302  if (write_field_managers){
1303  fmb->writeVolumeTextDependencyFiles(graphPrefix, physicsBlocks);
1304  fmb->writeBCTextDependencyFiles(field_manager_prefix);
1305  }
1306 
1307  return fmb;
1308  }
1309 
1310  template<typename ScalarT>
1314  const Teuchos::RCP<Teuchos::ParameterList> & physics_block_plist,
1316  const panzer::BCStrategyFactory & bc_factory,
1318  bool is_transient,bool is_explicit,
1320  const Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > & physics_me_in) const
1321  {
1322  typedef panzer::ModelEvaluator<ScalarT> PanzerME;
1323 
1324  Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > physics_me = physics_me_in==Teuchos::null ? m_physics_me : physics_me_in;
1325 
1326  const Teuchos::ParameterList& p = *this->getParameterList();
1327 
1328  // build PhysicsBlocks
1329  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;
1330  {
1331  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1332 
1333  // setup physical mappings and boundary conditions
1334  std::map<std::string,std::string> block_ids_to_physics_ids;
1335  panzer::buildBlockIdToPhysicsIdMap(block_ids_to_physics_ids, p.sublist("Block ID to Physics ID Mapping"));
1336 
1337  // build cell ( block id -> cell topology ) mapping
1338  std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
1339  for(std::map<std::string,std::string>::const_iterator itr=block_ids_to_physics_ids.begin();
1340  itr!=block_ids_to_physics_ids.end();++itr) {
1341  block_ids_to_cell_topo[itr->first] = m_mesh->getCellTopology(itr->first);
1342  TEUCHOS_ASSERT(block_ids_to_cell_topo[itr->first]!=Teuchos::null);
1343  }
1344 
1345  std::size_t workset_size = Teuchos::as<std::size_t>(assembly_params.get<int>("Workset Size"));
1346 
1347  panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
1348  block_ids_to_cell_topo,
1349  physics_block_plist,
1350  assembly_params.get<int>("Default Integration Order"),
1351  workset_size,
1352  eqset_factory,
1353  m_global_data,
1354  is_transient,
1355  physicsBlocks);
1356  }
1357 
1358  // build FMB
1360  {
1361  const Teuchos::ParameterList & user_data_params = p.sublist("User Data");
1362 
1363  bool write_dot_files = false;
1364  std::string prefix = "Cloned_";
1365 
1366  std::vector<panzer::BC> bcs;
1367  if(bc_list==Teuchos::null) {
1368  panzer::buildBCs(bcs, p.sublist("Boundary Conditions"), m_global_data);
1369  }
1370  else {
1371  panzer::buildBCs(bcs, *bc_list, m_global_data);
1372  }
1373 
1374  fmb = buildFieldManagerBuilder(// Teuchos::rcp_const_cast<panzer::WorksetContainer>(
1375  // m_response_library!=Teuchos::null ? m_response_library->getWorksetContainer()
1376  // : m_wkstContainer),
1377  m_wkstContainer,
1378  physicsBlocks,
1379  bcs,
1380  *eqset_factory,
1381  bc_factory,
1382  user_cm_factory,
1383  user_cm_factory,
1384  p.sublist("Closure Models"),
1385  *m_lin_obj_factory,
1386  user_data_params,
1387  write_dot_files,prefix,
1388  write_dot_files,prefix);
1389  }
1390 
1393  m_global_indexer,
1394  m_lin_obj_factory));
1395  // = Teuchos::rcp(new panzer::ResponseLibrary<panzer::Traits>(m_response_library->getWorksetContainer(),
1396  // m_response_library->getGlobalIndexer(),
1397  // m_response_library->getLinearObjFactory()));
1398 
1399  // using the FMB, build the model evaluator
1400  {
1401  // get nominal input values, make sure they match with internal me
1402  Thyra::ModelEvaluatorBase::InArgs<ScalarT> nomVals = physics_me->getNominalValues();
1403 
1404  // determine if this is a Epetra or Thyra ME
1405  Teuchos::RCP<Thyra::EpetraModelEvaluator> ep_thyra_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(physics_me);
1406  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(physics_me);
1407  bool useThyra = true;
1408  if(ep_thyra_me!=Teuchos::null)
1409  useThyra = false;
1410 
1411  // get parameter names
1412  std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > p_names(physics_me->Np());
1413  std::vector<Teuchos::RCP<Teuchos::Array<double> > > p_values(physics_me->Np());
1414  for(std::size_t i=0;i<p_names.size();i++) {
1415  p_names[i] = Teuchos::rcp(new Teuchos::Array<std::string>(*physics_me->get_p_names(i)));
1416  p_values[i] = Teuchos::rcp(new Teuchos::Array<double>(p_names[i]->size(),0.0));
1417  }
1418 
1420  = buildPhysicsModelEvaluator(useThyra,
1421  fmb,
1422  response_library,
1423  m_lin_obj_factory,
1424  p_names,
1425  p_values,
1426  solverFactory,
1427  m_global_data,
1428  is_transient,
1429  nomVals.get_t());
1430 
1431  // set the nominal values...does this work???
1432  thyra_me->getNominalValues() = nomVals;
1433 
1434  // build an explicit model evaluator
1435  if(is_explicit) {
1436  const Teuchos::ParameterList & assembly_params = p.sublist("Assembly");
1437  bool lumpExplicitMass = assembly_params.get<bool>("Lump Explicit Mass");
1438  thyra_me = Teuchos::rcp(new panzer::ExplicitModelEvaluator<ScalarT>(thyra_me,!useDynamicCoordinates_,lumpExplicitMass));
1439  }
1440 
1441  return thyra_me;
1442  }
1443  }
1444 
1445  template<typename ScalarT>
1452  const std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > & p_names,
1453  const std::vector<Teuchos::RCP<Teuchos::Array<double> > > & p_values,
1455  const Teuchos::RCP<panzer::GlobalData> & global_data,
1456  bool is_transient,double t_init) const
1457  {
1459  if(!buildThyraME) {
1461  = Teuchos::rcp(new panzer::ModelEvaluator_Epetra(fmb,rLibrary,lof, p_names,p_values, global_data, is_transient));
1462 
1463  if (is_transient)
1464  ep_me->set_t_init(t_init);
1465 
1466  // Build Thyra Model Evaluator
1467  thyra_me = Thyra::epetraModelEvaluator(ep_me,solverFactory);
1468  }
1469  else {
1471  (fmb,rLibrary,lof,p_names,p_values,solverFactory,global_data,is_transient,t_init));
1472  }
1473 
1474  return thyra_me;
1475  }
1476 
1477  template<typename ScalarT>
1480  const panzer_stk::STK_Interface & mesh) const
1481  {
1482  Teuchos::ParameterList validPL;
1483  {
1484  Teuchos::setStringToIntegralParameter<int>(
1485  "Start Time Type",
1486  "From Input File",
1487  "Set the start time",
1488  Teuchos::tuple<std::string>("From Input File","From Exodus File"),
1489  &validPL
1490  );
1491 
1492  validPL.set<double>("Start Time",0.0);
1493  }
1494 
1496 
1497  std::string t_init_type = p.get<std::string>("Start Time Type");
1498  double t_init = 10.0;
1499 
1500  if (t_init_type == "From Input File")
1501  t_init = p.get<double>("Start Time");
1502 
1503  if (t_init_type == "From Exodus File")
1504  t_init = mesh.getInitialStateTime();
1505 
1506  return t_init;
1507  }
1508 
1509  // Setup STK response library for writing out the solution fields
1511  template<typename ScalarT>
1516  const Teuchos::RCP<panzer_stk::STK_Interface> & mesh) const
1517  {
1520 
1521  std::vector<std::string> eBlocks;
1522  mesh->getElementBlockNames(eBlocks);
1523 
1525  builder.mesh = mesh;
1526  stkIOResponseLibrary->addResponse("Main Field Output",eBlocks,builder);
1527 
1528  return stkIOResponseLibrary;
1529  }
1530 
1531  template<typename ScalarT>
1534  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
1536  const Teuchos::ParameterList & closure_models,
1537  int workset_size, Teuchos::ParameterList & user_data) const
1538  {
1539  user_data.set<int>("Workset Size",workset_size);
1540  rl.buildResponseEvaluators(physicsBlocks, cm_factory, closure_models, user_data);
1541  }
1542 
1543  template<typename ScalarT>
1545  buildLOWSFactory(bool blockedAssembly,
1547  const Teuchos::RCP<panzer::ConnManagerBase<int> > & conn_manager,
1549  const Teuchos::RCP<const Teuchos::MpiComm<int> > & mpi_comm
1550  #ifdef PANZER_HAVE_TEKO
1551  , const Teuchos::RCP<Teko::RequestHandler> & reqHandler
1552  #endif
1553  ) const
1554  {
1555  const Teuchos::ParameterList & p = *this->getParameterList();
1556  const Teuchos::ParameterList & solncntl_params = p.sublist("Solution Control");
1557 
1558  // Build stratimikos solver (note that this is a hard coded path to linear solver options in nox list!)
1560  = Teuchos::rcp(new Teuchos::ParameterList(solncntl_params.sublist("NOX").sublist("Direction").
1561  sublist("Newton").sublist("Stratimikos Linear Solver").sublist("Stratimikos")));
1562 
1563  bool writeCoordinates = false;
1564  if(p.sublist("Options").isType<bool>("Write Coordinates"))
1565  writeCoordinates = p.sublist("Options").get<bool>("Write Coordinates");
1566 
1567  bool writeTopo = false;
1568  if(p.sublist("Options").isType<bool>("Write Topology"))
1569  writeTopo = p.sublist("Options").get<bool>("Write Topology");
1570 
1571 
1573  blockedAssembly,globalIndexer,conn_manager,
1574  Teuchos::as<int>(mesh->getDimension()), mpi_comm, strat_params,
1575  #ifdef PANZER_HAVE_TEKO
1576  reqHandler,
1577  #endif
1578  writeCoordinates,
1579  writeTopo
1580  );
1581  }
1582 
1583  template<typename ScalarT>
1586  const bool write_graphviz_file,
1587  const std::string& graphviz_file_prefix)
1588  {
1589  typedef panzer::ModelEvaluator<double> PanzerME;
1590 
1591  Teuchos::ParameterList & p = *this->getNonconstParameterList();
1592  Teuchos::ParameterList & user_data = p.sublist("User Data");
1593  Teuchos::ParameterList & closure_models = p.sublist("Closure Models");
1594 
1595  // uninitialize the thyra model evaluator, its respone counts are wrong!
1596  Teuchos::RCP<Thyra::EpetraModelEvaluator> thyra_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(m_physics_me);
1597  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(m_physics_me);
1598 
1599  if(thyra_me!=Teuchos::null && panzer_me==Teuchos::null) {
1602  thyra_me->uninitialize(&const_ep_me,&solveFactory); // this seems dangerous!
1603 
1604  // I don't need no const-ness!
1605  Teuchos::RCP<EpetraExt::ModelEvaluator> ep_me = Teuchos::rcp_const_cast<EpetraExt::ModelEvaluator>(const_ep_me);
1606  Teuchos::RCP<panzer::ModelEvaluator_Epetra> ep_panzer_me = Teuchos::rcp_dynamic_cast<panzer::ModelEvaluator_Epetra>(ep_me);
1607 
1608  ep_panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1609 
1610  // reinitialize the thyra model evaluator, now with the correct responses
1611  thyra_me->initialize(ep_me,solveFactory);
1612 
1613  return;
1614  }
1615  else if(panzer_me!=Teuchos::null && thyra_me==Teuchos::null) {
1616  panzer_me->buildResponses(m_physics_blocks,*m_eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
1617 
1618  return;
1619  }
1620 
1621  TEUCHOS_ASSERT(false);
1622  }
1623 }
1624 
1625 #endif
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, const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &auxGlobalIndexer, bool useCoordinates)
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.
const std::string & name() 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 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()
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 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
#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
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
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_
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
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
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
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< 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
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)
std::string printUGILoadBalancingInformation(const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi)
ConstIterator begin() const
int getOutputToRootOnly() const
void setBlockWeight(const std::string &blockId, double weight)
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.
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 buildResponses(const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
virtual void setMesh(const Teuchos::RCP< const panzer_stk::STK_Interface > &mesh)
const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > & getPhysicsBlocks() const
bool isType(const std::string &name) const
void enableRebalance(bool enable, const Teuchos::RCP< const Teuchos::ParameterList > &rebalanceList=Teuchos::null)
std::pair< std::string, Teuchos::RCP< panzer::PureBasis > > StrPureBasisPair
void finalizeMeshConstruction(const STK_MeshFactory &mesh_factory, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::MpiComm< int > mpi_comm, STK_Interface &mesh) const
void 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.
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)
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
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
bool is_null() const
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