Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STK_ModelEvaluatorFactory.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef PANZER_STK_MODEL_EVALUATOR_FACTORY_HPP
12 #define PANZER_STK_MODEL_EVALUATOR_FACTORY_HPP
13 
14 #include <iostream>
15 #include <string>
16 #include <map>
17 
18 #include "Teuchos_RCP.hpp"
19 #include "Teuchos_Ptr.hpp"
20 #include "Teuchos_Comm.hpp"
23 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
24 
25 #include "PanzerAdaptersSTK_config.hpp"
26 #include "Panzer_PhysicsBlock.hpp"
28 #include "Panzer_STK_Interface.hpp"
35 
36 #include "Panzer_NodeType.hpp"
37 
38 #ifdef PANZER_HAVE_EPETRA_STACK
40 #include "Thyra_EpetraModelEvaluator.hpp"
41 #endif
42 
43 #ifdef PANZER_HAVE_TEKO
44 #include "Teko_RequestHandler.hpp"
45 #endif
46 
47 namespace Piro {
48 #ifdef PANZER_HAVE_TEMPUS
49  template <typename ScalarT> class TempusSolverForwardOnly;
50 #endif
51 }
52 
53 namespace Thyra {
54  template<typename ScalarT> class ModelEvaluator;
55  template<typename ScalarT> class LinearOpWithSolveFactoryBase;
56 }
57 
58 namespace panzer {
59  struct GlobalData;
60  class GlobalIndexer;
61  template <typename> class LinearObjFactory;
62 
63  class BlockedDOFManager;
64  class DOFManager;
65  class ConnManager;
66 }
67 
68 namespace panzer_stk {
69 
70  class STKConnManager;
71  class NOXObserverFactory;
72 #ifdef PANZER_HAVE_TEMPUS
73  class TempusObserverFactory;
74 #endif
75  class WorksetFactory;
76 
77  template<typename ScalarT>
79 
80  public:
81 
87 
95  void buildObjects(const Teuchos::RCP<const Teuchos::Comm<int> >& comm,
96  const Teuchos::RCP<panzer::GlobalData>& global_data,
98  const panzer::BCStrategyFactory & bc_factory,
100  bool meConstructionOn=true);
101 
103 
106 
108 
109 #ifdef PANZER_HAVE_TEMPUS
110  void setTempusObserverFactory(const Teuchos::RCP<const panzer_stk::TempusObserverFactory>& tempus_observer_factory);
111 #endif
112 
113  template <typename BuilderT>
114  int addResponse(const std::string & responseName,const std::vector<panzer::WorksetDescriptor> & wkstDesc,const BuilderT & builder);
115 
117  const bool write_graphviz_file=false,
118  const std::string& graphviz_file_prefix="");
119 
121 
124  const Teuchos::RCP<panzer::GlobalData>& global_data,
125 #ifdef PANZER_HAVE_TEMPUS
126  const Teuchos::RCP<Piro::TempusSolverForwardOnly<ScalarT> > tempusSolver = Teuchos::null,
127 #endif
128  const Teuchos::Ptr<const panzer_stk::NOXObserverFactory> & in_nox_observer_factory=Teuchos::null
129 #ifdef PANZER_HAVE_TEMPUS
130  , const Teuchos::Ptr<const panzer_stk::TempusObserverFactory> & in_tempus_observer_factory=Teuchos::null
131 #endif
132  );
133 
135 
138 
140 
141  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & getPhysicsBlocks() const;
142 
145  { return m_mesh; }
146 
149  { return m_global_indexer; }
150 
153  { return m_conn_manager; }
154 
156  bool isBlockedAssembly() const
157  { return m_blockedAssembly; }
158 
161  { return m_lin_obj_factory; }
162 
163  bool isTransient() const
164  { return m_is_transient; }
165 
171  const Teuchos::RCP<Teuchos::ParameterList> & physics_block_plist,
173  const panzer::BCStrategyFactory & bc_factory,
175  bool is_transient,bool is_explicit,
176  const Teuchos::Ptr<const Teuchos::ParameterList> & bc_list=Teuchos::null,
177  const Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > & physics_me=Teuchos::null) const;
178 
183  panzer::WorksetContainer & wkstContainer,
184  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
187  const Teuchos::ParameterList & closure_pl,
188  const Teuchos::ParameterList & initial_cond_pl,
189  const Teuchos::ParameterList & user_data_pl,
190  bool write_dot_files,const std::string & dot_file_prefix) const;
191 
196  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
202  const Teuchos::ParameterList & closure_model_pl,
203  const Teuchos::ParameterList & user_data_pl,
204  int workset_size) const;
205 
209  buildPhysicsModelEvaluator(bool buildThyraME,
213  const std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > & p_names,
214  const std::vector<Teuchos::RCP<Teuchos::Array<double> > > & p_values,
216  const Teuchos::RCP<panzer::GlobalData> & global_data,
217  bool is_transient,double t_init) const;
218 
219 
221  { return useDynamicCoordinates_; }
222 
228  double getInitialTime(Teuchos::ParameterList& transient_ic_params,
229  const panzer_stk::STK_Interface& mesh) const;
230 
232  buildLOWSFactory(bool blockedAssembly,
233  const Teuchos::RCP<const panzer::GlobalIndexer> & globalIndexer,
234  const Teuchos::RCP<panzer::ConnManager> & conn_manager,
236  const Teuchos::RCP<const Teuchos::MpiComm<int> > & mpi_comm
237  #ifdef PANZER_HAVE_TEKO
238  , const Teuchos::RCP<Teko::RequestHandler> & req_handler=Teuchos::null
239  #endif
240  ) const;
241 
244  { return m_wkstContainer; }
245 
247  void addUserFieldsToMesh(panzer_stk::STK_Interface & mesh,const Teuchos::ParameterList & output_list) const;
248 
251 
252  void finalizeMeshConstruction(const STK_MeshFactory & mesh_factory,
253  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
254  const Teuchos::MpiComm<int> mpi_comm,
255  STK_Interface & mesh) const;
256 
257  protected:
258 
261  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
262  const std::vector<panzer::BC> & bcs,
263  const panzer::EquationSetFactory & eqset_factory,
264  const panzer::BCStrategyFactory& bc_factory,
267  const Teuchos::ParameterList& closure_models,
268  const panzer::LinearObjFactory<panzer::Traits> & lo_factory,
269  const Teuchos::ParameterList& user_data,
270  bool writeGraph,const std::string & graphPrefix,
271  bool write_field_managers,const std::string & field_manager_prefix) const;
272 
279  const Teuchos::RCP<panzer_stk::STK_Interface> & mesh) const;
280 
284  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
286  const Teuchos::ParameterList & closure_models,
287  int workset_size, Teuchos::ParameterList & user_data) const;
288 
289 
290  private:
291 
294 
296  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > m_physics_blocks;
297 
307 
309 #ifdef PANZER_HAVE_TEMPUS
311 #endif
314 
316  };
317 
318 template<typename ScalarT>
319 template <typename BuilderT>
321 addResponse(const std::string & responseName,const std::vector<panzer::WorksetDescriptor> & wkstDesc,const BuilderT & builder)
322 {
323  typedef panzer::ModelEvaluator<double> PanzerME;
324 
325 #ifdef PANZER_HAVE_EPETRA_STACK
326  Teuchos::RCP<Thyra::EpetraModelEvaluator> thyra_ep_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(m_physics_me);
327  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(m_physics_me);
328 
329  if(thyra_ep_me!=Teuchos::null && panzer_me==Teuchos::null) {
330  // I don't need no const-ness!
331  Teuchos::RCP<EpetraExt::ModelEvaluator> ep_me = Teuchos::rcp_const_cast<EpetraExt::ModelEvaluator>(thyra_ep_me->getEpetraModel());
332  Teuchos::RCP<panzer::ModelEvaluator_Epetra> ep_panzer_me = Teuchos::rcp_dynamic_cast<panzer::ModelEvaluator_Epetra>(ep_me);
333 
334  return ep_panzer_me->addResponse(responseName,wkstDesc,builder);
335  }
336  else if(panzer_me!=Teuchos::null && thyra_ep_me==Teuchos::null) {
337  return panzer_me->addResponse(responseName,wkstDesc,builder);
338  }
339 #else
340  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(m_physics_me);
341  if(panzer_me!=Teuchos::null) {
342  return panzer_me->addResponse(responseName,wkstDesc,builder);
343  }
344 #endif
345 
346  TEUCHOS_ASSERT(false);
347  return -1;
348 }
349 
350 }
351 
352 #endif
Interface for constructing a BCStrategy_TemplateManager.
int addResponse(const std::string &responseName, const std::vector< WorksetDescriptor > &wkst_desc, const ResponseEvaluatorFactory_BuilderT &builder)
Allocates and initializes an equation set template manager.
bool isBlockedAssembly() const
Is blocked assembly?
Teuchos::RCP< panzer::LinearObjFactory< panzer::Traits > > m_lin_obj_factory
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > m_response_library
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > getPhysicsModelEvaluator()
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > m_rome_me
Teuchos::RCP< panzer::GlobalIndexer > m_global_indexer
Teuchos::RCP< panzer::WorksetContainer > getWorksetContainer() const
Get the workset container associated with the mesh database.
Teuchos::RCP< panzer_stk::STK_Interface > m_mesh
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
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
Teuchos::RCP< panzer::ConnManager > m_conn_manager
Teuchos::RCP< STK_MeshFactory > buildSTKMeshFactory(const Teuchos::ParameterList &mesh_params) const
build STK mesh factory from a mesh parameter list
int addResponse(const std::string &responseName, const std::vector< panzer::WorksetDescriptor > &wkstDesc, const BuilderT &builder)
Teuchos::RCP< panzer::WorksetContainer > m_wkstContainer
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
Teuchos::RCP< panzer_stk::WorksetFactory > m_user_wkst_factory
Class that provides access to worksets on each element block and side set.
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > getResponseOnlyModelEvaluator()
Teuchos::RCP< panzer::GlobalData > m_global_data
Teuchos::RCP< Thyra::ModelEvaluator< double > > cloneWithNewPhysicsBlocks(const Teuchos::RCP< Thyra::LinearOpWithSolveFactoryBase< ScalarT > > &solverFactory, const Teuchos::RCP< Teuchos::ParameterList > &physics_block_plist, const Teuchos::RCP< const panzer::EquationSetFactory > &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &user_cm_factory, bool is_transient, bool is_explicit, const Teuchos::Ptr< const Teuchos::ParameterList > &bc_list=Teuchos::null, const Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > &physics_me=Teuchos::null) const
Teuchos::RCP< panzer_stk::STK_Interface > getMesh() const
Get mesh object used to build model evaluator.
Teuchos::RCP< const panzer_stk::NOXObserverFactory > m_nox_observer_factory
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)
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< Thyra::ModelEvaluator< ScalarT > > buildResponseOnlyModelEvaluator(const Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > &thyra_me, const Teuchos::RCP< panzer::GlobalData > &global_data, const Teuchos::Ptr< const panzer_stk::NOXObserverFactory > &in_nox_observer_factory=Teuchos::null)
void buildResponses(const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > & getPhysicsBlocks() const
Teuchos::RCP< Thyra::ModelEvaluator< ScalarT > > m_physics_me
Teuchos::RCP< panzer::LinearObjFactory< panzer::Traits > > getLinearObjFactory() const
Get linear object factory used to build model evaluator.
void finalizeMeshConstruction(const STK_MeshFactory &mesh_factory, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::MpiComm< int > mpi_comm, STK_Interface &mesh) const
void writeInitialConditions(const Thyra::ModelEvaluator< ScalarT > &model, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< panzer::WorksetContainer > &wc, const Teuchos::RCP< const panzer::GlobalIndexer > &ugi, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::RCP< panzer_stk::STK_Interface > &mesh, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_model_pl, const Teuchos::ParameterList &user_data_pl, int workset_size) const
Write the initial conditions to exodus. Note that this is entirely self contained.
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
#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...
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
Teuchos::RCP< panzer::GlobalIndexer > getGlobalIndexer() const
Get global indexer used to build model evaluator.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< const panzer::EquationSetFactory > m_eqset_factory
std::vector< Teuchos::RCP< panzer::PhysicsBlock > > m_physics_blocks
void setUserWorksetFactory(Teuchos::RCP< panzer_stk::WorksetFactory > &user_wkst_factory)
Set user defined workset factory.
Teuchos::RCP< panzer::ConnManager > getConnManager() const
Get connection manager.
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< 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