LCOV - code coverage report
Current view: top level - include/fvkernels - FVFluxKernel.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 1 1 100.0 %
Date: 2025-07-17 01:28:37 Functions: 1 1 100.0 %
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 "FVKernel.h"
      13             : #include "MathFVUtils.h"
      14             : #include "NeighborCoupleable.h"
      15             : #include "TwoMaterialPropertyInterface.h"
      16             : #include "NeighborMooseVariableInterface.h"
      17             : #include "NeighborCoupleableMooseVariableDependencyIntermediateInterface.h"
      18             : #include "FVFaceResidualObject.h"
      19             : #include "FaceArgInterface.h"
      20             : 
      21             : class FaceInfo;
      22             : 
      23             : /// FVFluxKernel is used for calculating residual contributions from numerical
      24             : /// fluxes from surface integral terms in a finite volume discretization of a
      25             : /// PDE (i.e.  terms where the divergence theorem is applied).  As with finite
      26             : /// element kernels, all solution values and material properties must be
      27             : /// indexed using the _qp member.  Note that all interfaces for finite volume
      28             : /// kernels are AD-based - be sure to use AD material properties and other AD
      29             : /// values to maintain good jacobian/derivative quality.
      30             : class FVFluxKernel : public FVKernel,
      31             :                      public TwoMaterialPropertyInterface,
      32             :                      public NeighborMooseVariableInterface<Real>,
      33             :                      public NeighborCoupleableMooseVariableDependencyIntermediateInterface,
      34             :                      public FVFaceResidualObject,
      35             :                      public FaceArgProducerInterface
      36             : {
      37             : public:
      38             :   static InputParameters validParams();
      39             :   FVFluxKernel(const InputParameters & params);
      40             : 
      41             :   void computeResidual() override;
      42             :   void computeJacobian() override;
      43             :   void computeResidualAndJacobian() override;
      44             :   void computeResidual(const FaceInfo & fi) override;
      45             :   void computeJacobian(const FaceInfo & fi) override;
      46             :   void computeResidualAndJacobian(const FaceInfo & fi) override;
      47             : 
      48        5147 :   const MooseVariableFV<Real> & variable() const override { return _var; }
      49             : 
      50             :   bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override;
      51             : 
      52             : protected:
      53             :   /// This is the primary function that must be implemented for flux kernel
      54             :   /// terms.  Material properties will be initialized on the face - using any
      55             :   /// reconstructed fv variable gradients if any.  Values for the solution are
      56             :   /// provided for both the elem and neighbor side of the face.
      57             :   virtual ADReal computeQpResidual() = 0;
      58             : 
      59             :   /// Calculates and returns "grad_u dot normal" on the face to be used for
      60             :   /// diffusive terms.  If using any cross-diffusion corrections, etc. all
      61             :   /// those calculations will be handled for appropriately by this function.
      62             :   virtual ADReal gradUDotNormal(const Moose::StateArg & time, const bool correct_skewness) const;
      63             : 
      64             :   /// Kernels are called even on boundaries in case one is for a variable with
      65             :   /// a dirichlet BC - in which case we need to run the kernel with a
      66             :   /// ghost-element.  This returns true if we need to run because of dirichlet
      67             :   /// conditions - otherwise this returns false and all jacobian/residual calcs
      68             :   /// should be skipped.
      69             :   virtual bool skipForBoundary(const FaceInfo & fi) const;
      70             : 
      71             :   const RealVectorValue & normal() const { return _normal; }
      72             : 
      73             :   MooseVariableFV<Real> & _var;
      74             : 
      75             :   const unsigned int _qp = 0;
      76             : 
      77             :   /// The elem solution value of the kernel's _var for the current face.
      78             :   const ADVariableValue & _u_elem;
      79             :   /// The neighbor solution value of the kernel's _var for the current face.
      80             :   const ADVariableValue & _u_neighbor;
      81             : 
      82             :   /// This is the outward unit normal vector for the face the kernel is currently
      83             :   /// operating on.  By convention, this is set to be pointing outward from the
      84             :   /// face's elem element and residual calculations should keep this in mind.
      85             :   RealVectorValue _normal;
      86             : 
      87             :   /// This is holds meta-data for geometric information relevant to the current
      88             :   /// face including elem+neighbor cell centroids, cell volumes, face area, etc.
      89             :   const FaceInfo * _face_info = nullptr;
      90             : 
      91             :   /// The face type
      92             :   FaceInfo::VarFaceNeighbors _face_type;
      93             : 
      94             :   /**
      95             :    * Return whether the supplied face is on a boundary of this object's execution
      96             :    */
      97             :   bool onBoundary(const FaceInfo & fi) const;
      98             : 
      99             :   /**
     100             :    * @return an element argument corresponding to the face info elem
     101             :    */
     102             :   Moose::ElemArg elemArg(bool correct_skewness = false) const;
     103             : 
     104             :   /**
     105             :    * @return an element argument corresponding to the face info neighbor
     106             :    */
     107             :   Moose::ElemArg neighborArg(bool correct_skewness = false) const;
     108             : 
     109             :   /**
     110             :    * Determine the single sided face argument when evaluating a functor on a face.
     111             :    * This is used to perform evaluations of material properties with the actual face values of
     112             :    * their dependences, rather than interpolate the material property to the boundary.
     113             :    * @param fi the FaceInfo for this face
     114             :    * @param limiter_type the limiter type, to be specified if more than the default average
     115             :    *        interpolation is required for the parameters of the functor
     116             :    * @param correct_skewness whether to perform skew correction at the face
     117             :    */
     118             :   Moose::FaceArg singleSidedFaceArg(
     119             :       const FaceInfo * fi = nullptr,
     120             :       Moose::FV::LimiterType limiter_type = Moose::FV::LimiterType::CentralDifference,
     121             :       bool correct_skewness = false,
     122             :       const Moose::StateArg * state_limiter = nullptr) const;
     123             : 
     124             :   /**
     125             :    * Returns whether to avoid execution on a boundary
     126             :    * @param fi the FaceInformation currently considered
     127             :    */
     128             :   bool avoidBoundary(const FaceInfo & fi) const;
     129             : 
     130             :   /// Which boundaries/sidesets to force the execution of flux kernels on
     131             :   std::unordered_set<BoundaryID> _boundaries_to_force;
     132             : 
     133             : private:
     134             :   /// Whether to force execution of flux kernels on all external boundaries
     135             :   const bool _force_boundary_execution;
     136             : 
     137             :   /// Which boundaries/sidesets to prevent the execution of flux kernels on
     138             :   std::unordered_set<BoundaryID> _boundaries_to_avoid;
     139             : };

Generated by: LCOV version 1.14