LCOV - code coverage report
Current view: top level - src/linearfvkernels - LinearFVMomentumBoussinesq.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 34 36 94.4 %
Date: 2026-05-29 20:37:52 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 "LinearFVMomentumBoussinesq.h"
      11             : #include "Assembly.h"
      12             : #include "SubProblem.h"
      13             : #include "NS.h"
      14             : #include "FEProblemBase.h"
      15             : 
      16             : registerMooseObject("NavierStokesApp", LinearFVMomentumBoussinesq);
      17             : 
      18             : InputParameters
      19         248 : LinearFVMomentumBoussinesq::validParams()
      20             : {
      21         248 :   InputParameters params = LinearFVElementalKernel::validParams();
      22         248 :   params.addClassDescription("Represents the Boussinesq term in the Navier Stokes momentum "
      23             :                              "equations, added to the right hand side.");
      24         248 :   params.addParam<VariableName>(NS::T_fluid, "The fluid temperature variable.");
      25         496 :   params.addRequiredParam<RealVectorValue>("gravity", "Gravitational acceleration vector.");
      26         496 :   params.addParam<MooseFunctorName>("alpha_name",
      27             :                                     NS::alpha_boussinesq,
      28             :                                     "The name of the thermal expansion coefficient"
      29             :                                     "this is of the form rho = rho_ref*(1-alpha (T-T_ref))");
      30         496 :   params.addRequiredParam<Real>("ref_temperature", "The value for the reference temperature.");
      31         248 :   params.addRequiredParam<MooseFunctorName>(NS::density, "The value for the density");
      32         496 :   MooseEnum momentum_component("x=0 y=1 z=2");
      33         496 :   params.addRequiredParam<MooseEnum>(
      34             :       "momentum_component",
      35             :       momentum_component,
      36             :       "The component of the momentum equation that this kernel applies to.");
      37         248 :   return params;
      38         248 : }
      39             : 
      40         128 : LinearFVMomentumBoussinesq::LinearFVMomentumBoussinesq(const InputParameters & params)
      41             :   : LinearFVElementalKernel(params),
      42         128 :     _index(getParam<MooseEnum>("momentum_component")),
      43         128 :     _temperature_var(getTemperatureVariable(NS::T_fluid)),
      44         256 :     _gravity(getParam<RealVectorValue>("gravity")),
      45         256 :     _alpha(getFunctor<Real>("alpha_name")),
      46         256 :     _ref_temperature(getParam<Real>("ref_temperature")),
      47         256 :     _rho(getFunctor<Real>(NS::density))
      48             : {
      49         128 :   if (!_rho.isConstant())
      50           0 :     paramError(NS::density, "The density in the boussinesq term is not constant!");
      51         128 : }
      52             : 
      53             : const MooseLinearVariableFV<Real> &
      54         128 : LinearFVMomentumBoussinesq::getTemperatureVariable(const std::string & vname)
      55             : {
      56         128 :   auto * ptr = dynamic_cast<MooseLinearVariableFV<Real> *>(
      57         128 :       &_fe_problem.getVariable(_tid, getParam<VariableName>(vname)));
      58             : 
      59         128 :   if (!ptr)
      60           0 :     paramError(NS::T_fluid,
      61             :                "The fluid temperature variable should be of type MooseLinearVariableFVReal!");
      62             : 
      63         128 :   return *ptr;
      64             : }
      65             : 
      66             : Real
      67     1094850 : LinearFVMomentumBoussinesq::computeMatrixContribution()
      68             : {
      69     1094850 :   return 0.0;
      70             : }
      71             : 
      72             : Real
      73     1224930 : LinearFVMomentumBoussinesq::computeRightHandSideContribution()
      74             : {
      75     1224930 :   const auto elem = makeElemArg(_current_elem_info->elem());
      76     1224930 :   const auto state = determineState();
      77     1224930 :   return -_alpha(elem, state) * _gravity(_index) * _rho(elem, state) *
      78     1224930 :          (_temperature_var.getElemValue(*_current_elem_info, state) - _ref_temperature) *
      79     1224930 :          _current_elem_volume;
      80             : }

Generated by: LCOV version 1.14