-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24863 from grmnptr/add-flow-resistance-meterial
Add friction material with exponential relationship.
- Loading branch information
Showing
16 changed files
with
319 additions
and
35 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...avier_stokes/doc/content/source/functormaterials/ExponentialFrictionMaterial.md
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,17 @@ | ||
# ExponentialFrictionMaterial | ||
|
||
!syntax description /FunctorMaterials/ExponentialFrictionMaterial | ||
|
||
This material is used to simulate friction factor correlations in the form of | ||
|
||
\begin{equation} | ||
f(Re) = C_1 \mathrm{Re}^{C_2}~, | ||
\end{equation} | ||
|
||
where $C_1$ and $C_2$ are (potentially space-dependent) constants supplied by the user. | ||
|
||
!syntax parameters /FunctorMaterials/ExponentialFrictionMaterial | ||
|
||
!syntax inputs /FunctorMaterials/ExponentialFrictionMaterial | ||
|
||
!syntax children /FunctorMaterials/ExponentialFrictionMaterial |
16 changes: 16 additions & 0 deletions
16
...ier_stokes/doc/content/source/functormaterials/ReynoldsNumberFunctorMaterial.md
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,16 @@ | ||
# ReynoldsNumberFunctorMaterial | ||
|
||
!syntax description /FunctorMaterials/ReynoldsNumberFunctorMaterial | ||
|
||
This material is used to compute the Reynolds number defined as: | ||
|
||
$\mathrm{Re} = \frac{D|u| \rho}{\mu}$ | ||
|
||
where $D$ is a characteristic length, $|u|$ is the velocity magnitude, while | ||
$\rho$ and $\mu$ are the density and dynamic viscosity of the fluid. | ||
|
||
!syntax parameters /FunctorMaterials/ReynoldsNumberFunctorMaterial | ||
|
||
!syntax inputs /FunctorMaterials/ReynoldsNumberFunctorMaterial | ||
|
||
!syntax children /FunctorMaterials/ReynoldsNumberFunctorMaterial |
42 changes: 42 additions & 0 deletions
42
modules/navier_stokes/include/functormaterials/ExponentialFrictionMaterial.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,42 @@ | ||
//* 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" | ||
|
||
/** | ||
* Class responsible for generating a friction factor for the | ||
* friction-based pressure loss terms in the form of: | ||
* | ||
* $f(Re) = C_1 Re^{C_2}$ | ||
* | ||
* This is common for flows in pipes. Designed to work with both | ||
* INSFV and PINSFV friction loss kernels. | ||
*/ | ||
class ExponentialFrictionMaterial : public FunctorMaterial | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
ExponentialFrictionMaterial(const InputParameters & parameters); | ||
|
||
private: | ||
/// Functor for the Reynolds number | ||
const Moose::Functor<ADReal> & _Re; | ||
/// Speed (velocity magnitude) of the fluid | ||
const Moose::Functor<ADReal> * const _speed; | ||
/// $C_1$ in $f(Re) = C_1 Re^{C_2}$ | ||
const Real _c1; | ||
/// $C_2$ in $f(Re) = C_1 Re^{C_2}$ | ||
const Real _c2; | ||
/// The name of the output friction factor functor | ||
const std::string _friction_factor_name; | ||
/// If a factor of velocity should be included or not | ||
const bool _include_velocity_factor; | ||
}; |
38 changes: 38 additions & 0 deletions
38
modules/navier_stokes/include/functormaterials/ReynoldsNumberFunctorMaterial.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" | ||
|
||
/** | ||
* Class responsible for generating functor for computing the Reynolds | ||
* number | ||
* | ||
* $\mathrm{Re} = \frac{\rho |u| D}{\mu}$ | ||
* | ||
* where $rho$, $|u|$, $\mu$ and $D$ are the fluid density, velocity magnitude, | ||
* dynamic viscosity and hydraulic diameter, respectively. | ||
*/ | ||
class ReynoldsNumberFunctorMaterial : public FunctorMaterial | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
ReynoldsNumberFunctorMaterial(const InputParameters & parameters); | ||
|
||
private: | ||
/// Speed (velocity magnitude) of the fluid | ||
const Moose::Functor<ADReal> & _speed; | ||
/// Functor for the dynamic viscosity | ||
const Moose::Functor<ADReal> & _mu; | ||
/// Functor for the density | ||
const Moose::Functor<ADReal> & _rho; | ||
/// Functor for the characteristic length | ||
const Moose::Functor<Real> & _characteristic_length; | ||
}; |
54 changes: 54 additions & 0 deletions
54
modules/navier_stokes/src/functormaterials/ExponentialFrictionMaterial.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,54 @@ | ||
//* 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 "ExponentialFrictionMaterial.h" | ||
#include "MooseMesh.h" | ||
#include "NS.h" | ||
|
||
registerMooseObject("NavierStokesApp", ExponentialFrictionMaterial); | ||
|
||
InputParameters | ||
ExponentialFrictionMaterial::validParams() | ||
{ | ||
InputParameters params = FunctorMaterial::validParams(); | ||
params.addClassDescription("Computes a Reynolds number-exponential friction factor."); | ||
params.addRequiredParam<MooseFunctorName>(NS::Reynolds, "The Reynolds number."); | ||
params.addParam<MooseFunctorName>(NS::speed, "The velocity magnitude of the fluid."); | ||
params.addRequiredParam<Real>("c1", "c2 in c1/Re^(c2) expression."); | ||
params.addRequiredParam<Real>("c2", "c2 in c1/Re^(c2) expression."); | ||
params.addRequiredParam<std::string>("friction_factor_name", | ||
"The name of the output friction factor."); | ||
params.addParam<bool>( | ||
"include_velocity_factor", | ||
false, | ||
"If a factor of velocity magnitude should be included in the friction factor. This is " | ||
"typically the case for prorous medium Forcheimer friction therms."); | ||
return params; | ||
} | ||
|
||
ExponentialFrictionMaterial::ExponentialFrictionMaterial(const InputParameters & parameters) | ||
: FunctorMaterial(parameters), | ||
_Re(getFunctor<ADReal>(NS::Reynolds)), | ||
_speed(isParamValid(NS::speed) ? &getFunctor<ADReal>(NS::speed) : nullptr), | ||
_c1(getParam<Real>("c1")), | ||
_c2(getParam<Real>("c2")), | ||
_friction_factor_name(getParam<std::string>("friction_factor_name")), | ||
_include_velocity_factor(getParam<bool>("include_velocity_factor")) | ||
{ | ||
if (_include_velocity_factor && !_speed) | ||
paramError(NS::speed, | ||
"To be able to include an additional multiplier in the friction factor, please " | ||
"provide the speed of the fluid."); | ||
addFunctorProperty<ADReal>(_friction_factor_name, | ||
[this](const auto & r, const auto & t) -> ADReal | ||
{ | ||
return _c1 * std::pow(_Re(r, t), _c2) * | ||
(_include_velocity_factor ? (*_speed)(r, t) : ADReal(1.0)); | ||
}); | ||
} |
41 changes: 41 additions & 0 deletions
41
modules/navier_stokes/src/functormaterials/ReynoldsNumberFunctorMaterial.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,41 @@ | ||
//* 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 "ReynoldsNumberFunctorMaterial.h" | ||
#include "MooseMesh.h" | ||
#include "NS.h" | ||
|
||
registerMooseObject("NavierStokesApp", ReynoldsNumberFunctorMaterial); | ||
|
||
InputParameters | ||
ReynoldsNumberFunctorMaterial::validParams() | ||
{ | ||
InputParameters params = FunctorMaterial::validParams(); | ||
params.addClassDescription("Computes a Reynolds number."); | ||
params.addRequiredParam<MooseFunctorName>(NS::speed, "The velocity magnitude of the fluid."); | ||
params.addRequiredParam<MooseFunctorName>(NS::density, "The density of the fluid."); | ||
params.addRequiredParam<MooseFunctorName>(NS::mu, "The dynamic viscosity of the fluid."); | ||
params.addRequiredParam<MooseFunctorName>("characteristic_length", | ||
"The characteristic length of the geometry."); | ||
|
||
return params; | ||
} | ||
|
||
ReynoldsNumberFunctorMaterial::ReynoldsNumberFunctorMaterial(const InputParameters & parameters) | ||
: FunctorMaterial(parameters), | ||
_speed(getFunctor<ADReal>(NS::speed)), | ||
_mu(getFunctor<ADReal>(NS::mu)), | ||
_rho(getFunctor<ADReal>(NS::density)), | ||
_characteristic_length(getFunctor<Real>("characteristic_length")) | ||
{ | ||
addFunctorProperty<ADReal>( | ||
NS::Reynolds, | ||
[this](const auto & r, const auto & t) -> ADReal | ||
{ return _rho(r, t) * _speed(r, t) * _characteristic_length(r, t) / _mu(r, t); }); | ||
} |
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
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
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...tests/finite_volume/ins/channel-flow/friction/gold/2d-rc-friction-exp-factor-action_out.e
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 @@ | ||
2d-rc-friction-exp-factor_out.e |
Binary file added
BIN
+112 KB
...s/test/tests/finite_volume/ins/channel-flow/friction/gold/2d-rc-friction-exp-factor_out.e
Binary file not shown.
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
modules/navier_stokes/test/tests/finite_volume/ins/channel-flow/friction/tests
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,62 @@ | ||
[Tests] | ||
issues = '#19472 #24856 #16872' | ||
design = 'navier_stokes/insfv.md NSFVAction.md' | ||
[linear-friction] | ||
type = 'Exodiff' | ||
input = 2d-rc-friction.i | ||
exodiff = 2d-rc-friction_out.e | ||
requirement = 'The system shall be able to model linear volumetric friction in a channel.' | ||
design = 'INSFVMomentumFriction.md' | ||
[] | ||
[quadratic-friction] | ||
type = 'Exodiff' | ||
input = 2d-rc-friction.i | ||
exodiff = 2d-rc-friction-quad_out.e | ||
requirement = 'The system shall be able to model quadratic volumetric friction in a channel.' | ||
cli_args = "Outputs/file_base='2d-rc-friction-quad_out' FVKernels/inactive='u_friction_linear " | ||
"v_friction_linear'" | ||
design = 'INSFVMomentumFriction.md' | ||
[] | ||
[exponential-friction-factor] | ||
type = 'Exodiff' | ||
input = 2d-rc-friction.i | ||
exodiff = 2d-rc-friction-exp-factor_out.e | ||
requirement = 'The system shall be able to model quadratic volumetric friction with an exponential friction factor correlation in a channel.' | ||
cli_args = "Outputs/file_base='2d-rc-friction-exp-factor_out' " | ||
"FVKernels/inactive='u_friction_linear v_friction_linear' " | ||
"Materials/inactive='friction_coefficient'" | ||
design = 'ExponentialFrictionMaterial.md' | ||
[] | ||
[exponential-friction-factor-jacobian] | ||
type = PetscJacobianTester | ||
input = 2d-rc-friction.i | ||
requirement = 'The system shall be able to build the correct Jacobian using exponential correlation for the friction factor.' | ||
cli_args = "Outputs/file_base='2d-rc-friction-exp-factor_out' " | ||
"FVKernels/inactive='u_friction_linear v_friction_linear' " | ||
"Materials/inactive='friction_coefficient' Mesh/gen/nx=4 Mesh/gen/ny=4 " | ||
[] | ||
[linear-friction-action] | ||
type = 'Exodiff' | ||
input = 2d-rc-friction-action.i | ||
exodiff = 2d-rc-friction-action_out.e | ||
requirement = 'The system shall be able to model linear volumetric friction in a channel using a custom action syntax.' | ||
[] | ||
[quadratic-friction-action] | ||
type = 'Exodiff' | ||
input = 2d-rc-friction-action.i | ||
exodiff = 2d-rc-friction-action-quad_out.e | ||
requirement = 'The system shall be able to model quadratic volumetric friction in a channel using a custom action syntax.' | ||
cli_args = "Modules/NavierStokesFV/friction_types='forchheimer' " | ||
"Outputs/file_base='2d-rc-friction-action-quad_out'" | ||
[] | ||
[exponential-friction-factor-action] | ||
type = 'Exodiff' | ||
input = 2d-rc-friction-action.i | ||
exodiff = 2d-rc-friction-exp-factor-action_out.e | ||
requirement = 'The system shall be able to model quadratic volumetric friction with an exponential friction factor correlation in a channel a custom action syntax.' | ||
cli_args = "Modules/NavierStokesFV/friction_types='forchheimer' " | ||
"Modules/NavierStokesFV/friction_coeffs='friction_coefficient' " | ||
"Outputs/file_base='2d-rc-friction-exp-factor-action_out' " | ||
design = 'ExponentialFrictionMaterial.md' | ||
[] | ||
[] |
Oops, something went wrong.