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 : #pragma once 11 : 12 : #include "MooseFunctor.h" 13 : 14 : namespace Moose 15 : { 16 : /** 17 : * This is essentially a forwarding functor that forwards the spatial and temporal evaluation 18 : * arguments to the parent array functor and then returns the result indexed at a given component. 19 : */ 20 : template <typename T, typename ArrayTypeFunctor> 21 : class ArrayComponentFunctor : public FunctorBase<T> 22 : { 23 : public: 24 : using typename FunctorBase<T>::ValueType; 25 : using typename FunctorBase<T>::GradientType; 26 : using typename FunctorBase<T>::DotType; 27 : 28 228 : ArrayComponentFunctor(const ArrayTypeFunctor & array, const unsigned int component) 29 228 : : FunctorBase<T>(array.functorName() + "_" + std::to_string(component)), 30 228 : _array(array), 31 684 : _component(component) 32 : { 33 456 : } 34 : 35 : bool isExtrapolatedBoundaryFace(const FaceInfo & fi, 36 : const Elem * elem, 37 : const Moose::StateArg & state) const override; 38 96 : bool hasBlocks(SubdomainID sub_id) const override { return _array.hasBlocks(sub_id); } 39 : 40 0 : bool supportsFaceArg() const override final { return _array.supportsFaceArg(); } 41 0 : bool supportsElemSideQpArg() const override final { return _array.supportsElemSideQpArg(); } 42 : 43 : private: 44 : /// The parent array functor 45 : const ArrayTypeFunctor & _array; 46 : 47 : /// The component at which we'll index the parent array functor evaluation result 48 : const unsigned int _component; 49 : 50 252 : ValueType evaluate(const ElemArg & elem, const StateArg & state) const override final 51 : { 52 252 : return _array(elem, state)[_component]; 53 : } 54 : 55 408 : ValueType evaluate(const FaceArg & face, const StateArg & state) const override final 56 : { 57 408 : return _array(face, state)[_component]; 58 : } 59 : 60 0 : ValueType evaluate(const ElemQpArg & elem_qp, const StateArg & state) const override final 61 : { 62 0 : return _array(elem_qp, state)[_component]; 63 : } 64 : 65 0 : ValueType evaluate(const ElemSideQpArg & elem_side_qp, 66 : const StateArg & state) const override final 67 : { 68 0 : return _array(elem_side_qp, state)[_component]; 69 : } 70 : 71 0 : ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const override final 72 : { 73 0 : return _array(elem_point, state)[_component]; 74 : } 75 : 76 0 : ValueType evaluate(const NodeArg & node, const StateArg & state) const override final 77 : { 78 0 : return _array(node, state)[_component]; 79 : } 80 : 81 : using FunctorBase<T>::evaluateGradient; 82 48 : GradientType evaluateGradient(const ElemArg & elem, const StateArg & state) const override final 83 : { 84 48 : return _array.gradient(elem, state)[_component]; 85 : } 86 0 : GradientType evaluateGradient(const NodeArg & node, const StateArg & state) const override final 87 : { 88 0 : return _array.gradient(node, state)[_component]; 89 : } 90 : }; 91 : 92 : template <typename T, typename ArrayTypeFunctor> 93 : bool 94 816 : ArrayComponentFunctor<T, ArrayTypeFunctor>::isExtrapolatedBoundaryFace( 95 : const FaceInfo & fi, const Elem * const elem, const Moose::StateArg & state) const 96 : { 97 816 : return _array.isExtrapolatedBoundaryFace(fi, elem, state); 98 : } 99 : }