www.mooseframework.org
BoundingBoxIC.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "BoundingBoxIC.h"
16 #include "libmesh/point.h"
17 
18 template <>
21 {
23  params.addRequiredParam<Real>("x1", "The x coordinate of the lower left-hand corner of the box");
24  params.addRequiredParam<Real>("y1", "The y coordinate of the lower left-hand corner of the box");
25  params.addParam<Real>("z1", 0.0, "The z coordinate of the lower left-hand corner of the box");
26 
27  params.addRequiredParam<Real>("x2", "The x coordinate of the upper right-hand corner of the box");
28  params.addRequiredParam<Real>("y2", "The y coordinate of the upper right-hand corner of the box");
29  params.addParam<Real>("z2", 0.0, "The z coordinate of the upper right-hand corner of the box");
30 
31  params.addParam<Real>("inside", 0.0, "The value of the variable inside the box");
32  params.addParam<Real>("outside", 0.0, "The value of the variable outside the box");
33  return params;
34 }
35 
37  : InitialCondition(parameters),
38  _x1(getParam<Real>("x1")),
39  _y1(getParam<Real>("y1")),
40  _z1(getParam<Real>("z1")),
41  _x2(getParam<Real>("x2")),
42  _y2(getParam<Real>("y2")),
43  _z2(getParam<Real>("z2")),
44  _inside(getParam<Real>("inside")),
45  _outside(getParam<Real>("outside")),
46  _bottom_left(_x1, _y1, _z1),
47  _top_right(_x2, _y2, _z2)
48 {
49 }
50 
51 Real
52 BoundingBoxIC::value(const Point & p)
53 {
54  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
55  if (p(i) < _bottom_left(i) || p(i) > _top_right(i))
56  return _outside;
57 
58  return _inside;
59 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual Real value(const Point &p)
The value of the variable at a point.
Definition: BoundingBoxIC.C:52
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
InitialConditions are objects that set the initial value of variables.
InputParameters validParams< BoundingBoxIC >()
Definition: BoundingBoxIC.C:20
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
InputParameters validParams< InitialCondition >()
Point _bottom_left
Definition: BoundingBoxIC.h:78
BoundingBoxIC(const InputParameters &parameters)
Constructor.
Definition: BoundingBoxIC.C:36