Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_BCStrategy_WeakDirichlet_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_WEAKDIRICHLET_DEFAULT_IMPL_IMPL_HPP
44 #define PANZER_BCSTRATEGY_WEAKDIRICHLET_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_WeakDirichlet_Residual.hpp"
63 #include "Panzer_GatherSolution_Epetra.hpp"
64 #include "Panzer_ScatterResidual_Epetra.hpp"
65 #include "Panzer_Normals.hpp"
66 
67 // ***********************************************************************
68 template <typename EvalT>
71  const Teuchos::RCP<panzer::GlobalData>& global_data) :
72  panzer::BCStrategy<EvalT>(bc),
73  panzer::GlobalDataAcceptorDefaultImpl(global_data)
74 {
75 
76 }
77 
78 // ***********************************************************************
79 template <typename EvalT>
82 {
83 
84 }
85 
86 // ***********************************************************************
87 template <typename EvalT>
90  const panzer::PhysicsBlock& pb,
92  const Teuchos::ParameterList& user_data) const
93 {
94  buildAndRegisterGatherAndOrientationEvaluators(fm,pb,lof,user_data);
95  buildAndRegisterScatterEvaluators(fm,pb,lof,user_data);
96 }
97 
98 // ***********************************************************************
99 template <typename EvalT>
102  const panzer::PhysicsBlock& pb,
104  const Teuchos::ParameterList& user_data) const
105 {
107  using Teuchos::RCP;
108  using Teuchos::rcp;
109  using std::vector;
110  using std::map;
111  using std::string;
112  using std::pair;
113 
114  // Gather
116 
117  // Iterate over each residual contribution
118  for (vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >::const_iterator eq =
119  m_residual_contributions.begin(); eq != m_residual_contributions.end(); ++eq) {
120 
121  const string& residual_name = std::get<0>(*eq);
122  const string& dof_name = std::get<1>(*eq);
123  const string& flux_name = std::get<2>(*eq);
124  //const int& integration_order = std::get<3>(*eq);
125  const RCP<const panzer::PureBasis> basis = std::get<4>(*eq);
126  const RCP<const panzer::IntegrationRule> ir = std::get<5>(*eq);
127 
128  // Normals evaluator
129  {
130  std::stringstream s;
131  s << "Side Normal:" << pb.cellData().side();
132  ParameterList p(s.str());
133  p.set<std::string>("Name","Side Normal");
134  p.set<int>("Side ID",pb.cellData().side());
135  p.set< Teuchos::RCP<panzer::IntegrationRule> >("IR", Teuchos::rcp_const_cast<panzer::IntegrationRule>(ir));
136  p.set<bool>("Normalize",true);
137 
139 
140  this->template registerEvaluator<EvalT>(fm, op);
141  }
142 
143  // Neumann Residual evaluator: residual += phi n dot flux
144  {
145  ParameterList p("Neumann Residual: " + residual_name + " to DOF: " + dof_name);
146  p.set("Residual Name", residual_name);
147  p.set("DOF Name",dof_name);
148  p.set("Flux Name", flux_name);
149  p.set("Normal Name", "Side Normal");
150  p.set("Basis", basis);
151  p.set("IR", ir);
152 
155 
156  this->template registerEvaluator<EvalT>(fm, op);
157  }
158 
159  }
160 }
161 
162 // ***********************************************************************
163 template <typename EvalT>
166  const panzer::PhysicsBlock& /* pb */,
168  const Teuchos::ParameterList& /* user_data */) const
169 {
171  using Teuchos::RCP;
172  using Teuchos::rcp;
173  using std::vector;
174  using std::map;
175  using std::string;
176  using std::pair;
177 
178  // Iterate over each residual contribution
179  for (vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >::const_iterator eq =
180  m_residual_contributions.begin(); eq != m_residual_contributions.end(); ++eq) {
181 
182  const string& residual_name = std::get<0>(*eq);
183  const string& dof_name = std::get<1>(*eq);
184  const RCP<const panzer::PureBasis> basis = std::get<4>(*eq);
185  const RCP<const panzer::IntegrationRule> ir = std::get<5>(*eq);
186 
187  // Scatter evaluator
188  {
189  ParameterList p("Scatter: "+ residual_name + " to " + dof_name);
190 
191  // Set name
192  string scatter_field_name = "Dummy Scatter: " + this->m_bc.identifier() + residual_name;
193  p.set("Scatter Name", scatter_field_name);
194  p.set("Basis", basis);
195 
196  RCP<vector<string> > residual_names = rcp(new vector<string>);
197  residual_names->push_back(residual_name);
198  p.set("Dependent Names", residual_names);
199 
200  RCP<map<string,string> > names_map = rcp(new map<string,string>);
201  names_map->insert(std::pair<string,string>(residual_name,dof_name));
202  p.set("Dependent Map", names_map);
203 
205 
206  this->template registerEvaluator<EvalT>(fm, op);
207 
208  // Require variables
209  {
210  using panzer::Dummy;
211  PHX::Tag<typename EvalT::ScalarT> tag(scatter_field_name,
212  rcp(new PHX::MDALayout<Dummy>(0)));
213  fm.template requireField<EvalT>(tag);
214  }
215 
216  } // end of Scatter
217 
218  }
219 }
220 
221 // ***********************************************************************
222 template <typename EvalT>
224 requireDOFGather(const std::string required_dof_name)
225 {
226  m_required_dof_names.push_back(required_dof_name);
227 }
228 
229 // ***********************************************************************
230 template <typename EvalT>
232 addResidualContribution(const std::string residual_name,
233  const std::string dof_name,
234  const std::string flux_name,
235  const int integration_order,
236  const panzer::PhysicsBlock& side_pb)
237 {
238  Teuchos::RCP<panzer::PureBasis> basis = this->getBasis(dof_name,side_pb);
239 
240  Teuchos::RCP<panzer::IntegrationRule> ir = buildIntegrationRule(integration_order,side_pb);
241 
242  m_residual_contributions.push_back(std::make_tuple(residual_name,
243  dof_name,
244  flux_name,
245  integration_order,
246  basis,
247  ir));
248 }
249 
250 // ***********************************************************************
251 template <typename EvalT>
252 const std::vector<std::tuple<std::string,std::string,std::string,int,Teuchos::RCP<panzer::PureBasis>,Teuchos::RCP<panzer::IntegrationRule> > >
254 {
255  return m_residual_contributions;
256 }
257 
258 // ***********************************************************************
259 template <typename EvalT>
262 getBasis(const std::string dof_name,const panzer::PhysicsBlock& side_pb) const
263 {
264  const std::vector<std::pair<std::string,Teuchos::RCP<panzer::PureBasis> > >& dofBasisPair = side_pb.getProvidedDOFs();
266  for (std::vector<std::pair<std::string,Teuchos::RCP<panzer::PureBasis> > >::const_iterator it =
267  dofBasisPair.begin(); it != dofBasisPair.end(); ++it) {
268  if (it->first == dof_name)
269  basis = it->second;
270  }
271 
272  TEUCHOS_TEST_FOR_EXCEPTION(is_null(basis), std::runtime_error,
273  "Error the name \"" << dof_name
274  << "\" is not a valid DOF for the boundary condition:\n"
275  << this->m_bc << "\n");
276 
277  return basis;
278 }
279 
280 // ***********************************************************************
281 template <typename EvalT>
284 buildIntegrationRule(const int integration_order,const panzer::PhysicsBlock& side_pb) const
285 {
286  TEUCHOS_ASSERT(side_pb.cellData().isSide());
288  return ir;
289 }
290 
291 // ***********************************************************************
292 template <typename EvalT>
293 const panzer::BC
295 {
296  return this->m_bc;
297 }
298 
299 // ***********************************************************************
300 
301 #endif
virtual void requireDOFGather(const std::string required_dof_name)
Requires that a gather evaluator for the DOF be constructed.
bool is_null(const boost::shared_ptr< T > &p)
Object that contains information on the physics and discretization of a block of elements with the SA...
Default implementation for accessing the GlobalData object.
const panzer::CellData & cellData() const
const panzer::BC bc() const
Returns the boundary condition data for this object.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.
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
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
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...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
BCStrategy_WeakDirichlet_DefaultImpl(const panzer::BC &bc, const Teuchos::RCP< panzer::GlobalData > &global_data)
virtual void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
virtual void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const 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.
#define TEUCHOS_ASSERT(assertion_test)
Evaluates a Weak Dirichlet BC residual contribution.
bool isSide() const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const