www.mooseframework.org
EBSDReaderAvgDataAux.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 
10 #include "EBSDReaderAvgDataAux.h"
11 #include "EBSDReader.h"
12 #include "GrainTrackerInterface.h"
13 
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<AuxKernel>();
21  params.addParam<unsigned int>("phase", "The phase to use for all queries.");
22  params.addRequiredParam<UserObjectName>("ebsd_reader", "The EBSDReader GeneralUserObject");
23  params.addRequiredParam<UserObjectName>("grain_tracker", "The GrainTracker UserObject");
24  MooseEnum field_types = EBSDAccessFunctors::getAvgDataFieldType();
25  params.addRequiredParam<MooseEnum>(
26  "data_name",
27  field_types,
28  "The averaged data to be extracted from the EBSD data by this AuxKernel");
29  params.addParam<Real>("invalid", -1.0, "Value to return for points without active grains.");
30  return params;
31 }
32 
33 EBSDReaderAvgDataAux::EBSDReaderAvgDataAux(const InputParameters & parameters)
34  : AuxKernel(parameters),
35  _phase(isParamValid("phase") ? getParam<unsigned int>("phase") : libMesh::invalid_uint),
36  _ebsd_reader(getUserObject<EBSDReader>("ebsd_reader")),
37  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker")),
38  _data_name(getParam<MooseEnum>("data_name")),
39  _val(_ebsd_reader.getAvgDataAccessFunctor(_data_name)),
40  _invalid(getParam<Real>("invalid"))
41 {
42 }
43 
44 void
46 {
47  // get the dominant grain for the current element/node
48  const int grain_id =
49  _grain_tracker.getEntityValue(isNodal() ? _current_node->id() : _current_elem->id(),
51  0);
52 
53  // no grain found
54  if (grain_id < 0)
55  _value = _invalid;
56 
57  // get the data for the grain
58  else
59  _value = _phase != libMesh::invalid_uint ? (*_val)(_ebsd_reader.getAvgData(_phase, grain_id))
60  : (*_val)(_ebsd_reader.getAvgData(grain_id));
61 }
62 
63 Real
65 {
66  return _value;
67 }
EBSDReaderAvgDataAux::_grain_tracker
const GrainTrackerInterface & _grain_tracker
Grain tracker user object.
Definition: EBSDReaderAvgDataAux.h:43
GrainTrackerInterface
This class defines the interface for the GrainTracking objects.
Definition: GrainTrackerInterface.h:24
FeatureFloodCount::FieldType::UNIQUE_REGION
EBSDReaderAvgDataAux::_val
MooseSharedPointer< EBSDAvgDataFunctor > _val
Accessor functor to fetch the selected data field form the EBSD data point.
Definition: EBSDReaderAvgDataAux.h:49
libMesh
Definition: RANFSNormalMechanicalContact.h:24
registerMooseObject
registerMooseObject("PhaseFieldApp", EBSDReaderAvgDataAux)
validParams< EBSDReaderAvgDataAux >
InputParameters validParams< EBSDReaderAvgDataAux >()
Definition: EBSDReaderAvgDataAux.C:18
EBSDReader.h
EBSDReader
A GeneralUserObject that reads an EBSD file and stores the centroid data in a data structure which in...
Definition: EBSDReader.h:36
EBSDReaderAvgDataAux::_invalid
const Real _invalid
Value to return for points without active grains.
Definition: EBSDReaderAvgDataAux.h:52
EBSDReaderAvgDataAux::_phase
const unsigned int _phase
Optional phase number needed for global grain index retrieval.
Definition: EBSDReaderAvgDataAux.h:37
EBSDReaderAvgDataAux::EBSDReaderAvgDataAux
EBSDReaderAvgDataAux(const InputParameters &parameters)
Definition: EBSDReaderAvgDataAux.C:33
EBSDReaderAvgDataAux.h
GrainTrackerInterface.h
EBSDReaderAvgDataAux
This kernel makes data from the EBSDReader GeneralUserObject available as AuxVariables.
Definition: EBSDReaderAvgDataAux.h:27
EBSDReaderAvgDataAux::precalculateValue
virtual void precalculateValue()
Definition: EBSDReaderAvgDataAux.C:45
GrainTrackerInterface::getEntityValue
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)
EBSDReader::getAvgData
const EBSDAvgData & getAvgData(unsigned int i) const
Get the requested type of average data for (global) grain number i.
Definition: EBSDReader.C:351
EBSDReaderAvgDataAux::computeValue
virtual Real computeValue()
Definition: EBSDReaderAvgDataAux.C:64
EBSDReaderAvgDataAux::_value
Real _value
precalculated element value
Definition: EBSDReaderAvgDataAux.h:55
EBSDAccessFunctors::getAvgDataFieldType
static MooseEnum getAvgDataFieldType()
Definition: EBSDAccessFunctors.C:19
EBSDReaderAvgDataAux::_ebsd_reader
const EBSDReader & _ebsd_reader
EBSD reader user object.
Definition: EBSDReaderAvgDataAux.h:40