LCOV - code coverage report
Current view: top level - src/linearfvbcs - LinearFVAdvectionDiffusionFunctorNeumannBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 37 43 86.0 %
Date: 2025-08-08 20:01:16 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       14797 : LinearFVAdvectionDiffusionFunctorNeumannBC::validParams()
      16             : {
      17       14797 :   InputParameters params = LinearFVAdvectionDiffusionBC::validParams();
      18       14797 :   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       14797 :   params.addRequiredParam<MooseFunctorName>(
      23             :       "functor", "The diffusive flux functor for this boundary condition.");
      24       14797 :   params.addParam<MooseFunctorName>("diffusion_coeff", 1.0, "The diffusion coefficient.");
      25       14797 :   return params;
      26           0 : }
      27             : 
      28         266 : LinearFVAdvectionDiffusionFunctorNeumannBC::LinearFVAdvectionDiffusionFunctorNeumannBC(
      29         266 :     const InputParameters & parameters)
      30             :   : LinearFVAdvectionDiffusionBC(parameters),
      31         266 :     _functor(getFunctor<Real>("functor")),
      32         532 :     _diffusion_coeff(getFunctor<Real>("diffusion_coeff"))
      33             : {
      34         266 :   _var.computeCellGradients();
      35         266 : }
      36             : 
      37             : Real
      38       26348 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValue() const
      39             : {
      40       26348 :   const auto face_arg = makeCDFace(*_current_face_info);
      41       52696 :   const auto elem_arg = makeElemArg(_current_face_type == FaceInfo::VarFaceNeighbors::ELEM
      42       26348 :                                         ? _current_face_info->elemPtr()
      43           0 :                                         : _current_face_info->neighborPtr());
      44       26348 :   const Real distance = computeCellToFaceDistance();
      45       26348 :   const auto d_cf = computeCellToFaceVector();
      46             :   // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy
      47             :   // correction_vector is a vector orthogonal to the boundary normal
      48             :   const auto correction_vector =
      49       26348 :       (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal());
      50       52696 :   return raw_value(_var(elem_arg, determineState())) +
      51       26348 :          _functor(singleSidedFaceArg(_current_face_info), determineState()) /
      52       26348 :              _diffusion_coeff(face_arg, determineState()) * distance +
      53       52696 :          _var.gradSln(*_current_face_info->elemInfo()) * correction_vector;
      54             : }
      55             : 
      56             : Real
      57           0 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryNormalGradient() const
      58             : {
      59           0 :   const auto face_arg = makeCDFace(*_current_face_info);
      60           0 :   return _functor(singleSidedFaceArg(_current_face_info), determineState()) /
      61           0 :          _diffusion_coeff(face_arg, determineState());
      62             : }
      63             : 
      64             : Real
      65        1848 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueMatrixContribution() const
      66             : {
      67        1848 :   return 1.0;
      68             : }
      69             : 
      70             : Real
      71        1848 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueRHSContribution() const
      72             : {
      73        1848 :   const auto face_arg = makeCDFace(*_current_face_info);
      74             :   // Fetch the boundary value from the provided functor.
      75        1848 :   const Real distance = computeCellToFaceDistance();
      76        1848 :   const auto d_cf = computeCellToFaceVector();
      77             :   // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy
      78             :   // correction_vector is a vector orthogonal to the boundary normal
      79             :   const auto correction_vector =
      80        1848 :       (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal());
      81        1848 :   return _functor(singleSidedFaceArg(_current_face_info), determineState()) /
      82        1848 :              _diffusion_coeff(face_arg, determineState()) * distance +
      83        1848 :          _var.gradSln(*_current_face_info->elemInfo()) * correction_vector;
      84             : }
      85             : 
      86             : Real
      87       13174 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientMatrixContribution() const
      88             : {
      89       13174 :   return 0.0;
      90             : }
      91             : 
      92             : Real
      93       13174 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientRHSContribution() const
      94             : {
      95       13174 :   return _functor(singleSidedFaceArg(_current_face_info), determineState());
      96             : }

Generated by: LCOV version 1.14