www.mooseframework.org
RndBoundingBoxIC.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "RndBoundingBoxIC.h"
8 #include "MooseRandom.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<InitialCondition>();
15  params.addClassDescription(
16  "Random noise with different min/max inside/outside of a bounding box");
17 
18  params.addRequiredParam<Real>("x1", "The x coordinate of the lower left-hand corner of the box");
19  params.addRequiredParam<Real>("y1", "The y coordinate of the lower left-hand corner of the box");
20  params.addParam<Real>("z1", 0.0, "The z coordinate of the lower left-hand corner of the box");
21 
22  params.addRequiredParam<Real>("x2", "The x coordinate of the upper right-hand corner of the box");
23  params.addRequiredParam<Real>("y2", "The y coordinate of the upper right-hand corner of the box");
24  params.addParam<Real>("z2", 0.0, "The z coordinate of the upper right-hand corner of the box");
25 
26  params.addRequiredParam<Real>("mx_invalue", "The max value of the variable invalue the box");
27  params.addRequiredParam<Real>("mx_outvalue", "The max value of the variable outvalue the box");
28 
29  params.addParam<Real>("mn_invalue", 0.0, "The min value of the variable invalue the box");
30  params.addParam<Real>("mn_outvalue", 0.0, "The min value of the variable outvalue the box");
31  return params;
32 }
33 
34 RndBoundingBoxIC::RndBoundingBoxIC(const InputParameters & parameters)
35  : InitialCondition(parameters),
36  _x1(parameters.get<Real>("x1")),
37  _y1(parameters.get<Real>("y1")),
38  _z1(parameters.get<Real>("z1")),
39  _x2(parameters.get<Real>("x2")),
40  _y2(parameters.get<Real>("y2")),
41  _z2(parameters.get<Real>("z2")),
42  _mx_invalue(parameters.get<Real>("mx_invalue")),
43  _mx_outvalue(parameters.get<Real>("mx_outvalue")),
44  _mn_invalue(parameters.get<Real>("mn_invalue")),
45  _mn_outvalue(parameters.get<Real>("mn_outvalue")),
46  _range_invalue(_mx_invalue - _mn_invalue),
47  _range_outvalue(_mx_outvalue - _mn_outvalue),
48  _bottom_left(_x1, _y1, _z1),
49  _top_right(_x2, _y2, _z2)
50 {
51  mooseAssert(_range_invalue >= 0.0, "Inside Min > Inside Max for RandomIC!");
52  mooseAssert(_range_outvalue >= 0.0, "Outside Min > Outside Max for RandomIC!");
53 }
54 
55 Real
56 RndBoundingBoxIC::value(const Point & p)
57 {
58  // Random number between 0 and 1
59  Real rand_num = MooseRandom::rand();
60 
61  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
62  if (p(i) < _bottom_left(i) || p(i) > _top_right(i))
63  return rand_num * _range_outvalue + _mn_outvalue;
64 
65  return rand_num * _range_invalue + _mn_invalue;
66 }
RndBoundingBoxIC(const InputParameters &parameters)
const Point _top_right
const Real _range_outvalue
const Real _range_invalue
const Point _bottom_left
const Real _mn_invalue
virtual Real value(const Point &p)
const Real _mn_outvalue
InputParameters validParams< RndBoundingBoxIC >()