Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_BCStrategy_Neumann_DefaultImpl_impl.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_BCSTRATEGY_NEUMANN_DEFAULT_IMPL_IMPL_HPP
12 #define PANZER_BCSTRATEGY_NEUMANN_DEFAULT_IMPL_IMPL_HPP
13 
15 #include "Teuchos_RCP.hpp"
16 #include "Teuchos_Assert.hpp"
17 #include "Phalanx_DataLayout_MDALayout.hpp"
18 #include "Phalanx_FieldManager.hpp"
19 #include "Panzer_PhysicsBlock.hpp"
20 
21 #include "Panzer_PureBasis.hpp"
22 
23 #include "Phalanx_MDField.hpp"
24 #include "Phalanx_DataLayout.hpp"
25 #include "Phalanx_DataLayout_MDALayout.hpp"
26 
27 #include <sstream>
28 
29 // Evaluators
30 #include "Panzer_Neumann_Residual.hpp"
31 
32 #ifdef PANZER_HAVE_EPETRA_STACK
33 #include "Panzer_GatherSolution_Epetra.hpp"
34 #include "Panzer_ScatterResidual_Epetra.hpp"
35 #endif
36 
37 #include "Panzer_Normals.hpp"
38 
39 // ***********************************************************************
40 template <typename EvalT>
43  const Teuchos::RCP<panzer::GlobalData>& global_data) :
44  panzer::BCStrategy<EvalT>(bc),
45  panzer::GlobalDataAcceptorDefaultImpl(global_data)
46 {
47 
48 }
49 
50 // ***********************************************************************
51 template <typename EvalT>
54 {
55 
56 }
57 
58 // ***********************************************************************
59 template <typename EvalT>
62  const panzer::PhysicsBlock& pb,
64  const Teuchos::ParameterList& user_data) const
65 {
66  buildAndRegisterGatherAndOrientationEvaluators(fm,pb,lof,user_data);
67  buildAndRegisterScatterEvaluators(fm,pb,lof,user_data);
68 }
69 
70 // ***********************************************************************
71 template <typename EvalT>
74  const panzer::PhysicsBlock& pb,
76  const Teuchos::ParameterList& user_data) const
77 {
79  using Teuchos::RCP;
80  using Teuchos::rcp;
81  using std::vector;
82  using std::map;
83  using std::string;
84  using std::pair;
85 
86  // Gather
88 
89  // Iterate over each residual contribution
90  for (vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >::const_iterator eq =
91  m_residual_contributions.begin(); eq != m_residual_contributions.end(); ++eq) {
92 
93  const string& residual_name = std::get<0>(*eq);
94  const string& dof_name = std::get<1>(*eq);
95  const string& flux_name = std::get<2>(*eq);
96  //const int& integration_order = std::get<3>(*eq);
97  const RCP<const panzer::PureBasis> basis = std::get<4>(*eq);
98  const RCP<const panzer::IntegrationRule> ir = std::get<5>(*eq);
99 
100  // Normals evaluator
101  {
102  std::stringstream s;
103  s << "Side Normal:" << pb.cellData().side();
104  ParameterList p(s.str());
105  p.set<std::string>("Name","Side Normal");
106  p.set<int>("Side ID",pb.cellData().side());
107  p.set< Teuchos::RCP<panzer::IntegrationRule> >("IR", Teuchos::rcp_const_cast<panzer::IntegrationRule>(ir));
108  p.set<bool>("Normalize",true);
109 
111 
112  this->template registerEvaluator<EvalT>(fm, op);
113  }
114 
115  // Neumann Residual evaluator: residual += phi n dot flux
116  {
117  ParameterList p("Neumann Residual: " + residual_name + " to DOF: " + dof_name);
118  p.set("Residual Name", residual_name);
119  p.set("DOF Name",dof_name);
120  p.set("Flux Name", flux_name);
121  p.set("Normal Name", "Side Normal");
122  p.set("Basis", basis);
123  p.set("IR", ir);
124 
127 
128  this->template registerEvaluator<EvalT>(fm, op);
129  }
130 
131  }
132 }
133 
134 // ***********************************************************************
135 template <typename EvalT>
138  const panzer::PhysicsBlock& /* pb */,
140  const Teuchos::ParameterList& /* user_data */) const
141 {
143  using Teuchos::RCP;
144  using Teuchos::rcp;
145  using std::vector;
146  using std::map;
147  using std::string;
148  using std::pair;
149 
150  // Iterate over each residual contribution
151  for (vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >::const_iterator eq =
152  m_residual_contributions.begin(); eq != m_residual_contributions.end(); ++eq) {
153 
154  const string& residual_name = std::get<0>(*eq);
155  const string& dof_name = std::get<1>(*eq);
156  const RCP<const panzer::PureBasis> basis = std::get<4>(*eq);
157  const RCP<const panzer::IntegrationRule> ir = std::get<5>(*eq);
158 
159  // Scatter evaluator
160  {
161  ParameterList p("Scatter: " + residual_name + " to " + dof_name);
162 
163  // Set name
164  string scatter_field_name = "Dummy Scatter: " + this->m_bc.identifier() + residual_name;
165  p.set("Scatter Name", scatter_field_name);
166  p.set("Basis", basis);
167 
168  RCP<vector<string> > residual_names = rcp(new vector<string>);
169  residual_names->push_back(residual_name);
170  p.set("Dependent Names", residual_names);
171 
172  RCP<map<string,string> > names_map = rcp(new map<string,string>);
173  names_map->insert(std::pair<string,string>(residual_name,dof_name));
174  p.set("Dependent Map", names_map);
175 
177 
178  this->template registerEvaluator<EvalT>(fm, op);
179 
180  // Require variables
181  {
182  using panzer::Dummy;
183  PHX::Tag<typename EvalT::ScalarT> tag(scatter_field_name,
184  rcp(new PHX::MDALayout<Dummy>(0)));
185  fm.template requireField<EvalT>(tag);
186  }
187 
188  } // end of Scatter
189 
190  }
191 }
192 
193 // ***********************************************************************
194 template <typename EvalT>
196 requireDOFGather(const std::string required_dof_name)
197 {
198  m_required_dof_names.push_back(required_dof_name);
199 }
200 
201 // ***********************************************************************
202 template <typename EvalT>
204 addResidualContribution(const std::string residual_name,
205  const std::string dof_name,
206  const std::string flux_name,
207  const int integration_order,
208  const panzer::PhysicsBlock& side_pb)
209 {
210  Teuchos::RCP<panzer::PureBasis> basis = this->getBasis(dof_name,side_pb);
211 
212  Teuchos::RCP<panzer::IntegrationRule> ir = buildIntegrationRule(integration_order,side_pb);
213 
214  m_residual_contributions.push_back(std::make_tuple(residual_name,
215  dof_name,
216  flux_name,
217  integration_order,
218  basis,
219  ir));
220 }
221 
222 // ***********************************************************************
223 template <typename EvalT>
224 const std::vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >
226 {
227  return m_residual_contributions;
228 }
229 
230 // ***********************************************************************
231 template <typename EvalT>
234 getBasis(const std::string dof_name,const panzer::PhysicsBlock& side_pb) const
235 {
236  const std::vector<std::pair<std::string,Teuchos::RCP<panzer::PureBasis> > >& dofBasisPair = side_pb.getProvidedDOFs();
238  for (std::vector<std::pair<std::string,Teuchos::RCP<panzer::PureBasis> > >::const_iterator it =
239  dofBasisPair.begin(); it != dofBasisPair.end(); ++it) {
240  if (it->first == dof_name)
241  basis = it->second;
242  }
243 
244  TEUCHOS_TEST_FOR_EXCEPTION(is_null(basis), std::runtime_error,
245  "Error the name \"" << dof_name
246  << "\" is not a valid DOF for the boundary condition:\n"
247  << this->m_bc << "\n");
248 
249  return basis;
250 }
251 
252 // ***********************************************************************
253 template <typename EvalT>
256 buildIntegrationRule(const int integration_order,const panzer::PhysicsBlock& side_pb) const
257 {
258  TEUCHOS_ASSERT(side_pb.cellData().isSide());
260  return ir;
261 }
262 
263 // ***********************************************************************
264 template <typename EvalT>
265 const panzer::BC
267 {
268  return this->m_bc;
269 }
270 
271 // ***********************************************************************
272 
273 #endif
BCStrategy_Neumann_DefaultImpl(const panzer::BC &bc, const Teuchos::RCP< panzer::GlobalData > &global_data)
bool is_null(const boost::shared_ptr< T > &p)
virtual void requireDOFGather(const std::string required_dof_name)
Requires that a gather evaluator for the DOF be constructed.
Object that contains information on the physics and discretization of a block of elements with the SA...
virtual void addResidualContribution(const std::string residual_name, const std::string dof_name, const std::string flux_name, const int integration_order, const panzer::PhysicsBlock &side_pb)
Adds a residual contribution for a neumann condition to a particular equation.
Default implementation for accessing the GlobalData object.
const panzer::CellData & cellData() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
Evaluates a Neumann BC residual contribution.
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const panzer::BC bc() const
Returns the boundary condition data for this object.
Teuchos::RCP< panzer::IntegrationRule > buildIntegrationRule(const int integration_order, const panzer::PhysicsBlock &side_pb) const
Allocates and returns the integration rule associated with an integration order and side physics bloc...
const std::vector< std::tuple< std::string, std::string, std::string, int, Teuchos::RCP< panzer::PureBasis >, Teuchos::RCP< panzer::IntegrationRule > > > getResidualContributionData() const
Returns information for the residual contribution integrations associated with this Neumann BC...
virtual void buildAndRegisterGatherScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
Stores input information for a boundary condition.
Definition: Panzer_BC.hpp:48
Teuchos::RCP< PHX::Evaluator< Traits > > buildScatter(const Teuchos::ParameterList &pl) const
Use preconstructed scatter evaluators.
virtual void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< panzer::PureBasis > getBasis(const std::string dof_name, const panzer::PhysicsBlock &side_pb) const
Finds the basis for the corresponding dof_name in the physics block.
bool isSide() const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const