19 params.
addClassDescription(
"Calculate types of grain boundaries in a polycrystalline sample");
21 "The GrainTracker UserObject to get values from.");
22 params.
addRequiredParam<UserObjectName>(
"ebsd_reader",
"The EBSDReader GeneralUserObject");
24 "v",
"var_name_base",
"op_num",
"Array of coupled variables");
25 params.
addParam<
Real>(
"angle_threshold", 15,
"Max LAGB Misorientation angle");
31 _grain_tracker(getUserObject<
GrainTracker>(
"grain_tracker")),
32 _ebsd_reader(getUserObject<
EBSDReader>(
"ebsd_reader")),
33 _op_num(coupledComponents(
"v")),
34 _vals(coupledValues(
"v")),
35 _angle_threshold(getParam<
Real>(
"angle_threshold")),
36 _gb_type(declareADProperty<
Real>(
"gb_type"))
89 if (grain_i > grain_j)
90 return grain_j + (grain_i - 1) * grain_i / 2;
92 return grain_i + (grain_j - 1) * grain_j / 2;
99 unsigned int lagb_num = 0;
100 unsigned int hagb_num = 0;
101 Real ratio_base = 0.0;
102 Real ratio_lagb = 0.0;
103 for (
unsigned int i = 1; i <
_gb_pairs.size(); ++i)
105 for (
unsigned int j = 0;
j < i; ++
j)
119 else if (hagb_num == 0)
122 return 2 - ratio_lagb / ratio_base;
128 Eigen::Quaternion<Real> & q)
131 if ((1 + O[0][0] + O[1][1] + O[2][2]) > 0)
133 q4 =
sqrt(1 + O[0][0] + O[1][1] + O[2][2]) / 2;
135 q.x() = (O[2][1] - O[1][2]) / (4 * q4);
136 q.y() = (O[0][2] - O[2][0]) / (4 * q4);
137 q.z() = (O[1][0] - O[0][1]) / (4 * q4);
139 else if ((1 + O[0][0] - O[1][1] - O[2][2]) > 0)
141 q4 =
sqrt(1 + O[0][0] - O[1][1] - O[2][2]) / 2;
142 q.w() = (O[2][1] - O[1][2]) / (4 * q4);
144 q.y() = (O[1][0] + O[0][1]) / (4 * q4);
145 q.z() = (O[0][2] + O[2][0]) / (4 * q4);
147 else if ((1 - O[0][0] + O[1][1] - O[2][2]) > 0)
149 q4 =
sqrt(1 - O[0][0] + O[1][1] - O[2][2]) / 2;
150 q.w() = (O[0][2] - O[2][0]) / (4 * q4);
151 q.x() = (O[1][0] + O[0][1]) / (4 * q4);
153 q.z() = (O[2][1] + O[1][2]) / (4 * q4);
155 else if ((1 - O[0][0] - O[1][1] + O[2][2]) > 0)
157 q4 =
sqrt(1 - O[0][0] - O[1][1] + O[2][2]) / 2;
158 q.w() = (O[1][0] - O[0][1]) / (4 * q4);
159 q.x() = (O[0][2] + O[2][0]) / (4 * q4);
160 q.y() = (O[2][1] + O[1][2]) / (4 * q4);
173 double sym_rotation[24][3][3] = {
174 {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{1, 0, 0}, {0, -1, 0}, {0, 0, -1}},
175 {{1, 0, 0}, {0, 0, -1}, {0, 1, 0}}, {{1, 0, 0}, {0, 0, 1}, {0, -1, 0}},
176 {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}}, {{-1, 0, 0}, {0, -1, 0}, {0, 0, 1}},
177 {{-1, 0, 0}, {0, 0, -1}, {0, -1, 0}}, {{-1, 0, 0}, {0, 0, 1}, {0, 1, 0}},
178 {{0, 1, 0}, {-1, 0, 0}, {0, 0, 1}}, {{0, 1, 0}, {0, 0, -1}, {-1, 0, 0}},
179 {{0, 1, 0}, {1, 0, 0}, {0, 0, -1}}, {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}},
180 {{0, -1, 0}, {1, 0, 0}, {0, 0, 1}}, {{0, -1, 0}, {0, 0, -1}, {1, 0, 0}},
181 {{0, -1, 0}, {-1, 0, 0}, {0, 0, -1}}, {{0, -1, 0}, {0, 0, 1}, {-1, 0, 0}},
182 {{0, 0, 1}, {0, 1, 0}, {-1, 0, 0}}, {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}},
183 {{0, 0, 1}, {0, -1, 0}, {1, 0, 0}}, {{0, 0, 1}, {-1, 0, 0}, {0, -1, 0}},
184 {{0, 0, -1}, {0, 1, 0}, {1, 0, 0}}, {{0, 0, -1}, {-1, 0, 0}, {0, 1, 0}},
185 {{0, 0, -1}, {0, -1, 0}, {-1, 0, 0}}, {{0, 0, -1}, {1, 0, 0}, {0, -1, 0}}};
188 for (
int o = 0; o <
_o_sym; o++)
195 const Eigen::Quaternion<Real> qj)
198 Eigen::Quaternion<Real> q, qib, qjb, qmin;
204 for (
int o1 = 0; o1 <
_o_sym; o1++)
206 for (
int o2 = 0; o2 <
_o_sym; o2++)
216 miso0 =
round(2 * std::acos(q.w()) * 1e5) / 1e5;
220 if (std::abs(miso0) < misom)
222 misom = std::abs(miso0);
228 miso0 = 2 * std::acos(qmin.w());
232 return std::abs(miso0);
250 mooseAssert(grain_id < grain_num,
"Feature ids cannot exceed max grain number");
255 for (
const auto j :
make_range(std::make_unsigned_t<int>(1), grain_num))
double getMisorientationFromQuaternion(const Eigen::Quaternion< Real > qi, const Eigen::Quaternion< Real > qj)
Function to return the misorientation of two quaternions.
const Real _angle_threshold
the max value of LAGB
ComputeGBMisorientationType(const InputParameters ¶meters)
virtual unsigned int getLineNum(unsigned int grain_i, unsigned int grain_j)
Function to obtain line number for a given grain pair.
void defineSymmetryOperator()
Function to define the symmetry operator.
void rotationSymmetryToQuaternion(const double O[3][3], Eigen::Quaternion< Real > &q)
Function to convert symmetry matrix to quaternion form.
registerMooseObject("PhaseFieldApp", ComputeGBMisorientationType)
virtual Real getTripleJunctionType()
Function to get the GB type for triple junctions.
std::vector< Real > _gb_op_pairs
std::vector< EulerAngles > _euler_angle
unsigned int getFeatureID(unsigned int phase, unsigned int local_id) const
Return the EBSD feature id for a given phase and phase (local) grain number.
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const override
Returns a list of active unique feature ids for a particular element.
std::vector< double > _misorientation_angles
Parameters to calculate the Misorientation angle file.
static InputParameters validParams()
virtual void computeQpProperties() override
Necessary override. This is where the property values are set.
const std::vector< const VariableValue * > _vals
const GrainTracker & _grain_tracker
Grain tracker object.
virtual const EulerAngles & getEulerAngles(unsigned int) const
EulerAngleProvider interface implementation to fetch a triplet of Euler angles.
A GeneralUserObject that reads an EBSD file and stores the centroid data in a data structure which in...
static const unsigned int invalid_id
std::vector< unsigned int > _gb_pairs
parameters to store the EBSD id and corresponding value on GB
std::vector< Eigen::Quaternion< Real > > _sym_quat
The parameters to calculate the misorientation.
virtual unsigned int getGrainNum() const
Return the total number of grains.
std::vector< Eigen::Quaternion< Real > > _quat_angle
static InputParameters validParams()
virtual unsigned int getTotalLineNum() const
Function to obtain the total line number in misorientation angle file.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
IntRange< T > make_range(T beg, T end)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
Visualize the location of grain boundaries in a polycrystalline simulation.
ADMaterialProperty< Real > & _gb_type
precalculated element value
auto index_range(const T &sizable)
const Elem *const & _current_elem
void getMisorientationAngles()
Get the Misorientation angle.
const EBSDReader & _ebsd_reader
EBSD reader user object.