LCOV - code coverage report
Current view: top level - src/kokkos/auxkernels - KokkosAuxKernel.K (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31761 (28487c) with base 701993 Lines: 52 57 91.2 %
Date: 2025-11-11 13:51:07 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://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             : #include "KokkosAuxKernel.h"
      11             : 
      12             : namespace Moose
      13             : {
      14             : namespace Kokkos
      15             : {
      16             : 
      17             : InputParameters
      18       61052 : AuxKernel::validParams()
      19             : {
      20       61052 :   InputParameters params = AuxKernelBase::validParams();
      21       61052 :   params.addPrivateParam<bool>(MooseBase::kokkos_object_param, true);
      22       61052 :   return params;
      23           0 : }
      24             : 
      25         316 : AuxKernel::AuxKernel(const InputParameters & parameters)
      26             :   : ::AuxKernelBase(parameters),
      27         238 :     MeshHolder(*_mesh.getKokkosMesh()),
      28         238 :     AssemblyHolder(_sys.feProblem().kokkosAssembly()),
      29         238 :     SystemHolder(_sys.feProblem().getKokkosSystems()),
      30         476 :     _nodal(_var.isNodal()),
      31             :     _test(),
      32         238 :     _u(_var, Moose::SOLUTION_TAG, _var.isNodal()),
      33         238 :     _t(TransientInterface::_t),
      34         238 :     _t_old(TransientInterface::_t_old),
      35         238 :     _t_step(TransientInterface::_t_step),
      36         238 :     _dt(TransientInterface::_dt),
      37         714 :     _dt_old(TransientInterface::_dt_old)
      38             : {
      39         316 :   if (!_nodal && _bnd)
      40           0 :     mooseError("Boundary restriction of a Kokkos AuxKernel is only supported for nodal variables.");
      41             : 
      42         316 :   auto tag = _sys.feProblem().addVectorTag("parallel_solution", Moose::VECTOR_TAG_SOLUTION);
      43             : 
      44         316 :   _kokkos_var.init(_var, tag);
      45         316 : }
      46             : 
      47       17319 : AuxKernel::AuxKernel(const AuxKernel & object)
      48             :   : ::AuxKernelBase(object, {}),
      49             :     MeshHolder(object),
      50             :     AssemblyHolder(object),
      51             :     SystemHolder(object),
      52       14921 :     _nodal(object._nodal),
      53       14921 :     _kokkos_var(object._kokkos_var),
      54       14921 :     _test(object._test),
      55       14921 :     _u(object._u),
      56       14921 :     _t(object._t),
      57       14921 :     _t_old(object._t_old),
      58       14921 :     _t_step(object._t_step),
      59       14921 :     _dt(object._dt),
      60       29842 :     _dt_old(object._dt_old)
      61             : {
      62       17319 : }
      63             : 
      64             : void
      65       17031 : AuxKernel::compute()
      66             : {
      67       17031 :   if (_var.isNodal())
      68             :   {
      69       12877 :     Policy policy = _bnd ? Policy(0, numKokkosBoundaryNodes()) : Policy(0, numKokkosBlockNodes());
      70             : 
      71       12877 :     if (!_node_dispatcher)
      72         176 :       _node_dispatcher = DispatcherRegistry::build<NodeLoop>(this, type());
      73             : 
      74       12877 :     _node_dispatcher->parallelFor(policy);
      75       12877 :   }
      76             :   else
      77             :   {
      78        4154 :     Policy policy = Policy(0, numKokkosBlockElements());
      79             : 
      80        4154 :     if (!_element_dispatcher)
      81         112 :       _element_dispatcher = DispatcherRegistry::build<ElementLoop>(this, type());
      82             : 
      83        4154 :     _element_dispatcher->parallelFor(policy);
      84        4154 :   }
      85       17031 : }
      86             : 
      87             : VariableValue
      88          24 : AuxKernel::uOld() const
      89             : {
      90          24 :   _var.sys().needSolutionState(1);
      91             : 
      92          24 :   return VariableValue(_var, Moose::OLD_SOLUTION_TAG, isNodal());
      93             : }
      94             : 
      95             : VariableValue
      96          12 : AuxKernel::uOlder() const
      97             : {
      98          12 :   _var.sys().needSolutionState(2);
      99             : 
     100          12 :   return VariableValue(_var, Moose::OLDER_SOLUTION_TAG, isNodal());
     101             : }
     102             : 
     103             : void
     104         112 : AuxKernel::getKokkosMaterialPropertyHook(const std::string & prop_name_in,
     105             :                                          const unsigned int /* state */)
     106             : {
     107         112 :   if (isNodal())
     108           0 :     mooseError("Nodal KokkosAuxKernel '",
     109           0 :                name(),
     110             :                "' attempted to reference material property '",
     111             :                prop_name_in,
     112             :                "'\nConsider using an elemental auxiliary variable for '",
     113           0 :                _var.name(),
     114             :                "'.");
     115         112 : }
     116             : 
     117             : } // namespace Kokkos
     118             : } // namespace Moose

Generated by: LCOV version 1.14