www.mooseframework.org
EBSDReaderAvgDataAux.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 "EBSDReaderAvgDataAux.h"
8 #include "EBSDReader.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<AuxKernel>();
16  params.addRequiredParam<UserObjectName>("ebsd_reader", "The EBSDReader GeneralUserObject");
17  params.addRequiredParam<UserObjectName>("grain_tracker", "The GrainTracker UserObject");
18  MooseEnum field_types = EBSDAccessFunctors::getAvgDataFieldType();
19  params.addRequiredParam<MooseEnum>(
20  "data_name",
21  field_types,
22  "The averaged data to be extracted from the EBSD data by this AuxKernel");
23  params.addParam<Real>("invalid", -1.0, "Value to return for points without active grains.");
24  return params;
25 }
26 
27 EBSDReaderAvgDataAux::EBSDReaderAvgDataAux(const InputParameters & parameters)
28  : AuxKernel(parameters),
29  _ebsd_reader(getUserObject<EBSDReader>("ebsd_reader")),
30  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker")),
31  _data_name(getParam<MooseEnum>("data_name")),
32  _val(_ebsd_reader.getAvgDataAccessFunctor(_data_name)),
33  _invalid(getParam<Real>("invalid"))
34 {
35 }
36 
37 void
39 {
40  // get the dominant grain for the current element/node
41  const int grain_id =
42  _grain_tracker.getEntityValue(isNodal() ? _current_node->id() : _current_elem->id(),
44  0);
45 
46  // no grain found
47  if (grain_id < 0)
48  _value = _invalid;
49 
50  // get the data for the grain
51  else
52  _value = (*_val)(_ebsd_reader.getAvgData(grain_id));
53 }
54 
55 Real
57 {
58  return _value;
59 }
static MooseEnum getAvgDataFieldType()
This class defines the interface for the GrainTracking objects.
InputParameters validParams< EBSDReaderAvgDataAux >()
Real _value
precalculated element value
const EBSDReader & _ebsd_reader
const GrainTrackerInterface & _grain_tracker
virtual Real getEntityValue(dof_id_type entity_id, FeatureFloodCount::FieldType, std::size_t var_index=0) const =0
Accessor for retrieving either nodal or elemental information (unique grains or variable indicies) ...
EBSDReaderAvgDataAux(const InputParameters &parameters)
A GeneralUserObject that reads an EBSD file and stores the centroid data in a data structure which in...
Definition: EBSDReader.h:34
const EBSDAvgData & getAvgData(unsigned int i) const
Get the requested type of average data for (global) grain number i.
Definition: EBSDReader.C:230
virtual void precalculateValue()
const Real _invalid
Value to return for points without active grains.