www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EulerAngleProvider2RGBAux Class Reference

Output euler angles from user object to an AuxVariable. More...

#include <EulerAngleProvider2RGBAux.h>

Inheritance diagram for EulerAngleProvider2RGBAux:
[legend]

Public Member Functions

 EulerAngleProvider2RGBAux (const InputParameters &parameters)
 
virtual unsigned int getNumGrains () const
 

Protected Member Functions

virtual Real computeValue ()
 
virtual void precalculateValue ()
 

Protected Attributes

const unsigned int _phase
 Optional phase number needed for global grain index retrieval. More...
 
const unsigned int _sd
 Reference direction of the sample. More...
 
const unsigned int _xtal_class
 Crystal structure of the sample. More...
 
const unsigned int _output_type
 Type of value to be outputted. More...
 
const EulerAngleProvider_euler
 Object providing the Euler angles. More...
 
const EBSDReader_ebsd_reader
 EBSDReader Object. More...
 
const GrainTracker_grain_tracker
 Grain tracker object. More...
 
Real _value
 precalculated element value More...
 
const Point _no_grain_color
 Vector containing values for color in regions without grains. More...
 

Detailed Description

Output euler angles from user object to an AuxVariable.

Definition at line 29 of file EulerAngleProvider2RGBAux.h.

Constructor & Destructor Documentation

◆ EulerAngleProvider2RGBAux()

EulerAngleProvider2RGBAux::EulerAngleProvider2RGBAux ( const InputParameters &  parameters)

Definition at line 46 of file EulerAngleProvider2RGBAux.C.

47  : AuxKernel(parameters),
48  _phase(isParamValid("phase") ? getParam<unsigned int>("phase") : libMesh::invalid_uint),
49  _sd(getParam<MooseEnum>("sd")),
50  _xtal_class(getParam<MooseEnum>("crystal_structure")),
51  _output_type(getParam<MooseEnum>("output_type")),
52  _euler(getUserObject<EulerAngleProvider>("euler_angle_provider")),
53  _ebsd_reader(isParamValid("phase") ? dynamic_cast<const EBSDReader *>(&_euler) : nullptr),
54  _grain_tracker(getUserObject<GrainTracker>("grain_tracker")),
55  _no_grain_color(getParam<Point>("no_grain_color"))
56 {
57 }
const unsigned int _sd
Reference direction of the sample.
const unsigned int _xtal_class
Crystal structure of the sample.
const unsigned int _output_type
Type of value to be outputted.
const Point _no_grain_color
Vector containing values for color in regions without grains.
const EBSDReader * _ebsd_reader
EBSDReader Object.
const EulerAngleProvider & _euler
Object providing the Euler angles.
const unsigned int _phase
Optional phase number needed for global grain index retrieval.
const GrainTracker & _grain_tracker
Grain tracker object.

Member Function Documentation

◆ computeValue()

Real EulerAngleProvider2RGBAux::computeValue ( )
protectedvirtual

Definition at line 122 of file EulerAngleProvider2RGBAux.C.

123 {
124  return _value;
125 }
Real _value
precalculated element value

◆ getNumGrains()

unsigned int EulerAngleProvider2RGBAux::getNumGrains ( ) const
virtual

Definition at line 60 of file EulerAngleProvider2RGBAux.C.

Referenced by precalculateValue().

61 {
62  if (_phase != libMesh::invalid_uint)
64  else
65  return _euler.getGrainNum();
66 }
virtual unsigned int getGrainNum() const =0
const EBSDReader * _ebsd_reader
EBSDReader Object.
const EulerAngleProvider & _euler
Object providing the Euler angles.
virtual unsigned int getGrainNum() const
Return the total number of grains.
Definition: EBSDReader.C:252
const unsigned int _phase
Optional phase number needed for global grain index retrieval.

◆ precalculateValue()

void EulerAngleProvider2RGBAux::precalculateValue ( )
protectedvirtual

Definition at line 69 of file EulerAngleProvider2RGBAux.C.

70 {
71  const auto grain_id =
72  _grain_tracker.getEntityValue(isNodal() ? _current_node->id() : _current_elem->id(),
74  0);
75 
76  // Recover Euler angles for current grain and assign correct RGB value either
77  // from Euler2RGB or from _no_grain_color
78  Point RGB;
79  if (grain_id < 0)
80  RGB = _no_grain_color;
81  else
82  {
83  /* The grain index retrieved from FeatureFloodCount is the "global_id" unless
84  the "phase" option is used in the simulation. For the phase dependent case,
85  the returned grain index is the "local_id." This must be converted to a
86  "global_id" using the getGlobalID function of EBSDREader before the Euler
87  Angles are retrieved. */
88 
89  auto global_id =
90  _phase != libMesh::invalid_uint ? _ebsd_reader->getGlobalID(_phase, grain_id) : grain_id;
91  const auto num_grns = getNumGrains();
92  if (global_id > num_grns)
93  mooseError(" global_id ", global_id, " out of index range");
94 
95  // Retrieve Euler Angle values from the EulerAngleProvider
96  const RealVectorValue & angles = _euler.getEulerAngles(global_id);
97 
98  // Convert Euler Angle values to RGB colorspace for visualization purposes
99  RGB = euler2RGB(_sd,
100  angles(0) / 180.0 * libMesh::pi,
101  angles(1) / 180.0 * libMesh::pi,
102  angles(2) / 180.0 * libMesh::pi,
103  1.0,
104  _xtal_class);
105  }
106 
107  // Create correct scalar output
108  if (_output_type < 3)
109  _value = RGB(_output_type);
110  else if (_output_type == 3)
111  {
112  Real RGBint = 0.0;
113  for (unsigned int i = 0; i < 3; ++i)
114  RGBint = 256 * RGBint + (RGB(i) >= 1 ? 255 : std::floor(RGB(i) * 256.0));
115  _value = RGBint;
116  }
117  else
118  mooseError("Incorrect value for output_type in EulerAngleProvider2RGBAux");
119 }
const unsigned int _sd
Reference direction of the sample.
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
virtual unsigned int getNumGrains() const
const unsigned int _xtal_class
Crystal structure of the sample.
const unsigned int _output_type
Type of value to be outputted.
const Point _no_grain_color
Vector containing values for color in regions without grains.
const EBSDReader * _ebsd_reader
EBSDReader Object.
const EulerAngleProvider & _euler
Object providing the Euler angles.
const unsigned int _phase
Optional phase number needed for global grain index retrieval.
Real _value
precalculated element value
virtual const EulerAngles & getEulerAngles(unsigned int) const =0
const GrainTracker & _grain_tracker
Grain tracker object.
virtual Real getEntityValue(dof_id_type node_id, FieldType field_type, std::size_t var_index=0) const override
Definition: GrainTracker.C:120
virtual unsigned int getGlobalID(unsigned int phase, unsigned int local_id) const
Return the (global) grain id for a given phase and (local) grain number.
Definition: EBSDReader.h:96

Member Data Documentation

◆ _ebsd_reader

const EBSDReader* EulerAngleProvider2RGBAux::_ebsd_reader
protected

EBSDReader Object.

Definition at line 55 of file EulerAngleProvider2RGBAux.h.

Referenced by getNumGrains(), and precalculateValue().

◆ _euler

const EulerAngleProvider& EulerAngleProvider2RGBAux::_euler
protected

Object providing the Euler angles.

Definition at line 52 of file EulerAngleProvider2RGBAux.h.

Referenced by getNumGrains(), and precalculateValue().

◆ _grain_tracker

const GrainTracker& EulerAngleProvider2RGBAux::_grain_tracker
protected

Grain tracker object.

Definition at line 58 of file EulerAngleProvider2RGBAux.h.

Referenced by precalculateValue().

◆ _no_grain_color

const Point EulerAngleProvider2RGBAux::_no_grain_color
protected

Vector containing values for color in regions without grains.

Definition at line 64 of file EulerAngleProvider2RGBAux.h.

Referenced by precalculateValue().

◆ _output_type

const unsigned int EulerAngleProvider2RGBAux::_output_type
protected

Type of value to be outputted.

Definition at line 49 of file EulerAngleProvider2RGBAux.h.

Referenced by precalculateValue().

◆ _phase

const unsigned int EulerAngleProvider2RGBAux::_phase
protected

Optional phase number needed for global grain index retrieval.

Definition at line 40 of file EulerAngleProvider2RGBAux.h.

Referenced by getNumGrains(), and precalculateValue().

◆ _sd

const unsigned int EulerAngleProvider2RGBAux::_sd
protected

Reference direction of the sample.

Definition at line 43 of file EulerAngleProvider2RGBAux.h.

Referenced by precalculateValue().

◆ _value

Real EulerAngleProvider2RGBAux::_value
protected

precalculated element value

Definition at line 61 of file EulerAngleProvider2RGBAux.h.

Referenced by computeValue(), and precalculateValue().

◆ _xtal_class

const unsigned int EulerAngleProvider2RGBAux::_xtal_class
protected

Crystal structure of the sample.

Definition at line 46 of file EulerAngleProvider2RGBAux.h.

Referenced by precalculateValue().


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