LCOV - code coverage report
Current view: top level - src/linearfvbcs - LinearFVAdvectionDiffusionFunctorNeumannBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 36 42 85.7 %
Date: 2025-07-17 01:28:37 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 : }
      35             : 
      36             : Real
      37       19180 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValue() const
      38             : {
      39       19180 :   const auto face_arg = makeCDFace(*_current_face_info);
      40       38360 :   const auto elem_arg = makeElemArg(_current_face_type == FaceInfo::VarFaceNeighbors::ELEM
      41       19180 :                                         ? _current_face_info->elemPtr()
      42           0 :                                         : _current_face_info->neighborPtr());
      43       19180 :   const Real distance = computeCellToFaceDistance();
      44       19180 :   const auto d_cf = computeCellToFaceVector();
      45             :   // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy
      46             :   // correction_vector is a vector orthogonal to the boundary normal
      47             :   const auto correction_vector =
      48       19180 :       (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal());
      49       38360 :   return raw_value(_var(elem_arg, determineState())) +
      50       19180 :          _functor(singleSidedFaceArg(_current_face_info), determineState()) /
      51       19180 :              _diffusion_coeff(face_arg, determineState()) * distance +
      52       38360 :          _var.gradSln(*_current_face_info->elemInfo()) * correction_vector;
      53             : }
      54             : 
      55             : Real
      56           0 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryNormalGradient() const
      57             : {
      58           0 :   const auto face_arg = makeCDFace(*_current_face_info);
      59           0 :   return _functor(singleSidedFaceArg(_current_face_info), determineState()) /
      60           0 :          _diffusion_coeff(face_arg, determineState());
      61             : }
      62             : 
      63             : Real
      64        1848 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueMatrixContribution() const
      65             : {
      66        1848 :   return 1.0;
      67             : }
      68             : 
      69             : Real
      70        1848 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueRHSContribution() const
      71             : {
      72        1848 :   const auto face_arg = makeCDFace(*_current_face_info);
      73             :   // Fetch the boundary value from the provided functor.
      74        1848 :   const Real distance = computeCellToFaceDistance();
      75        1848 :   const auto d_cf = computeCellToFaceVector();
      76             :   // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy
      77             :   // correction_vector is a vector orthogonal to the boundary normal
      78             :   const auto correction_vector =
      79        1848 :       (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal());
      80        1848 :   return _functor(singleSidedFaceArg(_current_face_info), determineState()) /
      81        1848 :              _diffusion_coeff(face_arg, determineState()) * distance +
      82        1848 :          _var.gradSln(*_current_face_info->elemInfo()) * correction_vector;
      83             : }
      84             : 
      85             : Real
      86       13174 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientMatrixContribution() const
      87             : {
      88       13174 :   return 0.0;
      89             : }
      90             : 
      91             : Real
      92       13174 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientRHSContribution() const
      93             : {
      94       13174 :   return _functor(singleSidedFaceArg(_current_face_info), determineState());
      95             : }

Generated by: LCOV version 1.14