Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
48 
49 //=======================================================================
50 //=======================================================================
51 void
52 panzer::buildBCs(std::vector<panzer::BC>& bcs,const Teuchos::ParameterList& p, const Teuchos::RCP<panzer::GlobalData> global_data)
53 {
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 //=======================================================================
77 panzer::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 //=======================================================================
94 panzer::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 {
109  *m_params = p;
110 }
111 
112 //=======================================================================
113 //=======================================================================
114 panzer::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 //=======================================================================
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 //=======================================================================
179 std::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 //=======================================================================
193 std::string panzer::BC::sidesetID() const
194 {
195  return m_sideset_id;
196 }
197 
198 //=======================================================================
199 //=======================================================================
200 std::string panzer::BC::elementBlockID() const
201 {
202  return m_element_block_id;
203 }
204 
205 //=======================================================================
206 //=======================================================================
207 std::string panzer::BC::elementBlockID2() const
208 {
209  return m_element_block_id2;
210 }
211 
212 //=======================================================================
213 //=======================================================================
214 std::string panzer::BC::equationSetName() const
215 {
216  return m_equation_set_name;
217 }
218 
219 //=======================================================================
220 //=======================================================================
221 std::string panzer::BC::equationSetName2() const
222 {
223  return m_equation_set_name2;
224 }
225 
226 //=======================================================================
227 //=======================================================================
228 std::string panzer::BC::strategy() const
229 {
230  return m_strategy;
231 }
232 
233 //=======================================================================
234 //=======================================================================
236 {
237  return m_params;
238 }
239 
240 //=======================================================================
241 //=======================================================================
243 {
244  return m_gd;
245 }
246 
247 //=======================================================================
248 //=======================================================================
251 {
252  return m_params;
253 }
254 
255 //=======================================================================
256 //=======================================================================
257 std::string panzer::BC::identifier() const
258 {
259  std::ostringstream os;
260  os << "BC(" << bcID() << ")";
261  return os.str();
262 }
263 
264 //=======================================================================
265 //=======================================================================
266 void 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 << " Side Set ID = " << m_sideset_id << endl;
286  os << " Element Block ID = " << m_element_block_id << endl;
287  if (m_bc_type == BCT_Interface)
288  os << " Second Element Block ID = " << m_element_block_id2 << endl;
289  os << " Strategy = " << m_strategy << endl;
290  os << " Variable Name(s) = " << m_equation_set_name << endl;
291  if (m_bc_type == BCT_Interface)
292  os << " Second Variable Name(s) = " << m_equation_set_name2 << endl;
293  os << " Strategy Name = " << m_strategy;
294 
295  if (!Teuchos::is_null(m_params))
296  os << endl << m_params;
297 
298 }
299 
300 //=======================================================================
301 //=======================================================================
303 {
304  Teuchos::ParameterList valid_params;
305 
306  valid_params.set<std::string>("Type", "Dirichlet");
307  valid_params.set<std::string>("Sideset ID", "???");
308  valid_params.set<std::string>("Element Block ID", "???");
309  valid_params.set<std::string>("Element Block ID2", "???");
310  valid_params.set<std::string>("Equation Set Name", "???");
311  valid_params.set<std::string>("Equation Set Name2", "???");
312  valid_params.set<std::string>("Strategy", "???");
313  valid_params.sublist("Data").disableRecursiveValidation();
314 
315  p.validateParametersAndSetDefaults(valid_params);
316 }
317 
318 //=======================================================================
319 //=======================================================================
320 std::ostream&
321 panzer::operator<<(std::ostream & os, const panzer::BC& bc)
322 {
323  bc.print(os);
324  return os;
325 }
326 
327 //=======================================================================
328 //=======================================================================
329 
332 {
333  if(bc.bcType()==BCT_Interface) {
335 
336  return desc;
337  }
338  else {
340 
341  return desc;
342  }
343 }
ConstIterator end() const
BCType
Type of boundary condition.
Definition: Panzer_BC.hpp:74
ParameterList & disableRecursiveValidation()
~BC()
Dtor.
Definition: Panzer_BC.cpp:174
std::string elementBlockID() const
Returns the element block id associated with this sideset.
Definition: Panzer_BC.cpp:200
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
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:187
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void validateParameters(Teuchos::ParameterList &p) const
Definition: Panzer_BC.cpp:302
bool isParameter(const std::string &name) const
std::string identifier() const
A unique string identifier for this boundary condition.
Definition: Panzer_BC.cpp:257
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
std::string equationSetName2() const
Returns the second unknown name/keyword.
Definition: Panzer_BC.cpp:221
std::string strategy() const
Returns the keyword used to construct a bc strategy.
Definition: Panzer_BC.cpp:228
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
BCType bcType() const
Returns the boundary condition type (Dirichlet or Neumann or Interface).
Definition: Panzer_BC.cpp:186
ConstIterator begin() const
std::string elementBlockID2() const
Returns the second element block id associated with this sideset.
Definition: Panzer_BC.cpp:207
void print(std::ostream &os) const
Print object using an ostream.
Definition: Panzer_BC.cpp:266
std::string equationSetName() const
Returns the unknown name/keyword.
Definition: Panzer_BC.cpp:214
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
std::string sidesetID() const
Returns the set id.
Definition: Panzer_BC.cpp:193
std::ostream & operator<<(std::ostream &os, const AssemblyEngineInArgs &in)
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
WorksetDescriptor bcDescriptor(const panzer::BC &bc)
Definition: Panzer_BC.cpp:331
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
Teuchos::RCP< panzer::GlobalData > global_data() const
Returns the RCP to the global data.
Definition: Panzer_BC.cpp:242