LCOV - code coverage report
Current view: top level - include/utils - FaceCenteredMapFunctor.h (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 17 23 73.9 %
Date: 2025-08-14 10:14:56 Functions: 6 27 22.2 %
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             : #include "MooseMesh.h"
      14             : #include "MooseError.h"
      15             : 
      16             : #include <set>
      17             : 
      18             : /**
      19             :  * A functor whose evaluation relies on querying a map where the keys are face info ids
      20             :  * and the values correspond to the face values. The primary purpose of this functor is to
      21             :  * store face based fields (face flux, face velocity, normal gradient) often encountered
      22             :  * in fluid dynamics problems using the finite volume method
      23             :  */
      24             : template <typename T, typename Map>
      25             : class FaceCenteredMapFunctor : public Moose::FunctorBase<T>, public Map
      26             : {
      27             : public:
      28             :   using typename Moose::FunctorBase<T>::ValueType;
      29             :   using typename Moose::FunctorBase<T>::GradientType;
      30             :   using typename Moose::FunctorBase<T>::DotType;
      31             :   using ElemArg = Moose::ElemArg;
      32             :   using FaceArg = Moose::FaceArg;
      33             :   using ElemQpArg = Moose::ElemQpArg;
      34             :   using ElemSideQpArg = Moose::ElemSideQpArg;
      35             :   using ElemPointArg = Moose::ElemPointArg;
      36             :   using StateArg = Moose::StateArg;
      37             :   using NodeArg = Moose::NodeArg;
      38             : 
      39             :   FaceCenteredMapFunctor(const MooseMesh & mesh, const std::string & name);
      40             : 
      41             :   FaceCenteredMapFunctor(const MooseMesh & mesh,
      42             :                          const std::set<SubdomainID> & sub_ids,
      43             :                          const std::string & name);
      44             : 
      45             :   bool hasBlocks(SubdomainID sub_id) const override;
      46             : 
      47             :   /**
      48             :    * Evaluate the face functor using a FaceInfo argument.
      49             :    * @param fi The object containing the face information
      50             :    */
      51             :   ValueType evaluate(const FaceInfo * const fi) const;
      52             : 
      53           0 :   bool supportsFaceArg() const override final { return true; }
      54           0 :   bool supportsElemSideQpArg() const override final { return false; }
      55             : 
      56             : private:
      57             :   /// The mesh that this functor lives on
      58             :   const MooseMesh & _mesh;
      59             : 
      60             :   /// The subdomain IDs that this functor lives on. If empty, then we consider the functor to live
      61             :   /// on all subdomains
      62             :   const std::set<SubdomainID> _sub_ids;
      63             : 
      64             :   ValueType evaluate(const ElemArg & elem_arg, const StateArg & state) const override final;
      65             :   ValueType evaluate(const FaceArg & face, const StateArg & state) const override final;
      66             :   ValueType evaluate(const ElemPointArg &, const StateArg &) const override;
      67             :   ValueType evaluate(const ElemQpArg &, const StateArg &) const override;
      68             :   ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override;
      69             :   ValueType evaluate(const NodeArg & node_arg, const StateArg & state) const override final;
      70             : };
      71             : 
      72             : template <typename T, typename Map>
      73           2 : FaceCenteredMapFunctor<T, Map>::FaceCenteredMapFunctor(const MooseMesh & mesh,
      74             :                                                        const std::string & name)
      75           8 :   : Moose::FunctorBase<T>(name), _mesh(mesh)
      76             : {
      77           4 : }
      78             : 
      79             : template <typename T, typename Map>
      80        3952 : FaceCenteredMapFunctor<T, Map>::FaceCenteredMapFunctor(const MooseMesh & mesh,
      81             :                                                        const std::set<SubdomainID> & sub_ids,
      82             :                                                        const std::string & name)
      83             :   : Moose::FunctorBase<T>(name),
      84        3952 :     _mesh(mesh),
      85       15808 :     _sub_ids(sub_ids == mesh.meshSubdomains() ? std::set<SubdomainID>() : sub_ids)
      86             : {
      87        7904 : }
      88             : 
      89             : template <typename T, typename Map>
      90             : bool
      91           0 : FaceCenteredMapFunctor<T, Map>::hasBlocks(const SubdomainID sub_id) const
      92             : {
      93           0 :   return _sub_ids.empty() || _sub_ids.count(sub_id);
      94             : }
      95             : 
      96             : template <typename T, typename Map>
      97             : typename FaceCenteredMapFunctor<T, Map>::ValueType
      98           1 : FaceCenteredMapFunctor<T, Map>::evaluate(const ElemPointArg &, const StateArg &) const
      99             : {
     100           1 :   mooseError("not implemented");
     101             : }
     102             : 
     103             : template <typename T, typename Map>
     104             : typename FaceCenteredMapFunctor<T, Map>::ValueType
     105           1 : FaceCenteredMapFunctor<T, Map>::evaluate(const ElemQpArg &, const StateArg &) const
     106             : {
     107           1 :   mooseError("not implemented");
     108             : }
     109             : 
     110             : template <typename T, typename Map>
     111             : typename FaceCenteredMapFunctor<T, Map>::ValueType
     112           1 : FaceCenteredMapFunctor<T, Map>::evaluate(const ElemSideQpArg &, const StateArg &) const
     113             : {
     114           1 :   mooseError("not implemented");
     115             : }
     116             : 
     117             : template <typename T, typename Map>
     118             : typename FaceCenteredMapFunctor<T, Map>::ValueType
     119           0 : FaceCenteredMapFunctor<T, Map>::evaluate(const NodeArg &, const StateArg &) const
     120             : {
     121           0 :   mooseError("not implemented");
     122             : }
     123             : 
     124             : template <typename T, typename Map>
     125             : inline void
     126             : dataStore(std::ostream & stream, FaceCenteredMapFunctor<T, Map> & m, void * context)
     127             : {
     128         137 :   Map & m_map = m;
     129         137 :   dataStore(stream, m_map, context);
     130             : }
     131             : 
     132             : template <typename T, typename Map>
     133             : inline void
     134             : dataLoad(std::istream & stream, FaceCenteredMapFunctor<T, Map> & m, void * context)
     135             : {
     136          68 :   Map & m_map = m;
     137          68 :   dataLoad(stream, m_map, context);
     138             : }

Generated by: LCOV version 1.14