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

SmoothcircleIC creates a circle of a given radius centered at a given point in the domain. More...

#include <SmoothCircleIC.h>

Inheritance diagram for SmoothCircleIC:
[legend]

Public Member Functions

 SmoothCircleIC (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 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 _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
 

Detailed Description

SmoothcircleIC creates a circle of a given radius centered at a given point in the domain.

If int_width > zero, the border of the circle with smoothly transition from the invalue to the outvalue.

Definition at line 23 of file SmoothCircleIC.h.

Constructor & Destructor Documentation

SmoothCircleIC::SmoothCircleIC ( const InputParameters &  parameters)

Definition at line 22 of file SmoothCircleIC.C.

23  : SmoothCircleBaseIC(parameters),
24  _x1(parameters.get<Real>("x1")),
25  _y1(parameters.get<Real>("y1")),
26  _z1(parameters.get<Real>("z1")),
27  _radius(parameters.get<Real>("radius")),
28  _center(_x1, _y1, _z1)
29 {
30 }
SmoothCircleBaseIC(const InputParameters &parameters)

Member Function Documentation

void SmoothCircleIC::computeCircleCenters ( )
protectedvirtual

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 ( )
protectedvirtual

Implements SmoothCircleBaseIC.

Definition at line 33 of file SmoothCircleIC.C.

34 {
35  _radii = {_radius};
36 }
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 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
Point SmoothCircleIC::_center
protected

Definition at line 36 of file SmoothCircleIC.h.

Referenced by 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
protected

Definition at line 35 of file SmoothCircleIC.h.

Referenced by computeCircleRadii().

MooseRandom SmoothCircleBaseIC::_random
protectedinherited
Real SmoothCircleIC::_x1
protected

Definition at line 32 of file SmoothCircleIC.h.

Real SmoothCircleIC::_y1
protected

Definition at line 33 of file SmoothCircleIC.h.

Real SmoothCircleIC::_z1
protected

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: