LCOV - code coverage report
Current view: top level - include/kokkos/linearfvkernels - KokkosLinearFVAdvection.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 15 15 100.0 %
Date: 2026-07-23 16:15:30 Functions: 7 7 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             : 
      14             : /**
      15             :  * Kokkos linear finite volume flux kernel implementing first-order upwind advection with a
      16             :  * constant velocity. It is the Kokkos analog of LinearFVAdvection for the upwind interpolation
      17             :  * case.
      18             :  */
      19             : class KokkosLinearFVAdvection : public Moose::Kokkos::LinearFVFluxKernel
      20             : {
      21             : public:
      22             :   static InputParameters validParams();
      23             : 
      24             :   KokkosLinearFVAdvection(const InputParameters & parameters);
      25             : 
      26          28 :   virtual bool needsBoundaryValueData() const override { return true; }
      27          28 :   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             :   /// Normal advective face flux
      42             :   KOKKOS_FUNCTION Real normalFaceFlux(const FVDatum & datum) const;
      43             : 
      44             :   /// Constant advecting velocity vector
      45             :   const Moose::Kokkos::Real3 _velocity;
      46             : };
      47             : 
      48             : template <typename Derived>
      49             : KOKKOS_FUNCTION Real
      50         988 : KokkosLinearFVAdvection::computeInternalMatrixContribution(const FVDatum & datum) const
      51             : {
      52         988 :   const auto face_flux = normalFaceFlux(datum);
      53         988 :   return face_flux > 0 ? face_flux * datum.faceArea() : 0;
      54             : }
      55             : 
      56             : template <typename Derived>
      57             : KOKKOS_FUNCTION Real
      58         988 : KokkosLinearFVAdvection::computeInternalNeighborMatrixContribution(const FVDatum & datum) const
      59             : {
      60         988 :   const auto face_flux = normalFaceFlux(datum);
      61         988 :   return face_flux < 0 ? face_flux * datum.faceArea() : 0;
      62             : }
      63             : 
      64             : template <typename Derived>
      65             : KOKKOS_FUNCTION Real
      66          28 : KokkosLinearFVAdvection::computeBoundaryMatrixContribution(
      67             :     const FVDatum & datum, const int bc_index, const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const
      68             : {
      69          28 :   return normalFaceFlux(datum) * datum.faceArea() *
      70          28 :          boundaryValueCoefficient(bc_index, bc_face_index);
      71             : }
      72             : 
      73             : template <typename Derived>
      74             : KOKKOS_FUNCTION Real
      75          28 : KokkosLinearFVAdvection::computeBoundaryRightHandSideContribution(
      76             :     const FVDatum & datum, const int bc_index, const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const
      77             : {
      78          28 :   return -normalFaceFlux(datum) * datum.faceArea() * boundaryValueSource(bc_index, bc_face_index);
      79             : }
      80             : 
      81             : KOKKOS_FUNCTION inline Real
      82        2032 : KokkosLinearFVAdvection::normalFaceFlux(const FVDatum & datum) const
      83             : {
      84        2032 :   return _velocity * datum.faceNormal();
      85             : }

Generated by: LCOV version 1.14