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 : 13 : /** 14 : * Interface class ("Veneer") to provide encapsulate fetching energy deposition 15 : * rates from a MyTRIMElementRun class 16 : */ 17 : template <class T> 18 : class MyTRIMElementEnergyAccess : public T 19 : { 20 : public: 21 : MyTRIMElementEnergyAccess(const InputParameters & parameters); 22 : 23 : static InputParameters validParams(); 24 : Real getEnergyDensity(); 25 : 26 : protected: 27 : const MyTRIMElementRun & _mytrim; 28 : 29 : private: 30 : /// calculate values only for qp 0 and cache them here 31 : Real _value_cache; 32 : }; 33 : 34 : template <class T> 35 20 : MyTRIMElementEnergyAccess<T>::MyTRIMElementEnergyAccess(const InputParameters & parameters) 36 20 : : T(parameters), _mytrim(this->template getUserObject<MyTRIMElementRun>("runner")) 37 : { 38 20 : if (this->isNodal()) 39 0 : mooseError("MyTRIMElementEnergyAccess needs to be applied to an elemental AuxVariable."); 40 20 : } 41 : 42 : template <typename T> 43 : InputParameters 44 36 : MyTRIMElementEnergyAccess<T>::validParams() 45 : { 46 36 : InputParameters params = T::validParams(); 47 72 : params.addRequiredParam<UserObjectName>( 48 : "runner", "Name of the MyTRIMElementRun userobject to pull data from."); 49 36 : return params; 50 0 : } 51 : 52 : template <typename T> 53 : Real 54 6470000 : MyTRIMElementEnergyAccess<T>::getEnergyDensity() 55 : { 56 6470000 : if (this->_qp == 0) 57 : { 58 1617500 : auto & result = _mytrim.result(this->_current_elem); 59 : 60 : // Warning: this volume is only correct in cartesian coordinate systems 61 1617500 : const Real volume = this->_current_elem->volume(); 62 : 63 1617500 : _value_cache = result._energy / volume; 64 : } 65 : 66 6470000 : return _value_cache; 67 : }