LCOV - code coverage report
Current view: top level - src/kokkos/auxkernels - KokkosAuxKernel.K (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 54 59 91.5 %
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://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::Kokkos
      13             : {
      14             : 
      15             : InputParameters
      16       22524 : AuxKernel::validParams()
      17             : {
      18       22524 :   InputParameters params = AuxKernelBase::validParams();
      19       22524 :   params.addPrivateParam<bool>(MooseBase::kokkos_object_param, true);
      20       22524 :   return params;
      21           0 : }
      22             : 
      23         636 : AuxKernel::AuxKernel(const InputParameters & parameters)
      24             :   : ::AuxKernelBase(parameters),
      25         343 :     MeshHolder(*_mesh.getKokkosMesh()),
      26         343 :     AssemblyHolder(_sys.feProblem().kokkosAssembly()),
      27         343 :     FESystemHolder(_sys.feProblem().getKokkosFESystems()),
      28         686 :     _nodal(_var.isNodal()),
      29             :     _test(),
      30         343 :     _u(_var, Moose::SOLUTION_TAG, _var.isNodal()),
      31         343 :     _t(TransientInterface::_t),
      32         343 :     _t_old(TransientInterface::_t_old),
      33         343 :     _t_step(TransientInterface::_t_step),
      34         343 :     _dt(TransientInterface::_dt),
      35        1029 :     _dt_old(TransientInterface::_dt_old)
      36             : {
      37         636 :   if (!_nodal && _bnd)
      38           0 :     mooseError("Boundary restriction of a Kokkos AuxKernel is only supported for nodal variables.");
      39             : 
      40         636 :   auto tag = _sys.feProblem().addVectorTag("parallel_solution", Moose::VECTOR_TAG_SOLUTION);
      41             : 
      42         636 :   _kokkos_var.init(_var, tag);
      43             : 
      44             :   // Kokkos aux kernels currently only consume variable information through finite element bases and
      45             :   // quadrature points
      46        1574 :   for (auto * const var : getMooseVariableDependencies())
      47         938 :     var->requireQpComputations();
      48         636 : }
      49             : 
      50       25532 : AuxKernel::AuxKernel(const AuxKernel & object)
      51             :   : ::AuxKernelBase(object, {}),
      52             :     MeshHolder(object),
      53             :     AssemblyHolder(object),
      54             :     FESystemHolder(object),
      55       15764 :     _nodal(object._nodal),
      56       15764 :     _kokkos_var(object._kokkos_var),
      57       15764 :     _test(object._test),
      58       15764 :     _u(object._u),
      59       15764 :     _t(object._t),
      60       15764 :     _t_old(object._t_old),
      61       15764 :     _t_step(object._t_step),
      62       15764 :     _dt(object._dt),
      63       31528 :     _dt_old(object._dt_old)
      64             : {
      65       25532 : }
      66             : 
      67             : void
      68       24937 : AuxKernel::compute()
      69             : {
      70       24937 :   if (_var.isNodal())
      71             :   {
      72       17890 :     Policy policy = _bnd ? Policy(0, numKokkosBoundaryNodes()) : Policy(0, numKokkosBlockNodes());
      73             : 
      74       17890 :     if (!_node_dispatcher)
      75         320 :       _node_dispatcher = DispatcherRegistry::build<NodeLoop>(this, type());
      76             : 
      77       17890 :     _node_dispatcher->parallelFor(policy);
      78       17890 :   }
      79             :   else
      80             :   {
      81        7047 :     Policy policy = Policy(0, numKokkosBlockElements());
      82             : 
      83        7047 :     if (!_element_dispatcher)
      84         275 :       _element_dispatcher = DispatcherRegistry::build<ElementLoop>(this, type());
      85             : 
      86        7047 :     _element_dispatcher->parallelFor(policy);
      87        7047 :   }
      88       24937 : }
      89             : 
      90             : VariableValue
      91          34 : AuxKernel::uOld() const
      92             : {
      93          34 :   _var.sys().needSolutionState(1);
      94             : 
      95          34 :   return VariableValue(_var, Moose::OLD_SOLUTION_TAG, isNodal());
      96             : }
      97             : 
      98             : VariableValue
      99          17 : AuxKernel::uOlder() const
     100             : {
     101          17 :   _var.sys().needSolutionState(2);
     102             : 
     103          17 :   return VariableValue(_var, Moose::OLDER_SOLUTION_TAG, isNodal());
     104             : }
     105             : 
     106             : void
     107         217 : AuxKernel::getKokkosMaterialPropertyHook(const std::string & prop_name_in,
     108             :                                          const unsigned int /* state */)
     109             : {
     110         217 :   if (isNodal())
     111           0 :     mooseError("Nodal KokkosAuxKernel '",
     112           0 :                name(),
     113             :                "' attempted to reference material property '",
     114             :                prop_name_in,
     115             :                "'\nConsider using an elemental auxiliary variable for '",
     116           0 :                _var.name(),
     117             :                "'.");
     118         217 : }
     119             : 
     120             : } // namespace Moose::Kokkos

Generated by: LCOV version 1.14