LCOV - code coverage report
Current view: top level - src/fvkernels - PCNSFVMomentumFriction.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 29 31 93.5 %
Date: 2026-05-29 20:37:52 Functions: 3 3 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 "PCNSFVMomentumFriction.h"
      11             : #include "NS.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", PCNSFVMomentumFriction);
      14             : 
      15             : InputParameters
      16          98 : PCNSFVMomentumFriction::validParams()
      17             : {
      18          98 :   InputParameters params = FVElementalKernel::validParams();
      19          98 :   params.addClassDescription("Computes a friction force term on fluid in porous media in the "
      20             :                              "Navier Stokes i-th momentum equation.");
      21         196 :   MooseEnum momentum_component("x=0 y=1 z=2");
      22         196 :   params.addRequiredParam<MooseEnum>(
      23             :       "momentum_component",
      24             :       momentum_component,
      25             :       "The component of the momentum equation that this kernel applies to.");
      26         196 :   params.addParam<MaterialPropertyName>("Darcy_name",
      27             :                                         "Name of the Darcy coefficients material property.");
      28         196 :   params.addParam<MaterialPropertyName>("Forchheimer_name",
      29             :                                         "Name of the Forchheimer coefficients material property.");
      30          98 :   params.addCoupledVar(NS::porosity, "Porosity variable.");
      31         196 :   params.addRequiredParam<MaterialPropertyName>(
      32             :       "momentum_name",
      33             :       "Name of the superficial momentum material property for "
      34             :       "the Darcy and Forchheimer friction terms.");
      35          98 :   return params;
      36          98 : }
      37             : 
      38          52 : PCNSFVMomentumFriction::PCNSFVMomentumFriction(const InputParameters & params)
      39             :   : FVElementalKernel(params),
      40          52 :     _component(getParam<MooseEnum>("momentum_component")),
      41         208 :     _cL(isParamValid("Darcy_name") ? &getADMaterialProperty<RealVectorValue>("Darcy_name")
      42             :                                    : nullptr),
      43          52 :     _cQ(isParamValid("Forchheimer_name")
      44          52 :             ? &getADMaterialProperty<RealVectorValue>("Forchheimer_name")
      45             :             : nullptr),
      46         104 :     _use_Darcy_friction_model(isParamValid("Darcy_name")),
      47         104 :     _use_Forchheimer_friction_model(isParamValid("Forchheimer_name")),
      48          52 :     _eps(isCoupled(NS::porosity) ? coupledValue(NS::porosity)
      49          52 :                                  : getMaterialProperty<Real>(NS::porosity).get()),
      50         156 :     _momentum(getADMaterialProperty<Real>("momentum_name"))
      51             : {
      52          52 :   if (!_use_Darcy_friction_model && !_use_Forchheimer_friction_model)
      53           0 :     mooseError("At least one friction model needs to be specified.");
      54          52 : }
      55             : 
      56             : ADReal
      57     1959660 : PCNSFVMomentumFriction::computeQpResidual()
      58             : {
      59     1959660 :   ADReal friction_term = 0;
      60             : 
      61     1959660 :   if (_use_Darcy_friction_model)
      62     3919320 :     friction_term += (*_cL)[_qp](_component) * _momentum[_qp] / _eps[_qp];
      63     1959660 :   if (_use_Forchheimer_friction_model)
      64           0 :     friction_term += (*_cQ)[_qp](_component) * _momentum[_qp] / _eps[_qp];
      65             : 
      66     1959660 :   return friction_term;
      67             : }

Generated by: LCOV version 1.14