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

Generated by: LCOV version 1.14