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