13 #include "MooseMesh.h"
14 #include "MooseVariable.h"
15 #include "DelimitedFileReader.h"
24 params.addRequiredParam<
unsigned int>(
"op_num",
"Number of order parameters");
26 params.addParam<
bool>(
27 "columnar_3D",
false,
"3D microstructure will be columnar in the z-direction?");
39 MooseEnum structure_options(
"grains voids");
40 params.addRequiredParam<MooseEnum>(
"structure_type",
42 "Which structure type is being initialized, grains or voids");
43 params.addParam<
unsigned int>(
"op_index",
45 "The index for the current "
46 "order parameter, not needed if "
47 "structure_type = voids");
48 params.addRequiredParam<UserObjectName>(
49 "polycrystal_ic_uo",
"UserObject for obtaining the polycrystal grain structure.");
50 params.addParam<FileName>(
53 "File containing grain centroids, if file_name is provided, the centroids "
54 "from the file will be used.");
60 _structure_type(getParam<MooseEnum>(
"structure_type")),
61 _op_num(getParam<unsigned int>(
"op_num")),
62 _op_index(getParam<unsigned int>(
"op_index")),
63 _columnar_3D(getParam<bool>(
"columnar_3D")),
65 _file_name(getParam<FileName>(
"file_name"))
68 mooseError(
"PolycrystalVoronoiVoidIC requires that the voids be "
69 "represented with invalue > outvalue");
71 mooseError(
"PolycrystalVoronoiVoidIC requires numbub > 0. If you want no voids to "
73 "represented, use invalue = outvalue. In general, you should use "
74 "PolycrystalVoronoi to represent Voronoi grain structures without "
82 mooseError(
"op_index is too large in CircleGrainVoidIC");
99 for (
unsigned int vp = 0; vp <
_numbub; ++vp)
102 unsigned int num_tries = 0;
110 mooseError(
"Too many tries of assigning void centers in "
111 "PolycrystalVoronoiVoidIC");
115 for (
unsigned int i = 0; i < LIBMESH_DIM; ++i)
120 std::vector<PolycrystalVoronoiVoidIC::DistancePoint> diff(
_grain_num);
122 for (
unsigned int gr = 0; gr <
_grain_num; ++gr)
135 Point diff_centerpoints =
136 _mesh.minPeriodicVector(_var.number(), closest_point, next_closest_point);
137 Point diff_rand_center =
_mesh.minPeriodicVector(_var.number(), closest_point, rand_point);
138 Point normal_vector = diff_centerpoints.cross(diff_rand_center);
139 Point slope = normal_vector.cross(diff_centerpoints);
142 Point midpoint = closest_point + (0.5 * diff_centerpoints);
146 Point mid_rand_vector =
_mesh.minPeriodicVector(_var.number(), midpoint, rand_point);
148 Real slope_dot = slope * slope;
149 mooseAssert(slope_dot > 0,
"The dot product of slope with itself is zero");
150 for (
unsigned int i = 0; i < LIBMESH_DIM; ++i)
151 lambda += (mid_rand_vector(i) * slope(i)) / slope_dot;
154 _centers[vp] = slope * lambda + midpoint;
157 for (
unsigned int i = 0; i < LIBMESH_DIM; i++)
161 for (
unsigned int i = 0; i < vp; ++i)
175 if (try_again ==
false)
177 Real min_rij_1, min_rij_2, rij, rij_diff_tol;
179 min_rij_1 =
_range.norm();
180 min_rij_2 =
_range.norm();
184 for (
unsigned int gr = 0; gr <
_grain_num; ++gr)
190 min_rij_2 = min_rij_1;
193 else if (rij < min_rij_2)
197 if (std::abs(min_rij_1 - min_rij_2) > rij_diff_tol)
201 }
while (try_again ==
true);
219 if (grain_value == 0)