Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_ResponseFactory_BCStrategyAdapter.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_ResponseFactory_BCStrategyAdapter_hpp__
12 #define __Panzer_ResponseFactory_BCStrategyAdapter_hpp__
13 
14 #include <vector>
15 #include <string>
16 #include <tuple>
17 
18 #include "Teuchos_RCP.hpp"
19 
20 #include "Panzer_BCStrategy.hpp"
23 #include "Panzer_Traits.hpp"
24 #include "Panzer_Normals.hpp"
25 
26 #include "Panzer_Traits.hpp"
27 #include "Phalanx_Evaluator_WithBaseImpl.hpp"
28 #include "Phalanx_FieldManager.hpp"
29 #include "Phalanx_MDField.hpp"
30 
31 // This file is used to make a set of ResponseEvaluatorFactory objects look
32 // like BCStrategy objects. It is only being used by the ResponseLibrary and
33 // is primarily there to unify the interface between volumetric response objects
34 // and surface response objects. It is a little bit painful!
35 
36 namespace panzer {
37 namespace response_bc_adapters {
38 
39  // An adapter that turns a ResponseEvaluatorFactory object into a
40  // BCStrategy object.
41  template <typename EvalT>
43  {
44  std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<panzer::Traits> > > > refVec_;
45 
46  public:
47 
49  : panzer::BCStrategy<EvalT>(bc), refVec_(refVec) {}
50 
52 
54 
55 
56  virtual void setup(const panzer::PhysicsBlock& /* side_pb */, const Teuchos::ParameterList& /* user_data */) {}
57 
59  const panzer::PhysicsBlock& side_pb,
61  const Teuchos::ParameterList& models,
62  const Teuchos::ParameterList& user_data) const
63  {
64  side_pb.buildAndRegisterEquationSetEvaluators(fm, user_data);
65  side_pb.buildAndRegisterClosureModelEvaluatorsForType<EvalT>(fm,factory,models,user_data);
66 
67  for(std::size_t i=0;i<refVec_.size();i++) {
68  Teuchos::RCP<const ResponseEvaluatorFactoryBase> respEvalFact = refVec_[i].second->template getAsBase<EvalT>();
69 
70  // only register evaluators if the type is supported
71  if(respEvalFact!=Teuchos::null && respEvalFact->typeSupported())
72  respEvalFact->buildAndRegisterEvaluators(refVec_[i].first,fm,side_pb,user_data);
73  }
74  }
75 
76  virtual void
78  const panzer::PhysicsBlock& /* side_pb */,
79  const LinearObjFactory<panzer::Traits> & /* lof */,
80  const Teuchos::ParameterList& /* user_data */) const {}
81 
82  virtual void
84  const panzer::PhysicsBlock& side_pb,
86  const Teuchos::ParameterList& user_data) const
87  {
88  using Teuchos::RCP;
89  using Teuchos::rcp;
90 
91  side_pb.buildAndRegisterGatherAndOrientationEvaluators(fm,lof,user_data);
92  side_pb.buildAndRegisterDOFProjectionsToIPEvaluators(fm,Teuchos::ptrFromRef(lof),user_data);
93 
94  // add in side normals
95  const std::map<int,Teuchos::RCP<panzer::IntegrationRule> > & int_rules = side_pb.getIntegrationRules();
96  for(std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator itr=int_rules.begin();
97  itr!=int_rules.end();++itr) {
98 
99  std::stringstream s;
100  s << "Side Normal:" << side_pb.cellData().side();
101  Teuchos::ParameterList p(s.str());
102  p.set<std::string>("Name","Side Normal");
103  p.set<int>("Side ID",side_pb.cellData().side());
104  p.set< Teuchos::RCP<panzer::IntegrationRule> >("IR", Teuchos::rcp_const_cast<panzer::IntegrationRule>(itr->second));
105  p.set<bool>("Normalize",true);
106 
108 
109  fm.template registerEvaluator<EvalT>(op);
110  }
111 
112  }
113 
115 
116  private:
117 
118  };
119 
121  public:
122  typedef std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<panzer::Traits> > > > RespFact_TM_Vector;
123  const BC & bc_;
125 
127  : bc_(bc), vec_(vec) {}
128 
129  template <typename EvalT>
132  };
133 
135  public:
136  typedef std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<panzer::Traits> > > > RespFact_TM_Vector;
137  typedef std::unordered_map<BC,Teuchos::RCP<RespFact_TM_Vector>,BC::BCHash,BC::BCEquality> BCHashMap;
138 
139  BCFactoryResponse(const BCHashMap & hashMap)
140  : hashMap_(hashMap) {}
141 
143  buildBCStrategy(const panzer::BC& bc, const Teuchos::RCP<panzer::GlobalData>& /* global_data */) const
144  {
147 
148  BCHashMap::const_iterator itr = hashMap_.find(bc);
149  TEUCHOS_ASSERT(itr!=hashMap_.end());
150 
151  BCStrategy_TM_ResponseAdapterBuilder builder(bc,*itr->second);
152  bcstrategy_tm->buildObjects(builder);
153 
154  return bcstrategy_tm;
155  }
156 
157  private:
159  };
160 
161 
162 } // response_bc_adapters
163 } // end panzer
164 
165 #endif
Interface for constructing a BCStrategy_TemplateManager.
Object that contains information on the physics and discretization of a block of elements with the SA...
virtual void setup(const panzer::PhysicsBlock &, const Teuchos::ParameterList &)
const panzer::CellData & cellData() const
Teuchos::RCP< panzer::BCStrategy_TemplateManager< panzer::Traits > > buildBCStrategy(const panzer::BC &bc, const Teuchos::RCP< panzer::GlobalData > &) const
void buildAndRegisterClosureModelEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const Teuchos::ParameterList &models, const Teuchos::ParameterList &user_data) const
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< panzer::Traits > > > > refVec_
ResponseFactory_BCStrategyAdapter(const panzer::BC &bc, const std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< panzer::Traits > > > > &refVec)
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
void buildAndRegisterDOFProjectionsToIPEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
virtual void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &, const panzer::PhysicsBlock &, const LinearObjFactory< panzer::Traits > &, const Teuchos::ParameterList &) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void buildAndRegisterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const Teuchos::ParameterList &models, const Teuchos::ParameterList &user_data) const
std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< panzer::Traits > > > > RespFact_TM_Vector
const std::map< int, Teuchos::RCP< panzer::IntegrationRule > > & getIntegrationRules() const
Returns the unique set of point rules, key is the unique panzer::PointRule::name() ...
Stores input information for a boundary condition.
Definition: Panzer_BC.hpp:48
std::unordered_map< BC, Teuchos::RCP< RespFact_TM_Vector >, BC::BCHash, BC::BCEquality > BCHashMap
#define TEUCHOS_ASSERT(assertion_test)
std::vector< std::pair< std::string, Teuchos::RCP< ResponseEvaluatorFactory_TemplateManager< panzer::Traits > > > > RespFact_TM_Vector
void buildAndRegisterEquationSetEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
virtual void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const