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

LatticeSmoothcircleIC creates a lattice of smoothcircles as an initial condition. More...

#include <LatticeSmoothCircleIC.h>

Inheritance diagram for LatticeSmoothCircleIC:
[legend]

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

Real _lattice_variation
 
std::vector< unsigned int > _circles_per_side
 
unsigned int _numbub
 
Real _radius
 
Real _radius_variation
 
MooseEnum _radius_variation_type
 
bool _avoid_bounds
 
Point _bottom_left
 
Point _top_right
 
Point _range
 
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
 

Detailed Description

LatticeSmoothcircleIC creates a lattice of smoothcircles as an initial condition.

They are either directly on the lattice or randomly perturbed from the lattice.

Definition at line 22 of file LatticeSmoothCircleIC.h.

Constructor & Destructor Documentation

LatticeSmoothCircleIC::LatticeSmoothCircleIC ( const InputParameters &  parameters)

Definition at line 36 of file LatticeSmoothCircleIC.C.

37  : SmoothCircleBaseIC(parameters),
38  _lattice_variation(isParamValid("Rnd_variation") ? getParam<Real>("Rnd_variation")
39  : getParam<Real>("pos_variation")),
40  _circles_per_side(getParam<std::vector<unsigned int>>("circles_per_side")),
41  _radius(getParam<Real>("radius")),
42  _radius_variation(getParam<Real>("radius_variation")),
43  _radius_variation_type(getParam<MooseEnum>("radius_variation_type")),
44  _avoid_bounds(getParam<bool>("avoid_bounds"))
45 {
46 }
std::vector< unsigned int > _circles_per_side
SmoothCircleBaseIC(const InputParameters &parameters)

Member Function Documentation

void LatticeSmoothCircleIC::computeCircleCenters ( )
protectedvirtual

Implements SmoothCircleBaseIC.

Definition at line 121 of file LatticeSmoothCircleIC.C.

122 {
123  _centers.resize(_numbub);
124 
125  Real x_sep = _range(0) / _circles_per_side[0];
126  Real y_sep = _range(1) / _circles_per_side[1];
127 
128  Real z_sep = 0.0;
129  unsigned int z_num = 1.0;
130 
131  if (_range(2) > 0.0)
132  {
133  z_sep = _range(2) / _circles_per_side[2];
134  z_num = _circles_per_side[2];
135  }
136 
137  unsigned int cnt = 0;
138  for (unsigned int i = 0; i < _circles_per_side[0]; ++i)
139  for (unsigned int j = 0; j < _circles_per_side[1]; ++j)
140  for (unsigned int k = 0; k < z_num; ++k)
141  {
142  Real xx = x_sep / 2.0 + i * x_sep;
143  Real yy = y_sep / 2.0 + j * y_sep;
144  Real zz = z_sep / 2.0 + k * z_sep;
145 
146  // Vary circle position
147  xx = xx + (1.0 - 2.0 * _random.rand(_tid)) * _lattice_variation;
148  yy = yy + (1.0 - 2.0 * _random.rand(_tid)) * _lattice_variation;
149 
150  if (_range(2) != 0.0)
151  zz = zz + (1.0 - 2.0 * _random.rand(_tid)) * _lattice_variation;
152 
153  // Verify not out of bounds
154  if (_avoid_bounds && xx < _radii[cnt] + _int_width)
155  xx = _radii[cnt] + _int_width;
156  if (_avoid_bounds && xx > _range(0) - (_radii[cnt] + _int_width))
157  xx = _range(0) - (_radii[cnt] + _int_width);
158  if (_avoid_bounds && yy < _radii[cnt] + _int_width)
159  yy = _radii[cnt] + _int_width;
160  if (_avoid_bounds && yy > _range(1) - (_radii[cnt] + _int_width))
161  yy = _range(1) - (_radii[cnt] + _int_width);
162  if (_range(2) != 0.0)
163  {
164  if (_avoid_bounds && zz < _radii[cnt] + _int_width)
165  zz = _radii[cnt] + _int_width;
166  if (_avoid_bounds && zz > _range(2) - (_radii[cnt] + _int_width))
167  zz = _range(2) - (_radii[cnt] + _int_width);
168  }
169 
170  _centers[cnt](0) = xx;
171  _centers[cnt](1) = yy;
172  _centers[cnt](2) = zz;
173 
174  cnt++;
175  }
176 }
std::vector< unsigned int > _circles_per_side
std::vector< Real > _radii
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 LatticeSmoothCircleIC::computeCircleRadii ( )
protectedvirtual

Implements SmoothCircleBaseIC.

Definition at line 96 of file LatticeSmoothCircleIC.C.

97 {
98  _radii.resize(_numbub);
99 
100  for (unsigned int i = 0; i < _numbub; i++)
101  {
102  // Vary bubble radius
103  switch (_radius_variation_type)
104  {
105  case 0: // Uniform distrubtion
106  _radii[i] = _radius * (1.0 + (1.0 - 2.0 * _random.rand(_tid)) * _radius_variation);
107  break;
108  case 1: // Normal distribution
109  _radii[i] = _random.randNormal(_tid, _radius, _radius_variation);
110  break;
111  case 2: // No variation
112  _radii[i] = _radius;
113  }
114 
115  if (_radii[i] < 0.0)
116  _radii[i] = 0.0;
117  }
118 }
std::vector< Real > _radii
Real SmoothCircleBaseIC::computeCircleValue ( const Point &  p,
const Point &  center,
const Real &  radius 
)
protectedvirtualinherited

Reimplemented in RndSmoothCircleIC.

Definition at line 100 of file SmoothCircleBaseIC.C.

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

101 {
102  Point l_center = center;
103  Point l_p = p;
104  if (!_3D_spheres) // Create 3D cylinders instead of spheres
105  {
106  l_p(2) = 0.0;
107  l_center(2) = 0.0;
108  }
109  // Compute the distance between the current point and the center
110  Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
111 
112  // Return value
113  Real value = _outvalue; // Outside circle
114 
115  if (dist <= radius - _int_width / 2.0) // Inside circle
116  value = _invalue;
117  else if (dist < radius + _int_width / 2.0) // Smooth interface
118  {
119  Real int_pos = (dist - radius + _int_width / 2.0) / _int_width;
120  value = _outvalue + (_invalue - _outvalue) * (1.0 + std::cos(int_pos * libMesh::pi)) / 2.0;
121  }
122 
123  return value;
124 }
virtual Real value(const Point &p)
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 LatticeSmoothCircleIC::initialSetup ( )
virtual

Reimplemented from SmoothCircleBaseIC.

Definition at line 49 of file LatticeSmoothCircleIC.C.

50 {
51  // pad circles per side vector to size 3 (with 0)
52  _circles_per_side.resize(3);
53 
54  // Set up domain bounds with mesh tools
55  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
56  {
57  _bottom_left(i) = _mesh.getMinInDimension(i);
58  _top_right(i) = _mesh.getMaxInDimension(i);
59  }
61 
62  // Error checks
63  if (_range(0) != 0.0 && _range(1) != 0.0 && _circles_per_side[1] == 0)
64  mooseError("If domain is > 1D, circles_per_side must have more than one value");
65 
66  if (_range(2) != 0.0 && _circles_per_side[2] == 0)
67  mooseError("If domain is 3D, circles_per_side must have three values");
68 
69  if (_range(1) == 0.0 && _range(2) == 0.0)
70  {
71  _circles_per_side[1] = 0;
72  _circles_per_side[2] = 0;
73  }
74 
75  // Set _numbub
76  if (_range(2) == 0.0)
77  {
78  _circles_per_side[2] = 0;
80  }
81  else
83 
84  switch (_radius_variation_type)
85  {
86  case 2: // No variation
87  if (_radius_variation > 0.0)
88  mooseError("If radius_variation > 0.0, you must pass in a radius_variation_type in "
89  "LatticeSmoothCircleIC");
90  break;
91  }
93 }
std::vector< unsigned int > _circles_per_side
virtual void initialSetup()
Real SmoothCircleBaseIC::value ( const Point &  p)
virtualinherited

Reimplemented in PolycrystalVoronoiVoidIC.

Definition at line 61 of file SmoothCircleBaseIC.C.

Referenced by RndSmoothCircleIC::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
bool LatticeSmoothCircleIC::_avoid_bounds
protected

Definition at line 41 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleCenters().

Point LatticeSmoothCircleIC::_bottom_left
protected

Definition at line 43 of file LatticeSmoothCircleIC.h.

Referenced by initialSetup().

std::vector<Point> SmoothCircleBaseIC::_centers
protectedinherited
std::vector<unsigned int> LatticeSmoothCircleIC::_circles_per_side
protected

Definition at line 34 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleCenters(), and initialSetup().

Real SmoothCircleBaseIC::_int_width
protectedinherited
Real SmoothCircleBaseIC::_invalue
protectedinherited
Real LatticeSmoothCircleIC::_lattice_variation
protected

Definition at line 33 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleCenters().

MooseMesh& SmoothCircleBaseIC::_mesh
protectedinherited
unsigned int SmoothCircleBaseIC::_num_dim
protectedinherited

Definition at line 50 of file SmoothCircleBaseIC.h.

unsigned int LatticeSmoothCircleIC::_numbub
protected

Definition at line 35 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleCenters(), computeCircleRadii(), and initialSetup().

Real SmoothCircleBaseIC::_outvalue
protectedinherited
std::vector<Real> SmoothCircleBaseIC::_radii
protectedinherited
Real LatticeSmoothCircleIC::_radius
protected

Definition at line 37 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleRadii().

Real LatticeSmoothCircleIC::_radius_variation
protected

Definition at line 38 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleRadii(), and initialSetup().

MooseEnum LatticeSmoothCircleIC::_radius_variation_type
protected

Definition at line 39 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleRadii(), and initialSetup().

MooseRandom SmoothCircleBaseIC::_random
protectedinherited
Point LatticeSmoothCircleIC::_range
protected

Definition at line 45 of file LatticeSmoothCircleIC.h.

Referenced by computeCircleCenters(), and initialSetup().

Point LatticeSmoothCircleIC::_top_right
protected

Definition at line 44 of file LatticeSmoothCircleIC.h.

Referenced by initialSetup().

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: