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

Generated by: LCOV version 1.14