https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
EBSDMeshGenerator Class Reference

Mesh generated from parameters read from a DREAM3D EBSD file. More...

#include <EBSDMeshGenerator.h>

Inheritance diagram for EBSDMeshGenerator:
[legend]

Classes

struct  Geometry
 

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 EBSDMeshGenerator (const InputParameters &parameters)
 
std::unique_ptr< MeshBase > generate () override
 
const GeometrygetEBSDGeometry () const
 
const std::string & getEBSDFilename () const
 
std::unique_ptr< CSG::CSGBasegenerateInternalCSG ()
 
std::unique_ptr< MeshBase > generateInternal ()
 
const std::set< MeshGeneratorName > & getRequestedMeshGenerators () const
 
const std::set< MeshGeneratorName > & getRequestedMeshGeneratorsForSub () const
 
void addParentMeshGenerator (const MeshGenerator &mg, const AddParentChildKey)
 
void addChildMeshGenerator (const MeshGenerator &mg, const AddParentChildKey)
 
const std::set< const MeshGenerator *, Comparator > & getParentMeshGenerators () const
 
const std::set< const MeshGenerator *, Comparator > & getChildMeshGenerators () const
 
const std::set< const MeshGenerator *, Comparator > & getSubMeshGenerators () const
 
bool isParentMeshGenerator (const MeshGeneratorName &name, const bool direct=true) const
 
bool isChildMeshGenerator (const MeshGeneratorName &name, const bool direct=true) const
 
bool isNullMeshName (const MeshGeneratorName &name) const
 
bool hasSaveMesh () const
 
bool hasOutput () const
 
const std::string & getSavedMeshName () const
 
bool hasGenerateData () const
 
bool hasGenerateCSG () const
 
bool isDataOnly () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static bool hasGenerateData (const InputParameters &params)
 
static bool hasGenerateCSG (const InputParameters &params)
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
static void setHasGenerateData (InputParameters &params)
 
static void setHasGenerateCSG (InputParameters &params)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string data_only_param
 
static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

std::unique_ptr< MeshBase > & buildMeshSubgenerator ()
 
void readEBSDHeader ()
 Read the EBSD data file header.
 
virtual void generateData ()
 
virtual std::unique_ptr< CSG::CSGBasegenerateCSG ()
 
TcopyMeshProperty (const std::string &target_data_name, const std::string &source_data_name, const std::string &source_mesh)
 
TcopyMeshProperty (const std::string &source_data_name, const std::string &source_mesh)
 
std::unique_ptr< MeshBase > & getMesh (const std::string &param_name, const bool allow_invalid=false)
 
std::vector< std::unique_ptr< MeshBase > * > getMeshes (const std::string &param_name)
 
std::unique_ptr< MeshBase > & getMeshByName (const MeshGeneratorName &mesh_generator_name)
 
std::vector< std::unique_ptr< MeshBase > * > getMeshesByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
std::unique_ptr< CSG::CSGBase > & getCSGBase (const std::string &param_name)
 
std::unique_ptr< CSG::CSGBase > & getCSGBaseByName (const MeshGeneratorName &mesh_generator_name)
 
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBases (const std::string &param_name)
 
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBasesByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
void declareMeshForSub (const std::string &param_name)
 
void declareMeshesForSub (const std::string &param_name)
 
void declareMeshForSubByName (const MeshGeneratorName &mesh_generator_name)
 
void declareMeshesForSubByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
std::unique_ptr< MeshBase > buildMeshBaseObject (unsigned int dim=libMesh::invalid_uint)
 
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh (unsigned int dim=libMesh::invalid_uint)
 
std::unique_ptr< DistributedMesh > buildDistributedMesh (unsigned int dim=libMesh::invalid_uint)
 
void addMeshSubgenerator (const std::string &type, const std::string &name, Ts... extra_input_parameters)
 
void addMeshSubgenerator (const std::string &type, const std::string &name, InputParameters params)
 
void declareNullMeshName (const MeshGeneratorName &name)
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
const TgetMeshProperty (const std::string &data_name, const std::string &prefix)
 
const TgetMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
TdeclareMeshProperty (const std::string &data_name, Args &&... args)
 
TdeclareMeshProperty (const std::string &data_name, const T &data_value)
 
TdeclareMeshProperty (const std::string &data_name, Args &&... args)
 
TdeclareMeshProperty (const std::string &data_name, const T &data_value)
 
TsetMeshProperty (const std::string &data_name, Args &&... args)
 
TsetMeshProperty (const std::string &data_name, const T &data_value)
 
TsetMeshProperty (const std::string &data_name, Args &&... args)
 
TsetMeshProperty (const std::string &data_name, const T &data_value)
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

const bool _distributed
 are we working on a distributed mesh?
 
const FileName & _filename
 Name of the file containing the EBSD data.
 
Geometry _geometry
 EBSD data file mesh information.
 
const unsigned int _pre_refine
 
std::unique_ptr< MeshBase > & _base
 
MooseMesh *const _mesh
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
const Parallel::Communicator & _communicator
 

Private Member Functions

virtual std::string meshPropertyPrefix (const std::string &) const override final
 
void checkGetMesh (const MeshGeneratorName &mesh_generator_name, const std::string &param_name) const
 
const MeshGeneratorName * getMeshGeneratorNameFromParam (const std::string &param_name, const bool allow_invalid) const
 
const std::vector< MeshGeneratorName > & getMeshGeneratorNamesFromParam (const std::string &param_name) const
 
RestartableDataValuesetMeshPropertyHelper (const std::string &data_name)
 
const RestartableDataValuegetMeshPropertyInternal (const std::string &data_name, const std::string &prefix) const
 
void mooseErrorInternal (Args &&... args) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

std::set< MeshGeneratorName > _requested_mesh_generators
 
std::set< MeshGeneratorName > _requested_mesh_generators_for_sub
 
std::vector< std::pair< std::string, std::unique_ptr< MeshBase > * > > _requested_meshes
 
std::vector< std::pair< std::string, std::unique_ptr< CSG::CSGBase > * > > _requested_csg_bases
 
std::unique_ptr< MeshBase > _null_mesh
 
std::unique_ptr< CSG::CSGBase_null_csg_base
 
std::set< const MeshGenerator *, Comparator > _parent_mesh_generators
 
std::set< const MeshGenerator *, Comparator > _child_mesh_generators
 
std::set< const MeshGenerator *, Comparator > _sub_mesh_generators
 
std::set< std::string > _null_mesh_names
 
const std::string & _save_with_name
 
const bool _data_only
 
const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
MooseApp_meta_data_app
 
const MooseObject *const _meta_data_object
 

Detailed Description

Mesh generated from parameters read from a DREAM3D EBSD file.

Definition at line 19 of file EBSDMeshGenerator.h.

Constructor & Destructor Documentation

◆ EBSDMeshGenerator()

EBSDMeshGenerator::EBSDMeshGenerator ( const InputParameters parameters)

Definition at line 45 of file EBSDMeshGenerator.C.

48 _filename(getParam<FileName>("filename")),
49 _pre_refine(isParamValid("pre_refine") ? getParam<unsigned int>("pre_refine")
50 : getParam<unsigned int>("uniform_refine")),
52{
53}
void ErrorVector unsigned int
const bool _distributed
are we working on a distributed mesh?
const FileName & _filename
Name of the file containing the EBSD data.
std::unique_ptr< MeshBase > & buildMeshSubgenerator()
std::unique_ptr< MeshBase > & _base
const unsigned int _pre_refine
MooseMesh *const _mesh
const InputParameters & parameters() const
const T & getParam(const std::string &name) const
bool isParamValid(const std::string &name) const
virtual bool isDistributedMesh() const

Member Function Documentation

◆ buildMeshSubgenerator()

std::unique_ptr< MeshBase > & EBSDMeshGenerator::buildMeshSubgenerator ( )
protected

Definition at line 56 of file EBSDMeshGenerator.C.

57{
59
60 const auto generator_type =
61 _distributed ? "DistributedRectilinearMeshGenerator" : "GeneratedMeshGenerator";
62 auto params = _app.getFactory().getValidParams(generator_type);
63
64 params.set<MooseEnum>("dim") = (_geometry.dim == 1 ? "1" : (_geometry.dim == 2 ? "2" : "3"));
65
66 std::array<unsigned int, 3> nr;
67 nr[0] = _geometry.n[0];
68 nr[1] = _geometry.n[1];
69 nr[2] = _geometry.n[2];
70
71 // set min/max box length
72 params.set<Real>("xmin") = _geometry.min[0];
73 params.set<Real>("xmax") = nr[0] * _geometry.d[0] + _geometry.min[0];
74 params.set<Real>("ymin") = _geometry.min[1];
75 params.set<Real>("ymax") = nr[1] * _geometry.d[1] + _geometry.min[1];
76 params.set<Real>("zmin") = _geometry.min[2];
77 params.set<Real>("zmax") = nr[2] * _geometry.d[2] + _geometry.min[2];
78
79 // check if the requested uniform refine level is possible and determine initial grid size
80 for (auto i : make_range(_geometry.dim))
81 {
82 auto factor = MathUtils::pow(2, _pre_refine);
83 if (nr[i] % factor != 0)
84 paramError("pre_refine",
85 "EBSDMeshGenerator error. Requested levels of pre refinement not possible.");
86 nr[i] /= factor;
87 }
88
89 if (_distributed)
90 {
91 params.set<dof_id_type>("nx") = nr[0];
92 params.set<dof_id_type>("ny") = nr[1];
93 params.set<dof_id_type>("nz") = nr[2];
94 params.set<processor_id_type>("num_cores_for_partition") =
95 isParamValid("num_cores_for_partition")
96 ? getParam<processor_id_type>("num_cores_for_partition")
97 : 0;
98 }
99 else
100 {
101 params.set<unsigned int>("nx") = nr[0];
102 params.set<unsigned int>("ny") = nr[1];
103 params.set<unsigned int>("nz") = nr[2];
104 }
105
106 addMeshSubgenerator(generator_type, name() + "_base_mesh", params);
107 return getMeshByName(name() + "_base_mesh");
108}
unsigned int dim
Geometry _geometry
EBSD data file mesh information.
void readEBSDHeader()
Read the EBSD data file header.
InputParameters getValidParams(const std::string &name) const
T & set(const std::string &name, bool quiet_mode=false)
void addMeshSubgenerator(const std::string &type, const std::string &name, Ts... extra_input_parameters)
std::unique_ptr< MeshBase > & getMeshByName(const MeshGeneratorName &mesh_generator_name)
Factory & getFactory()
const std::string & name() const
void paramError(const std::string &param, Args... args) const
MooseApp & _app
T pow(T x, int e)
uint8_t processor_id_type
uint8_t dof_id_type
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
std::array< Real, 3 > min
std::array< unsigned int, 3 > n

◆ generate()

std::unique_ptr< MeshBase > EBSDMeshGenerator::generate ( )
overridevirtual

Implements MeshGenerator.

Definition at line 191 of file EBSDMeshGenerator.C.

192{
193 if (_pre_refine)
194 {
195 libMesh::MeshRefinement mesh_refinement(*_base);
196 mesh_refinement.uniformly_refine(_pre_refine);
197 }
198 return std::move(_base);
199}

◆ getEBSDFilename()

const std::string & EBSDMeshGenerator::getEBSDFilename ( ) const
inline

Definition at line 42 of file EBSDMeshGenerator.h.

42{ return _filename; }

Referenced by EBSDReader::readFile().

◆ getEBSDGeometry()

const Geometry & EBSDMeshGenerator::getEBSDGeometry ( ) const
inline

Definition at line 41 of file EBSDMeshGenerator.h.

41{ return _geometry; }

Referenced by EBSDReader::readFile().

◆ readEBSDHeader()

void EBSDMeshGenerator::readEBSDHeader ( )
protected

Read the EBSD data file header.

Definition at line 111 of file EBSDMeshGenerator.C.

112{
113 std::ifstream stream_in(_filename.c_str());
114
115 if (!stream_in)
116 paramError("filename", "Can't open EBSD file: ", _filename);
117
118 // Labels to look for in the header
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"};
121
122 // Dimension variables to store once they are found in the header
123 // X_step, X_Dim, Y_step, Y_Dim, Z_step, Z_Dim
124 // We use Reals even though the Dim values should all be integers...
125 std::vector<Real> label_vals(labels.size(), 0.0);
126
127 std::string line;
128 while (std::getline(stream_in, line))
129 {
130 // We need to process the comment lines that have:
131 // X_step, X_Dim
132 // Y_step, Y_Dim
133 // Z_step, Z_Dim
134 // in them. The labels are case insensitive.
135 if (line.find("#") == 0)
136 {
137 // Process lines that start with a comment character (comments and meta data)
138 std::transform(line.begin(), line.end(), line.begin(), ::tolower);
139
140 for (unsigned i = 0; i < labels.size(); ++i)
141 if (line.find(labels[i]) != std::string::npos)
142 {
143 std::string dummy;
144 std::istringstream iss(line);
145 iss >> dummy >> dummy >> label_vals[i];
146
147 // One label per line, break out of for loop over labels
148 break;
149 }
150 }
151 else
152 // first non comment line marks the end of the header
153 break;
154 }
155
156 // Copy stuff out of the label_vars array into class variables
157 _geometry.d[0] = label_vals[0];
158 _geometry.n[0] = label_vals[1];
159 _geometry.min[0] = label_vals[6];
160
161 _geometry.d[1] = label_vals[2];
162 _geometry.n[1] = label_vals[3];
163 _geometry.min[1] = label_vals[7];
164
165 _geometry.d[2] = label_vals[4];
166 _geometry.n[2] = label_vals[5];
167 _geometry.min[2] = label_vals[8];
168
169 unsigned int dim;
170
171 // determine mesh dimension
172 for (dim = 3; dim > 0 && _geometry.n[dim - 1] == 0; --dim)
173 ;
174
175 // check if the data has nonzero stepsizes
176 for (unsigned i = 0; i < dim; ++i)
177 {
178 if (_geometry.n[i] == 0)
179 mooseError("Error reading header, EBSD grid size is zero.");
180 if (_geometry.d[i] == 0.0)
181 mooseError("Error reading header, EBSD data step size is zero.");
182 }
183
184 if (dim == 0)
185 mooseError("Error reading header, EBSD data is zero dimensional.");
186
187 _geometry.dim = dim;
188}
void mooseError(Args &&... args) const

Referenced by buildMeshSubgenerator().

◆ validParams()

InputParameters EBSDMeshGenerator::validParams ( )
static

Definition at line 22 of file EBSDMeshGenerator.C.

23{
25 params.addClassDescription("Mesh generated from a specified DREAM.3D EBSD data file.");
26 params.addRequiredParam<FileName>("filename", "The name of the file containing the EBSD data");
27
28 params.addDeprecatedParam<unsigned int>("uniform_refine",
29 "Deprecated. Use `pre_refine` instead.",
30 "Deprecated. Use `pre_refine` instead.");
31 params.addParam<unsigned int>(
32 "pre_refine",
33 0,
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')");
38
40 "num_cores_for_partition",
41 "Number of cores for partitioning the graph (dafaults to the number of MPI ranks)");
42 return params;
43}
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

Referenced by EBSDMeshErrorTest::testParam().

Member Data Documentation

◆ _base

std::unique_ptr<MeshBase>& EBSDMeshGenerator::_base
protected

Definition at line 63 of file EBSDMeshGenerator.h.

Referenced by generate().

◆ _distributed

const bool EBSDMeshGenerator::_distributed
protected

are we working on a distributed mesh?

Definition at line 51 of file EBSDMeshGenerator.h.

Referenced by buildMeshSubgenerator().

◆ _filename

const FileName& EBSDMeshGenerator::_filename
protected

Name of the file containing the EBSD data.

Definition at line 54 of file EBSDMeshGenerator.h.

Referenced by getEBSDFilename(), and readEBSDHeader().

◆ _geometry

Geometry EBSDMeshGenerator::_geometry
protected

EBSD data file mesh information.

Definition at line 57 of file EBSDMeshGenerator.h.

Referenced by buildMeshSubgenerator(), getEBSDGeometry(), and readEBSDHeader().

◆ _pre_refine

const unsigned int EBSDMeshGenerator::_pre_refine
protected

Definition at line 60 of file EBSDMeshGenerator.h.

Referenced by buildMeshSubgenerator(), and generate().


The documentation for this class was generated from the following files: