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 "EBSDReaderAvgDataAux.h" 11 : #include "EBSDReader.h" 12 : #include "GrainTrackerInterface.h" 13 : 14 : registerMooseObject("PhaseFieldApp", EBSDReaderAvgDataAux); 15 : 16 : InputParameters 17 69 : EBSDReaderAvgDataAux::validParams() 18 : { 19 69 : InputParameters params = AuxKernel::validParams(); 20 69 : params.addClassDescription("Outputs the requested EBSD reader average data, for a given phase if " 21 : "specified, for the grain at the local node/element."); 22 138 : params.addParam<unsigned int>("phase", "The phase to use for all queries."); 23 138 : params.addRequiredParam<UserObjectName>("ebsd_reader", "The EBSDReader GeneralUserObject"); 24 138 : params.addRequiredParam<UserObjectName>("grain_tracker", "The GrainTracker UserObject"); 25 69 : MooseEnum field_types = EBSDAccessFunctors::getAvgDataFieldType(); 26 138 : params.addRequiredParam<MooseEnum>( 27 : "data_name", 28 : field_types, 29 : "The averaged data to be extracted from the EBSD data by this AuxKernel"); 30 138 : params.addParam<Real>("invalid", -1.0, "Value to return for points without active grains."); 31 69 : return params; 32 69 : } 33 : 34 36 : EBSDReaderAvgDataAux::EBSDReaderAvgDataAux(const InputParameters & parameters) 35 : : AuxKernel(parameters), 36 60 : _phase(isParamValid("phase") ? getParam<unsigned int>("phase") : libMesh::invalid_uint), 37 36 : _ebsd_reader(getUserObject<EBSDReader>("ebsd_reader")), 38 36 : _grain_tracker(dynamic_cast<const GrainTrackerInterface &>(getUserObjectBase("grain_tracker"))), 39 72 : _data_name(getParam<MooseEnum>("data_name")), 40 36 : _val(_ebsd_reader.getAvgDataAccessFunctor(_data_name)), 41 108 : _invalid(getParam<Real>("invalid")) 42 : { 43 36 : } 44 : 45 : void 46 53313 : EBSDReaderAvgDataAux::precalculateValue() 47 : { 48 : // get the dominant grain for the current element/node 49 : const int grain_id = 50 53313 : _grain_tracker.getEntityValue(isNodal() ? _current_node->id() : _current_elem->id(), 51 : FeatureFloodCount::FieldType::UNIQUE_REGION, 52 53313 : 0); 53 : 54 : // no grain found 55 53313 : if (grain_id < 0) 56 3978 : _value = _invalid; 57 : 58 : // get the data for the grain 59 : else 60 66131 : _value = _phase != libMesh::invalid_uint ? (*_val)(_ebsd_reader.getAvgData(_phase, grain_id)) 61 16796 : : (*_val)(_ebsd_reader.getAvgData(grain_id)); 62 53313 : } 63 : 64 : Real 65 213252 : EBSDReaderAvgDataAux::computeValue() 66 : { 67 213252 : return _value; 68 : }