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 "ElementIntegralFunctorPostprocessor.h" 11 : 12 : registerMooseObject("MooseApp", ElementIntegralFunctorPostprocessor); 13 : registerMooseObject("MooseApp", ADElementIntegralFunctorPostprocessor); 14 : 15 : template <bool is_ad> 16 : InputParameters 17 9528 : ElementIntegralFunctorPostprocessorTempl<is_ad>::validParams() 18 : { 19 9528 : InputParameters params = ElementIntegralPostprocessor::validParams(); 20 38112 : params.addRequiredParam<MooseFunctorName>("functor", 21 : "The name of the functor that this object operates on"); 22 28584 : params.addParam<MooseFunctorName>( 23 19056 : "prefactor", 1, "The name of a pre-factor inside the integrand"); 24 19056 : params.addClassDescription("Computes a volume integral of the specified functor"); 25 19056 : MooseEnum evaluation_type(getFunctorEvaluationTypeOptions(), "QUADRATURE_POINT"); 26 28584 : params.addParam<MooseEnum>( 27 : "evaluation_type", evaluation_type, "How the functor should be evaluated."); 28 19056 : return params; 29 9528 : } 30 : 31 : template <bool is_ad> 32 135 : ElementIntegralFunctorPostprocessorTempl<is_ad>::ElementIntegralFunctorPostprocessorTempl( 33 : const InputParameters & parameters) 34 : : ElementIntegralPostprocessor(parameters), 35 135 : _functor(getFunctor<GenericReal<is_ad>>("functor")), 36 270 : _prefactor(getFunctor<GenericReal<is_ad>>("prefactor")), 37 135 : _evaluation_type( 38 405 : getParam<MooseEnum>("evaluation_type").template getEnum<FunctorEvaluationType>()) 39 : { 40 135 : } 41 : 42 : template <bool is_ad> 43 : Real 44 376 : ElementIntegralFunctorPostprocessorTempl<is_ad>::computeIntegral() 45 : { 46 376 : switch (_evaluation_type) 47 : { 48 259 : case FunctorEvaluationType::QUADRATURE_POINT: 49 259 : return ElementIntegralPostprocessor::computeIntegral(); 50 117 : case FunctorEvaluationType::CELL_AVERAGE: 51 117 : return _current_elem_volume * cellAverage(); 52 0 : default: 53 0 : mooseError("Unhandled enumerator type"); 54 : } 55 : } 56 : 57 : template <bool is_ad> 58 : Real 59 1795 : ElementIntegralFunctorPostprocessorTempl<is_ad>::computeQpIntegral() 60 : { 61 1795 : Moose::ElemQpArg elem_qp = {_current_elem, _qp, _qrule, _q_point[_qp]}; 62 3266 : return MetaPhysicL::raw_value(_prefactor(elem_qp, determineState()) * 63 4743 : MetaPhysicL::raw_value(_functor(elem_qp, determineState()))); 64 : } 65 : 66 : template <bool is_ad> 67 : Real 68 117 : ElementIntegralFunctorPostprocessorTempl<is_ad>::cellAverage() 69 : { 70 117 : const Moose::ElemArg elem_arg = makeElemArg(_current_elem); 71 117 : return MetaPhysicL::raw_value(_prefactor(elem_arg, determineState()) * 72 117 : MetaPhysicL::raw_value(_functor(elem_arg, determineState()))); 73 : } 74 : 75 : template class ElementIntegralFunctorPostprocessorTempl<false>; 76 : template class ElementIntegralFunctorPostprocessorTempl<true>;