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

MultismoothCircleIC creates multiple SmoothCircles (number = numbub) that are randomly positioned around the domain, with a minimum spacing equal to bubspac. More...

#include <MultiSmoothCircleIC.h>

Inheritance diagram for MultiSmoothCircleIC:
[legend]

Public Member Functions

 MultiSmoothCircleIC (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

const unsigned int _numbub
 
const Real _bubspac
 
const unsigned int _max_num_tries
 
const Real _radius
 
const Real _radius_variation
 
const MooseEnum _radius_variation_type
 
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

MultismoothCircleIC creates multiple SmoothCircles (number = numbub) that are randomly positioned around the domain, with a minimum spacing equal to bubspac.

Definition at line 22 of file MultiSmoothCircleIC.h.

Constructor & Destructor Documentation

MultiSmoothCircleIC::MultiSmoothCircleIC ( const InputParameters &  parameters)

Definition at line 37 of file MultiSmoothCircleIC.C.

38  : SmoothCircleBaseIC(parameters),
39  _numbub(getParam<unsigned int>("numbub")),
40  _bubspac(getParam<Real>("bubspac")),
41  _max_num_tries(getParam<unsigned int>("numtries")),
42  _radius(getParam<Real>("radius")),
43  _radius_variation(getParam<Real>("radius_variation")),
44  _radius_variation_type(getParam<MooseEnum>("radius_variation_type"))
45 {
46 }
const MooseEnum _radius_variation_type
const unsigned int _max_num_tries
SmoothCircleBaseIC(const InputParameters &parameters)
const unsigned int _numbub

Member Function Documentation

void MultiSmoothCircleIC::computeCircleCenters ( )
protectedvirtual

Implements SmoothCircleBaseIC.

Reimplemented in PolycrystalVoronoiVoidIC.

Definition at line 92 of file MultiSmoothCircleIC.C.

93 {
94  _centers.resize(_numbub);
95  for (unsigned int i = 0; i < _numbub; ++i)
96  {
97  // Vary circle center positions
98  unsigned int num_tries = 0;
99  while (num_tries < _max_num_tries)
100  {
101  num_tries++;
102 
103  RealTensorValue ran;
104  ran(0, 0) = _random.rand(_tid);
105  ran(1, 1) = _random.rand(_tid);
106  ran(2, 2) = _random.rand(_tid);
107 
108  _centers[i] = _bottom_left + ran * _range;
109 
110  for (unsigned int j = 0; j < i; ++j)
111  if (_mesh.minPeriodicDistance(_var.number(), _centers[j], _centers[i]) < _bubspac)
112  goto fail;
113 
114  // accept the position of the new center
115  goto accept;
116 
117  // retry a new position until tries are exhausted
118  fail:
119  continue;
120  }
121 
122  if (num_tries == _max_num_tries)
123  mooseError("Too many tries in MultiSmoothCircleIC");
124 
125  accept:
126  continue;
127  }
128 }
std::vector< Point > _centers
const unsigned int _max_num_tries
const unsigned int _numbub
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 MultiSmoothCircleIC::computeCircleRadii ( )
protectedvirtual

Implements SmoothCircleBaseIC.

Definition at line 68 of file MultiSmoothCircleIC.C.

69 {
70  _radii.resize(_numbub);
71 
72  for (unsigned int i = 0; i < _numbub; i++)
73  {
74  // Vary bubble radius
75  switch (_radius_variation_type)
76  {
77  case 0: // Uniform distribution
78  _radii[i] = _radius * (1.0 + (1.0 - 2.0 * _random.rand(_tid)) * _radius_variation);
79  break;
80  case 1: // Normal distribution
81  _radii[i] = _random.randNormal(_tid, _radius, _radius_variation);
82  break;
83  case 2: // No variation
84  _radii[i] = _radius;
85  }
86 
87  _radii[i] = std::max(_radii[i], 0.0);
88  }
89 }
std::vector< Real > _radii
const MooseEnum _radius_variation_type
const unsigned int _numbub
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 MultiSmoothCircleIC::initialSetup ( )
virtual

Reimplemented from SmoothCircleBaseIC.

Reimplemented in PolycrystalVoronoiVoidIC.

Definition at line 49 of file MultiSmoothCircleIC.C.

Referenced by PolycrystalVoronoiVoidIC::initialSetup().

50 {
51  // Set up domain bounds with mesh tools
52  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
53  {
54  _bottom_left(i) = _mesh.getMinInDimension(i);
55  _top_right(i) = _mesh.getMaxInDimension(i);
56  }
58 
59  // a variation is provided, but the type is set to 'none'
60  if (_radius_variation > 0.0 && _radius_variation_type == 2)
61  mooseError("If radius_variation > 0.0, you must pass in a radius_variation_type in "
62  "MultiSmoothCircleIC");
63 
65 }
const MooseEnum _radius_variation_type
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
Point MultiSmoothCircleIC::_bottom_left
protected
const Real MultiSmoothCircleIC::_bubspac
protected
std::vector<Point> SmoothCircleBaseIC::_centers
protectedinherited
Real SmoothCircleBaseIC::_int_width
protectedinherited
Real SmoothCircleBaseIC::_invalue
protectedinherited
const unsigned int MultiSmoothCircleIC::_max_num_tries
protected
MooseMesh& SmoothCircleBaseIC::_mesh
protectedinherited
unsigned int SmoothCircleBaseIC::_num_dim
protectedinherited

Definition at line 50 of file SmoothCircleBaseIC.h.

const unsigned int MultiSmoothCircleIC::_numbub
protected
Real SmoothCircleBaseIC::_outvalue
protectedinherited
std::vector<Real> SmoothCircleBaseIC::_radii
protectedinherited
const Real MultiSmoothCircleIC::_radius
protected
const Real MultiSmoothCircleIC::_radius_variation
protected

Definition at line 39 of file MultiSmoothCircleIC.h.

Referenced by computeCircleRadii(), and initialSetup().

const MooseEnum MultiSmoothCircleIC::_radius_variation_type
protected

Definition at line 40 of file MultiSmoothCircleIC.h.

Referenced by computeCircleRadii(), and initialSetup().

MooseRandom SmoothCircleBaseIC::_random
protectedinherited
Point MultiSmoothCircleIC::_range
protected
Point MultiSmoothCircleIC::_top_right
protected
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: