Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_ResponseLibrary.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_ResponseLibrary_hpp__
12 #define __Panzer_ResponseLibrary_hpp__
13 
14 #include <iostream>
15 #include <string>
16 #include <vector>
17 #include <map>
18 
19 #include <unordered_map>
20 
22 
23 #include "Phalanx_FieldManager.hpp"
24 
25 #include "PanzerDiscFE_config.hpp"
26 #include "Panzer_ResponseBase.hpp"
28 
31 #include "Panzer_PhysicsBlock.hpp"
32 
35 #include "Panzer_GlobalIndexer.hpp"
37 #include "Panzer_TypeAssocMap.hpp"
38 
40 
41 namespace panzer {
42 
43 class LinearObjContainer;
44 
57 template <typename TraitsT>
59 public:
60  typedef typename TraitsT::EvalTypes TypeSeq;
61 
63 
71  const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof,
72  bool residualType=false);
73 
74  ResponseLibrary(const ResponseLibrary & rl);
75 
80  const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof);
81 
89  const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof);
90 
91 
94  void initialize(const ResponseLibrary & rl);
95 
101  void copyResponses(const ResponseLibrary & rl);
102 
107  { return wkstContainer_; }
108 
111  { return globalIndexer_; }
112 
115  { return linObjFactory_; }
116 
123  template <typename ResponseEvaluatorFactory_BuilderT>
124  void addResponse(const std::string & responseName,
125  const std::vector<std::string> & blocks,
126  const ResponseEvaluatorFactory_BuilderT & builder);
127 
135  template <typename ResponseEvaluatorFactory_BuilderT>
136  void addResponse(const std::string & responseName,
137  const std::vector<std::pair<std::string,std::string> > & sideset_blocks,
138  const ResponseEvaluatorFactory_BuilderT & builder);
139 
148  template <typename ResponseEvaluatorFactory_BuilderT>
149  void addResponse(const std::string & responseName,
150  const std::vector<WorksetDescriptor> & wkst_desc,
151  const ResponseEvaluatorFactory_BuilderT & builder);
152 
160  template <typename EvalT>
161  Teuchos::RCP<ResponseBase> getResponse(const std::string & responseName) const;
162 
168  template <typename EvalT>
169  void getResponses(std::vector<Teuchos::RCP<ResponseBase> > & responses) const;
170 
175  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
177  const Teuchos::ParameterList& closure_models,
178  const Teuchos::ParameterList& user_data,
179  const bool write_graphviz_file=false,
180  const std::string& graphviz_file_prefix="")
181  { buildResponseEvaluators(physicsBlocks,Teuchos::null,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix); }
182 
187  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
188  const panzer::EquationSetFactory & eqset_factory,
190  const Teuchos::ParameterList& closure_models,
191  const Teuchos::ParameterList& user_data,
192  const bool write_graphviz_file=false,
193  const std::string& graphviz_file_prefix="")
194  { buildResponseEvaluators(physicsBlocks,Teuchos::ptrFromRef(eqset_factory),cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix); }
195 
200  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
201  const panzer::EquationSetFactory & eqset_factory,
202  const std::vector<BC> & bcs,
203  const panzer::BCStrategyFactory & bc_factory,
205  const Teuchos::ParameterList& closure_models,
206  const Teuchos::ParameterList& user_data,
207  const bool write_graphviz_file=false,
208  const std::string& graphviz_file_prefix="");
209 
214  { return responseEvaluatorsBuilt_; }
215 
218  template <typename EvalT>
219  void addResponsesToInArgs(panzer::AssemblyEngineInArgs & input_args) const;
220 
223  template <typename EvalT>
224  void evaluate(const panzer::AssemblyEngineInArgs& input_args);
225 
228  void print(std::ostream & os) const;
229 
231  { closureModelByEBlock_ = value; }
232 
233  void disableGather(bool value)
234  { disableGather_ = value; }
235 
236  void disableScatter(bool value)
237  { disableScatter_ = value; }
238 
239  bool isResidualType() const
240  { return residualType_; }
241 
242 protected:
243 
248  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
251  const Teuchos::ParameterList& closure_models,
252  const Teuchos::ParameterList& user_data,
253  const bool write_graphviz_file,
254  const std::string& graphviz_file_prefix);
255 
258  void addResidualResponse();
259 
261  template <typename EvalT> struct Overloader {};
262 
267 
272 
277 
281 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
283 #endif
284 
287  void addResponse(const std::string & responseName,
288  const std::vector<WorksetDescriptor> & wkst_desc,
290 
291 private:
292 
296 
298 
301 
302  typedef std::unordered_map<panzer::BC,
305 
306  // Store up response factories by element block
307  std::unordered_map<WorksetDescriptor,
308  std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<TraitsT> > > > > respFactories_;
310  std::size_t nextBC_id;
311 
313  std::unordered_map<std::string, Response_TemplateManager> responseObjects_;
318 
320 
322 
323  struct Printer {
325  std::ostream & os_;
326  Printer(const Response_TemplateManager & tm,std::ostream & os) : tm_(tm), os_(os) {}
327  template <typename T> void operator()(T) const {
328 // os_ << PHX::TypeString<T>::value << "=";
329  if(tm_.get<T>()!=Teuchos::null)
330  os_ << "ON ";
331  else
332  os_ << "OFF ";
333  }
334  };
335 };
336 
337 }
338 
340 
341 #endif
Teuchos::RCP< LinearObjContainer > ghostedContainer_
Interface for constructing a BCStrategy_TemplateManager.
void addResponse(const std::string &responseName, const std::vector< std::string > &blocks, const ResponseEvaluatorFactory_BuilderT &builder)
Allocates and initializes an equation set template manager.
void getResponses(std::vector< Teuchos::RCP< ResponseBase > > &responses) const
void addResponsesToInArgs(panzer::AssemblyEngineInArgs &input_args) const
void buildResponseEvaluators(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="")
std::unordered_map< WorksetDescriptor, std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< TraitsT > > > > > respFactories_
Printer(const Response_TemplateManager &tm, std::ostream &os)
const Response_TemplateManager & tm_
Teuchos::RCP< WorksetContainer > getWorksetContainer() const
ValueType get() const
Access routine.
Teuchos::RCP< const LinearObjFactory< TraitsT > > getLinearObjFactory() const
Get the internally stored linear object factory.
void evaluate(const panzer::AssemblyEngineInArgs &input_args)
void buildResidualResponseEvaluators(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::EquationSetFactory &eqset_factory, const std::vector< BC > &bcs, const panzer::BCStrategyFactory &bc_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< FieldManagerBuilder > fmb2_
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="")
void copyResponses(const ResponseLibrary &rl)
Teuchos::RCP< const GlobalIndexer > globalIndexer_
Teuchos::RCP< ResponseBase > getResponse(const std::string &responseName) const
Teuchos::RCP< WorksetContainer > wkstContainer_
TypeAssocMap< panzer::Traits::EvalTypes, Teuchos::RCP< ResponseBase > > Response_TemplateManager
std::unordered_map< std::string, Response_TemplateManager > responseObjects_
Store all the response objects.
std::unordered_map< panzer::BC, Teuchos::RCP< std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< TraitsT > > > > >, BC::BCHash, BC::BCEquality > BCHashMap
void initialize(const Teuchos::RCP< WorksetContainer > &wc, const Teuchos::RCP< const GlobalIndexer > &ugi, const Teuchos::RCP< const LinearObjFactory< TraitsT > > &lof)
void print(std::ostream &os) const
AssemblyEngine_TemplateManager< panzer::Traits > ae_tm2_
void initializeResidualType(const Teuchos::RCP< WorksetContainer > &wc, const Teuchos::RCP< const GlobalIndexer > &ugi, const Teuchos::RCP< const LinearObjFactory< TraitsT > > &lof)
Teuchos::RCP< const LinearObjFactory< TraitsT > > linObjFactory_
Stores input information for a boundary condition.
Definition: Panzer_BC.hpp:48
Teuchos::RCP< const GlobalIndexer > getGlobalIndexer() const
Get the internally stored global indexer.
void addResidualResponsesToInArgs(Overloader< typename TraitsT::Residual >, panzer::AssemblyEngineInArgs &input_args) const
A struct for handling function overloading.
void useClosureModelByEBlockInResponse(bool value)