Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_BCStrategy_Interface_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_INTERFACE_DEFAULT_IMPL_IMPL_HPP
12#define PANZER_BCSTRATEGY_INTERFACE_DEFAULT_IMPL_IMPL_HPP
13
14#include "Teuchos_ParameterList.hpp"
15#include "Teuchos_RCP.hpp"
16#include "Teuchos_Assert.hpp"
17#include "Phalanx_DataLayout_MDALayout.hpp"
18#include "Phalanx_FieldManager.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_Interface_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// ***********************************************************************
40template <typename EvalT>
43 const Teuchos::RCP<panzer::GlobalData>& global_data) :
44 panzer::BCStrategy<EvalT>(bc),
46{
47
48}
49
50// ***********************************************************************
51template <typename EvalT>
57
58// ***********************************************************************
59template <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// ***********************************************************************
71template <typename EvalT>
74 const panzer::PhysicsBlock& pb,
76 const Teuchos::ParameterList& user_data) const
77{
78 using Teuchos::ParameterList;
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
110 RCP< PHX::Evaluator<panzer::Traits> > op = rcp(new panzer::Normals<EvalT,panzer::Traits>(p));
111
112 this->template registerEvaluator<EvalT>(fm, op);
113 }
114
115 // Interface Residual evaluator: residual += phi n dot flux
116 {
117 ParameterList p("Interface 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
125 RCP< PHX::Evaluator<panzer::Traits> > op =
127
128 this->template registerEvaluator<EvalT>(fm, op);
129 }
130
131 }
132}
133
134// ***********************************************************************
135template <typename EvalT>
138 const panzer::PhysicsBlock& /* pb */,
140 const Teuchos::ParameterList& /* user_data */) const
141{
142 using Teuchos::ParameterList;
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
176 RCP< PHX::Evaluator<panzer::Traits> > op = lof.buildScatter<EvalT>(p);
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// ***********************************************************************
194template <typename EvalT>
196requireDOFGather(const std::string required_dof_name)
197{
198 m_required_dof_names.push_back(required_dof_name);
199}
200
201// ***********************************************************************
202template <typename EvalT>
204addResidualContribution(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// ***********************************************************************
223template <typename EvalT>
224const 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// ***********************************************************************
231template <typename EvalT>
232Teuchos::RCP<panzer::PureBasis>
234getBasis(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();
237 Teuchos::RCP<panzer::PureBasis> basis;
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// ***********************************************************************
253template <typename EvalT>
254Teuchos::RCP<panzer::IntegrationRule>
256buildIntegrationRule(const int integration_order,const panzer::PhysicsBlock& side_pb) const
257{
258 TEUCHOS_ASSERT(side_pb.cellData().isSide());
259 Teuchos::RCP<panzer::IntegrationRule> ir = Teuchos::rcp(new panzer::IntegrationRule(integration_order,side_pb.cellData()));
260 return ir;
261}
262
263// ***********************************************************************
264template <typename EvalT>
265const panzer::BC
267{
268 return this->m_bc;
269}
270
271// ***********************************************************************
272
273#endif
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.
virtual void requireDOFGather(const std::string required_dof_name)
Requires that a gather evaluator for the DOF be constructed.
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
virtual void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
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...
virtual void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &side_pb, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
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 an interface condition to a particular equation.
BCStrategy_Interface_DefaultImpl(const panzer::BC &bc, const Teuchos::RCP< panzer::GlobalData > &global_data)
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 interface BC.
Stores input information for a boundary condition.
Definition Panzer_BC.hpp:48
Default implementation for accessing the GlobalData object.
Evaluates an interface BC residual contribution.
Teuchos::RCP< PHX::Evaluator< Traits > > buildScatter(const Teuchos::ParameterList &pl) const
Use preconstructed scatter evaluators.
Object that contains information on the physics and discretization of a block of elements with the SA...
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
const panzer::CellData & cellData() const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const