LCOV - code coverage report
Current view: top level - src/linearfvbcs - LinearFVAdvectionDiffusionFunctorRobinBCBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 67 77 87.0 %
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 "LinearFVAdvectionDiffusionFunctorRobinBCBase.h"
      11             : 
      12             : InputParameters
      13        3205 : LinearFVAdvectionDiffusionFunctorRobinBCBase::validParams()
      14             : {
      15        3205 :   InputParameters params = LinearFVAdvectionDiffusionBC::validParams();
      16        3205 :   return params;
      17             : }
      18             : 
      19          72 : LinearFVAdvectionDiffusionFunctorRobinBCBase::LinearFVAdvectionDiffusionFunctorRobinBCBase(
      20          72 :     const InputParameters & parameters)
      21          72 :   : LinearFVAdvectionDiffusionBC(parameters)
      22             : {
      23          72 : }
      24             : 
      25             : Real
      26        2124 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValue() const
      27             : {
      28        2124 :   const auto face = singleSidedFaceArg(_current_face_info);
      29             :   mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
      30             :               "This should not be assigned on an internal face!");
      31        2124 :   const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
      32        2124 :                                ? _current_face_info->elemInfo()
      33           0 :                                : _current_face_info->neighborInfo();
      34        2124 :   const auto state = determineState();
      35             : 
      36        2124 :   const auto alpha = getAlpha(face, state);
      37        2124 :   const auto beta = getBeta(face, state);
      38        2124 :   const auto gamma = getGamma(face, state);
      39             : 
      40        2124 :   const auto phi = _var.getElemValue(*elem_info, state);
      41        2124 :   const auto grad_phi = _var.gradSln(*elem_info, state);
      42             : 
      43        2124 :   const auto & nhat = _current_face_info->normal();
      44             : 
      45        2124 :   const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
      46        2124 :   const auto projection = d_cf * nhat;
      47        2124 :   const auto vc = d_cf - (projection * nhat);
      48        2124 :   return ((alpha * phi) + (alpha * grad_phi * vc) + (gamma * projection)) /
      49        2124 :          (alpha + (beta * projection));
      50             : }
      51             : 
      52             : Real
      53           0 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryNormalGradient() const
      54             : {
      55           0 :   const auto face = singleSidedFaceArg(_current_face_info);
      56           0 :   const auto state = determineState();
      57           0 :   const auto alpha = getAlpha(face, state);
      58             :   mooseAssert(!MooseUtils::isZero(alpha), "Alpha should not be 0!");
      59           0 :   const auto beta = getBeta(face, state);
      60           0 :   const auto gamma = getGamma(face, state);
      61           0 :   return (gamma - beta * computeBoundaryValue()) / alpha;
      62             : }
      63             : 
      64             : // implicit terms for advection kernel
      65             : Real
      66         192 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValueMatrixContribution() const
      67             : {
      68         192 :   const auto face = singleSidedFaceArg(_current_face_info);
      69         192 :   const auto state = determineState();
      70         192 :   const auto alpha = getAlpha(face, state);
      71         192 :   const auto beta = getBeta(face, state);
      72         192 :   const auto & nhat = _current_face_info->normal();
      73             : 
      74         192 :   return alpha / (alpha + (beta * computeCellToFaceVector() * nhat));
      75             : }
      76             : 
      77             : // explicit terms for advection kernel
      78             : Real
      79         192 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValueRHSContribution() const
      80             : {
      81         192 :   const auto face = singleSidedFaceArg(_current_face_info);
      82         192 :   const auto state = determineState();
      83             :   mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
      84             :               "This should not be assigned on an internal face!");
      85         192 :   const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
      86         192 :                                ? _current_face_info->elemInfo()
      87           0 :                                : _current_face_info->neighborInfo();
      88             : 
      89         192 :   const auto alpha = getAlpha(face, state);
      90         192 :   const auto beta = getBeta(face, state);
      91         192 :   const auto gamma = getGamma(face, state);
      92             : 
      93         192 :   const auto & grad_phi = _var.gradSln(*elem_info, state);
      94             : 
      95         192 :   const auto & nhat = _current_face_info->normal();
      96             : 
      97         192 :   const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
      98         192 :   const auto projection = d_cf * nhat;
      99         192 :   const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells
     100             : 
     101         192 :   return (gamma * projection / (alpha + (beta * projection))) +
     102         192 :          (alpha * grad_phi * vc / (alpha + (beta * projection)));
     103             : }
     104             : 
     105             : // implicit terms for diffusion kernel
     106             : Real
     107         876 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryGradientMatrixContribution() const
     108             : {
     109         876 :   const auto face = singleSidedFaceArg(_current_face_info);
     110         876 :   const auto state = determineState();
     111             : 
     112         876 :   const auto alpha = getAlpha(face, state);
     113         876 :   const auto beta = getBeta(face, state);
     114             : 
     115         876 :   const auto & nhat = _current_face_info->normal();
     116             : 
     117         876 :   return beta / (alpha + (beta * computeCellToFaceVector() * nhat));
     118             : }
     119             : 
     120             : // explicit terms for diffusion kernel
     121             : Real
     122         876 : LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryGradientRHSContribution() const
     123             : {
     124             :   mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
     125             :               "This should not be assigned on an internal face!");
     126         876 :   const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
     127         876 :                                ? _current_face_info->elemInfo()
     128           0 :                                : _current_face_info->neighborInfo();
     129         876 :   const auto face = singleSidedFaceArg(_current_face_info);
     130         876 :   const auto state = determineState();
     131         876 :   const auto & grad_phi = _var.gradSln(*elem_info, state);
     132             : 
     133         876 :   const auto alpha = getAlpha(face, state);
     134         876 :   const auto beta = getBeta(face, state);
     135         876 :   const auto gamma = getGamma(face, state);
     136             : 
     137         876 :   const auto & nhat = _current_face_info->normal();
     138             : 
     139         876 :   const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
     140         876 :   const auto projection = d_cf * nhat;
     141         876 :   const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells
     142             : 
     143         876 :   return (gamma / alpha) + (-beta * gamma * projection / alpha / (alpha + (beta * projection))) +
     144         876 :          (-beta * grad_phi * vc / (alpha + (beta * projection)));
     145             : }

Generated by: LCOV version 1.14