forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding LinearFVEnthalpyFunctorMaterial idaholab#29531
- Loading branch information
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
modules/navier_stokes/include/functormaterials/LinearFVEnthalpyFunctorMaterial.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "FunctorMaterial.h" | ||
#include "Function.h" | ||
|
||
class SinglePhaseFluidProperties; | ||
class Function; | ||
|
||
/**e | ||
* Computes fluid properties in (P, T) formulation using functor material properties | ||
*/ | ||
class LinearFVEnthalpyFunctorMaterial : public FunctorMaterial | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
LinearFVEnthalpyFunctorMaterial(const InputParameters & parameters); | ||
|
||
protected: | ||
/// variables | ||
const Moose::Functor<ADReal> & _pressure; | ||
const Moose::Functor<ADReal> & _T_fluid; | ||
const Moose::Functor<ADReal> & _h; | ||
|
||
const SinglePhaseFluidProperties * _fluid; | ||
const Moose::Functor<Real> * _h_from_p_T_functor; | ||
const Moose::Functor<Real> * _T_from_p_h_functor; | ||
|
||
using UserObjectInterface::getUserObject; | ||
}; |
77 changes: 77 additions & 0 deletions
77
modules/navier_stokes/src/functormaterials/LinearFVEnthalpyFunctorMaterial.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#include "LinearFVEnthalpyFunctorMaterial.h" | ||
#include "NS.h" // Variable Term Names | ||
#include "NavierStokesMethods.h" | ||
#include "SinglePhaseFluidProperties.h" | ||
|
||
registerMooseObject("NavierStokesApp", LinearFVEnthalpyFunctorMaterial); | ||
|
||
InputParameters | ||
LinearFVEnthalpyFunctorMaterial::validParams() | ||
{ | ||
auto params = FunctorMaterial::validParams(); | ||
params.addClassDescription("Creates functor fluid properties using a (P, T) formulation"); | ||
|
||
params.addRequiredParam<MooseFunctorName>(NS::pressure, "Pressure"); | ||
params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "Fluid temperature"); | ||
params.addRequiredParam<MooseFunctorName>("h","Specific Enthalpy"); | ||
|
||
// Please choose between providing a fluid properties | ||
params.addParam<UserObjectName>(NS::fluid, "Fluid properties functor userobject"); | ||
// or the h_from_p_T and T_from_p_h functors. | ||
params.addParam<MooseFunctorName>("h_from_p_T_functor","User specified enthalpy from temperature functor"); | ||
params.addParam<MooseFunctorName>("T_from_p_h_functor","User specified temperature from enthalpy functor"); | ||
|
||
return params; | ||
} | ||
|
||
LinearFVEnthalpyFunctorMaterial::LinearFVEnthalpyFunctorMaterial(const InputParameters & params) | ||
: FunctorMaterial(params), | ||
_pressure(getFunctor<ADReal>(NS::pressure)), | ||
_T_fluid(getFunctor<ADReal>(NS::T_fluid)), | ||
_h(getFunctor<ADReal>("h")), | ||
_fluid(params.isParamValid(NS::fluid) ? &UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid) : nullptr), | ||
_h_from_p_T_functor(params.isParamValid("h_from_p_T_functor") ? &getFunctor<Real>("h_from_p_T_functor") : nullptr), | ||
_T_from_p_h_functor(params.isParamValid("T_from_p_h_functor") ? &getFunctor<Real>("T_from_p_h_functor") : nullptr) | ||
{ | ||
// Check parameters | ||
if (!( (_fluid && !_h_from_p_T_functor && !_T_from_p_h_functor) || | ||
(!_fluid && _h_from_p_T_functor && _T_from_p_h_functor))) | ||
{ | ||
mooseError(false, | ||
"For `LinearFVEnthalpyFunctorMaterial` , an unsupported combination of input parameters was given. Current" | ||
"supported combinations are either i) fp and no _h_from_p_T_functor and _T_from_p_h_functor, or ii) " | ||
"no fp and _h_from_p_T_functor and _T_from_p_h_functor."); | ||
} | ||
|
||
// | ||
// Set material properties functors | ||
// | ||
|
||
if (_fluid) | ||
{ | ||
addFunctorProperty<Real>("h_from_p_T", | ||
[this](const auto & r, const auto & t) -> Real | ||
{ return _fluid->h_from_p_T(raw_value(_pressure(r, t)), raw_value(_T_fluid(r, t))); }); | ||
addFunctorProperty<Real>("T_from_p_h", | ||
[this](const auto & r, const auto & t) -> Real | ||
{ return _fluid->T_from_p_h(raw_value(_pressure(r, t)), raw_value(_h(r, t))); }); | ||
} | ||
else | ||
{ | ||
addFunctorProperty<Real>("h_from_p_T", | ||
[this](const auto & r, const auto & t) -> Real | ||
{ return (*_h_from_p_T_functor)(r, t); }); | ||
addFunctorProperty<Real>("T_from_p_h", | ||
[this](const auto & r, const auto & t) -> Real | ||
{ return (*_T_from_p_h_functor)(r, t); }); | ||
} | ||
} |