LCOV - code coverage report
Current view: top level - include/kokkos/kernels - KokkosTimeDerivative.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 329044 Lines: 23 23 100.0 %
Date: 2026-08-03 21:12:22 Functions: 3 3 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 "KokkosTimeKernelValue.h"
      13             : 
      14             : class KokkosTimeDerivative : public Moose::Kokkos::TimeKernelValue
      15             : {
      16             : public:
      17             :   static InputParameters validParams();
      18             : 
      19             :   KokkosTimeDerivative(const InputParameters & parameters);
      20             : 
      21             :   template <typename Derived>
      22             :   KOKKOS_FUNCTION void computeJacobianInternal(const Derived & kernel, AssemblyDatum & datum) const;
      23             : 
      24             :   template <typename Derived>
      25             :   KOKKOS_FUNCTION Real precomputeQpResidual(const unsigned int qp, AssemblyDatum & datum) const;
      26             :   template <typename Derived>
      27             :   KOKKOS_FUNCTION Real precomputeQpJacobian(const unsigned int j,
      28             :                                             const unsigned int qp,
      29             :                                             AssemblyDatum & datum) const;
      30             : 
      31             : protected:
      32             :   const bool _lumping;
      33             : };
      34             : 
      35             : template <typename Derived>
      36             : KOKKOS_FUNCTION void
      37      301869 : KokkosTimeDerivative::computeJacobianInternal(const Derived & kernel, AssemblyDatum & datum) const
      38             : {
      39             :   using Moose::Kokkos::MAX_CACHED_DOF;
      40             : 
      41             :   Real local_ke[MAX_CACHED_DOF];
      42             : 
      43     1407721 :   for (unsigned int j = datum.local_thread_id(); j < datum.n_jdofs();
      44     1105852 :        j += datum.num_local_threads())
      45             :   {
      46     1105852 :     unsigned int num_batches = datum.n_idofs() / MAX_CACHED_DOF;
      47             : 
      48     1105852 :     if (datum.n_idofs() % MAX_CACHED_DOF)
      49     1105852 :       ++num_batches;
      50             : 
      51     2211704 :     for (unsigned int batch = 0; batch < num_batches; ++batch)
      52             :     {
      53     1105852 :       unsigned int ib = batch * MAX_CACHED_DOF;
      54     1105852 :       unsigned int ie = ::Kokkos::min(ib + MAX_CACHED_DOF, datum.n_idofs());
      55             : 
      56     5611708 :       for (unsigned int i = ib; i < ie; ++i)
      57     4505856 :         local_ke[i - ib] = 0;
      58             : 
      59     5907708 :       for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
      60             :       {
      61     4801856 :         Real value = datum.JxW(qp) * kernel.template precomputeQpJacobian<Derived>(j, qp, datum);
      62             : 
      63    26459744 :         for (unsigned int i = ib; i < ie; ++i)
      64    21657888 :           local_ke[i - ib] += value * _test(datum, i, qp);
      65             :       }
      66             : 
      67     5611708 :       for (unsigned int i = ib; i < ie; ++i)
      68     9011712 :         accumulateTaggedElementalMatrix(
      69     9011712 :             local_ke[i - ib], datum.elem().id, i, _lumping ? i : j, datum.jvar());
      70             :     }
      71             :   }
      72      301869 : }
      73             : 
      74             : template <typename Derived>
      75             : KOKKOS_FUNCTION Real
      76     7698840 : KokkosTimeDerivative::precomputeQpResidual(const unsigned int qp, AssemblyDatum & datum) const
      77             : {
      78     7698840 :   return _u_dot(datum, qp);
      79             : }
      80             : 
      81             : template <typename Derived>
      82             : KOKKOS_FUNCTION Real
      83     4801856 : KokkosTimeDerivative::precomputeQpJacobian(const unsigned int j,
      84             :                                            const unsigned int qp,
      85             :                                            AssemblyDatum & datum) const
      86             : {
      87     4801856 :   return _phi(datum, j, qp) * _du_dot_du;
      88             : }

Generated by: LCOV version 1.14