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

An InitialCondition for initializing phase variable in close packed circles/spheres pattern. More...

#include <ClosePackIC.h>

Inheritance diagram for ClosePackIC:
[legend]

Public Member Functions

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

Protected Member Functions

virtual void computeCircleRadii ()
 The radius are populated in the computeCircleCenters. More...
 
virtual void computeCircleCenters ()
 Compute the close packed centers and radii. More...
 
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 Real _radius
 User-supplied circle radius. More...
 
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

An InitialCondition for initializing phase variable in close packed circles/spheres pattern.

Definition at line 22 of file ClosePackIC.h.

Constructor & Destructor Documentation

ClosePackIC::ClosePackIC ( const InputParameters &  parameters)

Definition at line 24 of file ClosePackIC.C.

25  : SmoothCircleBaseIC(parameters), _radius(parameters.get<Real>("radius"))
26 {
27 }
const Real _radius
User-supplied circle radius.
Definition: ClosePackIC.h:35
SmoothCircleBaseIC(const InputParameters &parameters)

Member Function Documentation

void ClosePackIC::computeCircleCenters ( )
protectedvirtual

Compute the close packed centers and radii.

Implements SmoothCircleBaseIC.

Definition at line 30 of file ClosePackIC.C.

Referenced by computeCircleRadii().

31 {
32  // Determine the extents of the mesh
33  BoundingBox bbox = MeshTools::create_bounding_box(_fe_problem.mesh().getMesh());
34  const Point & min = bbox.min();
35  const Point & max = bbox.max();
36 
37  // Create the x,y,z limits for the while loops
38  Real x_min = min(0);
39  Real x_max = max(0) + 2.0 * _radius;
40 
41  Real y_min = min(1) - 2.0 * std::sqrt(3.0) * _radius + _radius;
42  Real y_max = max(1) + 2.0 * _radius;
43 
44  // Real z_min = min(2) - 2*std::sqrt(3.0)*_radius + _radius;
45  Real z_max = 0.0;
46 
47  // Initialize the coordinates that will be used in looping
48  Real x = x_min;
49  Real y = y_min;
50  Real z = 0.0;
51 
52  // Adjust the 3D z-dimension maximum
53  if (_fe_problem.mesh().dimension() == 3)
54  z_max = max(2) + 2.0 * _radius;
55 
56  // Counters for offsetting every other row column in x,y dimensions
57  unsigned int i = 0;
58  unsigned int j = 0;
59 
60  while (z <= z_max)
61  {
62  // Offset the y-coordinate by sqrt(3)*r every other loop
63  if (j % 2 != 0)
64  y += std::sqrt(3) * _radius / 2.0;
65 
66  while (y <= y_max)
67  {
68 
69  // Offset the x-coordinate by r every other loop
70  if (i % 2 == 0)
71  x += _radius;
72 
73  while (x <= x_max)
74  {
75  _centers.push_back(Point(x, y, z));
76  _radii.push_back(_radius);
77  x += 2.0 * _radius;
78  }
79 
80  // Reset x-coord and increment y-coord
81  x = x_min;
82  y += std::sqrt(3.0) * _radius;
83  i++;
84  }
85 
86  // Reset y-coord and increment z-coord
87  y = y_min;
88  z += std::sqrt(3.0) * _radius;
89  j++;
90  }
91 }
std::vector< Real > _radii
const Real _radius
User-supplied circle radius.
Definition: ClosePackIC.h:35
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 }
virtual void ClosePackIC::computeCircleRadii ( )
inlineprotectedvirtual

The radius are populated in the computeCircleCenters.

Implements SmoothCircleBaseIC.

Definition at line 29 of file ClosePackIC.h.

29 {}
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 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 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
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
const Real ClosePackIC::_radius
protected

User-supplied circle radius.

Definition at line 35 of file ClosePackIC.h.

Referenced by computeCircleCenters().

MooseRandom SmoothCircleBaseIC::_random
protectedinherited
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: