22 params.
addParam<
Real>(
"x_offset", 0.5,
"Specifies offset of hexagon grid in x-direction");
24 "perturbation_percent",
26 "perturbation_percent >= 0.0 & perturbation_percent <= 1.0",
27 "The percent to randomly perturb centers of grains relative to the size of the grain");
33 _x_offset(getParam<
Real>(
"x_offset")),
34 _perturbation_percent(getParam<
Real>(
"perturbation_percent"))
38 "PolycrystalHex is supported on 2D domains or 3D domains with the columnar_3D option");
40 mooseError(
"PolycrystalHex requires an even square number for 2D or columnar 3D");
48 unsigned int d =
_dim;
54 for (
unsigned int j = 0;
j <
d; ++
j)
56 for (
unsigned int i = 0; i <
_vars.size(); ++i)
58 mooseError(
"PolycrystalHex works only with periodic BCs");
64 unsigned int grain_pow =
root;
65 for (
unsigned int i = 1; i <
d; ++i)
70 "PolycrystalHex requires a square number for 2D or columnar 3D and a cubic number for 3D");
89 unsigned int count = 0;
91 for (
unsigned int k = 0;
k < (
d == 3 ?
root : 1); ++
k)
92 for (
unsigned int j = 0; j < (d >= 2 ?
root : 1); ++
j)
93 for (
unsigned int i = 0; i <
root; ++i)
96 holder[count](0) = i * ndist + (0.5 * ndist * (
j % 2)) +
_x_offset * ndist;
99 holder[count](1) =
j * ndist + (0.5 * ndist * (
k % 2));
102 holder[count](2) =
k * ndist;
109 for (
unsigned int grain = 0; grain <
_grain_num; ++grain)
virtual Real getMaxInDimension(unsigned int component) const
virtual Real getMinInDimension(unsigned int component) const
static InputParameters validParams()
void seed(std::size_t i, unsigned int seed)
bool isTranslatedPeriodic(unsigned int nonlinear_var_num, unsigned int component) const
static constexpr std::size_t dim
std::vector< Point > _centerpoints
const Real _perturbation_percent
virtual void precomputeGrainStructure()
This callback is triggered after the object is initialized and may be optionally overridden to do pre...
PolycrystalHex(const InputParameters ¶meters)
const unsigned int _dim
mesh dimension
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
Real root(std::function< Real(Real)> const &f, Real x1, Real x2, Real tol=1.0e-12)
Finds the root of a function using Brent's method.
PolycrystalHex creates a hexagonal polycrystal initial condition.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("PhaseFieldApp", PolycrystalHex)
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
MooseMesh & _mesh
A reference to the mesh.
MooseUnits pow(const MooseUnits &, int)
static const std::string k
unsigned int _grain_num
The number of grains to create.