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