Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_BC.cpp
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#include "Panzer_BC.hpp"
12#include "Teuchos_Assert.hpp"
13#include "Teuchos_ParameterList.hpp"
14
16
17//=======================================================================
18//=======================================================================
19void
20panzer::buildBCs(std::vector<panzer::BC>& bcs,const Teuchos::ParameterList& p, const Teuchos::RCP<panzer::GlobalData> global_data)
21{
22 using Teuchos::ParameterList;
23
24 bcs.clear();
25
26 // Check for non-backward compatible change
27 TEUCHOS_TEST_FOR_EXCEPTION(p.isParameter("Number of Boundary Conditions"),
28 std::logic_error,
29 "Error - the parameter \"Number of Boundary Conditions\" is no longer valid for the boundary condition sublist. Please remove this from your input file!");
30
31 std::size_t bc_index = 0;
32 for (ParameterList::ConstIterator bc_pl=p.begin(); bc_pl != p.end(); ++bc_pl,++bc_index) {
33 TEUCHOS_TEST_FOR_EXCEPTION( !(bc_pl->second.isList()), std::logic_error,
34 "Error - All objects in the boundary condition sublist must be BC sublists!" );
35 ParameterList& sublist = Teuchos::getValue<Teuchos::ParameterList>(bc_pl->second);
36
37 panzer::BC bc(bc_index,sublist,global_data);
38 bcs.push_back(bc);
39 }
40
41}
42
43//=======================================================================
44//=======================================================================
45panzer::BC::BC(std::size_t bc_id,
46 BCType bc_type,
47 std::string sideset_id,
48 std::string element_block_id,
49 std::string eq_set_name,
50 std::string strategy) :
51 m_bc_id(bc_id),
52 m_bc_type(bc_type),
53 m_sideset_id(sideset_id),
54 m_element_block_id(element_block_id),
55 m_equation_set_name(eq_set_name),
56 m_strategy(strategy)
57{
58}
59
60//=======================================================================
61//=======================================================================
62panzer::BC::BC(std::size_t bc_id,
63 BCType bc_type,
64 std::string sideset_id,
65 std::string element_block_id,
66 std::string eq_set_name,
67 std::string strategy,
68 const Teuchos::ParameterList& p) :
69 m_bc_id(bc_id),
70 m_bc_type(bc_type),
71 m_sideset_id(sideset_id),
72 m_element_block_id(element_block_id),
73 m_equation_set_name(eq_set_name),
74 m_strategy(strategy)
75{
76 m_params = Teuchos::rcp(new Teuchos::ParameterList(""));
77 *m_params = p;
78}
79
80//=======================================================================
81//=======================================================================
82panzer::BC::BC(std::size_t bc_id,const Teuchos::ParameterList& p)
83{
84 Teuchos::RCP<Teuchos::ParameterList> params = Teuchos::parameterList();
85 *params = p;
86
87 this->validateParameters(*params);
88
89 m_bc_id = bc_id;
90 std::string type = params->get<std::string>("Type");
91 if (type == "Dirichlet")
92 m_bc_type = BCT_Dirichlet;
93 else if (type == "Neumann")
94 m_bc_type = BCT_Neumann;
95 else if (type == "Interface")
96 m_bc_type = BCT_Interface;
97
98 m_sideset_id = params->get<std::string>("Sideset ID");
99 m_element_block_id = params->get<std::string>("Element Block ID");
100 m_equation_set_name = params->get<std::string>("Equation Set Name");
101 m_strategy = params->get<std::string>("Strategy");
102 m_params = Teuchos::sublist(params,"Data");
103 if (type == "Interface") {
104 m_element_block_id2 = params->get<std::string>("Element Block ID2");
105 m_equation_set_name2 = params->get<std::string>("Equation Set Name2");
106 }
107}
108
109//=======================================================================
110//=======================================================================
111panzer::BC::BC(std::size_t bc_id,const Teuchos::ParameterList& p, const Teuchos::RCP<panzer::GlobalData> gd)
112{
113 Teuchos::RCP<Teuchos::ParameterList> params = Teuchos::parameterList();
114 *params = p;
115
116 m_gd = gd;
117
118 this->validateParameters(*params);
119
120 m_bc_id = bc_id;
121 std::string type = params->get<std::string>("Type");
122 if (type == "Dirichlet")
123 m_bc_type = BCT_Dirichlet;
124 else if (type == "Neumann")
125 m_bc_type = BCT_Neumann;
126 else if (type == "Interface")
127 m_bc_type = BCT_Interface;
128
129 m_sideset_id = params->get<std::string>("Sideset ID");
130 m_element_block_id = params->get<std::string>("Element Block ID");
131 m_equation_set_name = params->get<std::string>("Equation Set Name");
132 m_strategy = params->get<std::string>("Strategy");
133 m_params = Teuchos::sublist(params,"Data");
134 if (type == "Interface") {
135 m_element_block_id2 = params->get<std::string>("Element Block ID2");
136 m_equation_set_name2 = params->get<std::string>("Equation Set Name2");
137 }
138}
139
140//=======================================================================
141//=======================================================================
144
145//=======================================================================
146//=======================================================================
147std::size_t panzer::BC::bcID() const
148{
149 return m_bc_id;
150}
151
152//=======================================================================
153//=======================================================================
155{
156 return m_bc_type;
157}
158
159//=======================================================================
160//=======================================================================
161std::string panzer::BC::sidesetID() const
162{
163 return m_sideset_id;
164}
165
166//=======================================================================
167//=======================================================================
168std::string panzer::BC::elementBlockID() const
169{
170 return m_element_block_id;
171}
172
173//=======================================================================
174//=======================================================================
176{
177 return m_element_block_id2;
178}
179
180//=======================================================================
181//=======================================================================
183{
184 return m_equation_set_name;
185}
186
187//=======================================================================
188//=======================================================================
190{
191 return m_equation_set_name2;
192}
193
194//=======================================================================
195//=======================================================================
196std::string panzer::BC::strategy() const
197{
198 return m_strategy;
199}
200
201//=======================================================================
202//=======================================================================
203Teuchos::RCP<const Teuchos::ParameterList> panzer::BC::params() const
204{
205 return m_params;
206}
207
208//=======================================================================
209//=======================================================================
210Teuchos::RCP<panzer::GlobalData> panzer::BC::global_data() const
211{
212 return m_gd;
213}
214
215//=======================================================================
216//=======================================================================
217Teuchos::RCP<Teuchos::ParameterList>
219{
220 return m_params;
221}
222
223//=======================================================================
224//=======================================================================
225std::string panzer::BC::identifier() const
226{
227 std::ostringstream os;
228 os << "BC(" << bcID() << ")";
229 return os.str();
230}
231
232//=======================================================================
233//=======================================================================
234void panzer::BC::print(std::ostream& os) const
235{
236 using std::endl;
237
238 os << "panzer::BC" << endl;
239
240 os << " BC ID = " << m_bc_id << endl;
241
242 std::string type;
243 if (m_bc_type == BCT_Dirichlet)
244 type = "Dirichlet";
245 else if (m_bc_type == BCT_Neumann)
246 type = "Neumann";
247 else if (m_bc_type == BCT_Interface)
248 type = "Interface";
249 else
250 type = "Neumann";
251
252 os << " Type = " << type << endl;
253 os << " Identifier = " << identifier() << endl;
254 os << " Side Set ID = " << m_sideset_id << endl;
255 os << " Element Block ID = " << m_element_block_id << endl;
256 if (m_bc_type == BCT_Interface)
257 os << " Second Element Block ID = " << m_element_block_id2 << endl;
258 os << " Strategy = " << m_strategy << endl;
259 os << " Variable Name(s) = " << m_equation_set_name << endl;
260 if (m_bc_type == BCT_Interface)
261 os << " Second Variable Name(s) = " << m_equation_set_name2 << endl;
262 os << " Strategy Name = " << m_strategy;
263
264 if (!Teuchos::is_null(m_params))
265 os << endl << m_params;
266
267}
268
269//=======================================================================
270//=======================================================================
271void panzer::BC::validateParameters(Teuchos::ParameterList& p) const
272{
273 Teuchos::ParameterList valid_params;
274
275 valid_params.set<std::string>("Type", "Dirichlet");
276 valid_params.set<std::string>("Sideset ID", "???");
277 valid_params.set<std::string>("Element Block ID", "???");
278 valid_params.set<std::string>("Element Block ID2", "???");
279 valid_params.set<std::string>("Equation Set Name", "???");
280 valid_params.set<std::string>("Equation Set Name2", "???");
281 valid_params.set<std::string>("Strategy", "???");
282 valid_params.sublist("Data").disableRecursiveValidation();
283
284 p.validateParametersAndSetDefaults(valid_params);
285}
286
287//=======================================================================
288//=======================================================================
289std::ostream&
290panzer::operator<<(std::ostream & os, const panzer::BC& bc)
291{
292 bc.print(os);
293 return os;
294}
295
296//=======================================================================
297//=======================================================================
298
301{
302 if(bc.bcType()==BCT_Interface) {
304
305 return desc;
306 }
307 else {
309
310 return desc;
311 }
312}
Stores input information for a boundary condition.
Definition Panzer_BC.hpp:48
Teuchos::RCP< Teuchos::ParameterList > nonconstParams() const
Returns a nonconst parameter list with user defined parameters for bc. Nonconst is meant to be used f...
std::string sidesetID() const
Returns the set id.
std::size_t bcID() const
Returns a unique identifier for this bc - needed for unique parameter setting in LOCA and for map key...
Teuchos::RCP< const Teuchos::ParameterList > params() const
Returns a parameter list with user defined parameters for bc.
void print(std::ostream &os) const
Print object using an ostream.
BCType bcType() const
Returns the boundary condition type (Dirichlet or Neumann or Interface).
std::string elementBlockID() const
Returns the element block id associated with this sideset.
Teuchos::RCP< panzer::GlobalData > global_data() const
Returns the RCP to the global data.
std::string elementBlockID2() const
Returns the second element block id associated with this sideset.
std::string equationSetName2() const
Returns the second unknown name/keyword.
std::string identifier() const
A unique string identifier for this boundary condition.
void validateParameters(Teuchos::ParameterList &p) const
Teuchos::RCP< Teuchos::ParameterList > m_params
std::string strategy() const
Returns the keyword used to construct a bc strategy.
std::string equationSetName() const
Returns the unknown name/keyword.
BC(std::size_t bc_id, BCType bc_type, std::string sideset_id, std::string element_block_id, std::string equation_set_name, std::string strategy)
Ctor.
Definition Panzer_BC.cpp:45
std::ostream & operator<<(std::ostream &os, const AssemblyEngineInArgs &in)
WorksetDescriptor bcDescriptor(const panzer::BC &bc)
BCType
Type of boundary condition.
Definition Panzer_BC.hpp:41
@ BCT_Dirichlet
Definition Panzer_BC.hpp:42
@ BCT_Neumann
Definition Panzer_BC.hpp:43
@ BCT_Interface
Definition Panzer_BC.hpp:44