14 #include "libmesh/utility.h" 24 "Polycrystal circles generated from a vector input or read from a file");
25 params.
addParam<
bool>(
"read_from_file",
27 "Set to true to read the position and radius " 28 "vectors from a file rather than inputing them " 31 "columnar_3D",
false,
"3D microstructure will be columnar in the z-direction?");
32 params.
addParam<std::vector<Real>>(
"x_positions",
"x coordinate for each circle center");
33 params.
addParam<std::vector<Real>>(
"y_positions",
"y coordinate for each circle center");
34 params.
addParam<std::vector<Real>>(
"z_positions",
"z coordinate for each circle center");
35 params.
addParam<std::vector<Real>>(
"radii",
"The radius for each circle");
36 params.
addParam<FileName>(
"file_name",
"File containing circle centers and radii");
37 params.
addParam<
Real>(
"int_width", 0.0,
"Width of diffuse interface");
44 _columnar_3D(getParam<bool>(
"columnar_3D")),
45 _int_width(getParam<
Real>(
"int_width")),
52 std::vector<unsigned int> & grains)
const 57 for (
unsigned int i = 0; i < n_grains; ++i)
78 std::vector<unsigned int> grain_ids;
82 for (
auto grain_id : grain_ids)
85 active_grain_on_op = grain_id;
95 bool readfromfile = getParam<bool>(
"read_from_file");
99 const FileName file_name = getParam<FileName>(
"file_name");
103 std::vector<std::string> col_names = txt_reader.getNames();
104 std::vector<std::vector<Real>> data = txt_reader.getData();
108 std::array<int, 4> col_map = {{-1, -1, -1, -1}};
110 for (
unsigned int i = 0; i < col_names.size(); ++i)
114 mooseError(
"Columns in ", file_name,
" do not have uniform lengths.");
117 if (col_names[i] ==
"x")
119 else if (col_names[i] ==
"y")
121 else if (col_names[i] ==
"z")
123 else if (col_names[i] ==
"r")
128 if (col_map[
X] == -1)
129 mooseError(
"No column 'x' in ", file_name,
".");
130 if (col_map[
Y] == -1)
131 mooseError(
"No column 'y' in ", file_name,
".");
132 if (col_map[
Z] == -1)
133 mooseError(
"No column 'z' in ", file_name,
".");
134 if (col_map[
R] == -1)
135 mooseError(
"No column 'r' in ", file_name,
".");
138 _radii.assign(data[col_map[
R]].begin(), data[col_map[
R]].end());
149 std::vector<Real> x_c = getParam<std::vector<Real>>(
"x_positions");
150 std::vector<Real> y_c = getParam<std::vector<Real>>(
"y_positions");
151 std::vector<Real> z_c = getParam<std::vector<Real>>(
"z_positions");
152 std::vector<Real> r_c = getParam<std::vector<Real>>(
"radii");
159 mooseError(
"The vector length of x_positions does not match the length of radii");
161 mooseError(
"The vector length of y_positions does not match the length of radii");
163 mooseError(
"The vector length of z_positions does not match the length of radii");
166 _radii.assign(r_c.begin(), r_c.end());
unsigned int _grain_num
Number of crystal grains to create.
std::map< unsigned int, unsigned int > _grain_to_op
A map of the grain_id to op.
const bool _columnar_3D
Whether to use columns or spheres in 3D geometries.
This object provides the base capability for creating proper polycrystal ICs.
registerMooseObject("PhaseFieldApp", PolycrystalCircles)
const Parallel::Communicator & _communicator
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
Real distance(const Point &p)
std::vector< Real > _radii
Radius for each circular grain created.
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
static const unsigned int invalid_id
virtual Real getVariableValue(unsigned int op_index, const Point &p) const override
Returns the variable value for a given op_index and mesh point.
Real minPeriodicDistance(unsigned int nonlinear_var_num, Point p, Point q) const
Real computeDiffuseInterface(const Point &p, const unsigned int &i) const
PolycrystalCircles(const InputParameters ¶meters)
virtual void precomputeGrainStructure() override
This callback is triggered after the object is initialized and may be optionally overridden to do pre...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void mooseError(Args &&... args) const
virtual void getGrainsBasedOnPoint(const Point &point, std::vector< unsigned int > &grains) const override
Method for retrieving active grain IDs based on some point in the mesh.
std::vector< Point > _centerpoints
x,y,z coordinates of circle centers
MooseMesh & _mesh
A reference to the mesh.
const Real _int_width
Interfacial width.
PolycrystalCircles creates a polycrystal made up of circles.
static InputParameters validParams()