11 #include "MooseRandom.h"
12 #include "MooseMesh.h"
13 #include "MathUtils.h"
22 params.addClassDescription(
"Perturbed hexagonal polycrystal");
23 params.addParam<Real>(
"x_offset", 0.5,
"Specifies offset of hexagon grid in x-direction");
24 params.addRangeCheckedParam<Real>(
25 "perturbation_percent",
27 "perturbation_percent >= 0.0 & perturbation_percent <= 1.0",
28 "The percent to randomly perturb centers of grains relative to the size of the grain");
34 _x_offset(getParam<Real>(
"x_offset")),
35 _perturbation_percent(getParam<Real>(
"perturbation_percent"))
37 _random.seed(_tid, getParam<unsigned int>(
"rand_seed"));
46 unsigned int grain_pow =
root;
47 for (
unsigned int i = 1; i <
_dim; ++i)
51 mooseError(
"PolycrystalHex requires a square or cubic number depending on the mesh dimension");
54 for (
unsigned int i = 0; i < LIBMESH_DIM; ++i)
66 const Real ndist = 1.0 /
root;
70 unsigned int count = 0;
71 for (
unsigned int k = 0; k < (
_dim == 3 ?
root : 1); ++k)
72 for (
unsigned int j = 0; j < (
_dim >= 2 ?
root : 1); ++j)
73 for (
unsigned int i = 0; i <
root; ++i)
76 holder[count](0) = i * ndist + (0.5 * ndist * (j % 2)) +
_x_offset * ndist;
79 holder[count](1) = j * ndist + (0.5 * ndist * (k % 2));
82 holder[count](2) = k * ndist;
89 for (
unsigned int grain = 0; grain <
_grain_num; ++grain)
90 for (
unsigned int i = 0; i < LIBMESH_DIM; ++i)