www.mooseframework.org
RndBoundingBoxIC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "RndBoundingBoxIC.h"
11 #include "MooseRandom.h"
12 
13 registerMooseObject("PhaseFieldApp", RndBoundingBoxIC);
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<InitialCondition>();
20  params.addClassDescription(
21  "Random noise with different min/max inside/outside of a bounding box");
22 
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.addRequiredParam<Real>("mx_invalue", "The max value of the variable invalue the box");
32  params.addRequiredParam<Real>("mx_outvalue", "The max value of the variable outvalue the box");
33 
34  params.addParam<Real>("mn_invalue", 0.0, "The min value of the variable invalue the box");
35  params.addParam<Real>("mn_outvalue", 0.0, "The min value of the variable outvalue the box");
36  return params;
37 }
38 
39 RndBoundingBoxIC::RndBoundingBoxIC(const InputParameters & parameters)
40  : InitialCondition(parameters),
41  _x1(parameters.get<Real>("x1")),
42  _y1(parameters.get<Real>("y1")),
43  _z1(parameters.get<Real>("z1")),
44  _x2(parameters.get<Real>("x2")),
45  _y2(parameters.get<Real>("y2")),
46  _z2(parameters.get<Real>("z2")),
47  _mx_invalue(parameters.get<Real>("mx_invalue")),
48  _mx_outvalue(parameters.get<Real>("mx_outvalue")),
49  _mn_invalue(parameters.get<Real>("mn_invalue")),
50  _mn_outvalue(parameters.get<Real>("mn_outvalue")),
51  _range_invalue(_mx_invalue - _mn_invalue),
52  _range_outvalue(_mx_outvalue - _mn_outvalue),
53  _bottom_left(_x1, _y1, _z1),
54  _top_right(_x2, _y2, _z2)
55 {
56  mooseAssert(_range_invalue >= 0.0, "Inside Min > Inside Max for RandomIC!");
57  mooseAssert(_range_outvalue >= 0.0, "Outside Min > Outside Max for RandomIC!");
58 }
59 
60 Real
61 RndBoundingBoxIC::value(const Point & p)
62 {
63  // Random number between 0 and 1
64  Real rand_num = MooseRandom::rand();
65 
66  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
67  if (p(i) < _bottom_left(i) || p(i) > _top_right(i))
68  return rand_num * _range_outvalue + _mn_outvalue;
69 
70  return rand_num * _range_invalue + _mn_invalue;
71 }
validParams< RndBoundingBoxIC >
InputParameters validParams< RndBoundingBoxIC >()
Definition: RndBoundingBoxIC.C:17
registerMooseObject
registerMooseObject("PhaseFieldApp", RndBoundingBoxIC)
RndBoundingBoxIC::_mn_invalue
const Real _mn_invalue
Definition: RndBoundingBoxIC.h:49
RndBoundingBoxIC::value
virtual Real value(const Point &p)
Definition: RndBoundingBoxIC.C:61
RndBoundingBoxIC::_mn_outvalue
const Real _mn_outvalue
Definition: RndBoundingBoxIC.h:50
RndBoundingBoxIC::RndBoundingBoxIC
RndBoundingBoxIC(const InputParameters &parameters)
Definition: RndBoundingBoxIC.C:39
RndBoundingBoxIC::_range_outvalue
const Real _range_outvalue
Definition: RndBoundingBoxIC.h:52
RndBoundingBoxIC::_top_right
const Point _top_right
Definition: RndBoundingBoxIC.h:55
RndBoundingBoxIC.h
RndBoundingBoxIC
RndBoundingBoxIC allows setting the initial condition of a value inside and outside of a specified bo...
Definition: RndBoundingBoxIC.h:33
RndBoundingBoxIC::_range_invalue
const Real _range_invalue
Definition: RndBoundingBoxIC.h:51
RndBoundingBoxIC::_bottom_left
const Point _bottom_left
Definition: RndBoundingBoxIC.h:54