www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
RndSmoothCircleIC Class Reference

RndSmoothcircleIC creates a smooth circle with a random distribution of values inside and outside of the circle. More...

#include <RndSmoothCircleIC.h>

Inheritance diagram for RndSmoothCircleIC:
[legend]

Public Member Functions

 RndSmoothCircleIC (const InputParameters &parameters)
 
virtual Real value (const Point &p)
 
virtual RealGradient gradient (const Point &p)
 
virtual void initialSetup ()
 

Protected Member Functions

virtual void computeCircleRadii ()
 
virtual void computeCircleCenters ()
 
virtual RealGradient computeCircleGradient (const Point &p, const Point &center, const Real &radius)
 

Protected Attributes

Real _x1
 
Real _y1
 
Real _z1
 
Real _radius
 
Point _center
 
MooseMesh & _mesh
 
Real _invalue
 
Real _outvalue
 
Real _int_width
 
bool _3D_spheres
 
bool _zero_gradient
 
unsigned int _num_dim
 
std::vector< Point > _centers
 
std::vector< Real > _radii
 
MooseRandom _random
 

Private Member Functions

virtual Real computeCircleValue (const Point &p, const Point &center, const Real &radius)
 

Private Attributes

const Real _variation_invalue
 
const Real _variation_outvalue
 

Detailed Description

RndSmoothcircleIC creates a smooth circle with a random distribution of values inside and outside of the circle.

Definition at line 22 of file RndSmoothCircleIC.h.

Constructor & Destructor Documentation

RndSmoothCircleIC::RndSmoothCircleIC ( const InputParameters &  parameters)

Definition at line 26 of file RndSmoothCircleIC.C.

27  : SmoothCircleIC(parameters),
28  _variation_invalue(parameters.get<Real>("variation_invalue")),
29  _variation_outvalue(parameters.get<Real>("variation_outvalue"))
30 {
31 }
const Real _variation_outvalue
const Real _variation_invalue
SmoothCircleIC(const InputParameters &parameters)

Member Function Documentation

void SmoothCircleIC::computeCircleCenters ( )
protectedvirtualinherited

Implements SmoothCircleBaseIC.

Definition at line 39 of file SmoothCircleIC.C.

40 {
41  _centers = {_center};
42 }
std::vector< Point > _centers
RealGradient SmoothCircleBaseIC::computeCircleGradient ( const Point &  p,
const Point &  center,
const Real &  radius 
)
protectedvirtualinherited

Definition at line 127 of file SmoothCircleBaseIC.C.

Referenced by SmoothCircleBaseIC::gradient().

130 {
131  Point l_center = center;
132  Point l_p = p;
133  if (!_3D_spheres) // Create 3D cylinders instead of spheres
134  {
135  l_p(2) = 0.0;
136  l_center(2) = 0.0;
137  }
138  // Compute the distance between the current point and the center
139  Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
140 
141  Real DvalueDr = 0.0;
142 
143  if (dist < radius + _int_width / 2.0 && dist > radius - _int_width / 2.0)
144  {
145  Real int_pos = (dist - radius + _int_width / 2.0) / _int_width;
146  Real Dint_posDr = 1.0 / _int_width;
147  DvalueDr = Dint_posDr * (_invalue - _outvalue) *
148  (-std::sin(int_pos * libMesh::pi) * libMesh::pi) / 2.0;
149  }
150 
151  // Set gradient over the smooth interface
152  if (dist != 0.0)
153  return _mesh.minPeriodicVector(_var.number(), center, p) * (DvalueDr / dist);
154  else
155  return 0.0;
156 }
void SmoothCircleIC::computeCircleRadii ( )
protectedvirtualinherited

Implements SmoothCircleBaseIC.

Definition at line 33 of file SmoothCircleIC.C.

34 {
35  _radii = {_radius};
36 }
std::vector< Real > _radii
Real RndSmoothCircleIC::computeCircleValue ( const Point &  p,
const Point &  center,
const Real &  radius 
)
privatevirtual

Reimplemented from SmoothCircleBaseIC.

Definition at line 34 of file RndSmoothCircleIC.C.

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 }
virtual Real value(const Point &p)
const Real _variation_outvalue
const Real _variation_invalue
RealGradient SmoothCircleBaseIC::gradient ( const Point &  p)
virtualinherited

Reimplemented in PolycrystalVoronoiVoidIC.

Definition at line 77 of file SmoothCircleBaseIC.C.

Referenced by PolycrystalVoronoiVoidIC::gradient().

78 {
79  if (_zero_gradient)
80  return 0.0;
81 
82  RealGradient gradient = 0.0;
83  Real value = _outvalue;
84  Real val2 = 0.0;
85 
86  for (unsigned int circ = 0; circ < _centers.size(); ++circ)
87  {
88  val2 = computeCircleValue(p, _centers[circ], _radii[circ]);
89  if ((val2 > value && _invalue > _outvalue) || (val2 < value && _outvalue > _invalue))
90  {
91  value = val2;
92  gradient = computeCircleGradient(p, _centers[circ], _radii[circ]);
93  }
94  }
95 
96  return gradient;
97 }
virtual Real computeCircleValue(const Point &p, const Point &center, const Real &radius)
std::vector< Real > _radii
std::vector< Point > _centers
virtual Real value(const Point &p)
virtual RealGradient computeCircleGradient(const Point &p, const Point &center, const Real &radius)
virtual RealGradient gradient(const Point &p)
void SmoothCircleBaseIC::initialSetup ( )
virtualinherited

Reimplemented in PolycrystalVoronoiVoidIC, LatticeSmoothCircleIC, and MultiSmoothCircleIC.

Definition at line 47 of file SmoothCircleBaseIC.C.

Referenced by LatticeSmoothCircleIC::initialSetup(), and MultiSmoothCircleIC::initialSetup().

48 {
49  // Compute radii and centers and initialize vector sizes
52 
53  if (_centers.size() != _radii.size())
54  mooseError("_center and _radii vectors are not the same size in the Circle IC");
55 
56  if (_centers.size() < 1)
57  mooseError("_center and _radii were not initialized in the Circle IC");
58 }
std::vector< Real > _radii
std::vector< Point > _centers
virtual void computeCircleRadii()=0
virtual void computeCircleCenters()=0
Real SmoothCircleBaseIC::value ( const Point &  p)
virtualinherited

Reimplemented in PolycrystalVoronoiVoidIC.

Definition at line 61 of file SmoothCircleBaseIC.C.

Referenced by computeCircleValue(), SmoothCircleBaseIC::computeCircleValue(), SmoothCircleBaseIC::gradient(), and PolycrystalVoronoiVoidIC::value().

62 {
63  Real value = _outvalue;
64  Real val2 = 0.0;
65 
66  for (unsigned int circ = 0; circ < _centers.size() && value != _invalue; ++circ)
67  {
68  val2 = computeCircleValue(p, _centers[circ], _radii[circ]);
69  if ((val2 > value && _invalue > _outvalue) || (val2 < value && _outvalue > _invalue))
70  value = val2;
71  }
72 
73  return value;
74 }
virtual Real computeCircleValue(const Point &p, const Point &center, const Real &radius)
std::vector< Real > _radii
std::vector< Point > _centers
virtual Real value(const Point &p)

Member Data Documentation

bool SmoothCircleBaseIC::_3D_spheres
protectedinherited
Point SmoothCircleIC::_center
protectedinherited

Definition at line 36 of file SmoothCircleIC.h.

Referenced by SmoothCircleIC::computeCircleCenters().

std::vector<Point> SmoothCircleBaseIC::_centers
protectedinherited
Real SmoothCircleBaseIC::_int_width
protectedinherited
Real SmoothCircleBaseIC::_invalue
protectedinherited
MooseMesh& SmoothCircleBaseIC::_mesh
protectedinherited
unsigned int SmoothCircleBaseIC::_num_dim
protectedinherited

Definition at line 50 of file SmoothCircleBaseIC.h.

Real SmoothCircleBaseIC::_outvalue
protectedinherited
std::vector<Real> SmoothCircleBaseIC::_radii
protectedinherited
Real SmoothCircleIC::_radius
protectedinherited

Definition at line 35 of file SmoothCircleIC.h.

Referenced by SmoothCircleIC::computeCircleRadii().

MooseRandom SmoothCircleBaseIC::_random
protectedinherited
const Real RndSmoothCircleIC::_variation_invalue
private

Definition at line 30 of file RndSmoothCircleIC.h.

Referenced by computeCircleValue().

const Real RndSmoothCircleIC::_variation_outvalue
private

Definition at line 31 of file RndSmoothCircleIC.h.

Referenced by computeCircleValue().

Real SmoothCircleIC::_x1
protectedinherited

Definition at line 32 of file SmoothCircleIC.h.

Real SmoothCircleIC::_y1
protectedinherited

Definition at line 33 of file SmoothCircleIC.h.

Real SmoothCircleIC::_z1
protectedinherited

Definition at line 34 of file SmoothCircleIC.h.

bool SmoothCircleBaseIC::_zero_gradient
protectedinherited

Definition at line 48 of file SmoothCircleBaseIC.h.

Referenced by SmoothCircleBaseIC::gradient().


The documentation for this class was generated from the following files: