LCOV - code coverage report
Current view: top level - src/fvbcs - FVFunctorDirichletBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 24 28 85.7 %
Date: 2025-07-17 01:28:37 Functions: 8 8 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 "FVFunctorDirichletBC.h"
      11             : 
      12             : registerMooseObject("MooseApp", FVFunctorDirichletBC);
      13             : registerMooseObject("MooseApp", FVADFunctorDirichletBC);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17       28724 : FVFunctorDirichletBCTempl<is_ad>::validParams()
      18             : {
      19       28724 :   InputParameters params = FVDirichletBCBase::validParams();
      20       28724 :   params.addClassDescription("Uses the value of a functor to set a Dirichlet boundary value.");
      21       28724 :   params.addRequiredParam<MooseFunctorName>(
      22             :       "functor", "The name of the functor whose value is imposed on the boundary");
      23       86172 :   params.addParam<bool>(
      24             :       "functor_only_defined_on_other_side",
      25       57448 :       false,
      26             :       "Whether to evaluate the functor on the other side of the boundary. Note that depending on "
      27             :       "the functor type, this may require the 'ghost_layers' parameter to be set. For a FV "
      28             :       "variable with two term expansion, three ghost layers are needed.");
      29       28724 :   params.addParam<unsigned int>("ghost_layers", 0, "Number of ghost layers needed");
      30             : 
      31             :   // We need to add ghosting if we are going to use values from the other side
      32       28724 :   params.addRelationshipManager(
      33             :       "ElementSideNeighborLayers",
      34             :       Moose::RelationshipManagerType::GEOMETRIC | Moose::RelationshipManagerType::ALGEBRAIC |
      35             :           Moose::RelationshipManagerType::COUPLING,
      36         412 :       [](const InputParameters & obj_params, InputParameters & rm_params)
      37             :       {
      38         206 :         rm_params.set<unsigned short>("layers") = obj_params.get<unsigned int>("ghost_layers");
      39         206 :         rm_params.set<bool>("use_point_neighbors") = false;
      40             :       });
      41             : 
      42       28724 :   return params;
      43           0 : }
      44             : 
      45             : template <bool is_ad>
      46          96 : FVFunctorDirichletBCTempl<is_ad>::FVFunctorDirichletBCTempl(const InputParameters & parameters)
      47             :   : FVDirichletBCBase(parameters),
      48          96 :     _functor(getFunctor<GenericReal<is_ad>>("functor")),
      49         192 :     _use_other_side(getParam<bool>("functor_only_defined_on_other_side"))
      50             : {
      51          96 : }
      52             : 
      53             : template <bool is_ad>
      54             : ADReal
      55        8002 : FVFunctorDirichletBCTempl<is_ad>::boundaryValue(const FaceInfo & fi,
      56             :                                                 const Moose::StateArg & state) const
      57             : {
      58        8002 :   auto sfa = singleSidedFaceArg(&fi);
      59        8002 :   if (!_use_other_side)
      60       10736 :     return _functor(sfa, state);
      61         147 :   else if (fi.elemPtr() == sfa.face_side)
      62         147 :     return _functor(
      63         147 :         {&fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.neighborPtr(), nullptr},
      64         147 :         state);
      65             :   else
      66           0 :     return _functor(
      67           0 :         {&fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.elemPtr(), nullptr},
      68           0 :         state);
      69             : }
      70             : 
      71             : template class FVFunctorDirichletBCTempl<false>;
      72             : template class FVFunctorDirichletBCTempl<true>;

Generated by: LCOV version 1.14