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 : #pragma once 11 : 12 : #include "MooseObject.h" 13 : #include "MooseEnum.h" 14 : #include "EulerAngles.h" 15 : 16 : #include "libmesh/point.h" 17 : 18 : /** 19 : * Mix-in class that adds so called access functors to select a field from 20 : * an EBSDPointData or EBSDPointData (todo) structure. The field name is specified 21 : * by name as a std::string. 22 : */ 23 : class EBSDAccessFunctors 24 : { 25 : public: 26 : /// Per element EBSD data point 27 586612 : struct EBSDPointData 28 : { 29 : ///@{ Euler angles 30 : Real _phi1; 31 : Real _Phi; 32 : Real _phi2; 33 : ///@} 34 : 35 : /// Element centroid position 36 : Point _p; 37 : 38 : ///@{ EBSD feature id, (gklobal) grain number, symmetry, and phase data 39 : unsigned int _feature_id; 40 : unsigned int _phase; 41 : unsigned int _symmetry; 42 : ///@} 43 : 44 : /// Custom data columns 45 : std::vector<Real> _custom; 46 : }; 47 : 48 : /// Averaged EBSD data 49 3546 : struct EBSDAvgData 50 : { 51 : /// Averaged Euler angles 52 : EulerAngles * _angles; 53 : 54 : ///@{ EBSD grain, symmetry, and phase data 55 : unsigned int _feature_id; 56 : unsigned int _phase; 57 : unsigned int _symmetry; 58 : ///@} 59 : 60 : /// Index in the per-phase list of global IDs 61 : unsigned int _local_id; 62 : 63 : /// Number of EBSD data points in the global grain 64 : unsigned int _n; 65 : 66 : /// Center of mass for the global grain 67 : Point _p; 68 : 69 : /// Grain averaged custom data columns 70 : std::vector<Real> _custom; 71 : }; 72 : 73 : static MooseEnum getPointDataFieldType(); 74 : static MooseEnum getAvgDataFieldType(); 75 : 76 : /// Access functor base class for EBSDPointData 77 : struct EBSDPointDataFunctor 78 : { 79 : virtual Real operator()(const EBSDPointData &) = 0; 80 : virtual ~EBSDPointDataFunctor(){}; 81 : }; 82 : /// Access functor base class for EBSDAvgData 83 : struct EBSDAvgDataFunctor 84 : { 85 : virtual Real operator()(const EBSDAvgData &) = 0; 86 : virtual ~EBSDAvgDataFunctor(){}; 87 : }; 88 : 89 : // List of specialized access functors (one for each field in EBSDPointData) 90 66 : struct EBSDPointDataPhi1 : EBSDPointDataFunctor 91 : { 92 41345 : virtual Real operator()(const EBSDPointData & d) { return d._phi1; }; 93 : }; 94 66 : struct EBSDPointDataPhi : EBSDPointDataFunctor 95 : { 96 41345 : virtual Real operator()(const EBSDPointData & d) { return d._Phi; }; 97 : }; 98 66 : struct EBSDPointDataPhi2 : EBSDPointDataFunctor 99 : { 100 41345 : virtual Real operator()(const EBSDPointData & d) { return d._phi2; }; 101 : }; 102 116 : struct EBSDPointDataFeatureID : EBSDPointDataFunctor 103 : { 104 96195 : virtual Real operator()(const EBSDPointData & d) { return d._feature_id; }; 105 : }; 106 18 : struct EBSDPointDataPhase : EBSDPointDataFunctor 107 : { 108 7841 : virtual Real operator()(const EBSDPointData & d) { return d._phase; }; 109 : }; 110 12 : struct EBSDPointDataSymmetry : EBSDPointDataFunctor 111 : { 112 4705 : virtual Real operator()(const EBSDPointData & d) { return d._symmetry; }; 113 : }; 114 : struct EBSDPointDataCustom : EBSDPointDataFunctor 115 : { 116 0 : EBSDPointDataCustom(unsigned int index) : _index(index) {} 117 0 : virtual Real operator()(const EBSDPointData & d) 118 : { 119 : mooseAssert(_index < d._custom.size(), 120 : "Requesting out of bounds index in EBSDPointDataCustom."); 121 3 : return d._custom[_index]; 122 : }; 123 : const unsigned int _index; 124 : }; 125 : 126 : // List of specialized access functors (one for each field in EBSDAvgData) 127 0 : struct EBSDAvgDataPhi1 : EBSDAvgDataFunctor 128 : { 129 1 : virtual Real operator()(const EBSDAvgData & a) { return a._angles->phi1; }; 130 : }; 131 0 : struct EBSDAvgDataPhi : EBSDAvgDataFunctor 132 : { 133 0 : virtual Real operator()(const EBSDAvgData & a) { return a._angles->Phi; }; 134 : }; 135 0 : struct EBSDAvgDataPhi2 : EBSDAvgDataFunctor 136 : { 137 1 : virtual Real operator()(const EBSDAvgData & a) { return a._angles->phi2; }; 138 : }; 139 0 : struct EBSDAvgDataPhase : EBSDAvgDataFunctor 140 : { 141 1 : virtual Real operator()(const EBSDAvgData & a) { return a._phase; }; 142 : }; 143 0 : struct EBSDAvgDataSymmetry : EBSDAvgDataFunctor 144 : { 145 1 : virtual Real operator()(const EBSDAvgData & a) { return a._symmetry; }; 146 : }; 147 0 : struct EBSDAvgDataLocalID : EBSDAvgDataFunctor 148 : { 149 1 : virtual Real operator()(const EBSDAvgData & a) { return a._local_id; }; 150 : }; 151 36 : struct EBSDAvgDataFeatureID : EBSDAvgDataFunctor 152 : { 153 49336 : virtual Real operator()(const EBSDAvgData & a) { return a._feature_id; }; 154 : }; 155 : struct EBSDAvgDataCustom : EBSDAvgDataFunctor 156 : { 157 0 : EBSDAvgDataCustom(unsigned int index) : _index(index) {} 158 0 : virtual Real operator()(const EBSDAvgData & a) 159 : { 160 : mooseAssert(_index < a._custom.size(), 161 : "Requesting out of bounds index in EBSDPointDataCustom."); 162 3 : return a._custom[_index]; 163 : }; 164 : const unsigned int _index; 165 : }; 166 : };