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 "FunctorVectorElementalAux.h" 11 : #include "metaphysicl/raw_type.h" 12 : 13 : registerMooseObject("MooseApp", FunctorVectorElementalAux); 14 : registerMooseObject("MooseApp", ADFunctorVectorElementalAux); 15 : 16 : template <bool is_ad> 17 : InputParameters 18 28717 : FunctorVectorElementalAuxTempl<is_ad>::validParams() 19 : { 20 28717 : InputParameters params = AuxKernel::validParams(); 21 28717 : params.addClassDescription( 22 : "Evaluates a vector functor (material property usually) on the current element." 23 : "For finite volume, this evaluates the vector functor at the centroid."); 24 28717 : params.addRequiredParam<MooseFunctorName>("functor", "The functor to evaluate"); 25 28717 : params.addRequiredParam<unsigned int>("component", "Component of the vector functor"); 26 28717 : params.addParam<MooseFunctorName>("factor", 1, "A factor to apply on the functor"); 27 : 28 28717 : return params; 29 0 : } 30 : 31 : template <bool is_ad> 32 91 : FunctorVectorElementalAuxTempl<is_ad>::FunctorVectorElementalAuxTempl( 33 : const InputParameters & parameters) 34 : : AuxKernel(parameters), 35 91 : _functor(getFunctor<GenericRealVectorValue<is_ad>>("functor")), 36 91 : _component(getParam<unsigned int>("component")), 37 182 : _factor(getFunctor<GenericReal<is_ad>>("factor")) 38 : { 39 91 : if (isNodal()) 40 0 : paramError("variable", "This AuxKernel only supports Elemental fields"); 41 91 : } 42 : 43 : template <bool is_ad> 44 : Real 45 3584 : FunctorVectorElementalAuxTempl<is_ad>::computeValue() 46 : { 47 3584 : const auto elem_arg = makeElemArg(_current_elem); 48 3584 : const auto state = determineState(); 49 4864 : return MetaPhysicL::raw_value(_factor(elem_arg, state)) * 50 4864 : MetaPhysicL::raw_value(_functor(elem_arg, state)(_component)); 51 : }