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

SpecifiedSmoothSuperellipsoidIC creates multiple SmoothSuperellipsoids (number = size of x_positions) that are positioned in the set locations with the set semiaxes a, b, c and exponents n. More...

#include <SpecifiedSmoothSuperellipsoidIC.h>

Inheritance diagram for SpecifiedSmoothSuperellipsoidIC:
[legend]

Public Member Functions

 SpecifiedSmoothSuperellipsoidIC (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

std::vector< Real > _x_positions
 
std::vector< Real > _y_positions
 
std::vector< Real > _z_positions
 
std::vector< Real > _input_as
 
std::vector< Real > _input_bs
 
std::vector< Real > _input_cs
 
std::vector< Real > _input_ns
 
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

SpecifiedSmoothSuperellipsoidIC creates multiple SmoothSuperellipsoids (number = size of x_positions) that are positioned in the set locations with the set semiaxes a, b, c and exponents n.

Definition at line 26 of file SpecifiedSmoothSuperellipsoidIC.h.

Constructor & Destructor Documentation

◆ SpecifiedSmoothSuperellipsoidIC()

SpecifiedSmoothSuperellipsoidIC::SpecifiedSmoothSuperellipsoidIC ( const InputParameters &  parameters)

Definition at line 36 of file SpecifiedSmoothSuperellipsoidIC.C.

37  : SmoothSuperellipsoidBaseIC(parameters),
38  _x_positions(getParam<std::vector<Real>>("x_positions")),
39  _y_positions(getParam<std::vector<Real>>("y_positions")),
40  _z_positions(getParam<std::vector<Real>>("z_positions")),
41  _input_as(getParam<std::vector<Real>>("as")),
42  _input_bs(getParam<std::vector<Real>>("bs")),
43  _input_cs(getParam<std::vector<Real>>("cs")),
44  _input_ns(getParam<std::vector<Real>>("ns"))
45 {
46 }
SmoothSuperellipsoidBaseIC(const InputParameters &parameters)

Member Function Documentation

◆ computeSuperellipsoidCenters()

void SpecifiedSmoothSuperellipsoidIC::computeSuperellipsoidCenters ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Reimplemented in BimodalInverseSuperellipsoidsIC, and BimodalSuperellipsoidsIC.

Definition at line 49 of file SpecifiedSmoothSuperellipsoidIC.C.

50 {
51  _centers.resize(_x_positions.size());
52 
53  for (unsigned int circ = 0; circ < _x_positions.size(); ++circ)
54  {
55  _centers[circ](0) = _x_positions[circ];
56  _centers[circ](1) = _y_positions[circ];
57  _centers[circ](2) = _z_positions[circ];
58  }
59 }

◆ computeSuperellipsoidExponents()

void SpecifiedSmoothSuperellipsoidIC::computeSuperellipsoidExponents ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Reimplemented in BimodalSuperellipsoidsIC.

Definition at line 77 of file SpecifiedSmoothSuperellipsoidIC.C.

78 {
79  _ns.resize(_input_ns.size());
80 
81  for (unsigned int circ = 0; circ < _input_ns.size(); ++circ)
82  _ns[circ] = _input_ns[circ];
83 }

◆ 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 SpecifiedSmoothSuperellipsoidIC::computeSuperellipsoidSemiaxes ( )
protectedvirtual

Implements SmoothSuperellipsoidBaseIC.

Reimplemented in BimodalSuperellipsoidsIC.

Definition at line 62 of file SpecifiedSmoothSuperellipsoidIC.C.

63 {
64  _as.resize(_input_as.size());
65  _bs.resize(_input_bs.size());
66  _cs.resize(_input_cs.size());
67 
68  for (unsigned int circ = 0; circ < _input_as.size(); ++circ)
69  {
70  _as[circ] = _input_as[circ];
71  _bs[circ] = _input_bs[circ];
72  _cs[circ] = _input_cs[circ];
73  }
74 }

◆ 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

◆ _as

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

◆ _bs

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

◆ _centers

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

◆ _cs

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

◆ _input_as

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_as
protected

◆ _input_bs

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_bs
protected

◆ _input_cs

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_cs
protected

◆ _input_ns

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_ns
protected

◆ _int_width

Real SmoothSuperellipsoidBaseIC::_int_width
protectedinherited

◆ _invalue

Real SmoothSuperellipsoidBaseIC::_invalue
protectedinherited

◆ _mesh

MooseMesh& SmoothSuperellipsoidBaseIC::_mesh
protectedinherited

◆ _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

◆ _x_positions

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_x_positions
protected

◆ _y_positions

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_y_positions
protected

◆ _z_positions

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_z_positions
protected

◆ _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: