LCOV - code coverage report
Current view: top level - include/utils - VectorComponentFunctor.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 28 30 93.3 %
Date: 2025-07-17 01:28:37 Functions: 13 45 28.9 %
Legend: Lines: hit not hit

          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 vector functor and then returns the result indexed at a given component.
      19             :  */
      20             : template <typename T>
      21             : class VectorComponentFunctor : 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             :   using VectorArg = typename libMesh::TensorTools::IncrementRank<T>::type;
      28             :   using VectorFunctor = FunctorBase<VectorArg>;
      29             : 
      30          10 :   VectorComponentFunctor(const VectorFunctor & vector, const unsigned int component)
      31          10 :     : FunctorBase<T>(vector.functorName() + "_" + std::to_string(component)),
      32          10 :       _vector(vector),
      33          30 :       _component(component)
      34             :   {
      35          20 :   }
      36             : 
      37             :   bool isExtrapolatedBoundaryFace(const FaceInfo & fi,
      38             :                                   const Elem * elem,
      39             :                                   const Moose::StateArg & state) const override;
      40           6 :   bool hasBlocks(SubdomainID sub_id) const override { return _vector.hasBlocks(sub_id); }
      41             : 
      42           0 :   bool supportsFaceArg() const override final { return _vector.supportsFaceArg(); }
      43           0 :   bool supportsElemSideQpArg() const override final { return _vector.supportsElemSideQpArg(); }
      44             : 
      45             : private:
      46             :   /// The parent vector functor
      47             :   const VectorFunctor & _vector;
      48             : 
      49             :   /// The component at which we'll index the parent vector functor evaluation result
      50             :   const unsigned int _component;
      51             : 
      52          19 :   ValueType evaluate(const ElemArg & elem, const StateArg & state) const override final
      53             :   {
      54          19 :     return _vector(elem, state)(_component);
      55             :   }
      56             : 
      57          25 :   ValueType evaluate(const FaceArg & face, const StateArg & state) const override final
      58             :   {
      59          25 :     return _vector(face, state)(_component);
      60             :   }
      61             : 
      62           1 :   ValueType evaluate(const ElemQpArg & elem_qp, const StateArg & state) const override final
      63             :   {
      64           1 :     return _vector(elem_qp, state)(_component);
      65             :   }
      66             : 
      67           1 :   ValueType evaluate(const ElemSideQpArg & elem_side_qp,
      68             :                      const StateArg & state) const override final
      69             :   {
      70           1 :     return _vector(elem_side_qp, state)(_component);
      71             :   }
      72             : 
      73           1 :   ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const override final
      74             :   {
      75           1 :     return _vector(elem_point, state)(_component);
      76             :   }
      77             : 
      78           1 :   ValueType evaluate(const NodeArg & node, const StateArg & state) const override final
      79             :   {
      80           1 :     return _vector(node, state)(_component);
      81             :   }
      82             : 
      83             :   using FunctorBase<T>::evaluateGradient;
      84           2 :   GradientType evaluateGradient(const ElemArg & elem_arg,
      85             :                                 const StateArg & state) const override final
      86             :   {
      87           2 :     return _vector.gradient(elem_arg, state).row(_component);
      88             :   }
      89             : 
      90           1 :   GradientType evaluateGradient(const FaceArg & face, const StateArg & state) const override final
      91             :   {
      92           1 :     return _vector.gradient(face, state).row(_component);
      93             :   }
      94             : 
      95             :   using FunctorBase<T>::evaluateGradDot;
      96           2 :   GradientType evaluateGradDot(const ElemArg & elem_arg,
      97             :                                const StateArg & state) const override final
      98             :   {
      99           2 :     return _vector.gradDot(elem_arg, state).row(_component);
     100             :   }
     101             : 
     102           1 :   GradientType evaluateGradDot(const FaceArg & face, const StateArg & state) const override final
     103             :   {
     104           1 :     return _vector.gradDot(face, state).row(_component);
     105             :   }
     106             : };
     107             : 
     108             : template <typename T>
     109             : bool
     110          48 : VectorComponentFunctor<T>::isExtrapolatedBoundaryFace(const FaceInfo & fi,
     111             :                                                       const Elem * elem,
     112             :                                                       const Moose::StateArg & state) const
     113             : {
     114          48 :   return _vector.isExtrapolatedBoundaryFace(fi, elem, state);
     115             : }
     116             : }

Generated by: LCOV version 1.14