Panzer Version of the Day
Loading...
Searching...
No Matches
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
53#include "Teuchos_ParameterList.hpp"
54
55#include "Phalanx_FieldManager.hpp"
56
57#include "PanzerDiscFE_config.hpp"
60
64
70
72
73namespace panzer {
74
75class LinearObjContainer;
76
89template <typename TraitsT>
91public:
92 typedef typename TraitsT::EvalTypes TypeSeq;
93
95
101 ResponseLibrary(const Teuchos::RCP<WorksetContainer> & wc,
102 const Teuchos::RCP<const GlobalIndexer> & ugi,
103 const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof,
104 bool residualType=false);
105
107
110 void initialize(const Teuchos::RCP<WorksetContainer> & wc,
111 const Teuchos::RCP<const GlobalIndexer> & ugi,
112 const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof);
113
119 void initializeResidualType(const Teuchos::RCP<WorksetContainer> & wc,
120 const Teuchos::RCP<const GlobalIndexer> & ugi,
121 const Teuchos::RCP<const LinearObjFactory<TraitsT> > & lof);
122
123
126 void initialize(const ResponseLibrary & rl);
127
133 void copyResponses(const ResponseLibrary & rl);
134
138 Teuchos::RCP<WorksetContainer> getWorksetContainer() const
139 { return wkstContainer_; }
140
142 Teuchos::RCP<const GlobalIndexer> getGlobalIndexer() const
143 { return globalIndexer_; }
144
146 Teuchos::RCP<const LinearObjFactory<TraitsT> > getLinearObjFactory() const
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
274protected:
275
280 const std::vector<Teuchos::RCP<panzer::PhysicsBlock> >& physicsBlocks,
281 const Teuchos::Ptr<const panzer::EquationSetFactory> & eqset_factory,
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,
321 const Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<TraitsT> > & modelFact_tm);
322
323private:
324
325 Teuchos::RCP<WorksetContainer> wkstContainer_;
326 Teuchos::RCP<const GlobalIndexer> globalIndexer_;
327 Teuchos::RCP<const LinearObjFactory<TraitsT> > linObjFactory_;
328
330
331 Teuchos::RCP<FieldManagerBuilder> fmb2_;
333
334 typedef std::unordered_map<panzer::BC,
335 Teuchos::RCP<std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<TraitsT> > > > >,
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
353 mutable Teuchos::RCP<LinearObjContainer> ghostedContainer_;
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
Stores input information for a boundary condition.
Definition: Panzer_BC.hpp:81
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="")
Teuchos::RCP< const GlobalIndexer > getGlobalIndexer() const
Get the internally stored global indexer.
void initialize(const Teuchos::RCP< WorksetContainer > &wc, const Teuchos::RCP< const GlobalIndexer > &ugi, const Teuchos::RCP< const LinearObjFactory< TraitsT > > &lof)
Teuchos::RCP< WorksetContainer > getWorksetContainer() const
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="")
std::unordered_map< panzer::BC, Teuchos::RCP< std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< TraitsT > > > > >, BC::BCHash, BC::BCEquality > BCHashMap
AssemblyEngine_TemplateManager< panzer::Traits > ae_tm2_
void copyResponses(const ResponseLibrary &rl)
void print(std::ostream &os) const
Teuchos::RCP< const LinearObjFactory< TraitsT > > getLinearObjFactory() const
Get the internally stored linear object factory.
void getResponses(std::vector< Teuchos::RCP< ResponseBase > > &responses) const
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< const LinearObjFactory< TraitsT > > linObjFactory_
Teuchos::RCP< ResponseBase > getResponse(const std::string &responseName) const
void addResponse(const std::string &responseName, const std::vector< std::string > &blocks, const ResponseEvaluatorFactory_BuilderT &builder)
TypeAssocMap< panzer::Traits::EvalTypes, Teuchos::RCP< ResponseBase > > Response_TemplateManager
void initializeResidualType(const Teuchos::RCP< WorksetContainer > &wc, const Teuchos::RCP< const GlobalIndexer > &ugi, const Teuchos::RCP< const LinearObjFactory< TraitsT > > &lof)
void evaluate(const panzer::AssemblyEngineInArgs &input_args)
std::unordered_map< std::string, Response_TemplateManager > responseObjects_
Store all the response objects.
Teuchos::RCP< LinearObjContainer > ghostedContainer_
Teuchos::RCP< const GlobalIndexer > globalIndexer_
Teuchos::RCP< WorksetContainer > wkstContainer_
void addResponsesToInArgs(panzer::AssemblyEngineInArgs &input_args) const
Teuchos::RCP< FieldManagerBuilder > fmb2_
void addResidualResponsesToInArgs(Overloader< typename TraitsT::Residual >, panzer::AssemblyEngineInArgs &input_args) const
void useClosureModelByEBlockInResponse(bool value)
std::unordered_map< WorksetDescriptor, std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< TraitsT > > > > > respFactories_
ValueType get() const
Access routine.
Interface for constructing a BCStrategy_TemplateManager.
Allocates and initializes an equation set template manager.
A struct for handling function overloading.
Printer(const Response_TemplateManager &tm, std::ostream &os)
const Response_TemplateManager & tm_