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 : // Navier-Stokes includes 11 : #include "RhoFromPTFunctorMaterial.h" 12 : #include "NS.h" 13 : 14 : // FluidProperties includes 15 : #include "SinglePhaseFluidProperties.h" 16 : 17 : registerMooseObject("NavierStokesApp", RhoFromPTFunctorMaterial); 18 : 19 : InputParameters 20 403 : RhoFromPTFunctorMaterial::validParams() 21 : { 22 403 : auto params = FunctorMaterial::validParams(); 23 403 : params.addRequiredParam<UserObjectName>(NS::fluid, "fluid userobject"); 24 403 : params.addClassDescription( 25 : "Computes the density from coupled pressure and temperature functors (variables, " 26 : "functions, functor material properties"); 27 403 : params.addRequiredParam<MooseFunctorName>(NS::temperature, "temperature functor"); 28 403 : params.addRequiredParam<MooseFunctorName>(NS::pressure, "pressure functor"); 29 806 : params.addParam<MooseFunctorName>( 30 : "density_name", NS::density, "name to use to declare the density functor"); 31 806 : params.addParam<bool>("neglect_derivatives_of_density_time_derivative", 32 806 : false, 33 : "Whether to neglect the derivatives with regards to nonlinear variables " 34 : "of the density time derivatives"); 35 403 : return params; 36 0 : } 37 : 38 220 : RhoFromPTFunctorMaterial::RhoFromPTFunctorMaterial(const InputParameters & parameters) 39 : : FunctorMaterial(parameters), 40 220 : _pressure(getFunctor<ADReal>(NS::pressure)), 41 220 : _temperature(getFunctor<ADReal>(NS::temperature)), 42 220 : _fluid(getUserObject<SinglePhaseFluidProperties>(NS::fluid)), 43 440 : _density_name(getParam<MooseFunctorName>("density_name")) 44 : { 45 660 : addFunctorProperty<ADReal>(_density_name, 46 33083047 : [this](const auto & r, const auto & t) -> ADReal 47 33083047 : { return _fluid.rho_from_p_T(_pressure(r, t), _temperature(r, t)); }); 48 440 : if (getParam<bool>("neglect_derivatives_of_density_time_derivative")) 49 0 : addFunctorProperty<ADReal>( 50 0 : NS::time_deriv(_density_name), 51 0 : [this](const auto & r, const auto & t) -> ADReal 52 : { 53 : Real rho, drho_dp, drho_dT; 54 0 : _fluid.rho_from_p_T( 55 0 : _pressure(r, t).value(), _temperature(r, t).value(), rho, drho_dp, drho_dT); 56 0 : return drho_dp * _pressure.dot(r, t) + drho_dT * _temperature.dot(r, t); 57 : }); 58 : else 59 880 : addFunctorProperty<ADReal>( 60 440 : NS::time_deriv(_density_name), 61 2301064 : [this](const auto & r, const auto & t) -> ADReal 62 : { 63 : ADReal rho, drho_dp, drho_dT; 64 2301064 : _fluid.rho_from_p_T(_pressure(r, t), _temperature(r, t), rho, drho_dp, drho_dT); 65 6903192 : return drho_dp * _pressure.dot(r, t) + drho_dT * _temperature.dot(r, t); 66 : }); 67 660 : }