www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SmoothSuperellipsoidBaseIC Class Referenceabstract

SmoothSuperellipsoidBaseIC is the base class for all initial conditions that create superellipsoids. More...

#include <SmoothSuperellipsoidBaseIC.h>

Inheritance diagram for SmoothSuperellipsoidBaseIC:
[legend]

Public Member Functions

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

Protected Member Functions

virtual Real computeSuperellipsoidValue (const Point &p, const Point &center, Real a, Real b, Real c, Real n)
 
virtual Real computeSuperellipsoidInverseValue (const Point &p, const Point &center, Real a, Real b, Real c, Real n)
 
RealGradient computeSuperellipsoidGradient (const Point &p, const Point &center, Real a, Real b, Real c, Real n)
 
virtual void computeSuperellipsoidSemiaxes ()=0
 
virtual void computeSuperellipsoidExponents ()=0
 
virtual void computeSuperellipsoidCenters ()=0
 

Protected Attributes

MooseMesh & _mesh
 
Real _invalue
 
Real _outvalue
 
Real _nestedvalue
 
Real _int_width
 
bool _zero_gradient
 
unsigned int _num_dim
 
std::vector< Point > _centers
 
std::vector< Real > _as
 
std::vector< Real > _bs
 
std::vector< Real > _cs
 
std::vector< Real > _ns
 
MooseRandom _random
 

Detailed Description

SmoothSuperellipsoidBaseIC is the base class for all initial conditions that create superellipsoids.

A superellipsoid is described by \( \left|\frac{x}{a}\right|^n + \left|\frac{y}{b}\right|^n + \left|\frac{z}{c}\right|^n = 1\). Note that all children must resize _as, _bs, _cs, _ns, and _centers.

Definition at line 26 of file SmoothSuperellipsoidBaseIC.h.

Constructor & Destructor Documentation

SmoothSuperellipsoidBaseIC::SmoothSuperellipsoidBaseIC ( const InputParameters &  parameters)

Definition at line 35 of file SmoothSuperellipsoidBaseIC.C.

36  : InitialCondition(parameters),
37  _mesh(_fe_problem.mesh()),
38  _invalue(parameters.get<Real>("invalue")),
39  _outvalue(parameters.get<Real>("outvalue")),
40  _nestedvalue(isParamValid("nestedvalue") ? parameters.get<Real>("nestedvalue")
41  : parameters.get<Real>("outvalue")),
42  _int_width(parameters.get<Real>("int_width")),
43  _zero_gradient(parameters.get<bool>("zero_gradient"))
44 {
45  _random.seed(_tid, getParam<unsigned int>("rand_seed"));
46 }

Member Function Documentation

virtual void SmoothSuperellipsoidBaseIC::computeSuperellipsoidCenters ( )
protectedpure virtual
virtual void SmoothSuperellipsoidBaseIC::computeSuperellipsoidExponents ( )
protectedpure virtual
RealGradient SmoothSuperellipsoidBaseIC::computeSuperellipsoidGradient ( const Point &  p,
const Point &  center,
Real  a,
Real  b,
Real  c,
Real  n 
)
protected

Definition at line 193 of file SmoothSuperellipsoidBaseIC.C.

Referenced by gradient().

195 {
196  Point l_center = center;
197  Point l_p = p;
198  // Compute the distance between the current point and the center
199  Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
200 
201  // When dist is 0 we are exactly at the center of the superellipsoid so return 0
202  // Handle this case independently because we cannot calculate polar angles at this point
203  if (dist == 0.0)
204  return 0.0;
205 
206  // Compute the distance r from the center of the superellipsoid to its outside edge
207  // along the vector from the center to the current point
208  // This uses the equation for a superellipse in polar coordinates and substitutes
209  // distances for sin, cos functions
210  Point dist_vec = _mesh.minPeriodicVector(_var.number(), center, p);
211  // First calculate rmn = r^(-n)
212  Real rmn = (std::pow(std::abs(dist_vec(0) / dist / a), n) +
213  std::pow(std::abs(dist_vec(1) / dist / b), n) +
214  std::pow(std::abs(dist_vec(2) / dist / c), n));
215  // Then calculate r from rmn
216  Real r = std::pow(rmn, (-1.0 / n));
217 
218  Real DvalueDr = 0.0;
219 
220  if (dist < r + _int_width / 2.0 && dist > r - _int_width / 2.0) // in interfacial region
221  {
222  Real int_pos = (dist - r + _int_width / 2.0) / _int_width;
223  Real Dint_posDr = 1.0 / _int_width;
224  DvalueDr = Dint_posDr * (_invalue - _outvalue) *
225  (-std::sin(int_pos * libMesh::pi) * libMesh::pi) / 2.0;
226  }
227 
228  return dist_vec * (DvalueDr / dist);
229 }
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Real SmoothSuperellipsoidBaseIC::computeSuperellipsoidInverseValue ( const Point &  p,
const Point &  center,
Real  a,
Real  b,
Real  c,
Real  n 
)
protectedvirtual

Definition at line 153 of file SmoothSuperellipsoidBaseIC.C.

Referenced by BimodalInverseSuperellipsoidsIC::value().

155 {
156  Point l_center = center;
157  Point l_p = p;
158  // Compute the distance between the current point and the center
159  Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
160 
161  // When dist is 0 we are exactly at the center of the superellipsoid so return _invalue
162  // Handle this case independently because we cannot calculate polar angles at this point
163  if (dist == 0.0)
164  return _nestedvalue;
165 
166  // Compute the distance r from the center of the superellipsoid to its outside edge
167  // along the vector from the center to the current point
168  // This uses the equation for a superellipse in polar coordinates and substitutes
169  // distances for sin, cos functions
170  Point dist_vec = _mesh.minPeriodicVector(_var.number(), center, p);
171 
172  // First calculate rmn = r^(-n), replacing sin, cos functions with distances
173  Real rmn = (std::pow(std::abs(dist_vec(0) / dist / a), n) +
174  std::pow(std::abs(dist_vec(1) / dist / b), n) +
175  std::pow(std::abs(dist_vec(2) / dist / c), n));
176  // Then calculate r from rmn
177  Real r = std::pow(rmn, (-1.0 / n));
178 
179  Real value = _invalue;
180 
181  if (dist <= r - _int_width / 2.0) // Reversing inside and outside values
182  value = _nestedvalue;
183  else if (dist < r + _int_width / 2.0) // Smooth interface
184  {
185  Real int_pos = (dist - r + _int_width / 2.0) / _int_width;
186  value = _invalue + (_nestedvalue - _invalue) * (1.0 + std::cos(int_pos * libMesh::pi)) / 2.0;
187  }
188 
189  return value;
190 }
virtual Real value(const Point &p)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
virtual void SmoothSuperellipsoidBaseIC::computeSuperellipsoidSemiaxes ( )
protectedpure virtual
Real SmoothSuperellipsoidBaseIC::computeSuperellipsoidValue ( const Point &  p,
const Point &  center,
Real  a,
Real  b,
Real  c,
Real  n 
)
protectedvirtual

Definition at line 112 of file SmoothSuperellipsoidBaseIC.C.

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

114 {
115  Point l_center = center;
116  Point l_p = p;
117  // Compute the distance between the current point and the center
118  Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
119 
120  // When dist is 0 we are exactly at the center of the superellipsoid so return _invalue
121  // Handle this case independently because we cannot calculate polar angles at this point
122  if (dist == 0.0)
123  return _invalue;
124 
125  // Compute the distance r from the center of the superellipsoid to its outside edge
126  // along the vector from the center to the current point
127  // This uses the equation for a superellipse in polar coordinates and substitutes
128  // distances for sin, cos functions
129  Point dist_vec = _mesh.minPeriodicVector(_var.number(), center, p);
130 
131  // First calculate rmn = r^(-n), replacing sin, cos functions with distances
132  Real rmn = (std::pow(std::abs(dist_vec(0) / dist / a), n) +
133  std::pow(std::abs(dist_vec(1) / dist / b), n) +
134  std::pow(std::abs(dist_vec(2) / dist / c), n));
135  // Then calculate r from rmn
136  Real r = std::pow(rmn, (-1.0 / n));
137 
138  Real value = _outvalue; // Outside superellipsoid
139 
140  if (dist <= r - _int_width / 2.0) // Inside superellipsoid
141  value = _invalue;
142  else if (dist < r + _int_width / 2.0) // Smooth interface
143  {
144  Real int_pos = (dist - r + _int_width / 2.0) / _int_width;
145  value = _outvalue + (_invalue - _outvalue) * (1.0 + std::cos(int_pos * libMesh::pi)) / 2.0;
146  }
147 
148  return value;
149 }
virtual Real value(const Point &p)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
RealGradient SmoothSuperellipsoidBaseIC::gradient ( const Point &  p)
virtual

Definition at line 87 of file SmoothSuperellipsoidBaseIC.C.

88 {
89  if (_zero_gradient)
90  return 0.0;
91 
92  RealGradient gradient = 0.0;
93  Real value = _outvalue;
94  Real val2 = 0.0;
95 
96  for (unsigned int ellip = 0; ellip < _centers.size(); ++ellip)
97  {
99  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
100  if ((val2 > value && _invalue > _outvalue) || (val2 < value && _outvalue > _invalue))
101  {
102  value = val2;
104  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
105  }
106  }
107 
108  return gradient;
109 }
virtual RealGradient gradient(const Point &p)
virtual Real value(const Point &p)
RealGradient computeSuperellipsoidGradient(const Point &p, const Point &center, Real a, Real b, Real c, Real n)
virtual Real computeSuperellipsoidValue(const Point &p, const Point &center, Real a, Real b, Real c, Real n)
void SmoothSuperellipsoidBaseIC::initialSetup ( )
virtual

Reimplemented in BimodalInverseSuperellipsoidsIC, BimodalSuperellipsoidsIC, and MultiSmoothSuperellipsoidIC.

Definition at line 49 of file SmoothSuperellipsoidBaseIC.C.

Referenced by MultiSmoothSuperellipsoidIC::initialSetup(), and BimodalSuperellipsoidsIC::initialSetup().

50 {
51  // Compute centers, semiaxes, exponents, and initialize vector sizes
55 
56  if (_centers.size() != _as.size())
57  mooseError("_center and semiaxis _as vectors are not the same size in the Superellipsoid IC");
58  if (_centers.size() != _bs.size())
59  mooseError("_center and semiaxis _bs vectors are not the same size in the Superellipsoid IC");
60  if (_centers.size() != _cs.size())
61  mooseError("_center and semiaxis _cs vectors are not the same size in the Superellipsoid IC");
62  if (_centers.size() != _ns.size())
63  mooseError("_center and exponent _ns vectors are not the same size in the Superellipsoid IC");
64 
65  if (_centers.size() < 1)
66  mooseError("_centers, _as, _bs, _cs, and _ns were not initialized in the Superellipsoid IC");
67 }
virtual void computeSuperellipsoidSemiaxes()=0
virtual void computeSuperellipsoidCenters()=0
virtual void computeSuperellipsoidExponents()=0
Real SmoothSuperellipsoidBaseIC::value ( const Point &  p)
virtual

Reimplemented in BimodalInverseSuperellipsoidsIC.

Definition at line 70 of file SmoothSuperellipsoidBaseIC.C.

Referenced by computeSuperellipsoidInverseValue(), computeSuperellipsoidValue(), and gradient().

71 {
72  Real value = _outvalue;
73  Real val2 = 0.0;
74 
75  for (unsigned int ellip = 0; ellip < _centers.size() && value != _invalue; ++ellip)
76  {
78  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
79  if ((val2 > value && _invalue > _outvalue) || (val2 < value && _outvalue > _invalue))
80  value = val2;
81  }
82 
83  return value;
84 }
virtual Real value(const Point &p)
virtual Real computeSuperellipsoidValue(const Point &p, const Point &center, Real a, Real b, Real c, Real n)

Member Data Documentation

std::vector<Real> SmoothSuperellipsoidBaseIC::_as
protected
std::vector<Real> SmoothSuperellipsoidBaseIC::_bs
protected
std::vector<Point> SmoothSuperellipsoidBaseIC::_centers
protected
std::vector<Real> SmoothSuperellipsoidBaseIC::_cs
protected
Real SmoothSuperellipsoidBaseIC::_int_width
protected
Real SmoothSuperellipsoidBaseIC::_invalue
protected
MooseMesh& SmoothSuperellipsoidBaseIC::_mesh
protected
Real SmoothSuperellipsoidBaseIC::_nestedvalue
protected

Definition at line 52 of file SmoothSuperellipsoidBaseIC.h.

Referenced by computeSuperellipsoidInverseValue().

std::vector<Real> SmoothSuperellipsoidBaseIC::_ns
protected
unsigned int SmoothSuperellipsoidBaseIC::_num_dim
protected

Definition at line 56 of file SmoothSuperellipsoidBaseIC.h.

Real SmoothSuperellipsoidBaseIC::_outvalue
protected
MooseRandom SmoothSuperellipsoidBaseIC::_random
protected
bool SmoothSuperellipsoidBaseIC::_zero_gradient
protected

Definition at line 54 of file SmoothSuperellipsoidBaseIC.h.

Referenced by gradient().


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