LCOV - code coverage report
Current view: top level - src/linearfvbcs - LinearFVAdvectionDiffusionFunctorNeumannBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 41 49 83.7 %
Date: 2026-05-29 20:35:17 Functions: 7 8 87.5 %
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 "LinearFVAdvectionDiffusionFunctorNeumannBC.h"
      11             : 
      12             : registerMooseObject("MooseApp", LinearFVAdvectionDiffusionFunctorNeumannBC);
      13             : 
      14             : InputParameters
      15        3289 : LinearFVAdvectionDiffusionFunctorNeumannBC::validParams()
      16             : {
      17        3289 :   InputParameters params = LinearFVAdvectionDiffusionBC::validParams();
      18        6578 :   params.addClassDescription(
      19             :       "Adds a fixed diffusive flux BC which can be used for the assembly of linear "
      20             :       "finite volume system and whose normal face gradient values are determined "
      21             :       "using a functor. This kernel is only designed to work with advection-diffusion problems.");
      22       13156 :   params.addRequiredParam<MooseFunctorName>(
      23             :       "functor", "The diffusive flux functor for this boundary condition.");
      24        9867 :   params.addParam<MooseFunctorName>("diffusion_coeff", 1.0, "The diffusion coefficient.");
      25        3289 :   return params;
      26           0 : }
      27             : 
      28         114 : LinearFVAdvectionDiffusionFunctorNeumannBC::LinearFVAdvectionDiffusionFunctorNeumannBC(
      29         114 :     const InputParameters & parameters)
      30             :   : LinearFVAdvectionDiffusionBC(parameters),
      31         114 :     _functor(getFunctor<Real>("functor")),
      32         342 :     _diffusion_coeff(getFunctor<Real>("diffusion_coeff"))
      33             : {
      34         114 :   _var.computeCellGradients();
      35         114 : }
      36             : 
      37             : Real
      38       11292 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValue() const
      39             : {
      40       11292 :   const auto state = determineState();
      41       11292 :   const auto face_arg = makeCDFace(*_current_face_info);
      42       11292 :   const auto elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
      43       11292 :                              ? _current_face_info->elemInfo()
      44           0 :                              : _current_face_info->neighborInfo();
      45       11292 :   const Real distance = computeCellToFaceDistance();
      46       11292 :   const auto d_cf = computeCellToFaceVector();
      47             :   // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy
      48             :   // correction_vector is a vector orthogonal to the boundary normal
      49             :   const auto correction_vector =
      50       11292 :       (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal());
      51       11292 :   return _var.getElemValue(*elem_info, state) +
      52       11292 :          _functor(singleSidedFaceArg(_current_face_info), state) /
      53       11292 :              _diffusion_coeff(face_arg, state) * distance +
      54       11292 :          _var.gradSln(*elem_info, state) * correction_vector;
      55             : }
      56             : 
      57             : Real
      58           0 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryNormalGradient() const
      59             : {
      60           0 :   const auto state = determineState();
      61           0 :   const auto face_arg = makeCDFace(*_current_face_info);
      62           0 :   return _functor(singleSidedFaceArg(_current_face_info), state) /
      63           0 :          _diffusion_coeff(face_arg, state);
      64             : }
      65             : 
      66             : Real
      67         792 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueMatrixContribution() const
      68             : {
      69         792 :   return 1.0;
      70             : }
      71             : 
      72             : Real
      73         792 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueRHSContribution() const
      74             : {
      75         792 :   const auto state = determineState();
      76         792 :   const auto face_arg = makeCDFace(*_current_face_info);
      77         792 :   const auto elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
      78         792 :                              ? _current_face_info->elemInfo()
      79           0 :                              : _current_face_info->neighborInfo();
      80             : 
      81             :   // Fetch the boundary value from the provided functor.
      82         792 :   const Real distance = computeCellToFaceDistance();
      83         792 :   const auto d_cf = computeCellToFaceVector();
      84             :   // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy
      85             :   // correction_vector is a vector orthogonal to the boundary normal
      86             :   const auto correction_vector =
      87         792 :       (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal());
      88         792 :   return _functor(singleSidedFaceArg(_current_face_info), state) /
      89         792 :              _diffusion_coeff(face_arg, state) * distance +
      90         792 :          _var.gradSln(*elem_info, state) * correction_vector;
      91             : }
      92             : 
      93             : Real
      94        5646 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientMatrixContribution() const
      95             : {
      96        5646 :   return 0.0;
      97             : }
      98             : 
      99             : Real
     100        5646 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientRHSContribution() const
     101             : {
     102        5646 :   return _functor(singleSidedFaceArg(_current_face_info), determineState());
     103             : }

Generated by: LCOV version 1.14