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

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

#include <BimodalSuperellipsoidsIC.h>

Inheritance diagram for BimodalSuperellipsoidsIC:
[legend]

Public Member Functions

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

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

BimodalSuperellipsoidsIC 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. As each random particle is placed, it it checked to make sure it does not collide with previously placed particles (either large or small ones). Variables to describe the specified (larger) superellipsoids are inherited from the parent class.

Definition at line 30 of file BimodalSuperellipsoidsIC.h.

Constructor & Destructor Documentation

◆ BimodalSuperellipsoidsIC()

BimodalSuperellipsoidsIC::BimodalSuperellipsoidsIC ( const InputParameters &  parameters)

Definition at line 54 of file BimodalSuperellipsoidsIC.C.

55  : SpecifiedSmoothSuperellipsoidIC(parameters),
56  _npart(getParam<unsigned int>("npart")),
57  _small_spac(getParam<Real>("small_spac")),
58  _large_spac(getParam<Real>("large_spac")),
59  _small_a(getParam<Real>("small_a")),
60  _small_b(getParam<Real>("small_b")),
61  _small_c(getParam<Real>("small_c")),
62  _small_n(getParam<Real>("small_n")),
63  _size_variation(getParam<Real>("size_variation")),
64  _size_variation_type(getParam<MooseEnum>("size_variation_type")),
65  _max_num_tries(getParam<unsigned int>("numtries"))
66 {
67 }
unsigned int _npart
Variables to describe the randomly placed (smaller) superellipsoids.
SpecifiedSmoothSuperellipsoidIC(const InputParameters &parameters)

Member Function Documentation

◆ computeSuperellipsoidCenters()

void BimodalSuperellipsoidsIC::computeSuperellipsoidCenters ( )
protectedvirtual

Reimplemented from SpecifiedSmoothSuperellipsoidIC.

Reimplemented in BimodalInverseSuperellipsoidsIC.

Definition at line 152 of file BimodalSuperellipsoidsIC.C.

153 {
154  _centers.resize(_x_positions.size() + _npart);
155 
156  // First place the specified (large) particles from the input file
157  for (unsigned int i = 0; i < _x_positions.size(); ++i)
158  {
159  _centers[i](0) = _x_positions[i];
160  _centers[i](1) = _y_positions[i];
161  _centers[i](2) = _z_positions[i];
162  }
163 
164  // Next place the randomly positioned (small) particles
165  for (unsigned int i = _x_positions.size(); i < _x_positions.size() + _npart; ++i)
166  {
167  unsigned int num_tries = 0;
168 
169  while (num_tries < _max_num_tries)
170  {
171  num_tries++;
172 
173  RealTensorValue ran;
174  ran(0, 0) = _random.rand(_tid);
175  ran(1, 1) = _random.rand(_tid);
176  ran(2, 2) = _random.rand(_tid);
177 
178  _centers[i] = _bottom_left + ran * _range;
179 
180  // check for collisions with the specified (large) and randomly placed small particles
181  for (unsigned int j = 0; j < i; ++j)
182  {
183  // Compute the distance r1 from the center of each specified superellipsoid to its
184  // outside edge along the vector between the specified superellipsoid and the current
185  // randomly positioned one.
186  // This uses the equation for a superellipse in polar coordinates and substitutes
187  // distances for sin, cos functions.
188  Point dist_vec = _mesh.minPeriodicVector(_var.number(), _centers[i], _centers[j]);
189  const Real dist = dist_vec.norm();
190 
191  // First calculate rmn1 = r1^(-n), replacing sin, cos functions with distances
192  Real rmn1 = (std::pow(std::abs(dist_vec(0) / dist / _as[j]), _ns[j]) +
193  std::pow(std::abs(dist_vec(1) / dist / _bs[j]), _ns[j]) +
194  std::pow(std::abs(dist_vec(2) / dist / _cs[j]), _ns[j]));
195  // Then calculate r1 from rmn1
196  const Real r1 = std::pow(rmn1, (-1.0 / _ns[j]));
197 
198  // Now calculate the distance r2 from the center of the randomly placed
199  // superellipsoid to its outside edge in the same manner
200  Real rmn2 = (std::pow(std::abs(dist_vec(0) / dist / _as[i]), _ns[i]) +
201  std::pow(std::abs(dist_vec(1) / dist / _bs[i]), _ns[i]) +
202  std::pow(std::abs(dist_vec(2) / dist / _cs[i]), _ns[i]));
203  const Real r2 = std::pow(rmn2, (-1.0 / _ns[i]));
204 
205  // Calculate the distance between the edges (first in the list are the large then come the
206  // small)
207  if ((dist - r1 - r2) < (j < _x_positions.size() ? _large_spac : _small_spac))
208  goto fail;
209  }
210 
211  // accept the position of the new center
212  goto accept;
213 
214  // retry a new position until tries are exhausted
215  fail:
216  continue;
217  }
218 
219  if (num_tries == _max_num_tries)
220  mooseError("Too many tries in MultiSmoothCircleIC");
221 
222  accept:
223  continue;
224  }
225 }
unsigned int _npart
Variables to describe the randomly placed (smaller) superellipsoids.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)

◆ computeSuperellipsoidExponents()

void BimodalSuperellipsoidsIC::computeSuperellipsoidExponents ( )
protectedvirtual

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

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

Reimplemented from SmoothSuperellipsoidBaseIC.

Reimplemented in BimodalInverseSuperellipsoidsIC.

Definition at line 70 of file BimodalSuperellipsoidsIC.C.

Referenced by BimodalInverseSuperellipsoidsIC::initialSetup().

71 {
72  // Set up domain bounds with mesh tools
73  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
74  {
75  _bottom_left(i) = _mesh.getMinInDimension(i);
76  _top_right(i) = _mesh.getMaxInDimension(i);
77  }
79 
80  if (_size_variation_type == 2 && _size_variation > 0.0)
81  mooseError("If size_variation > 0.0, you must pass in a size_variation_type in "
82  "BimodalSuperellipsoidsIC");
83 
85 }

◆ 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

◆ _bottom_left

Point BimodalSuperellipsoidsIC::_bottom_left
protected

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

◆ _max_num_tries

const unsigned int BimodalSuperellipsoidsIC::_max_num_tries
protected

◆ _mesh

MooseMesh& SmoothSuperellipsoidBaseIC::_mesh
protectedinherited

◆ _nestedvalue

Real SmoothSuperellipsoidBaseIC::_nestedvalue
protectedinherited

◆ _npart

unsigned int BimodalSuperellipsoidsIC::_npart
protected

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

◆ _size_variation

const Real BimodalSuperellipsoidsIC::_size_variation
protected

◆ _size_variation_type

const MooseEnum BimodalSuperellipsoidsIC::_size_variation_type
protected

◆ _small_a

Real BimodalSuperellipsoidsIC::_small_a
protected

Definition at line 46 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidSemiaxes().

◆ _small_b

Real BimodalSuperellipsoidsIC::_small_b
protected

Definition at line 47 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidSemiaxes().

◆ _small_c

Real BimodalSuperellipsoidsIC::_small_c
protected

Definition at line 48 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidSemiaxes().

◆ _small_n

Real BimodalSuperellipsoidsIC::_small_n
protected

Definition at line 49 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidExponents().

◆ _small_spac

Real BimodalSuperellipsoidsIC::_small_spac
protected

◆ _top_right

Point BimodalSuperellipsoidsIC::_top_right
protected

Definition at line 57 of file BimodalSuperellipsoidsIC.h.

Referenced by 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: