Skip to content

Commit

Permalink
Enable selection of names for turbulence k-eps variables
Browse files Browse the repository at this point in the history
Add support for using a functor material for mu_t, preserving derivatives
refs #9007
  • Loading branch information
GiudGiud committed May 14, 2024
1 parent 752cf46 commit 2b0eff5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ class WCNSFVTurbulencePhysics final : public NavierStokesPhysicsBase,
/// List of boundaries to act as walls for turbulence models
std::vector<BoundaryName> _turbulence_walls;
/// Name of the turbulent kinetic energy
const VariableName _tke_name = NS::TKE;
const VariableName _tke_name;
/// Name of the turbulent kinetic energy dissipation
const VariableName _tked_name = NS::TKED;
const VariableName _tked_name;
/// Name of the turbulence viscosity auxiliary variable (or property)
const VariableName _turbulent_viscosity_name = NS::mu_t;
};
63 changes: 47 additions & 16 deletions modules/navier_stokes/src/physics/WCNSFVTurbulencePhysics.C
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ WCNSFVTurbulencePhysics::validParams()
params.suppressParameter<MooseEnum>("preconditioning");

// K-Epsilon parameters
params.addParam<MooseFunctorName>(
"tke_name", NS::TKE, "Name of the turbulent kinetic energy variable");
params.addParam<MooseFunctorName>(
"tked_name", NS::TKED, "Name of the turbulent kinetic energy dissipation variable");
params.addParam<FunctionName>("initial_tke", "Initial value for the turbulence kinetic energy");
params.addParam<FunctionName>("initial_tked",
"Initial value for the turbulence kinetic energy dissipation");
Expand Down Expand Up @@ -116,10 +120,15 @@ WCNSFVTurbulencePhysics::validParams()
true,
"If a two-term Taylor expansion is needed for the determination of the boundary values"
"of the turbulent kinetic energy dissipation.");
params.addParam<MooseEnum>("turbulent_viscosity_face_interpolation",
face_interpol_types,
"The numerical scheme to interpolate the turbulent viscosity to the "
"face.");
params.addParam<bool>(
"turbulent_viscosity_two_term_bc_expansion",
true,
"If a two-term Taylor expansion is needed for the determination of the boundary values"
"of the turbulent viscosity.");
params.addParam<bool>("mu_t_as_aux_variable",
false,
"Whether to use an auxiliary variable instead of a functor material "
"property for the turbulent viscosity");

// Add the coupled physics
// TODO Remove the defaults once NavierStokesFV action is removed
Expand All @@ -141,6 +150,16 @@ WCNSFVTurbulencePhysics::validParams()
params.addParamNamesToGroup("fluid_heat_transfer_physics turbulent_prandtl "
"scalar_transport_physics passive_scalar_schmidt_number",
"Coupled Physics");
params.addParamNamesToGroup("initial_tke initial_tked C1_eps C2_eps sigma_k sigma_eps "
"non_equilibrium_treatment",
"K-Epsilon model");
params.addParamNamesToGroup("C_mu linearized_yplus bulk_wall_treatment wall_treatment",
"K-Epsilon wall function");
params.addParamNamesToGroup(
"tke_scaling tke_face_interpolation tke_two_term_bc_expansion tked_scaling "
"tked_face_interpolation tked_two_term_bc_expansion "
"turbulent_viscosity_two_term_bc_expansion mu_t_as_aux_variable",
"K-Epsilon model numerical");

return params;
}
Expand All @@ -150,7 +169,9 @@ WCNSFVTurbulencePhysics::WCNSFVTurbulencePhysics(const InputParameters & paramet
WCNSFVCoupledAdvectionPhysicsHelper(parameters, this),
_turbulence_model(getParam<MooseEnum>("turbulence_handling")),
_mixing_length_name(getParam<AuxVariableName>("mixing_length_name")),
_turbulence_walls(getParam<std::vector<BoundaryName>>("turbulence_walls"))
_turbulence_walls(getParam<std::vector<BoundaryName>>("turbulence_walls")),
_tke_name(getParam<MooseFunctorName>("tke_name")),
_tked_name(getParam<MooseFunctorName>("tked_name"))
{
if (_verbose && _turbulence_model != "none")
_console << "Creating a " << std::string(_turbulence_model) << " turbulence model."
Expand Down Expand Up @@ -514,8 +535,9 @@ WCNSFVTurbulencePhysics::addKEpsilonDiffusion()
{
const std::string kernel_type = "INSFVTurbulentDiffusion";
InputParameters params = getFactory().getValidParams(kernel_type);

assignBlocks(params, _blocks);
params.set<std::vector<BoundaryName>>("walls") = _turbulence_walls;

params.set<NonlinearVariableName>("variable") = _tke_name;
params.set<MooseFunctorName>("coeff") = _flow_equations_physics->dynamicViscosityName();
getProblem().addFVKernel(kernel_type, prefix() + "tke_diffusion_mu", params);
Expand Down Expand Up @@ -597,7 +619,7 @@ WCNSFVTurbulencePhysics::addAuxiliaryKernels()

getProblem().addAuxKernel(ml_kernel_type, prefix() + "mixing_length_aux ", ml_params);
}
else if (_turbulence_model == "k-epsilon")
else if (_turbulence_model == "k-epsilon" && getParam<bool>("mu_t_as_aux_variable"))
{
const std::string u_names[3] = {"u", "v", "w"};
const std::string mut_kernel_type = "kEpsilonViscosityAux";
Expand Down Expand Up @@ -693,23 +715,32 @@ WCNSFVTurbulencePhysics::addMaterials()
}
else if (_turbulence_model == "k-epsilon")
{
InputParameters params = getFactory().getValidParams("ADParsedFunctorMaterial");
assignBlocks(params, _blocks);
const auto mu_name = _flow_equations_physics->dynamicViscosityName();
if (!MooseUtils::isFloat(_turbulent_viscosity_name) && !MooseUtils::isFloat(mu_name))
params.set<std::vector<std::string>>("functor_names") = {_turbulent_viscosity_name, mu_name};
else if (MooseUtils::isFloat(_turbulent_viscosity_name) && !MooseUtils::isFloat(mu_name))
params.set<std::vector<std::string>>("functor_names") = {mu_name};
else if (!MooseUtils::isFloat(_turbulent_viscosity_name) && MooseUtils::isFloat(mu_name))
params.set<std::vector<std::string>>("functor_names") = {_turbulent_viscosity_name};

if (!getProblem().hasFunctor(NS::mu_eff, /*thread_id=*/0))
{
InputParameters params = getFactory().getValidParams("ADParsedFunctorMaterial");
assignBlocks(params, _blocks);
const auto mu_name = _flow_equations_physics->dynamicViscosityName();
if (!MooseUtils::isFloat(_turbulent_viscosity_name) && !MooseUtils::isFloat(mu_name))
params.set<std::vector<std::string>>("functor_names") = {_turbulent_viscosity_name,
mu_name};
else if (MooseUtils::isFloat(_turbulent_viscosity_name) && !MooseUtils::isFloat(mu_name))
params.set<std::vector<std::string>>("functor_names") = {mu_name};
else if (!MooseUtils::isFloat(_turbulent_viscosity_name) && MooseUtils::isFloat(mu_name))
params.set<std::vector<std::string>>("functor_names") = {_turbulent_viscosity_name};

params.set<std::string>("expression") =
_flow_equations_physics->dynamicViscosityName() + " + " + _turbulent_viscosity_name;
params.set<std::string>("property_name") = NS::mu_eff;
getProblem().addMaterial("ADParsedFunctorMaterial", prefix() + "effective_viscosity", params);
}
if (!getProblem().hasFunctor(NS::mu_t, /*thread_id=*/0))
{
InputParameters params = getFactory().getValidParams("INSFVkEpsilonViscosityMaterial");
params.set<MooseFunctorName>(NS::TKE) = _tke_name;
params.set<MooseFunctorName>(NS::TKED) = _tked_name;
params.set<MooseFunctorName>(NS::density) = _density_name;
}
}
}

Expand Down

0 comments on commit 2b0eff5

Please sign in to comment.