Line data Source code
1 : /**********************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ 4 : /* */ 5 : /* Copyright 2017 Battelle Energy Alliance, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /**********************************************************************/ 8 : 9 : #pragma once 10 : 11 : #include "MyTRIMElementRun.h" 12 : #include "MyTRIMRasterizer.h" 13 : #include "ThreadedRecoilLoopBase.h" 14 : 15 : /** 16 : * Interface class ("Veneer") to provide encapsulate fetching defect production 17 : * rates from a MyTRIMElementRun class 18 : */ 19 : template <class T> 20 : class MyTRIMElementResultAccess : public T 21 : { 22 : public: 23 : MyTRIMElementResultAccess(const InputParameters & parameters); 24 : 25 : static InputParameters validParams(); 26 : Real getDefectRate(); 27 : 28 : protected: 29 : const MyTRIMElementRun & _mytrim; 30 : const MyTRIMRasterizer & _rasterizer; 31 : const unsigned int _ivar; 32 : ThreadedRecoilLoopBase::DefectType _defect; 33 : 34 : private: 35 : /// calculate values only for qp 0 and cache them here 36 : Real _value_cache; 37 : }; 38 : 39 : template <class T> 40 223 : MyTRIMElementResultAccess<T>::MyTRIMElementResultAccess(const InputParameters & parameters) 41 : : T(parameters), 42 223 : _mytrim(this->template getUserObject<MyTRIMElementRun>("runner")), 43 223 : _rasterizer(_mytrim.rasterizer()), 44 446 : _ivar(this->template getParam<unsigned int>("ivar")), 45 446 : _defect(this->template getParam<MooseEnum>("defect") 46 223 : .template getEnum<ThreadedRecoilLoopBase::DefectType>()) 47 : { 48 223 : if (this->isNodal()) 49 0 : mooseError("MyTRIMElementResultAccess needs to be applied to an elemental AuxVariable."); 50 : 51 223 : if (_ivar >= _mytrim.nVars()) 52 0 : mooseError("Requested invalid element index."); 53 223 : } 54 : 55 : template <typename T> 56 : InputParameters 57 405 : MyTRIMElementResultAccess<T>::validParams() 58 : { 59 405 : InputParameters params = T::validParams(); 60 810 : params.addRequiredParam<UserObjectName>( 61 : "runner", "Name of the MyTRIMElementRun userobject to pull data from."); 62 810 : params.addParam<unsigned int>("ivar", "Element index"); 63 810 : MooseEnum defectType("VAC=0 INT REPLACEMENT_IN REPLACEMENT_OUT", "VAC"); 64 810 : params.addParam<MooseEnum>("defect", defectType, "Defect type to read out"); 65 405 : return params; 66 405 : } 67 : 68 : template <typename T> 69 : Real 70 4478416 : MyTRIMElementResultAccess<T>::getDefectRate() 71 : { 72 4478416 : if (this->_qp == 0) 73 : { 74 762094 : auto & result = _mytrim.result(this->_current_elem); 75 : mooseAssert(_ivar < result._defects.size(), 76 : "Result set does not contain the requested element."); 77 : 78 762094 : const Real volume = this->_current_elem->volume(); 79 762094 : _value_cache = result._defects[_ivar][_defect] / volume; 80 : } 81 : 82 4478416 : return _value_cache; 83 : }