14 #include "libmesh/int_range.h" 15 #include "libmesh/mesh_refinement.h" 26 params.
addRequiredParam<FileName>(
"filename",
"The name of the file containing the EBSD data");
29 "Deprecated. Use `pre_refine` instead.",
30 "Deprecated. Use `pre_refine` instead.");
34 "Number of coarsening levels available in adaptive mesh refinement. The resulting mesh will " 35 "have one mesh element per EBSD data cell, but will be based on a refined coarser mesh with " 36 "'pre_refine' levels of refinement. This requires all dimension of the EBSD data to be " 37 "divisible by 2^pre_refine.(this parameter was formerly called 'uniform_refine')");
40 "num_cores_for_partition",
41 "Number of cores for partitioning the graph (dafaults to the number of MPI ranks)");
47 _distributed(_mesh->isDistributedMesh()),
48 _filename(getParam<FileName>(
"filename")),
49 _pre_refine(isParamValid(
"pre_refine") ? getParam<unsigned
int>(
"pre_refine")
50 : getParam<unsigned
int>(
"uniform_refine")),
51 _base(buildMeshSubgenerator())
55 std::unique_ptr<MeshBase> &
60 const auto generator_type =
61 _distributed ?
"DistributedRectilinearMeshGenerator" :
"GeneratedMeshGenerator";
66 std::array<unsigned int, 3> nr;
83 if (nr[i] % factor != 0)
85 "EBSDMeshGenerator error. Requested levels of pre refinement not possible.");
96 ? getParam<processor_id_type>(
"num_cores_for_partition")
101 params.set<
unsigned int>(
"nx") = nr[0];
102 params.set<
unsigned int>(
"ny") = nr[1];
103 params.set<
unsigned int>(
"nz") = nr[2];
113 std::ifstream stream_in(
_filename.c_str());
119 const std::vector<std::string> labels = {
120 "x_step",
"x_dim",
"y_step",
"y_dim",
"z_step",
"z_dim",
"x_min",
"y_min",
"z_min"};
125 std::vector<Real> label_vals(labels.size(), 0.0);
128 while (std::getline(stream_in, line))
135 if (line.find(
"#") == 0)
138 std::transform(line.begin(), line.end(), line.begin(), ::tolower);
140 for (
unsigned i = 0; i < labels.size(); ++i)
141 if (line.find(labels[i]) != std::string::npos)
144 std::istringstream iss(line);
145 iss >> dummy >> dummy >> label_vals[i];
176 for (
unsigned i = 0; i <
dim; ++i)
179 mooseError(
"Error reading header, EBSD grid size is zero.");
181 mooseError(
"Error reading header, EBSD data step size is zero.");
185 mooseError(
"Error reading header, EBSD data is zero dimensional.");
190 std::unique_ptr<MeshBase>
198 return std::move(
_base);
std::unique_ptr< MeshBase > & getMeshByName(const MeshGeneratorName &mesh_generator_name)
static InputParameters validParams()
EBSDMeshGenerator(const InputParameters ¶meters)
InputParameters getValidParams(const std::string &name) const
registerMooseObject("PhaseFieldApp", EBSDMeshGenerator)
virtual const std::string & name() const
const bool _distributed
are we working on a distributed mesh?
Mesh generated from parameters read from a DREAM3D EBSD file.
void readEBSDHeader()
Read the EBSD data file header.
const unsigned int _pre_refine
bool isParamValid(const std::string &name) const
uint8_t processor_id_type
void addMeshSubgenerator(const std::string &type, const std::string &name, Ts... extra_input_parameters)
std::array< Real, 3 > min
std::unique_ptr< MeshBase > generate() override
void paramError(const std::string ¶m, Args... args) const
static InputParameters validParams()
Geometry _geometry
EBSD data file mesh information.
const FileName & _filename
Name of the file containing the EBSD data.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::unique_ptr< MeshBase > & _base
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
std::array< unsigned int, 3 > n
std::unique_ptr< MeshBase > & buildMeshSubgenerator()
void ErrorVector unsigned int
void uniformly_refine(unsigned int n=1)