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

BimodalInverseSuperellipsoidsIC takes a specified number of superellipsoids, each with given parameters These are intended to be the larger particles. More...

#include <BimodalInverseSuperellipsoidsIC.h>

Inheritance diagram for BimodalInverseSuperellipsoidsIC:
[legend]

Public Member Functions

 BimodalInverseSuperellipsoidsIC (const InputParameters &parameters)
 
virtual Real value (const Point &p)
 Have to do things slightly different from SmoothSuperellipsoidBaseIC because of the inverse structure. More...
 
virtual void initialSetup ()
 
virtual void computeSuperellipsoidCenters ()
 
virtual RealGradient gradient (const Point &p)
 

Protected Member Functions

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 unsigned int _max_num_tries
 
Point _bottom_left
 
Point _top_right
 
Point _range
 
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
 
unsigned int _npart
 Variables to describe the randomly placed (smaller) superellipsoids. More...
 
Real _small_spac
 
Real _large_spac
 
Real _small_a
 
Real _small_b
 
Real _small_c
 
Real _small_n
 
const Real _size_variation
 
const MooseEnum _size_variation_type
 

Detailed Description

BimodalInverseSuperellipsoidsIC takes a specified number of superellipsoids, each with given parameters These are intended to be the larger particles.

Then the IC creates a specified number of particles at random locations. These are the smaller particles. Unlike in the parent class, the smaller particles are embedded inside the larger particles, which is why this IC is referred to as Inverse.

Definition at line 30 of file BimodalInverseSuperellipsoidsIC.h.

Constructor & Destructor Documentation

◆ BimodalInverseSuperellipsoidsIC()

BimodalInverseSuperellipsoidsIC::BimodalInverseSuperellipsoidsIC ( const InputParameters &  parameters)

Definition at line 29 of file BimodalInverseSuperellipsoidsIC.C.

30  : BimodalSuperellipsoidsIC(parameters)
31 {
32 }
BimodalSuperellipsoidsIC(const InputParameters &parameters)

Member Function Documentation

◆ computeSuperellipsoidCenters()

void BimodalInverseSuperellipsoidsIC::computeSuperellipsoidCenters ( )
virtual

Reimplemented from BimodalSuperellipsoidsIC.

Definition at line 73 of file BimodalInverseSuperellipsoidsIC.C.

74 {
75  _centers.resize(_x_positions.size() + _npart);
76 
77  // First place the specified (large) particles from the input file
78  for (unsigned int i = 0; i < _x_positions.size(); ++i)
79  {
80  _centers[i](0) = _x_positions[i];
81  _centers[i](1) = _y_positions[i];
82  _centers[i](2) = _z_positions[i];
83  }
84 
85  // Next place the randomly positioned (small) particles
86  for (unsigned int i = _x_positions.size(); i < _x_positions.size() + _npart; ++i)
87  {
88  unsigned int num_tries = 0;
89 
90  while (num_tries < _max_num_tries)
91  {
92  num_tries++;
93 
94  RealTensorValue ran;
95  ran(0, 0) = _random.rand(_tid);
96  ran(1, 1) = _random.rand(_tid);
97  ran(2, 2) = _random.rand(_tid);
98 
99  _centers[i] = _bottom_left + ran * _range;
100 
101  // check for collisions with the specified (large) and randomly placed small particles
102  for (unsigned int j = 0; j < i; ++j)
103  {
104  // Compute the distance r1 from the center of each specified superellipsoid to its
105  // outside edge along the vector between the specified superellipsoid and the current
106  // randomly positioned one.
107  // This uses the equation for a superellipse in polar coordinates and substitutes
108  // distances for sin, cos functions.
109  Point dist_vec = _mesh.minPeriodicVector(_var.number(), _centers[i], _centers[j]);
110  const Real dist = dist_vec.norm();
111 
112  // First calculate rmn1 = r1^(-n), replacing sin, cos functions with distances
113  Real rmn1 = (std::pow(std::abs(dist_vec(0) / dist / _as[j]), _ns[j]) +
114  std::pow(std::abs(dist_vec(1) / dist / _bs[j]), _ns[j]) +
115  std::pow(std::abs(dist_vec(2) / dist / _cs[j]), _ns[j]));
116  // Then calculate r1 from rmn1
117  const Real r1 = std::pow(rmn1, (-1.0 / _ns[j]));
118 
119  // Now calculate the distance r2 from the center of the randomly placed
120  // superellipsoid to its outside edge in the same manner
121  Real rmn2 = (std::pow(std::abs(dist_vec(0) / dist / _as[i]), _ns[i]) +
122  std::pow(std::abs(dist_vec(1) / dist / _bs[i]), _ns[i]) +
123  std::pow(std::abs(dist_vec(2) / dist / _cs[i]), _ns[i]));
124  const Real r2 = std::pow(rmn2, (-1.0 / _ns[i]));
125 
126  if (j < _x_positions.size())
127  {
128  if (r1 - dist - r2 < _large_spac)
129  goto fail;
130  }
131  else
132  {
133  if (dist - r1 - r2 < _small_spac)
134  goto fail;
135  }
136  }
137 
138  // accept the position of the new center
139  goto accept;
140 
141  // retry a new position until tries are exhausted
142  fail:
143  continue;
144  }
145 
146  if (num_tries == _max_num_tries)
147  mooseError("Too many tries in MultiSmoothCircleIC");
148 
149  accept:
150  continue;
151  }
152 }
unsigned int _npart
Variables to describe the randomly placed (smaller) superellipsoids.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)

◆ computeSuperellipsoidExponents()

void BimodalSuperellipsoidsIC::computeSuperellipsoidExponents ( )
protectedvirtualinherited

Reimplemented from SpecifiedSmoothSuperellipsoidIC.

Definition at line 137 of file BimodalSuperellipsoidsIC.C.

138 {
139  _ns.resize(_input_ns.size() + _npart);
140 
141  // First fill in the specified (large) superellipsoids from the input file
142  for (unsigned int i = 0; i < _input_ns.size(); ++i)
143  _ns[i] = _input_ns[i];
144 
145  // Then fill in the randomly positioned (small) superellipsoids
146  // The shape is assumed to stay constant so n does not vary
147  for (unsigned int i = _input_ns.size(); i < _input_ns.size() + _npart; ++i)
148  _ns[i] = _small_n;
149 }
unsigned int _npart
Variables to describe the randomly placed (smaller) superellipsoids.

◆ 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 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 BimodalSuperellipsoidsIC::computeSuperellipsoidSemiaxes ( )
protectedvirtualinherited

Reimplemented from SpecifiedSmoothSuperellipsoidIC.

Definition at line 88 of file BimodalSuperellipsoidsIC.C.

89 {
90  _as.resize(_input_as.size() + _npart);
91  _bs.resize(_input_bs.size() + _npart);
92  _cs.resize(_input_cs.size() + _npart);
93 
94  // First fill in the specified (large) superellipsoids from the input file
95  for (unsigned int i = 0; i < _input_as.size(); ++i)
96  {
97  _as[i] = _input_as[i];
98  _bs[i] = _input_bs[i];
99  _cs[i] = _input_cs[i];
100  }
101 
102  // Then fill in the randomly positioned (small) superellipsoids
103  for (unsigned int i = _input_as.size(); i < _input_as.size() + _npart; ++i)
104  {
105  // Vary semiaxes
106  switch (_size_variation_type)
107  {
108  case 0: // Random distrubtion, maintaining constant shape
109  {
110  Real rand_num = _random.rand(_tid);
111  _as[i] = _small_a * (1.0 + (1.0 - 2.0 * rand_num) * _size_variation);
112  _bs[i] = _small_b * (1.0 + (1.0 - 2.0 * rand_num) * _size_variation);
113  _cs[i] = _small_c * (1.0 + (1.0 - 2.0 * rand_num) * _size_variation);
114  break;
115  }
116  case 1: // Normal distribution of semiaxis size, maintaining constant shape
117  _as[i] = _random.randNormal(_tid, _small_a, _size_variation);
118  _bs[i] = _as[i] * _small_b / _small_a;
119  _cs[i] = _as[i] * _small_c / _small_a;
120  break;
121  case 2: // No variation
122  _as[i] = _small_a;
123  _bs[i] = _small_b;
124  _cs[i] = _small_c;
125  }
126 
127  if (_as[i] < 0.0)
128  _as[i] = 0.0;
129  if (_bs[i] < 0.0)
130  _bs[i] = 0.0;
131  if (_cs[i] < 0.0)
132  _cs[i] = 0.0;
133  }
134 }
unsigned int _npart
Variables to describe the randomly placed (smaller) superellipsoids.

◆ 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 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 BimodalInverseSuperellipsoidsIC::initialSetup ( )
virtual

Reimplemented from BimodalSuperellipsoidsIC.

Definition at line 35 of file BimodalInverseSuperellipsoidsIC.C.

36 {
37  if (_size_variation_type == 2 && _size_variation > 0.0)
38  paramError("size_variation",
39  "If size_variation > 0.0, you must pass in a size_variation_type in "
40  "BimodalInverseSuperellipsoidsIC");
41 
43 }

◆ value()

Real BimodalInverseSuperellipsoidsIC::value ( const Point &  p)
virtual

Have to do things slightly different from SmoothSuperellipsoidBaseIC because of the inverse structure.

Reimplemented from SmoothSuperellipsoidBaseIC.

Definition at line 46 of file BimodalInverseSuperellipsoidsIC.C.

47 {
48  Real value = _outvalue;
49  Real val2 = 0.0;
50 
51  // First loop over the specified superellipsoids
52  for (unsigned int ellip = 0; ellip < _x_positions.size() && value != _invalue; ++ellip)
53  {
55  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
56  if ((val2 > value && _invalue > _outvalue) || (val2 < value && _outvalue > _invalue))
57  value = val2;
58  }
59 
60  // Then loop over the randomly positioned particles and set value inside them back to outvalue
61  for (unsigned int ellip = _x_positions.size(); ellip < _x_positions.size() + _npart; ++ellip)
62  {
64  p, _centers[ellip], _as[ellip], _bs[ellip], _cs[ellip], _ns[ellip]);
65  if ((val2 < value && _invalue > _outvalue) || (val2 > value && _outvalue > _invalue))
66  value = val2;
67  }
68 
69  return value;
70 }
virtual Real value(const Point &p)
Have to do things slightly different from SmoothSuperellipsoidBaseIC because of the inverse structure...
unsigned int _npart
Variables to describe the randomly placed (smaller) superellipsoids.
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)

Member Data Documentation

◆ _as

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

◆ _bottom_left

Point BimodalSuperellipsoidsIC::_bottom_left
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
protectedinherited

◆ _input_bs

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

◆ _input_cs

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

◆ _input_ns

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

◆ _int_width

Real SmoothSuperellipsoidBaseIC::_int_width
protectedinherited

◆ _invalue

Real SmoothSuperellipsoidBaseIC::_invalue
protectedinherited

◆ _large_spac

Real BimodalSuperellipsoidsIC::_large_spac
protectedinherited

◆ _max_num_tries

const unsigned int BimodalSuperellipsoidsIC::_max_num_tries
protectedinherited

◆ _mesh

MooseMesh& SmoothSuperellipsoidBaseIC::_mesh
protectedinherited

◆ _nestedvalue

Real SmoothSuperellipsoidBaseIC::_nestedvalue
protectedinherited

◆ _npart

unsigned int BimodalSuperellipsoidsIC::_npart
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

◆ _range

Point BimodalSuperellipsoidsIC::_range
protectedinherited

◆ _size_variation

const Real BimodalSuperellipsoidsIC::_size_variation
protectedinherited

◆ _size_variation_type

const MooseEnum BimodalSuperellipsoidsIC::_size_variation_type
protectedinherited

◆ _small_a

Real BimodalSuperellipsoidsIC::_small_a
protectedinherited

◆ _small_b

Real BimodalSuperellipsoidsIC::_small_b
protectedinherited

◆ _small_c

Real BimodalSuperellipsoidsIC::_small_c
protectedinherited

◆ _small_n

Real BimodalSuperellipsoidsIC::_small_n
protectedinherited

◆ _small_spac

Real BimodalSuperellipsoidsIC::_small_spac
protectedinherited

◆ _top_right

Point BimodalSuperellipsoidsIC::_top_right
protectedinherited

Definition at line 57 of file BimodalSuperellipsoidsIC.h.

Referenced by BimodalSuperellipsoidsIC::initialSetup().

◆ _x_positions

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

◆ _y_positions

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

◆ _z_positions

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

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