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

SmoothSuperellipsoidIC creates a Superellipsoid of given semiaxes a,b,c and exponent n centered at a given point in the domain. More...

#include <SmoothSuperellipsoidIC.h>

Inheritance diagram for SmoothSuperellipsoidIC:
[legend]

Public Member Functions

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

Protected Member Functions

virtual void computeSuperellipsoidCenters ()
 
virtual void computeSuperellipsoidSemiaxes ()
 
virtual void computeSuperellipsoidExponents ()
 
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)
 

Protected Attributes

const Real _x1
 
const Real _y1
 
const Real _z1
 
const Real _a
 
const Real _b
 
const Real _c
 
const Real _n
 
const Point _center
 
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

SmoothSuperellipsoidIC creates a Superellipsoid of given semiaxes a,b,c and exponent n centered at a given point in the domain.

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

Definition at line 24 of file SmoothSuperellipsoidIC.h.

Constructor & Destructor Documentation

SmoothSuperellipsoidIC::SmoothSuperellipsoidIC ( const InputParameters &  parameters)

Definition at line 25 of file SmoothSuperellipsoidIC.C.

26  : SmoothSuperellipsoidBaseIC(parameters),
27  _x1(parameters.get<Real>("x1")),
28  _y1(parameters.get<Real>("y1")),
29  _z1(parameters.get<Real>("z1")),
30  _a(parameters.get<Real>("a")),
31  _b(parameters.get<Real>("b")),
32  _c(parameters.get<Real>("c")),
33  _n(parameters.get<Real>("n")),
34  _center(_x1, _y1, _z1)
35 {
36 }
SmoothSuperellipsoidBaseIC(const InputParameters &parameters)

Member Function Documentation

void SmoothSuperellipsoidIC::computeSuperellipsoidCenters ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Definition at line 39 of file SmoothSuperellipsoidIC.C.

40 {
41  _centers = {_center};
42 }
void SmoothSuperellipsoidIC::computeSuperellipsoidExponents ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Definition at line 53 of file SmoothSuperellipsoidIC.C.

54 {
55  _ns = {_n};
56 }
RealGradient SmoothSuperellipsoidBaseIC::computeSuperellipsoidGradient ( const Point &  p,
const Point &  center,
Real  a,
Real  b,
Real  c,
Real  n 
)
protectedinherited

Definition at line 193 of file SmoothSuperellipsoidBaseIC.C.

Referenced by SmoothSuperellipsoidBaseIC::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 
)
protectedvirtualinherited

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)
void SmoothSuperellipsoidIC::computeSuperellipsoidSemiaxes ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Definition at line 45 of file SmoothSuperellipsoidIC.C.

Real SmoothSuperellipsoidBaseIC::computeSuperellipsoidValue ( const Point &  p,
const Point &  center,
Real  a,
Real  b,
Real  c,
Real  n 
)
protectedvirtualinherited

Definition at line 112 of file SmoothSuperellipsoidBaseIC.C.

Referenced by SmoothSuperellipsoidBaseIC::gradient(), SmoothSuperellipsoidBaseIC::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)
virtualinherited

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

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)
virtualinherited

Reimplemented in BimodalInverseSuperellipsoidsIC.

Definition at line 70 of file SmoothSuperellipsoidBaseIC.C.

Referenced by SmoothSuperellipsoidBaseIC::computeSuperellipsoidInverseValue(), SmoothSuperellipsoidBaseIC::computeSuperellipsoidValue(), and SmoothSuperellipsoidBaseIC::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

const Real SmoothSuperellipsoidIC::_a
protected

Definition at line 37 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidSemiaxes().

std::vector<Real> SmoothSuperellipsoidBaseIC::_as
protectedinherited
const Real SmoothSuperellipsoidIC::_b
protected

Definition at line 38 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidSemiaxes().

std::vector<Real> SmoothSuperellipsoidBaseIC::_bs
protectedinherited
const Real SmoothSuperellipsoidIC::_c
protected

Definition at line 39 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidSemiaxes().

const Point SmoothSuperellipsoidIC::_center
protected

Definition at line 41 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidCenters().

std::vector<Point> SmoothSuperellipsoidBaseIC::_centers
protectedinherited
std::vector<Real> SmoothSuperellipsoidBaseIC::_cs
protectedinherited
Real SmoothSuperellipsoidBaseIC::_int_width
protectedinherited
Real SmoothSuperellipsoidBaseIC::_invalue
protectedinherited
MooseMesh& SmoothSuperellipsoidBaseIC::_mesh
protectedinherited
const Real SmoothSuperellipsoidIC::_n
protected

Definition at line 40 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidExponents().

Real SmoothSuperellipsoidBaseIC::_nestedvalue
protectedinherited
std::vector<Real> SmoothSuperellipsoidBaseIC::_ns
protectedinherited
unsigned int SmoothSuperellipsoidBaseIC::_num_dim
protectedinherited

Definition at line 56 of file SmoothSuperellipsoidBaseIC.h.

Real SmoothSuperellipsoidBaseIC::_outvalue
protectedinherited
MooseRandom SmoothSuperellipsoidBaseIC::_random
protectedinherited
const Real SmoothSuperellipsoidIC::_x1
protected

Definition at line 34 of file SmoothSuperellipsoidIC.h.

const Real SmoothSuperellipsoidIC::_y1
protected

Definition at line 35 of file SmoothSuperellipsoidIC.h.

const Real SmoothSuperellipsoidIC::_z1
protected

Definition at line 36 of file SmoothSuperellipsoidIC.h.

bool SmoothSuperellipsoidBaseIC::_zero_gradient
protectedinherited

Definition at line 54 of file SmoothSuperellipsoidBaseIC.h.

Referenced by SmoothSuperellipsoidBaseIC::gradient().


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