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 //
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 
44 #ifndef __Panzer_ResponseFactory_BCStrategyAdapter_hpp__
45 #define __Panzer_ResponseFactory_BCStrategyAdapter_hpp__
46 
47 #include <vector>
48 #include <string>
49 #include <tuple>
50 
51 #include "Teuchos_RCP.hpp"
52 
53 #include "Panzer_BCStrategy.hpp"
56 #include "Panzer_Traits.hpp"
57 #include "Panzer_Normals.hpp"
58 
59 #include "Panzer_Traits.hpp"
60 #include "Phalanx_Evaluator_WithBaseImpl.hpp"
61 #include "Phalanx_FieldManager.hpp"
62 #include "Phalanx_MDField.hpp"
63 
64 // This file is used to make a set of ResponseEvaluatorFactory objects look
65 // like BCStrategy objects. It is only being used by the ResponseLibrary and
66 // is primarily there to unify the interface between volumetric response objects
67 // and surface response objects. It is a little bit painful!
68 
69 namespace panzer {
70 namespace response_bc_adapters {
71 
72  // An adapter that turns a ResponseEvaluatorFactory object into a
73  // BCStrategy object.
74  template <typename EvalT>
76  {
77  std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<panzer::Traits> > > > refVec_;
78 
79  public:
80 
82  : panzer::BCStrategy<EvalT>(bc), refVec_(refVec) {}
83 
85 
87 
88 
89  virtual void setup(const panzer::PhysicsBlock& /* side_pb */, const Teuchos::ParameterList& /* user_data */) {}
90 
92  const panzer::PhysicsBlock& side_pb,
94  const Teuchos::ParameterList& models,
95  const Teuchos::ParameterList& user_data) const
96  {
97  side_pb.buildAndRegisterEquationSetEvaluators(fm, user_data);
98  side_pb.buildAndRegisterClosureModelEvaluatorsForType<EvalT>(fm,factory,models,user_data);
99 
100  for(std::size_t i=0;i<refVec_.size();i++) {
101  Teuchos::RCP<const ResponseEvaluatorFactoryBase> respEvalFact = refVec_[i].second->template getAsBase<EvalT>();
102 
103  // only register evaluators if the type is supported
104  if(respEvalFact!=Teuchos::null && respEvalFact->typeSupported())
105  respEvalFact->buildAndRegisterEvaluators(refVec_[i].first,fm,side_pb,user_data);
106  }
107  }
108 
109  virtual void
111  const panzer::PhysicsBlock& /* side_pb */,
112  const LinearObjFactory<panzer::Traits> & /* lof */,
113  const Teuchos::ParameterList& /* user_data */) const {}
114 
115  virtual void
117  const panzer::PhysicsBlock& side_pb,
119  const Teuchos::ParameterList& user_data) const
120  {
121  using Teuchos::RCP;
122  using Teuchos::rcp;
123 
124  side_pb.buildAndRegisterGatherAndOrientationEvaluators(fm,lof,user_data);
125  side_pb.buildAndRegisterDOFProjectionsToIPEvaluators(fm,Teuchos::ptrFromRef(lof),user_data);
126 
127  // add in side normals
128  const std::map<int,Teuchos::RCP<panzer::IntegrationRule> > & int_rules = side_pb.getIntegrationRules();
129  for(std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator itr=int_rules.begin();
130  itr!=int_rules.end();++itr) {
131 
132  std::stringstream s;
133  s << "Side Normal:" << side_pb.cellData().side();
134  Teuchos::ParameterList p(s.str());
135  p.set<std::string>("Name","Side Normal");
136  p.set<int>("Side ID",side_pb.cellData().side());
137  p.set< Teuchos::RCP<panzer::IntegrationRule> >("IR", Teuchos::rcp_const_cast<panzer::IntegrationRule>(itr->second));
138  p.set<bool>("Normalize",true);
139 
141 
142  fm.template registerEvaluator<EvalT>(op);
143  }
144 
145  }
146 
148 
149  private:
150 
151  };
152 
154  public:
155  typedef std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<panzer::Traits> > > > RespFact_TM_Vector;
156  const BC & bc_;
158 
160  : bc_(bc), vec_(vec) {}
161 
162  template <typename EvalT>
165  };
166 
168  public:
169  typedef std::vector<std::pair<std::string,Teuchos::RCP<ResponseEvaluatorFactory_TemplateManager<panzer::Traits> > > > RespFact_TM_Vector;
170  typedef std::unordered_map<BC,Teuchos::RCP<RespFact_TM_Vector>,BC::BCHash,BC::BCEquality> BCHashMap;
171 
172  BCFactoryResponse(const BCHashMap & hashMap)
173  : hashMap_(hashMap) {}
174 
176  buildBCStrategy(const panzer::BC& bc, const Teuchos::RCP<panzer::GlobalData>& /* global_data */) const
177  {
180 
181  BCHashMap::const_iterator itr = hashMap_.find(bc);
182  TEUCHOS_ASSERT(itr!=hashMap_.end());
183 
184  BCStrategy_TM_ResponseAdapterBuilder builder(bc,*itr->second);
185  bcstrategy_tm->buildObjects(builder);
186 
187  return bcstrategy_tm;
188  }
189 
190  private:
192  };
193 
194 
195 } // response_bc_adapters
196 } // end panzer
197 
198 #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
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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
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:81
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