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 27 of file SmoothSuperellipsoidIC.h.

Constructor & Destructor Documentation

◆ SmoothSuperellipsoidIC()

SmoothSuperellipsoidIC::SmoothSuperellipsoidIC ( const InputParameters &  parameters)

Definition at line 30 of file SmoothSuperellipsoidIC.C.

31  : SmoothSuperellipsoidBaseIC(parameters),
32  _x1(parameters.get<Real>("x1")),
33  _y1(parameters.get<Real>("y1")),
34  _z1(parameters.get<Real>("z1")),
35  _a(parameters.get<Real>("a")),
36  _b(parameters.get<Real>("b")),
37  _c(parameters.get<Real>("c")),
38  _n(parameters.get<Real>("n")),
39  _center(_x1, _y1, _z1)
40 {
41 }
SmoothSuperellipsoidBaseIC(const InputParameters &parameters)

Member Function Documentation

◆ computeSuperellipsoidCenters()

void SmoothSuperellipsoidIC::computeSuperellipsoidCenters ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Definition at line 44 of file SmoothSuperellipsoidIC.C.

45 {
46  _centers = {_center};
47 }

◆ computeSuperellipsoidExponents()

void SmoothSuperellipsoidIC::computeSuperellipsoidExponents ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Definition at line 58 of file SmoothSuperellipsoidIC.C.

59 {
60  _ns = {_n};
61 }

◆ computeSuperellipsoidGradient()

RealGradient SmoothSuperellipsoidBaseIC::computeSuperellipsoidGradient ( const Point &  p,
const Point &  center,
Real  a,
Real  b,
Real  c,
Real  n 
)
protectedinherited

Definition at line 195 of file SmoothSuperellipsoidBaseIC.C.

Referenced by SmoothSuperellipsoidBaseIC::gradient().

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

◆ computeSuperellipsoidInverseValue()

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

Definition at line 155 of file SmoothSuperellipsoidBaseIC.C.

Referenced by BimodalInverseSuperellipsoidsIC::value().

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

◆ computeSuperellipsoidSemiaxes()

void SmoothSuperellipsoidIC::computeSuperellipsoidSemiaxes ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Definition at line 50 of file SmoothSuperellipsoidIC.C.

◆ computeSuperellipsoidValue()

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

Definition at line 114 of file SmoothSuperellipsoidBaseIC.C.

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

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

◆ gradient()

RealGradient SmoothSuperellipsoidBaseIC::gradient ( const Point &  p)
virtualinherited

Definition at line 89 of file SmoothSuperellipsoidBaseIC.C.

90 {
91  if (_zero_gradient)
92  return 0.0;
93 
94  RealGradient gradient = 0.0;
95  Real value = _outvalue;
96  Real val2 = 0.0;
97 
98  for (unsigned int ellip = 0; ellip < _centers.size(); ++ellip)
99  {
101  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
102  if ((val2 > value && _invalue > _outvalue) || (val2 < value && _outvalue > _invalue))
103  {
104  value = val2;
106  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
107  }
108  }
109 
110  return gradient;
111 }
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)

◆ initialSetup()

void SmoothSuperellipsoidBaseIC::initialSetup ( )
virtualinherited

Reimplemented in BimodalInverseSuperellipsoidsIC, BimodalSuperellipsoidsIC, and MultiSmoothSuperellipsoidIC.

Definition at line 51 of file SmoothSuperellipsoidBaseIC.C.

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

52 {
53  // Compute centers, semiaxes, exponents, and initialize vector sizes
57 
58  if (_centers.size() != _as.size())
59  mooseError("_center and semiaxis _as vectors are not the same size in the Superellipsoid IC");
60  if (_centers.size() != _bs.size())
61  mooseError("_center and semiaxis _bs vectors are not the same size in the Superellipsoid IC");
62  if (_centers.size() != _cs.size())
63  mooseError("_center and semiaxis _cs vectors are not the same size in the Superellipsoid IC");
64  if (_centers.size() != _ns.size())
65  mooseError("_center and exponent _ns vectors are not the same size in the Superellipsoid IC");
66 
67  if (_centers.size() < 1)
68  mooseError("_centers, _as, _bs, _cs, and _ns were not initialized in the Superellipsoid IC");
69 }
virtual void computeSuperellipsoidSemiaxes()=0
virtual void computeSuperellipsoidCenters()=0
virtual void computeSuperellipsoidExponents()=0

◆ value()

Real SmoothSuperellipsoidBaseIC::value ( const Point &  p)
virtualinherited

Reimplemented in BimodalInverseSuperellipsoidsIC.

Definition at line 72 of file SmoothSuperellipsoidBaseIC.C.

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

73 {
74  Real value = _outvalue;
75  Real val2 = 0.0;
76 
77  for (unsigned int ellip = 0; ellip < _centers.size() && value != _invalue; ++ellip)
78  {
80  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
81  if ((val2 > value && _invalue > _outvalue) || (val2 < value && _outvalue > _invalue))
82  value = val2;
83  }
84 
85  return value;
86 }
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

◆ _a

const Real SmoothSuperellipsoidIC::_a
protected

Definition at line 40 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidSemiaxes().

◆ _as

std::vector<Real> SmoothSuperellipsoidBaseIC::_as
protectedinherited

◆ _b

const Real SmoothSuperellipsoidIC::_b
protected

Definition at line 41 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidSemiaxes().

◆ _bs

std::vector<Real> SmoothSuperellipsoidBaseIC::_bs
protectedinherited

◆ _c

const Real SmoothSuperellipsoidIC::_c
protected

Definition at line 42 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidSemiaxes().

◆ _center

const Point SmoothSuperellipsoidIC::_center
protected

Definition at line 44 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidCenters().

◆ _centers

std::vector<Point> SmoothSuperellipsoidBaseIC::_centers
protectedinherited

◆ _cs

std::vector<Real> SmoothSuperellipsoidBaseIC::_cs
protectedinherited

◆ _int_width

Real SmoothSuperellipsoidBaseIC::_int_width
protectedinherited

◆ _invalue

Real SmoothSuperellipsoidBaseIC::_invalue
protectedinherited

◆ _mesh

MooseMesh& SmoothSuperellipsoidBaseIC::_mesh
protectedinherited

◆ _n

const Real SmoothSuperellipsoidIC::_n
protected

Definition at line 43 of file SmoothSuperellipsoidIC.h.

Referenced by computeSuperellipsoidExponents().

◆ _nestedvalue

Real SmoothSuperellipsoidBaseIC::_nestedvalue
protectedinherited

◆ _ns

std::vector<Real> SmoothSuperellipsoidBaseIC::_ns
protectedinherited

◆ _num_dim

unsigned int SmoothSuperellipsoidBaseIC::_num_dim
protectedinherited

Definition at line 59 of file SmoothSuperellipsoidBaseIC.h.

◆ _outvalue

Real SmoothSuperellipsoidBaseIC::_outvalue
protectedinherited

◆ _random

MooseRandom SmoothSuperellipsoidBaseIC::_random
protectedinherited

◆ _x1

const Real SmoothSuperellipsoidIC::_x1
protected

Definition at line 37 of file SmoothSuperellipsoidIC.h.

◆ _y1

const Real SmoothSuperellipsoidIC::_y1
protected

Definition at line 38 of file SmoothSuperellipsoidIC.h.

◆ _z1

const Real SmoothSuperellipsoidIC::_z1
protected

Definition at line 39 of file SmoothSuperellipsoidIC.h.

◆ _zero_gradient

bool SmoothSuperellipsoidBaseIC::_zero_gradient
protectedinherited

Definition at line 57 of file SmoothSuperellipsoidBaseIC.h.

Referenced by SmoothSuperellipsoidBaseIC::gradient().


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