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 "ElementAverageMaterialProperty.h" 11 : 12 : registerMooseObject("MooseApp", ElementAverageMaterialProperty); 13 : registerMooseObject("MooseApp", ADElementAverageMaterialProperty); 14 : 15 : template <bool is_ad> 16 : InputParameters 17 29009 : ElementAverageMaterialPropertyTempl<is_ad>::validParams() 18 : { 19 29009 : InputParameters params = ElementIntegralMaterialPropertyTempl<is_ad>::validParams(); 20 29009 : params.addClassDescription("Computes the average of a material property over a volume."); 21 29009 : return params; 22 0 : } 23 : 24 : template <bool is_ad> 25 251 : ElementAverageMaterialPropertyTempl<is_ad>::ElementAverageMaterialPropertyTempl( 26 : const InputParameters & parameters) 27 251 : : ElementIntegralMaterialPropertyTempl<is_ad>(parameters), _volume(0.0) 28 : { 29 251 : } 30 : 31 : template <bool is_ad> 32 : void 33 648 : ElementAverageMaterialPropertyTempl<is_ad>::initialize() 34 : { 35 648 : ElementIntegralMaterialPropertyTempl<is_ad>::initialize(); 36 : 37 648 : _volume = 0.0; 38 648 : } 39 : 40 : template <bool is_ad> 41 : void 42 481968 : ElementAverageMaterialPropertyTempl<is_ad>::execute() 43 : { 44 481968 : ElementIntegralMaterialPropertyTempl<is_ad>::execute(); 45 : 46 481968 : _volume += this->_current_elem_volume; 47 481968 : } 48 : 49 : template <bool is_ad> 50 : Real 51 594 : ElementAverageMaterialPropertyTempl<is_ad>::getValue() const 52 : { 53 594 : return _integral_value / _volume; 54 : } 55 : 56 : template <bool is_ad> 57 : void 58 594 : ElementAverageMaterialPropertyTempl<is_ad>::finalize() 59 : { 60 594 : ElementIntegralMaterialPropertyTempl<is_ad>::gatherSum(_volume); 61 594 : ElementIntegralMaterialPropertyTempl<is_ad>::gatherSum(_integral_value); 62 594 : } 63 : 64 : template <bool is_ad> 65 : void 66 54 : ElementAverageMaterialPropertyTempl<is_ad>::threadJoin(const UserObject & y) 67 : { 68 54 : ElementIntegralMaterialPropertyTempl<is_ad>::threadJoin(y); 69 : 70 54 : const auto & pps = static_cast<const ElementAverageMaterialPropertyTempl<is_ad> &>(y); 71 54 : _volume += pps._volume; 72 54 : } 73 : 74 : template class ElementAverageMaterialPropertyTempl<false>; 75 : template class ElementAverageMaterialPropertyTempl<true>;