www.mooseframework.org
EulerAngleVariables2RGBAux.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 #include "Euler2RGB.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<AuxKernel>();
15  MooseEnum sd_enum = MooseEnum("100=1 010=2 001=3", "001");
16  params.addParam<MooseEnum>("sd", sd_enum, "Reference sample direction");
17  MooseEnum output_types = MooseEnum("red green blue scalar", "scalar");
18  params.addParam<MooseEnum>("output_type", output_types, "Type of value that will be outputted");
19  params.addCoupledVar("phi1", "Euler angle 1");
20  params.addCoupledVar("phi", "Euler angle 2");
21  params.addCoupledVar("phi2", "Euler angle 3");
22  params.addCoupledVar("phase", "Grain phase index");
23  params.addCoupledVar("symmetry", "Grain symmetry indentifier");
24  return params;
25 }
26 
27 EulerAngleVariables2RGBAux::EulerAngleVariables2RGBAux(const InputParameters & parameters)
28  : AuxKernel(parameters),
29  _sd(getParam<MooseEnum>("sd")),
30  _output_type(getParam<MooseEnum>("output_type")),
31  _phi1(coupledValue("phi1")),
32  _phi(coupledValue("phi")),
33  _phi2(coupledValue("phi2")),
34  _phase(coupledValue("phase")),
35  _sym(coupledValue("symmetry"))
36 {
37 }
38 
39 Real
41 {
42  // Call Euler2RGB Function to get RGB vector
43  Point RGB = euler2RGB(_sd,
44  _phi1[0] / 180.0 * libMesh::pi,
45  _phi[0] / 180.0 * libMesh::pi,
46  _phi2[0] / 180.0 * libMesh::pi,
47  _phase[0],
48  _sym[0]);
49 
50  // Create correct scalar output
51  if (_output_type < 3)
52  return RGB(_output_type);
53  else if (_output_type == 3)
54  {
55  Real RGBint = 0.0;
56  for (unsigned int i = 0; i < 3; ++i)
57  RGBint = 256 * RGBint + (RGB(i) >= 1 ? 255 : std::floor(RGB(i) * 256.0));
58 
59  return RGBint;
60  }
61  else
62  mooseError("Incorrect value for output_type in EulerAngleVariables2RGBAux");
63 }
InputParameters validParams< EulerAngleVariables2RGBAux >()
Point euler2RGB(unsigned int sd, Real phi1, Real PHI, Real phi2, unsigned int phase, unsigned int sym)
This function rotates a set of three Bunge Euler angles into the standard Stereographic triangle...
Definition: Euler2RGB.C:43
const unsigned int _sd
Reference direction of the sample.
const unsigned int _output_type
Type of value to be outputted.
const VariableValue & _phase
EBSD Phase index.
const VariableValue & _sym
EBSD Crystal symmetry identifier.
EulerAngleVariables2RGBAux(const InputParameters &parameters)
const VariableValue & _phi1
Euler angles to visualize.