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 //
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_BCSTRATEGY_NEUMANN_DEFAULT_IMPL_IMPL_HPP
44 #define PANZER_BCSTRATEGY_NEUMANN_DEFAULT_IMPL_IMPL_HPP
45 
47 #include "Teuchos_RCP.hpp"
48 #include "Teuchos_Assert.hpp"
49 #include "Phalanx_DataLayout_MDALayout.hpp"
50 #include "Phalanx_FieldManager.hpp"
51 #include "Panzer_PhysicsBlock.hpp"
52 
53 #include "Panzer_PureBasis.hpp"
54 
55 #include "Phalanx_MDField.hpp"
56 #include "Phalanx_DataLayout.hpp"
57 #include "Phalanx_DataLayout_MDALayout.hpp"
58 
59 #include <sstream>
60 
61 // Evaluators
62 #include "Panzer_Neumann_Residual.hpp"
63 
64 #ifdef PANZER_HAVE_EPETRA_STACK
65 #include "Panzer_GatherSolution_Epetra.hpp"
66 #include "Panzer_ScatterResidual_Epetra.hpp"
67 #endif
68 
69 #include "Panzer_Normals.hpp"
70 
71 // ***********************************************************************
72 template <typename EvalT>
75  const Teuchos::RCP<panzer::GlobalData>& global_data) :
76  panzer::BCStrategy<EvalT>(bc),
77  panzer::GlobalDataAcceptorDefaultImpl(global_data)
78 {
79 
80 }
81 
82 // ***********************************************************************
83 template <typename EvalT>
86 {
87 
88 }
89 
90 // ***********************************************************************
91 template <typename EvalT>
94  const panzer::PhysicsBlock& pb,
96  const Teuchos::ParameterList& user_data) const
97 {
98  buildAndRegisterGatherAndOrientationEvaluators(fm,pb,lof,user_data);
99  buildAndRegisterScatterEvaluators(fm,pb,lof,user_data);
100 }
101 
102 // ***********************************************************************
103 template <typename EvalT>
106  const panzer::PhysicsBlock& pb,
108  const Teuchos::ParameterList& user_data) const
109 {
111  using Teuchos::RCP;
112  using Teuchos::rcp;
113  using std::vector;
114  using std::map;
115  using std::string;
116  using std::pair;
117 
118  // Gather
120 
121  // Iterate over each residual contribution
122  for (vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >::const_iterator eq =
123  m_residual_contributions.begin(); eq != m_residual_contributions.end(); ++eq) {
124 
125  const string& residual_name = std::get<0>(*eq);
126  const string& dof_name = std::get<1>(*eq);
127  const string& flux_name = std::get<2>(*eq);
128  //const int& integration_order = std::get<3>(*eq);
129  const RCP<const panzer::PureBasis> basis = std::get<4>(*eq);
130  const RCP<const panzer::IntegrationRule> ir = std::get<5>(*eq);
131 
132  // Normals evaluator
133  {
134  std::stringstream s;
135  s << "Side Normal:" << pb.cellData().side();
136  ParameterList p(s.str());
137  p.set<std::string>("Name","Side Normal");
138  p.set<int>("Side ID",pb.cellData().side());
139  p.set< Teuchos::RCP<panzer::IntegrationRule> >("IR", Teuchos::rcp_const_cast<panzer::IntegrationRule>(ir));
140  p.set<bool>("Normalize",true);
141 
143 
144  this->template registerEvaluator<EvalT>(fm, op);
145  }
146 
147  // Neumann Residual evaluator: residual += phi n dot flux
148  {
149  ParameterList p("Neumann Residual: " + residual_name + " to DOF: " + dof_name);
150  p.set("Residual Name", residual_name);
151  p.set("DOF Name",dof_name);
152  p.set("Flux Name", flux_name);
153  p.set("Normal Name", "Side Normal");
154  p.set("Basis", basis);
155  p.set("IR", ir);
156 
159 
160  this->template registerEvaluator<EvalT>(fm, op);
161  }
162 
163  }
164 }
165 
166 // ***********************************************************************
167 template <typename EvalT>
170  const panzer::PhysicsBlock& /* pb */,
172  const Teuchos::ParameterList& /* user_data */) const
173 {
175  using Teuchos::RCP;
176  using Teuchos::rcp;
177  using std::vector;
178  using std::map;
179  using std::string;
180  using std::pair;
181 
182  // Iterate over each residual contribution
183  for (vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >::const_iterator eq =
184  m_residual_contributions.begin(); eq != m_residual_contributions.end(); ++eq) {
185 
186  const string& residual_name = std::get<0>(*eq);
187  const string& dof_name = std::get<1>(*eq);
188  const RCP<const panzer::PureBasis> basis = std::get<4>(*eq);
189  const RCP<const panzer::IntegrationRule> ir = std::get<5>(*eq);
190 
191  // Scatter evaluator
192  {
193  ParameterList p("Scatter: " + residual_name + " to " + dof_name);
194 
195  // Set name
196  string scatter_field_name = "Dummy Scatter: " + this->m_bc.identifier() + residual_name;
197  p.set("Scatter Name", scatter_field_name);
198  p.set("Basis", basis);
199 
200  RCP<vector<string> > residual_names = rcp(new vector<string>);
201  residual_names->push_back(residual_name);
202  p.set("Dependent Names", residual_names);
203 
204  RCP<map<string,string> > names_map = rcp(new map<string,string>);
205  names_map->insert(std::pair<string,string>(residual_name,dof_name));
206  p.set("Dependent Map", names_map);
207 
209 
210  this->template registerEvaluator<EvalT>(fm, op);
211 
212  // Require variables
213  {
214  using panzer::Dummy;
215  PHX::Tag<typename EvalT::ScalarT> tag(scatter_field_name,
216  rcp(new PHX::MDALayout<Dummy>(0)));
217  fm.template requireField<EvalT>(tag);
218  }
219 
220  } // end of Scatter
221 
222  }
223 }
224 
225 // ***********************************************************************
226 template <typename EvalT>
228 requireDOFGather(const std::string required_dof_name)
229 {
230  m_required_dof_names.push_back(required_dof_name);
231 }
232 
233 // ***********************************************************************
234 template <typename EvalT>
236 addResidualContribution(const std::string residual_name,
237  const std::string dof_name,
238  const std::string flux_name,
239  const int integration_order,
240  const panzer::PhysicsBlock& side_pb)
241 {
242  Teuchos::RCP<panzer::PureBasis> basis = this->getBasis(dof_name,side_pb);
243 
244  Teuchos::RCP<panzer::IntegrationRule> ir = buildIntegrationRule(integration_order,side_pb);
245 
246  m_residual_contributions.push_back(std::make_tuple(residual_name,
247  dof_name,
248  flux_name,
249  integration_order,
250  basis,
251  ir));
252 }
253 
254 // ***********************************************************************
255 template <typename EvalT>
256 const std::vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >
258 {
259  return m_residual_contributions;
260 }
261 
262 // ***********************************************************************
263 template <typename EvalT>
266 getBasis(const std::string dof_name,const panzer::PhysicsBlock& side_pb) const
267 {
268  const std::vector<std::pair<std::string,Teuchos::RCP<panzer::PureBasis> > >& dofBasisPair = side_pb.getProvidedDOFs();
270  for (std::vector<std::pair<std::string,Teuchos::RCP<panzer::PureBasis> > >::const_iterator it =
271  dofBasisPair.begin(); it != dofBasisPair.end(); ++it) {
272  if (it->first == dof_name)
273  basis = it->second;
274  }
275 
276  TEUCHOS_TEST_FOR_EXCEPTION(is_null(basis), std::runtime_error,
277  "Error the name \"" << dof_name
278  << "\" is not a valid DOF for the boundary condition:\n"
279  << this->m_bc << "\n");
280 
281  return basis;
282 }
283 
284 // ***********************************************************************
285 template <typename EvalT>
288 buildIntegrationRule(const int integration_order,const panzer::PhysicsBlock& side_pb) const
289 {
290  TEUCHOS_ASSERT(side_pb.cellData().isSide());
292  return ir;
293 }
294 
295 // ***********************************************************************
296 template <typename EvalT>
297 const panzer::BC
299 {
300  return this->m_bc;
301 }
302 
303 // ***********************************************************************
304 
305 #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:81
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