LCOV - code coverage report
Current view: top level - src/linearfvkernels - LinearFVMomentumPressure.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 26 27 96.3 %
Date: 2025-08-14 10:14:56 Functions: 5 5 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 "LinearFVMomentumPressure.h"
      11             : #include "Assembly.h"
      12             : #include "SubProblem.h"
      13             : #include "NS.h"
      14             : #include "FEProblemBase.h"
      15             : 
      16             : registerMooseObject("NavierStokesApp", LinearFVMomentumPressure);
      17             : 
      18             : InputParameters
      19        2978 : LinearFVMomentumPressure::validParams()
      20             : {
      21        2978 :   InputParameters params = LinearFVElementalKernel::validParams();
      22        2978 :   params.addClassDescription("Represents the pressure gradient term in the Navier Stokes momentum "
      23             :                              "equations, added to the right hand side.");
      24        2978 :   params.addParam<VariableName>(NS::pressure,
      25             :                                 "The pressure variable whose gradient should be used.");
      26        5956 :   MooseEnum momentum_component("x=0 y=1 z=2");
      27        5956 :   params.addRequiredParam<MooseEnum>(
      28             :       "momentum_component",
      29             :       momentum_component,
      30             :       "The component of the momentum equation that this kernel applies to.");
      31        2978 :   return params;
      32        2978 : }
      33             : 
      34        1579 : LinearFVMomentumPressure::LinearFVMomentumPressure(const InputParameters & params)
      35             :   : LinearFVElementalKernel(params),
      36        1579 :     _index(getParam<MooseEnum>("momentum_component")),
      37        1579 :     _pressure_var(getPressureVariable(NS::pressure)),
      38        1579 :     _pressure_gradient(_pressure_var.sys().gradientContainer()),
      39        1579 :     _pressure_var_num(_pressure_var.number()),
      40        3158 :     _pressure_sys_num(_pressure_var.sys().number())
      41             : {
      42        1579 :   _pressure_var.computeCellGradients();
      43        1579 : }
      44             : 
      45             : MooseLinearVariableFV<Real> &
      46        1579 : LinearFVMomentumPressure::getPressureVariable(const std::string & vname)
      47             : {
      48        1579 :   auto * ptr = dynamic_cast<MooseLinearVariableFV<Real> *>(
      49        1579 :       &_fe_problem.getVariable(_tid, getParam<VariableName>(vname)));
      50             : 
      51        1579 :   if (!ptr)
      52           0 :     paramError(NS::pressure, "The pressure variable should be of type MooseLinearVariableFVReal!");
      53             : 
      54        1579 :   return *ptr;
      55             : }
      56             : 
      57             : Real
      58    22935970 : LinearFVMomentumPressure::computeMatrixContribution()
      59             : {
      60    22935970 :   return 0.0;
      61             : }
      62             : 
      63             : Real
      64    22935970 : LinearFVMomentumPressure::computeRightHandSideContribution()
      65             : {
      66    22935970 :   const auto dof_value = _current_elem_info->dofIndices()[_pressure_sys_num][_pressure_var_num];
      67    22935970 :   return -(*_pressure_gradient[_index])(dof_value)*_current_elem_volume;
      68             : }

Generated by: LCOV version 1.14