www.mooseframework.org
EulerAngleVariables2RGBAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "Euler2RGB.h"
12 
14 
17 {
19  MooseEnum sd_enum = MooseEnum("100=1 010=2 001=3", "001");
20  params.addParam<MooseEnum>("sd", sd_enum, "Reference sample direction");
21  MooseEnum output_types = MooseEnum("red green blue scalar", "scalar");
22  params.addParam<MooseEnum>("output_type", output_types, "Type of value that will be outputted");
23  params.addCoupledVar("phi1", "Euler angle 1");
24  params.addCoupledVar("phi", "Euler angle 2");
25  params.addCoupledVar("phi2", "Euler angle 3");
26  params.addCoupledVar("phase", "Grain phase index");
27  params.addCoupledVar("symmetry", "Grain symmetry identifier");
28  return params;
29 }
30 
32  : AuxKernel(parameters),
33  _sd(getParam<MooseEnum>("sd")),
34  _output_type(getParam<MooseEnum>("output_type")),
35  _phi1(coupledValue("phi1")),
36  _phi(coupledValue("phi")),
37  _phi2(coupledValue("phi2")),
38  _phase(coupledValue("phase")),
39  _sym(coupledValue("symmetry"))
40 {
41 }
42 
43 Real
45 {
46  // Call Euler2RGB Function to get RGB vector
47  Point RGB = euler2RGB(_sd,
48  _phi1[0] / 180.0 * libMesh::pi,
49  _phi[0] / 180.0 * libMesh::pi,
50  _phi2[0] / 180.0 * libMesh::pi,
51  _phase[0],
52  _sym[0]);
53 
54  // Create correct scalar output
55  if (_output_type < 3)
56  return RGB(_output_type);
57  else if (_output_type == 3)
58  {
59  Real RGBint = 0.0;
60  for (unsigned int i = 0; i < 3; ++i)
61  RGBint = 256 * RGBint + (RGB(i) >= 1 ? 255 : std::floor(RGB(i) * 256.0));
62 
63  return RGBint;
64  }
65  else
66  mooseError("Incorrect value for output_type in EulerAngleVariables2RGBAux");
67 }
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:46
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
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)
void addCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Create an encoded RGB triplet from Euler angle data.
static InputParameters validParams()
void mooseError(Args &&... args) const
static InputParameters validParams()
registerMooseObject("PhaseFieldApp", EulerAngleVariables2RGBAux)
const VariableValue & _phi1
Euler angles to visualize.
const Real pi