LCOV - code coverage report
Current view: top level - include/kokkos/linearfvkernels - KokkosLinearFVDiffusion.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 16 16 100.0 %
Date: 2026-07-23 16:15:30 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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 "KokkosLinearFVFluxKernel.h"
      13             : #include "KokkosParsedFunction.h"
      14             : 
      15             : /**
      16             :  * Kokkos linear finite volume flux kernel implementing the diffusion term. It is the Kokkos analog
      17             :  * of LinearFVDiffusion.
      18             :  */
      19             : class KokkosLinearFVDiffusion : public Moose::Kokkos::LinearFVFluxKernel
      20             : {
      21             : public:
      22             :   static InputParameters validParams();
      23             : 
      24             :   KokkosLinearFVDiffusion(const InputParameters & parameters);
      25             : 
      26         312 :   virtual bool needsBoundaryNormalGradientData() const override { return true; }
      27         312 :   virtual bool hasInternalRightHandSideContribution() const override { return false; }
      28             : 
      29             :   template <typename Derived>
      30             :   KOKKOS_FUNCTION Real computeInternalMatrixContribution(const FVDatum & datum) const;
      31             :   template <typename Derived>
      32             :   KOKKOS_FUNCTION Real computeInternalNeighborMatrixContribution(const FVDatum & datum) const;
      33             :   template <typename Derived>
      34             :   KOKKOS_FUNCTION Real computeBoundaryMatrixContribution(
      35             :       const FVDatum & datum, const int bc_index, const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const;
      36             :   template <typename Derived>
      37             :   KOKKOS_FUNCTION Real computeBoundaryRightHandSideContribution(
      38             :       const FVDatum & datum, const int bc_index, const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const;
      39             : 
      40             : private:
      41             :   /**
      42             :    * Method for evaluating the face diffusion coefficient times the face area divided by the
      43             :    * distance between cell centers. The name "conductance" is used here for this finite volume face
      44             :    * coefficient because heat conduction problems provide a thermal conductivity as the diffusion
      45             :    * coefficient, which has conductance units after multiplying by area over length. Similar
      46             :    * "diffusive conductance" terminology is also used in mass transport contexts; see
      47             :    * https://www.goldsim.com/Courses/ContaminantTransport/Unit8/Lesson3/
      48             :    */
      49             :   KOKKOS_FUNCTION Real faceConductance(const FVDatum & datum) const;
      50             : 
      51             :   /// Method for evaluating the face diffusion coefficient
      52             :   KOKKOS_FUNCTION Real faceDiffusionCoefficient(const FVDatum & datum) const;
      53             : 
      54             :   /// Diffusion coefficient
      55             :   Moose::Kokkos::ReferenceWrapper<const KokkosParsedFunction> _diffusion_coeff;
      56             : };
      57             : 
      58             : template <typename Derived>
      59             : KOKKOS_FUNCTION Real
      60       38870 : KokkosLinearFVDiffusion::computeInternalMatrixContribution(const FVDatum & datum) const
      61             : {
      62       38870 :   return faceConductance(datum);
      63             : }
      64             : 
      65             : template <typename Derived>
      66             : KOKKOS_FUNCTION Real
      67       38870 : KokkosLinearFVDiffusion::computeInternalNeighborMatrixContribution(const FVDatum & datum) const
      68             : {
      69       38870 :   return -faceConductance(datum);
      70             : }
      71             : 
      72             : template <typename Derived>
      73             : KOKKOS_FUNCTION Real
      74        1570 : KokkosLinearFVDiffusion::computeBoundaryMatrixContribution(
      75             :     const FVDatum & datum, const int bc_index, const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const
      76             : {
      77        1570 :   return -faceDiffusionCoefficient(datum) * datum.faceArea() *
      78        1570 :          boundaryNormalGradientCoefficient(bc_index, bc_face_index);
      79             : }
      80             : 
      81             : template <typename Derived>
      82             : KOKKOS_FUNCTION Real
      83        1570 : KokkosLinearFVDiffusion::computeBoundaryRightHandSideContribution(
      84             :     const FVDatum & datum, const int bc_index, const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const
      85             : {
      86        1570 :   return faceDiffusionCoefficient(datum) * datum.faceArea() *
      87        1570 :          boundaryNormalGradientSource(bc_index, bc_face_index);
      88             : }
      89             : 
      90             : KOKKOS_FUNCTION inline Real
      91       77740 : KokkosLinearFVDiffusion::faceConductance(const FVDatum & datum) const
      92             : {
      93       77740 :   return faceDiffusionCoefficient(datum) * datum.faceArea() / datum.faceDCNMag();
      94             : }
      95             : 
      96             : KOKKOS_FUNCTION inline Real
      97       80880 : KokkosLinearFVDiffusion::faceDiffusionCoefficient(const FVDatum & datum) const
      98             : {
      99       80880 :   return _diffusion_coeff->value(_t, datum.faceCentroid());
     100             : }

Generated by: LCOV version 1.14