LCOV - code coverage report
Current view: top level - src/kokkos/linearfvbcs - KokkosLinearFVBoundaryCondition.K (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 70 77 90.9 %
Date: 2026-07-23 16:15:30 Functions: 10 10 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 "KokkosLinearFVBoundaryCondition.h"
      11             : 
      12             : #include "FEProblemBase.h"
      13             : #include "InputParameters.h"
      14             : #include "SubProblem.h"
      15             : #include "SystemBase.h"
      16             : 
      17             : namespace Moose::Kokkos
      18             : {
      19             : 
      20             : InputParameters
      21        4930 : LinearFVBoundaryCondition::validParams()
      22             : {
      23        4930 :   auto params = MooseObject::validParams();
      24        4930 :   params += TransientInterface::validParams();
      25        4930 :   params += MeshChangedInterface::validParams();
      26        4930 :   params += BoundaryRestrictableRequired::validParams();
      27             : 
      28        4930 :   params.addPrivateParam<bool>(MooseBase::kokkos_object_param, true);
      29       14790 :   params.addRequiredParam<LinearVariableName>(
      30             :       "variable", "The name of the variable this boundary condition supplies data for");
      31       14790 :   params.declareControllable("enable");
      32        9860 :   params.set<bool>("_residual_object") = false;
      33        9860 :   params.registerBase("LinearFVBoundaryCondition");
      34        4930 :   params.registerSystemAttributeName("LinearFVBoundaryCondition");
      35        4930 :   return params;
      36           0 : }
      37             : 
      38        2009 : LinearFVBoundaryCondition::LinearFVBoundaryCondition(const InputParameters & parameters)
      39             :   : MooseObject(parameters),
      40             :     SetupInterface(this),
      41             :     FunctionInterface(this),
      42             :     UserObjectInterface(this),
      43             :     TransientInterface(this),
      44             :     PostprocessorInterface(this),
      45             :     VectorPostprocessorInterface(this, false),
      46         344 :     Restartable(this, getBase() + "s"),
      47             :     MeshChangedInterface(parameters),
      48             :     BoundaryRestrictableRequired(this, false),
      49         688 :     MeshHolder(*getCheckedPointerParam<SubProblem *>("_subproblem")->mesh().getKokkosMesh()),
      50         688 :     SystemHolder(getCheckedPointerParam<SystemBase *>("_sys")->feProblem().getKokkosSystems()),
      51         172 :     _fe_problem(*getParam<FEProblemBase *>("_fe_problem_base")),
      52         172 :     _t(TransientInterface::_t),
      53         172 :     _t_old(TransientInterface::_t_old),
      54         172 :     _t_step(TransientInterface::_t_step),
      55         172 :     _dt(TransientInterface::_dt),
      56        1548 :     _dt_old(TransientInterface::_dt_old)
      57             : {
      58        1356 :   const auto * const subproblem = getCheckedPointerParam<SubProblem *>("_subproblem");
      59         506 :   _var.init(subproblem->getVariable(0,
      60         516 :                                     getParam<LinearVariableName>("variable"),
      61             :                                     Moose::VarKindType::VAR_SOLVER,
      62             :                                     Moose::VarFieldType::VAR_FIELD_STANDARD),
      63             :             Moose::SOLUTION_TAG);
      64         339 : }
      65             : 
      66        1004 : LinearFVBoundaryCondition::LinearFVBoundaryCondition(const LinearFVBoundaryCondition & object)
      67             :   : MooseObject(object, {}),
      68             :     SetupInterface(object, {}),
      69             :     FunctionInterface(object, {}),
      70             :     UserObjectInterface(object, {}),
      71             :     TransientInterface(object, {}),
      72             :     PostprocessorInterface(object, {}),
      73             :     VectorPostprocessorInterface(object, {}),
      74             :     Restartable(object, {}),
      75             :     MeshChangedInterface(object, {}),
      76             :     BoundaryRestrictableRequired(object, {}),
      77             :     MeshHolder(object),
      78             :     SystemHolder(object),
      79         516 :     _fe_problem(object._fe_problem),
      80         516 :     _var(object._var),
      81         516 :     _boundary_data(object._boundary_data),
      82         516 :     _t(object._t),
      83         516 :     _t_old(object._t_old),
      84         516 :     _t_step(object._t_step),
      85         516 :     _dt(object._dt),
      86        1548 :     _dt_old(object._dt_old)
      87             : {
      88        1004 : }
      89             : 
      90             : MOOSE_KOKKOS_INDEX_TYPE
      91         734 : LinearFVBoundaryCondition::numBoundaryFaces() const
      92             : {
      93         734 :   return libMesh::cast_int<MOOSE_KOKKOS_INDEX_TYPE>(numKokkosBoundarySides());
      94             : }
      95             : 
      96             : Pair<ContiguousElementID, unsigned int>
      97        3024 : LinearFVBoundaryCondition::boundaryFaceID(const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const
      98             : {
      99        3024 :   return kokkosBoundaryElementSideID(bc_face_index);
     100             : }
     101             : 
     102             : void
     103         339 : LinearFVBoundaryCondition::initialSetup()
     104             : {
     105         339 :   const auto n_boundary_faces = numBoundaryFaces();
     106             : 
     107         339 :   _boundary_data.value.coefficient.create(n_boundary_faces);
     108         339 :   _boundary_data.value.source.create(n_boundary_faces);
     109         339 :   _boundary_data.normal_gradient.coefficient.create(n_boundary_faces);
     110         339 :   _boundary_data.normal_gradient.source.create(n_boundary_faces);
     111         339 :   _boundary_data.value.coefficient = 0;
     112         339 :   _boundary_data.value.source = 0;
     113         339 :   _boundary_data.normal_gradient.coefficient = 0;
     114         339 :   _boundary_data.normal_gradient.source = 0;
     115         339 : }
     116             : 
     117             : bool
     118          56 : LinearFVBoundaryCondition::hasBoundaryValue() const
     119             : {
     120          56 :   return DispatcherRegistry::hasUserMethod<BoundaryValueLoop>(type());
     121             : }
     122             : 
     123             : bool
     124         563 : LinearFVBoundaryCondition::hasBoundaryNormalGradient() const
     125             : {
     126         563 :   return DispatcherRegistry::hasUserMethod<BoundaryNormalGradientLoop>(type());
     127             : }
     128             : 
     129             : void
     130          56 : LinearFVBoundaryCondition::computeBoundaryValueData()
     131             : {
     132          56 :   if (!hasBoundaryValue())
     133           0 :     mooseError("Kokkos linear FV boundary condition '",
     134           0 :                name(),
     135             :                "' (type '",
     136           0 :                type(),
     137             :                "') was asked to compute boundary values, but it does not override "
     138             :                "computeBoundaryValue().");
     139             : 
     140          56 :   Policy policy(0, numKokkosBoundarySides());
     141          56 :   if (!_boundary_value_dispatcher)
     142          56 :     _boundary_value_dispatcher = DispatcherRegistry::build<BoundaryValueLoop>(this, type());
     143          56 :   _boundary_value_dispatcher->parallelFor(policy);
     144          56 : }
     145             : 
     146             : void
     147         563 : LinearFVBoundaryCondition::computeBoundaryNormalGradientData()
     148             : {
     149         563 :   if (!hasBoundaryNormalGradient())
     150           0 :     mooseError("Kokkos linear FV boundary condition '",
     151           0 :                name(),
     152             :                "' (type '",
     153           0 :                type(),
     154             :                "') was asked to compute boundary normal gradients, but it does not override "
     155             :                "computeBoundaryNormalGradient().");
     156             : 
     157         563 :   Policy policy(0, numKokkosBoundarySides());
     158         563 :   if (!_boundary_normal_gradient_dispatcher)
     159         162 :     _boundary_normal_gradient_dispatcher =
     160         167 :         DispatcherRegistry::build<BoundaryNormalGradientLoop>(this, type());
     161         563 :   _boundary_normal_gradient_dispatcher->parallelFor(policy);
     162         563 : }
     163             : 
     164             : } // namespace Moose::Kokkos

Generated by: LCOV version 1.14