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

Constructor & Destructor Documentation

BimodalSuperellipsoidsIC::BimodalSuperellipsoidsIC ( const InputParameters &  parameters)

Definition at line 50 of file BimodalSuperellipsoidsIC.C.

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

Member Function Documentation

void BimodalSuperellipsoidsIC::computeSuperellipsoidCenters ( )
protectedvirtual

Reimplemented from SpecifiedSmoothSuperellipsoidIC.

Reimplemented in BimodalInverseSuperellipsoidsIC.

Definition at line 148 of file BimodalSuperellipsoidsIC.C.

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

Reimplemented from SpecifiedSmoothSuperellipsoidIC.

Definition at line 133 of file BimodalSuperellipsoidsIC.C.

134 {
135  _ns.resize(_input_ns.size() + _npart);
136 
137  // First fill in the specified (large) superellipsoids from the input file
138  for (unsigned int i = 0; i < _input_ns.size(); ++i)
139  _ns[i] = _input_ns[i];
140 
141  // Then fill in the randomly positioned (small) superellipsoids
142  // The shape is assumed to stay constant so n does not vary
143  for (unsigned int i = _input_ns.size(); i < _input_ns.size() + _npart; ++i)
144  _ns[i] = _small_n;
145 }
unsigned int _npart
Variables to describe the randomly placed (smaller) superellipsoids.
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 BimodalSuperellipsoidsIC::computeSuperellipsoidSemiaxes ( )
protectedvirtual

Reimplemented from SpecifiedSmoothSuperellipsoidIC.

Definition at line 84 of file BimodalSuperellipsoidsIC.C.

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

Reimplemented from SmoothSuperellipsoidBaseIC.

Reimplemented in BimodalInverseSuperellipsoidsIC.

Definition at line 66 of file BimodalSuperellipsoidsIC.C.

Referenced by BimodalInverseSuperellipsoidsIC::initialSetup().

67 {
68  // Set up domain bounds with mesh tools
69  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
70  {
71  _bottom_left(i) = _mesh.getMinInDimension(i);
72  _top_right(i) = _mesh.getMaxInDimension(i);
73  }
75 
76  if (_size_variation_type == 2 && _size_variation > 0.0)
77  mooseError("If size_variation > 0.0, you must pass in a size_variation_type in "
78  "BimodalSuperellipsoidsIC");
79 
81 }
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

std::vector<Real> SmoothSuperellipsoidBaseIC::_as
protectedinherited
Point BimodalSuperellipsoidsIC::_bottom_left
protected
std::vector<Real> SmoothSuperellipsoidBaseIC::_bs
protectedinherited
std::vector<Point> SmoothSuperellipsoidBaseIC::_centers
protectedinherited
std::vector<Real> SmoothSuperellipsoidBaseIC::_cs
protectedinherited
std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_as
protectedinherited
std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_bs
protectedinherited
std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_cs
protectedinherited
std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_input_ns
protectedinherited
Real SmoothSuperellipsoidBaseIC::_int_width
protectedinherited
Real SmoothSuperellipsoidBaseIC::_invalue
protectedinherited
Real BimodalSuperellipsoidsIC::_large_spac
protected
const unsigned int BimodalSuperellipsoidsIC::_max_num_tries
protected
MooseMesh& SmoothSuperellipsoidBaseIC::_mesh
protectedinherited
Real SmoothSuperellipsoidBaseIC::_nestedvalue
protectedinherited
unsigned int BimodalSuperellipsoidsIC::_npart
protected
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
Point BimodalSuperellipsoidsIC::_range
protected
const Real BimodalSuperellipsoidsIC::_size_variation
protected
const MooseEnum BimodalSuperellipsoidsIC::_size_variation_type
protected
Real BimodalSuperellipsoidsIC::_small_a
protected

Definition at line 43 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidSemiaxes().

Real BimodalSuperellipsoidsIC::_small_b
protected

Definition at line 44 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidSemiaxes().

Real BimodalSuperellipsoidsIC::_small_c
protected

Definition at line 45 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidSemiaxes().

Real BimodalSuperellipsoidsIC::_small_n
protected

Definition at line 46 of file BimodalSuperellipsoidsIC.h.

Referenced by computeSuperellipsoidExponents().

Real BimodalSuperellipsoidsIC::_small_spac
protected
Point BimodalSuperellipsoidsIC::_top_right
protected

Definition at line 54 of file BimodalSuperellipsoidsIC.h.

Referenced by initialSetup().

std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_x_positions
protectedinherited
std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_y_positions
protectedinherited
std::vector<Real> SpecifiedSmoothSuperellipsoidIC::_z_positions
protectedinherited
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: