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