11 #include "MooseMesh.h"
12 #include "MooseVariable.h"
14 #include "libmesh/utility.h"
24 params.addClassDescription(
25 "Polycrystal circles generated from a vector input or read from a file");
26 params.addParam<
bool>(
"read_from_file",
28 "Set to true to read the position and radius "
29 "vectors from a file rather than inputing them "
31 params.addParam<
bool>(
32 "columnar_3D",
false,
"3D microstructure will be columnar in the z-direction?");
33 params.addParam<std::vector<Real>>(
"x_positions",
"x coordinate for each circle center");
34 params.addParam<std::vector<Real>>(
"y_positions",
"y coordinate for each circle center");
35 params.addParam<std::vector<Real>>(
"z_positions",
"z coordinate for each circle center");
36 params.addParam<std::vector<Real>>(
"radii",
"The radius for each circle");
37 params.addParam<FileName>(
"file_name",
"File containing circle centers and radii");
38 params.addParam<Real>(
"int_width", 0.0,
"Width of diffuse interface");
45 _columnar_3D(getParam<bool>(
"columnar_3D")),
46 _int_width(getParam<Real>(
"int_width")),
53 std::vector<unsigned int> & grains)
const
58 for (
unsigned int i = 0; i < n_grains; ++i)
66 distance = std::sqrt(d_x + d_y);
79 std::vector<unsigned int> grain_ids;
83 for (
auto grain_id : grain_ids)
86 active_grain_on_op = grain_id;
96 bool readfromfile = getParam<bool>(
"read_from_file");
100 const FileName file_name = getParam<FileName>(
"file_name");
101 MooseUtils::DelimitedFileReader txt_reader(file_name, &_communicator);
104 std::vector<std::string> col_names = txt_reader.getNames();
105 std::vector<std::vector<Real>> data = txt_reader.getData();
109 std::array<int, 4> col_map = {{-1, -1, -1, -1}};
111 for (
unsigned int i = 0; i < col_names.size(); ++i)
115 mooseError(
"Columns in ", file_name,
" do not have uniform lengths.");
118 if (col_names[i] ==
"x")
120 else if (col_names[i] ==
"y")
122 else if (col_names[i] ==
"z")
124 else if (col_names[i] ==
"r")
129 if (col_map[
X] == -1)
130 mooseError(
"No column 'x' in ", file_name,
".");
131 if (col_map[
Y] == -1)
132 mooseError(
"No column 'y' in ", file_name,
".");
133 if (col_map[
Z] == -1)
134 mooseError(
"No column 'z' in ", file_name,
".");
135 if (col_map[
R] == -1)
136 mooseError(
"No column 'r' in ", file_name,
".");
139 _radii.assign(data[col_map[
R]].begin(), data[col_map[
R]].end());
150 std::vector<Real> x_c = getParam<std::vector<Real>>(
"x_positions");
151 std::vector<Real> y_c = getParam<std::vector<Real>>(
"y_positions");
152 std::vector<Real> z_c = getParam<std::vector<Real>>(
"z_positions");
153 std::vector<Real> r_c = getParam<std::vector<Real>>(
"radii");
160 mooseError(
"The vector length of x_positions does not match the length of radii");
162 mooseError(
"The vector length of y_positions does not match the length of radii");
164 mooseError(
"The vector length of z_positions does not match the length of radii");
167 _radii.assign(r_c.begin(), r_c.end());
189 d = std::sqrt(d_x + d_y);