www.mooseframework.org
RndSmoothCircleIC.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 
8 #include "RndSmoothCircleIC.h"
9 
10 // MOOSE includes
11 #include "MooseMesh.h"
12 #include "MooseVariable.h"
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<SmoothCircleIC>();
19  params.addClassDescription(
20  "Random noise with different min/max inside/outside of a smooth circle");
21  params.addRequiredParam<Real>("variation_invalue", "Plus or minus this amount on the invalue");
22  params.addRequiredParam<Real>("variation_outvalue", "Plus or minus this amount on the outvalue");
23  return params;
24 }
25 
26 RndSmoothCircleIC::RndSmoothCircleIC(const InputParameters & parameters)
27  : SmoothCircleIC(parameters),
28  _variation_invalue(parameters.get<Real>("variation_invalue")),
29  _variation_outvalue(parameters.get<Real>("variation_outvalue"))
30 {
31 }
32 
33 Real
34 RndSmoothCircleIC::computeCircleValue(const Point & p, const Point & center, const Real & radius)
35 {
36  Point l_center = center;
37  Point l_p = p;
38  if (!_3D_spheres) // Create 3D cylinders instead of spheres
39  {
40  l_p(2) = 0.0;
41  l_center(2) = 0.0;
42  }
43  // Compute the distance between the current point and the center
44  Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
45 
46  // Return value
47  Real value = 0.0;
48 
49  if (dist <= radius - _int_width / 2.0) // Random value inside circle
50  value = _invalue - _variation_invalue + 2.0 * _random.rand(_tid) * _variation_invalue;
51  else if (dist < radius + _int_width / 2.0) // Smooth interface
52  {
53  Real int_pos = (dist - radius + _int_width / 2.0) / _int_width;
54  value = _outvalue + (_invalue - _outvalue) * (1.0 + std::cos(int_pos * libMesh::pi)) / 2.0;
55  }
56  else // Random value outside circle
57  value = _outvalue - _variation_outvalue + 2.0 * _random.rand(_tid) * _variation_outvalue;
58 
59  return value;
60 }
SmoothcircleIC creates a circle of a given radius centered at a given point in the domain...
virtual Real computeCircleValue(const Point &p, const Point &center, const Real &radius)
InputParameters validParams< SmoothCircleIC >()
virtual Real value(const Point &p)
InputParameters validParams< RndSmoothCircleIC >()
const Real _variation_outvalue
const Real _variation_invalue
RndSmoothCircleIC(const InputParameters &parameters)