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 //
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_ResponseLibrary_hpp__
44 #define __Panzer_ResponseLibrary_hpp__
45 
46 #include <iostream>
47 #include <string>
48 #include <vector>
49 #include <map>
50 
51 #include <unordered_map>
52 
54 
55 #include "Phalanx_FieldManager.hpp"
56 
57 #include "PanzerDiscFE_config.hpp"
58 #include "Panzer_ResponseBase.hpp"
60 
63 #include "Panzer_PhysicsBlock.hpp"
64 
69 #include "Panzer_TypeAssocMap.hpp"
70 
72 
73 namespace panzer {
74 
75 class LinearObjContainer;
76 
89 template <typename TraitsT>
91 public:
92  typedef typename TraitsT::EvalTypes TypeSeq;
93 
95 
103  const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof,
104  bool residualType=false);
105 
106  ResponseLibrary(const ResponseLibrary & rl);
107 
112  const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof);
113 
121  const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof);
122 
123 
126  void initialize(const ResponseLibrary & rl);
127 
133  void copyResponses(const ResponseLibrary & rl);
134 
139  { return wkstContainer_; }
140 
143  { return globalIndexer_; }
144 
147  { return linObjFactory_; }
148 
155  template <typename ResponseEvaluatorFactory_BuilderT>
156  void addResponse(const std::string & responseName,
157  const std::vector<std::string> & blocks,
158  const ResponseEvaluatorFactory_BuilderT & builder);
159 
167  template <typename ResponseEvaluatorFactory_BuilderT>
168  void addResponse(const std::string & responseName,
169  const std::vector<std::pair<std::string,std::string> > & sideset_blocks,
170  const ResponseEvaluatorFactory_BuilderT & builder);
171 
180  template <typename ResponseEvaluatorFactory_BuilderT>
181  void addResponse(const std::string & responseName,
182  const std::vector<WorksetDescriptor> & wkst_desc,
183  const ResponseEvaluatorFactory_BuilderT & builder);
184 
192  template <typename EvalT>
193  Teuchos::RCP<ResponseBase> getResponse(const std::string & responseName) const;
194 
200  template <typename EvalT>
201  void getResponses(std::vector<Teuchos::RCP<ResponseBase> > & responses) const;
202 
207  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
209  const Teuchos::ParameterList& closure_models,
210  const Teuchos::ParameterList& user_data,
211  const bool write_graphviz_file=false,
212  const std::string& graphviz_file_prefix="")
213  { buildResponseEvaluators(physicsBlocks,Teuchos::null,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix); }
214 
219  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
220  const panzer::EquationSetFactory & eqset_factory,
222  const Teuchos::ParameterList& closure_models,
223  const Teuchos::ParameterList& user_data,
224  const bool write_graphviz_file=false,
225  const std::string& graphviz_file_prefix="")
226  { buildResponseEvaluators(physicsBlocks,Teuchos::ptrFromRef(eqset_factory),cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix); }
227 
232  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
233  const panzer::EquationSetFactory & eqset_factory,
234  const std::vector<BC> & bcs,
235  const panzer::BCStrategyFactory & bc_factory,
237  const Teuchos::ParameterList& closure_models,
238  const Teuchos::ParameterList& user_data,
239  const bool write_graphviz_file=false,
240  const std::string& graphviz_file_prefix="");
241 
246  { return responseEvaluatorsBuilt_; }
247 
250  template <typename EvalT>
251  void addResponsesToInArgs(panzer::AssemblyEngineInArgs & input_args) const;
252 
255  template <typename EvalT>
256  void evaluate(const panzer::AssemblyEngineInArgs& input_args);
257 
260  void print(std::ostream & os) const;
261 
263  { closureModelByEBlock_ = value; }
264 
265  void disableGather(bool value)
266  { disableGather_ = value; }
267 
268  void disableScatter(bool value)
269  { disableScatter_ = value; }
270 
271  bool isResidualType() const
272  { return residualType_; }
273 
274 protected:
275 
280  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
283  const Teuchos::ParameterList& closure_models,
284  const Teuchos::ParameterList& user_data,
285  const bool write_graphviz_file,
286  const std::string& graphviz_file_prefix);
287 
290  void addResidualResponse();
291 
293  template <typename EvalT> struct Overloader {};
294 
299 
304 
309 
313 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
315 #endif
316 
319  void addResponse(const std::string & responseName,
320  const std::vector<WorksetDescriptor> & wkst_desc,
322 
323 private:
324 
328 
330 
333 
334  typedef std::unordered_map<panzer::BC,
337 
338  // Store up response factories by element block
339  std::unordered_map<WorksetDescriptor,
340  std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<TraitsT> > > > > respFactories_;
342  std::size_t nextBC_id;
343 
345  std::unordered_map<std::string, Response_TemplateManager> responseObjects_;
350 
352 
354 
355  struct Printer {
357  std::ostream & os_;
358  Printer(const Response_TemplateManager & tm,std::ostream & os) : tm_(tm), os_(os) {}
359  template <typename T> void operator()(T) const {
360 // os_ << PHX::TypeString<T>::value << "=";
361  if(tm_.get<T>()!=Teuchos::null)
362  os_ << "ON ";
363  else
364  os_ << "OFF ";
365  }
366  };
367 };
368 
369 }
370 
372 
373 #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 initializeResidualType(const Teuchos::RCP< WorksetContainer > &wc, const Teuchos::RCP< const UniqueGlobalIndexerBase > &ugi, const Teuchos::RCP< const LinearObjFactory< TraitsT > > &lof)
void initialize(const Teuchos::RCP< WorksetContainer > &wc, const Teuchos::RCP< const UniqueGlobalIndexerBase > &ugi, const Teuchos::RCP< const LinearObjFactory< TraitsT > > &lof)
void getResponses(std::vector< Teuchos::RCP< ResponseBase > > &responses) const
void addResponsesToInArgs(panzer::AssemblyEngineInArgs &input_args) const
Teuchos::RCP< const UniqueGlobalIndexerBase > globalIndexer_
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< ResponseBase > getResponse(const std::string &responseName) const
Teuchos::RCP< WorksetContainer > wkstContainer_
Teuchos::RCP< const UniqueGlobalIndexerBase > getGlobalIndexer() const
Get the internally stored global indexer.
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 print(std::ostream &os) const
AssemblyEngine_TemplateManager< panzer::Traits > ae_tm2_
Teuchos::RCP< const LinearObjFactory< TraitsT > > linObjFactory_
Stores input information for a boundary condition.
Definition: Panzer_BC.hpp:81
void addResidualResponsesToInArgs(Overloader< typename TraitsT::Residual >, panzer::AssemblyEngineInArgs &input_args) const
A struct for handling function overloading.
void useClosureModelByEBlockInResponse(bool value)