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 //
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_HPP
44 #define PANZER_STK_MODEL_EVALUATOR_FACTORY_HPP
45 
46 #include <iostream>
47 #include <string>
48 #include <map>
49 
50 #include "Teuchos_RCP.hpp"
51 #include "Teuchos_Ptr.hpp"
52 #include "Teuchos_Comm.hpp"
55 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
56 
57 #include "PanzerAdaptersSTK_config.hpp"
58 #include "Panzer_PhysicsBlock.hpp"
60 #include "Panzer_STK_Interface.hpp"
68 
69 #include "Panzer_NodeType.hpp"
70 
71 #include "Thyra_EpetraModelEvaluator.hpp"
72 
73 #ifdef PANZER_HAVE_TEKO
74 #include "Teko_RequestHandler.hpp"
75 #endif
76 
77 namespace Piro {
78  template <typename ScalarT> class RythmosSolver;
79 }
80 
81 namespace Thyra {
82  template<typename ScalarT> class ModelEvaluator;
83  template<typename ScalarT> class LinearOpWithSolveFactoryBase;
84 }
85 
86 namespace panzer {
87  struct GlobalData;
88  class GlobalIndexer;
89  template <typename> class LinearObjFactory;
90 
91  class BlockedDOFManager;
92  class DOFManager;
93  class ConnManager;
94 }
95 
96 namespace panzer_stk {
97 
98  class STKConnManager;
99  class NOXObserverFactory;
100  class RythmosObserverFactory;
101  class WorksetFactory;
102 
103  template<typename ScalarT>
105 
106  public:
107 
113 
122  void buildObjects(const Teuchos::RCP<const Teuchos::Comm<int> >& comm,
123  const Teuchos::RCP<panzer::GlobalData>& global_data,
125  const panzer::BCStrategyFactory & bc_factory,
127  bool meConstructionOn=true);
128 
130 
133 
135 
137 
138  template <typename BuilderT>
139  int addResponse(const std::string & responseName,const std::vector<panzer::WorksetDescriptor> & wkstDesc,const BuilderT & builder);
140 
142  const bool write_graphviz_file=false,
143  const std::string& graphviz_file_prefix="");
144 
146 
149  const Teuchos::RCP<panzer::GlobalData>& global_data,
150  const Teuchos::RCP<Piro::RythmosSolver<ScalarT> > rythmosSolver = Teuchos::null,
151  const Teuchos::Ptr<const panzer_stk::NOXObserverFactory> & in_nox_observer_factory=Teuchos::null,
152  const Teuchos::Ptr<const panzer_stk::RythmosObserverFactory> & in_rythmos_observer_factory=Teuchos::null);
153 
155 
158 
160 
161  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & getPhysicsBlocks() const;
162 
165  { return m_mesh; }
166 
169  { return m_global_indexer; }
170 
173  { return m_conn_manager; }
174 
176  bool isBlockedAssembly() const
177  { return m_blockedAssembly; }
178 
181  { return m_lin_obj_factory; }
182 
183  bool isTransient() const
184  { return m_is_transient; }
185 
191  const Teuchos::RCP<Teuchos::ParameterList> & physics_block_plist,
193  const panzer::BCStrategyFactory & bc_factory,
195  bool is_transient,bool is_explicit,
196  const Teuchos::Ptr<const Teuchos::ParameterList> & bc_list=Teuchos::null,
197  const Teuchos::RCP<Thyra::ModelEvaluator<ScalarT> > & physics_me=Teuchos::null) const;
198 
203  panzer::WorksetContainer & wkstContainer,
204  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
207  const Teuchos::ParameterList & closure_pl,
208  const Teuchos::ParameterList & initial_cond_pl,
209  const Teuchos::ParameterList & user_data_pl,
210  bool write_dot_files,const std::string & dot_file_prefix) const;
211 
216  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
222  const Teuchos::ParameterList & closure_model_pl,
223  const Teuchos::ParameterList & user_data_pl,
224  int workset_size) const;
225 
229  buildPhysicsModelEvaluator(bool buildThyraME,
233  const std::vector<Teuchos::RCP<Teuchos::Array<std::string> > > & p_names,
234  const std::vector<Teuchos::RCP<Teuchos::Array<double> > > & p_values,
236  const Teuchos::RCP<panzer::GlobalData> & global_data,
237  bool is_transient,double t_init) const;
238 
239 
241  { return useDynamicCoordinates_; }
242 
248  double getInitialTime(Teuchos::ParameterList& transient_ic_params,
249  const panzer_stk::STK_Interface& mesh) const;
250 
252  buildLOWSFactory(bool blockedAssembly,
253  const Teuchos::RCP<const panzer::GlobalIndexer> & globalIndexer,
254  const Teuchos::RCP<panzer::ConnManager> & conn_manager,
256  const Teuchos::RCP<const Teuchos::MpiComm<int> > & mpi_comm
257  #ifdef PANZER_HAVE_TEKO
258  , const Teuchos::RCP<Teko::RequestHandler> & req_handler=Teuchos::null
259  #endif
260  ) const;
261 
264  { return m_wkstContainer; }
265 
267  void addUserFieldsToMesh(panzer_stk::STK_Interface & mesh,const Teuchos::ParameterList & output_list) const;
268 
271 
272  void finalizeMeshConstruction(const STK_MeshFactory & mesh_factory,
273  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
274  const Teuchos::MpiComm<int> mpi_comm,
275  STK_Interface & mesh) const;
276 
277  protected:
278 
281  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
282  const std::vector<panzer::BC> & bcs,
283  const panzer::EquationSetFactory & eqset_factory,
284  const panzer::BCStrategyFactory& bc_factory,
287  const Teuchos::ParameterList& closure_models,
288  const panzer::LinearObjFactory<panzer::Traits> & lo_factory,
289  const Teuchos::ParameterList& user_data,
290  bool writeGraph,const std::string & graphPrefix,
291  bool write_field_managers,const std::string & field_manager_prefix) const;
292 
299  const Teuchos::RCP<panzer_stk::STK_Interface> & mesh) const;
300 
304  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
306  const Teuchos::ParameterList & closure_models,
307  int workset_size, Teuchos::ParameterList & user_data) const;
308 
309 
310  private:
311 
314 
316  std::vector<Teuchos::RCP<panzer::PhysicsBlock> > m_physics_blocks;
317 
327 
332 
334  };
335 
336 template<typename ScalarT>
337 template <typename BuilderT>
339 addResponse(const std::string & responseName,const std::vector<panzer::WorksetDescriptor> & wkstDesc,const BuilderT & builder)
340 {
341  typedef panzer::ModelEvaluator<double> PanzerME;
342 
343  Teuchos::RCP<Thyra::EpetraModelEvaluator> thyra_ep_me = Teuchos::rcp_dynamic_cast<Thyra::EpetraModelEvaluator>(m_physics_me);
344  Teuchos::RCP<PanzerME> panzer_me = Teuchos::rcp_dynamic_cast<PanzerME>(m_physics_me);
345 
346  if(thyra_ep_me!=Teuchos::null && panzer_me==Teuchos::null) {
347  // I don't need no const-ness!
348  Teuchos::RCP<EpetraExt::ModelEvaluator> ep_me = Teuchos::rcp_const_cast<EpetraExt::ModelEvaluator>(thyra_ep_me->getEpetraModel());
349  Teuchos::RCP<panzer::ModelEvaluator_Epetra> ep_panzer_me = Teuchos::rcp_dynamic_cast<panzer::ModelEvaluator_Epetra>(ep_me);
350 
351  return ep_panzer_me->addResponse(responseName,wkstDesc,builder);
352  }
353  else if(panzer_me!=Teuchos::null && thyra_ep_me==Teuchos::null) {
354  return panzer_me->addResponse(responseName,wkstDesc,builder);
355  }
356 
357  TEUCHOS_ASSERT(false);
358  return -1;
359 }
360 
361 }
362 
363 #endif
void setRythmosObserverFactory(const Teuchos::RCP< const panzer_stk::RythmosObserverFactory > &rythmos_observer_factory)
Interface for constructing a BCStrategy_TemplateManager.
int addResponse(const std::string &responseName, const std::vector< WorksetDescriptor > &wkst_desc, const ResponseEvaluatorFactory_BuilderT &builder)
Teuchos::RCP< const panzer_stk::RythmosObserverFactory > m_rythmos_observer_factory
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 > > 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)
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.
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