LCOV - code coverage report
Current view: top level - src/kokkos/materials - KokkosMaterial.K (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31653 (1b668c) with base bb0a08 Lines: 72 73 98.6 %
Date: 2025-11-03 17:02:13 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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 "KokkosMaterial.h"
      11             : 
      12             : namespace Moose
      13             : {
      14             : namespace Kokkos
      15             : {
      16             : 
      17             : InputParameters
      18      132116 : Material::validParams()
      19             : {
      20      132116 :   InputParameters params = MaterialBase::validParams();
      21      132116 :   params += MaterialPropertyInterface::validParams();
      22      396348 :   params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
      23      132116 :   return params;
      24           0 : }
      25             : 
      26         952 : Material::Material(const InputParameters & parameters)
      27             :   : MaterialBase(parameters),
      28             :     Coupleable(this, false),
      29             :     MaterialPropertyInterface(this, blockIDs(), boundaryIDs()),
      30         766 :     _bnd(_material_data_type != Moose::BLOCK_MATERIAL_DATA),
      31         766 :     _neighbor(_material_data_type == Moose::NEIGHBOR_MATERIAL_DATA),
      32         770 :     _qrule(_bnd ? (_neighbor ? _subproblem.assembly(_tid, 0).qRuleNeighbor()
      33         260 :                              : _subproblem.assembly(_tid, 0).qRuleFace())
      34         766 :                 : _subproblem.assembly(_tid, 0).qRule())
      35             : {
      36        1108 :   for (auto coupled_var : getCoupledMooseVars())
      37         156 :     addMooseVariableDependency(coupled_var);
      38         952 : }
      39             : 
      40       50065 : Material::Material(const Material & object)
      41             :   : MaterialBase(object),
      42             :     Coupleable(object, {}),
      43             :     MaterialPropertyInterface(object, {}),
      44       41155 :     _bnd(object._bnd),
      45       41155 :     _neighbor(object._neighbor),
      46       41155 :     _qrule(object._qrule)
      47             : {
      48       50065 : }
      49             : 
      50             : void
      51        1086 : Material::initStatefulProperties(unsigned int)
      52             : {
      53        1086 :   if (!_bnd && !_neighbor)
      54             :   {
      55         356 :     if (!DispatcherRegistry::hasUserMethod<ElementInit>(type()))
      56          58 :       return;
      57             : 
      58         298 :     Policy policy(0, numKokkosElements());
      59             : 
      60         298 :     if (!_init_dispatcher)
      61         168 :       _init_dispatcher = DispatcherRegistry::build<ElementInit>(this, type());
      62             : 
      63         298 :     _init_dispatcher->parallelFor(policy);
      64         298 :   }
      65         730 :   else if (_bnd && !_neighbor)
      66             :   {
      67         374 :     if (!DispatcherRegistry::hasUserMethod<SideInit>(type()))
      68          56 :       return;
      69             : 
      70         318 :     Policy policy(0, numKokkosElementSides());
      71             : 
      72         318 :     if (!_init_dispatcher)
      73         178 :       _init_dispatcher = DispatcherRegistry::build<SideInit>(this, type());
      74             : 
      75         318 :     _init_dispatcher->parallelFor(policy);
      76         318 :   }
      77             :   else
      78             :   {
      79         356 :     if (!DispatcherRegistry::hasUserMethod<NeighborInit>(type()))
      80          58 :       return;
      81             : 
      82         298 :     Policy policy(0, numKokkosElementSides());
      83             : 
      84         298 :     if (!_init_dispatcher)
      85         168 :       _init_dispatcher = DispatcherRegistry::build<NeighborInit>(this, type());
      86             : 
      87         298 :     _init_dispatcher->parallelFor(policy);
      88         298 :   }
      89             : }
      90             : 
      91             : void
      92       47995 : Material::computeProperties()
      93             : {
      94       47995 :   if (!_bnd && !_neighbor)
      95             :   {
      96       15708 :     Policy policy(0, numKokkosElements());
      97             : 
      98       15708 :     if (!_compute_dispatcher)
      99         210 :       _compute_dispatcher = DispatcherRegistry::build<ElementCompute>(this, type());
     100             : 
     101       15708 :     _compute_dispatcher->parallelFor(policy);
     102       15708 :   }
     103       32287 :   else if (_bnd && !_neighbor)
     104             :   {
     105       16579 :     Policy policy(0, numKokkosElementSides());
     106             : 
     107       16579 :     if (!_compute_dispatcher)
     108         222 :       _compute_dispatcher = DispatcherRegistry::build<SideCompute>(this, type());
     109             : 
     110       16579 :     _compute_dispatcher->parallelFor(policy);
     111       16579 :   }
     112             :   else
     113             :   {
     114       15708 :     Policy policy(0, numKokkosElementSides());
     115             : 
     116       15708 :     if (!_compute_dispatcher)
     117         210 :       _compute_dispatcher = DispatcherRegistry::build<NeighborCompute>(this, type());
     118             : 
     119       15708 :     _compute_dispatcher->parallelFor(policy);
     120       15708 :   }
     121       47995 : }
     122             : 
     123             : void
     124         871 : Material::getKokkosMaterialPropertyHook(const std::string & prop_name_in, const unsigned int state)
     125             : {
     126         871 :   MaterialBase::checkExecutionStage();
     127             : 
     128         177 :   const auto prop_name =
     129         694 :       _get_suffix.empty()
     130         694 :           ? prop_name_in
     131         694 :           : MooseUtils::join(std::vector<std::string>({prop_name_in, _get_suffix}), "_");
     132             : 
     133         871 :   if (state == 0)
     134         123 :     _requested_props.insert(prop_name);
     135             : 
     136         871 :   registerPropName(prop_name, true, state);
     137         871 : }
     138             : 
     139             : } // namespace Kokkos
     140             : } // namespace Moose

Generated by: LCOV version 1.14