Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 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 : 10 : #include "EulerAngleVariables2RGBAux.h" 11 : #include "Euler2RGB.h" 12 : 13 : registerMooseObject("PhaseFieldApp", EulerAngleVariables2RGBAux); 14 : 15 : InputParameters 16 23 : EulerAngleVariables2RGBAux::validParams() 17 : { 18 23 : InputParameters params = AuxKernel::validParams(); 19 23 : params.addClassDescription("Outputs one color or a scalar for the RGB-encoding of the local " 20 : "Euler angles for the grain orientation"); 21 46 : MooseEnum sd_enum = MooseEnum("100=1 010=2 001=3", "001"); 22 46 : params.addParam<MooseEnum>("sd", sd_enum, "Reference sample direction"); 23 46 : MooseEnum output_types = MooseEnum("red green blue scalar", "scalar"); 24 46 : params.addParam<MooseEnum>("output_type", output_types, "Type of value that will be outputted"); 25 46 : params.addCoupledVar("phi1", "Euler angle 1"); 26 46 : params.addCoupledVar("phi", "Euler angle 2"); 27 46 : params.addCoupledVar("phi2", "Euler angle 3"); 28 46 : params.addCoupledVar("phase", "Grain phase index"); 29 46 : params.addCoupledVar("symmetry", "Grain symmetry identifier"); 30 23 : return params; 31 23 : } 32 : 33 12 : EulerAngleVariables2RGBAux::EulerAngleVariables2RGBAux(const InputParameters & parameters) 34 : : AuxKernel(parameters), 35 12 : _sd(getParam<MooseEnum>("sd")), 36 24 : _output_type(getParam<MooseEnum>("output_type")), 37 12 : _phi1(coupledValue("phi1")), 38 12 : _phi(coupledValue("phi")), 39 12 : _phi2(coupledValue("phi2")), 40 12 : _phase(coupledValue("phase")), 41 24 : _sym(coupledValue("symmetry")) 42 : { 43 12 : } 44 : 45 : Real 46 4704 : EulerAngleVariables2RGBAux::computeValue() 47 : { 48 : // Call Euler2RGB Function to get RGB vector 49 4704 : Point RGB = euler2RGB(_sd, 50 4704 : _phi1[0] / 180.0 * libMesh::pi, 51 4704 : _phi[0] / 180.0 * libMesh::pi, 52 4704 : _phi2[0] / 180.0 * libMesh::pi, 53 4704 : _phase[0], 54 4704 : _sym[0]); 55 : 56 : // Create correct scalar output 57 4704 : if (_output_type < 3) 58 0 : return RGB(_output_type); 59 4704 : else if (_output_type == 3) 60 : { 61 : Real RGBint = 0.0; 62 18816 : for (unsigned int i = 0; i < 3; ++i) 63 14112 : RGBint = 256 * RGBint + (RGB(i) >= 1 ? 255 : std::floor(RGB(i) * 256.0)); 64 : 65 4704 : return RGBint; 66 : } 67 : else 68 0 : mooseError("Incorrect value for output_type in EulerAngleVariables2RGBAux"); 69 : }