LCOV - code coverage report
Current view: top level - include/kokkos/auxkernels - KokkosCopyValueAux.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31706 (f8ed4a) with base bb0a08 Lines: 15 15 100.0 %
Date: 2025-11-03 17:23:24 Functions: 2 2 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 "KokkosAuxKernel.h"
      13             : 
      14             : /**
      15             :  * Copies one variable onto an auxiliary variable
      16             :  */
      17             : class KokkosCopyValueAux : public Moose::Kokkos::AuxKernel
      18             : {
      19             : public:
      20             :   static InputParameters validParams();
      21             : 
      22             :   KokkosCopyValueAux(const InputParameters & parameters);
      23             : 
      24             :   template <typename Derived>
      25             :   KOKKOS_FUNCTION void computeElementInternal(const Derived & auxkernel,
      26             :                                               AssemblyDatum & datum) const;
      27             :   template <typename Derived>
      28             :   KOKKOS_FUNCTION void computeNodeInternal(const Derived & auxkernel, AssemblyDatum & datum) const;
      29             : 
      30             : protected:
      31             :   /// Variable used to specify state being copied
      32             :   unsigned short _state;
      33             : 
      34             :   /// The variable value to copy from
      35             :   const Moose::Kokkos::VariableValue _v;
      36             : 
      37             :   /// A reference to the variable to copy from
      38             :   const MooseVariable & _source_variable;
      39             : };
      40             : 
      41             : template <typename Derived>
      42             : KOKKOS_FUNCTION void
      43         600 : KokkosCopyValueAux::computeElementInternal(const Derived & /* auxkernel */,
      44             :                                            AssemblyDatum & datum) const
      45             : {
      46         600 :   auto & sys = kokkosSystem(_kokkos_var.sys());
      47         600 :   auto var = _kokkos_var.var();
      48         600 :   auto tag = _kokkos_var.tag();
      49         600 :   auto elem = datum.elem().id;
      50             : 
      51        1200 :   for (unsigned int i = 0; i < datum.n_dofs(); ++i)
      52         600 :     sys.getVectorDofValue(sys.getElemLocalDofIndex(elem, i, var), tag) = _v(datum, i);
      53         600 : }
      54             : 
      55             : template <typename Derived>
      56             : KOKKOS_FUNCTION void
      57         926 : KokkosCopyValueAux::computeNodeInternal(const Derived & /* auxkernel */,
      58             :                                         AssemblyDatum & datum) const
      59             : {
      60         926 :   auto & sys = kokkosSystem(_kokkos_var.sys());
      61         926 :   auto var = _kokkos_var.var();
      62         926 :   auto tag = _kokkos_var.tag();
      63         926 :   auto node = datum.node();
      64             : 
      65         926 :   sys.getVectorDofValue(sys.getNodeLocalDofIndex(node, 0, var), tag) = _v(datum, 0);
      66         926 : }

Generated by: LCOV version 1.14