www.mooseframework.org
EulerAngle2RGBAction.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 /****************************************************************/
7 #include "EulerAngle2RGBAction.h"
8 #include "Factory.h"
9 #include "FEProblem.h"
10 
11 #include "libmesh/string_to_enum.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<Action>();
18  params.addParam<std::string>("auxvariable_name_base", "RGB", "Base name of the auxvariables");
19  params.addClassDescription("Set up auxvariables and auxkernels to output Euler angles as RGB "
20  "values interpolated across inverse pole figure");
21  MooseEnum sd_enum = MooseEnum("100=1 010=2 001=3", "001");
22  params.addParam<MooseEnum>("sd", sd_enum, "Reference sample direction");
23  MooseEnum structure_enum = MooseEnum(
24  "cubic=43 hexagonal=62 tetragonal=42 trigonal=32 orthorhombic=22 monoclinic=2 triclinic=1");
25  params.addRequiredParam<MooseEnum>(
26  "crystal_structure", structure_enum, "Crystal structure of the material");
27  params.addRequiredParam<UserObjectName>("euler_angle_provider",
28  "Name of Euler angle provider user object");
29  params.addRequiredParam<UserObjectName>("grain_tracker",
30  "The GrainTracker UserObject to get values from.");
31  params.addParam<Point>(
32  "no_grain_color",
33  Point(0, 0, 0),
34  "RGB value of color used to represent area with no grains, defaults to black");
35  return params;
36 }
37 
38 EulerAngle2RGBAction::EulerAngle2RGBAction(const InputParameters & params)
39  : Action(params), _var_name_base(getParam<std::string>("auxvariable_name_base"))
40 {
41 }
42 
43 void
45 {
46  // Auxvariable suffix names that will automatically become a vector in Paraview
47  std::vector<std::string> suffixes = {"_x", "_y", "_z"};
48 
49  // Three color types that will be outputted
50  std::vector<std::string> colors = {"red", "green", "blue"};
51 
52  for (unsigned int i = 0; i < 3; ++i)
53  {
54  // Create the auxvariable name
55  std::string var_name = _var_name_base + suffixes[i];
56 
57  if (_current_task == "add_aux_variable")
58  {
59  // Create scalar auxvariables for the three components of the RGB vector
60  _problem->addAuxVariable(var_name,
61  FEType(Utility::string_to_enum<Order>("CONSTANT"),
62  Utility::string_to_enum<FEFamily>("MONOMIAL")));
63  }
64  else if (_current_task == "add_aux_kernel")
65  {
66  // Create auxkernels corresponding to each auxvariable
67  InputParameters params = _factory.getValidParams("EulerAngleProvider2RGBAux");
68  params.set<AuxVariableName>("variable") = var_name;
69  params.set<MooseEnum>("sd") = getParam<MooseEnum>("sd");
70  params.set<MooseEnum>("crystal_structure") = getParam<MooseEnum>("crystal_structure");
71  params.set<MooseEnum>("output_type") = colors[i];
72  params.set<UserObjectName>("euler_angle_provider") =
73  getParam<UserObjectName>("euler_angle_provider");
74  params.set<UserObjectName>("grain_tracker") = getParam<UserObjectName>("grain_tracker");
75  params.set<MultiMooseEnum>("execute_on") = "initial timestep_end";
76  params.set<Point>("no_grain_color") = getParam<Point>("no_grain_color");
77  _problem->addAuxKernel("EulerAngleProvider2RGBAux", var_name, params);
78  }
79  else
80  mooseError("Internal error in EulerAngle2RGBAction.");
81  }
82 }
const std::string _var_name_base
EulerAngle2RGBAction(const InputParameters &params)
InputParameters validParams< EulerAngle2RGBAction >()