https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WCNSLinearFVTwoPhaseMixturePhysics.C
Go to the documentation of this file.
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
14#include "WCNSFVFlowPhysics.h"
15
18registerMooseAction("NavierStokesApp",
20 "add_interpolation_method_physics");
21registerMooseAction("NavierStokesApp", WCNSLinearFVTwoPhaseMixturePhysics, "add_material");
22registerMooseAction("NavierStokesApp", WCNSLinearFVTwoPhaseMixturePhysics, "check_integrity");
23
26{
27 // The parameters are mostly the same being the linear and nonlinear version
30 // The flow physics is obtained from the scalar transport base class
31 // The fluid heat transfer physics is retrieved even if unspecified
32 params.addParam<PhysicsName>(
33 "fluid_heat_transfer_physics",
34 "NavierStokesFV",
35 "WCNSLinearFVFluidHeatTransferPhysics generating the fluid energy equation");
37 params.addParamNamesToGroup("fluid_heat_transfer_physics", "Phase change");
38 params.addClassDescription("Define the additional terms for a mixture model for the two phase "
39 "weakly-compressible Navier Stokes equations using the linearized "
40 "segregated finite volume discretization");
41
42 // This is added to match a nonlinear test result. If the underlying issue is fixed, remove it
43 params.addParam<bool>("add_gravity_term_in_slip_velocity",
44 true,
45 "Whether to add the gravity term in the slip velocity vector computation");
46 return params;
47}
48
50 const InputParameters & parameters)
52 _add_phase_equation(_has_scalar_equation),
53 _phase_1_fraction_name(getParam<MooseFunctorName>("phase_1_fraction_name")),
54 _phase_2_fraction_name(_passive_scalar_names[0]),
55 _phase_1_density(getParam<MooseFunctorName>("phase_1_density_name")),
56 _phase_1_viscosity(getParam<MooseFunctorName>("phase_1_viscosity_name")),
57 _phase_1_specific_heat(getParam<MooseFunctorName>("phase_1_specific_heat_name")),
58 _phase_1_thermal_conductivity(getParam<MooseFunctorName>("phase_1_thermal_conductivity_name")),
59 _phase_2_density(getParam<MooseFunctorName>("phase_2_density_name")),
60 _phase_2_viscosity(getParam<MooseFunctorName>("phase_2_viscosity_name")),
61 _phase_2_specific_heat(getParam<MooseFunctorName>("phase_2_specific_heat_name")),
62 _phase_2_thermal_conductivity(getParam<MooseFunctorName>("phase_2_thermal_conductivity_name")),
63 _use_external_mixture_properties(getParam<bool>("use_external_mixture_properties")),
64 _use_drift_flux(getParam<bool>("add_drift_flux_momentum_terms")),
65 _use_advection_slip(getParam<bool>("add_advection_slip_term"))
66{
69 "porous_medium_treatment",
70 "The porous medium treatment is not implemented for the linear two-phase mixture physics");
71 // Check that only one scalar was passed, as we are using vector parameters
72 if (_passive_scalar_names.size() > 1)
73 paramError("phase_fraction_name", "Only one phase fraction currently supported.");
74 if (_passive_scalar_inlet_functors.size() > 1)
75 paramError("phase_fraction_inlet_functors", "Only one phase fraction currently supported");
76
77 // Retrieve the fluid energy equation if it exists
78 if (isParamValid("fluid_heat_transfer_physics"))
79 {
80 _fluid_energy_physics = getCoupledPhysics<WCNSLinearFVFluidHeatTransferPhysics>(
81 getParam<PhysicsName>("fluid_heat_transfer_physics"), true);
82 // Check for a missing parameter / do not support isolated physics for now
84 !getCoupledPhysics<const WCNSLinearFVFluidHeatTransferPhysics>(true).empty())
86 "fluid_heat_transfer_physics",
87 "We currently do not support creating both a phase transport equation and fluid heat "
88 "transfer physics that are not coupled together");
91 else
93 }
94 else
95 {
97 _fluid_energy_physics = nullptr;
98 }
99
100 // Check that the mixture parameters are correctly in use in the other physics
102 {
103 if (_fluid_energy_physics->densityName() != "rho_mixture")
105 "Density name for Physics '", _fluid_energy_physics->name(), "' should be 'rho_mixture'");
106 if (_fluid_energy_physics->getSpecificHeatName() != "cp_mixture")
107 mooseError("Specific heat name for Physics '",
109 "' should be 'cp_mixture'");
110 }
112 if (_flow_equations_physics->densityName() != "rho_mixture")
113 mooseError("Density name for Physics ,",
115 "' should be 'rho_mixture'");
116
117 if (_verbose)
118 {
120 mooseInfoRepeated("Coupled to fluid flow physics " + _flow_equations_physics->name());
122 mooseInfoRepeated("Coupled to fluid heat transfer physics " + _fluid_energy_physics->name());
123 }
124
125 // Parameter checking
126 // The two models are not consistent
127 if (isParamSetByUser("alpha_exchange") && getParam<bool>("add_phase_change_energy_term"))
128 paramError("alpha_exchange",
129 "A phase exchange coefficient cannot be specified if the phase change is handled "
130 "with a phase change heat loss model");
132 paramError("phase_1_fraction_name",
133 "First phase fraction name should be different from second phase fraction name");
135 paramError("add_drift_flux_momentum_terms",
136 "Drift flux model cannot be used at the same time as the advection slip model");
137 if (!getParam<bool>("add_drift_flux_momentum_terms"))
138 errorDependentParameter("add_drift_flux_momentum_terms", "true", {"density_interp_method"});
139 if (!getParam<bool>("use_dispersed_phase_drag_model"))
140 errorDependentParameter("use_dispersed_phase_drag_model", "true", {"particle_diameter"});
141}
142
143void
145{
147 mooseError("Expected a flow physics");
148
149 // Check the mesh for unsupported sknewness + buoyancy
150 if (_flow_equations_physics->gravityVector().norm() > 0)
151 {
152 const auto tol = 1e-2;
153 if (_problem->mesh().allFaceInfo().empty())
154 _problem->mesh().setupFiniteVolumeMeshData();
155 for (const auto & fi : _problem->mesh().allFaceInfo())
156 {
157 if (fi.skewnessCorrectionVector().norm() > tol * fi.dCNMag())
158 mooseError("Face with centroid ",
159 fi.faceCentroid(),
160 " requires skewness correction. We currently do not support mixture flow with "
161 "buoyancy and mesh skewness. Please contact a MOOSE or Navier Stokes module "
162 "developer if you require this.");
163 }
164 }
165}
166
167void
184
185void
187{
188 params.set<MooseFunctorName>("u_slip") = "vel_slip_x";
189 if (dimension() >= 2)
190 params.set<MooseFunctorName>("v_slip") = "vel_slip_y";
191 if (dimension() >= 3)
192 params.set<MooseFunctorName>("w_slip") = "vel_slip_z";
193}
194
195void
197{
198 // Recreate the phase interface term from existing kernels
199 {
200 auto params = getFactory().getValidParams("LinearFVReaction");
201 assignBlocks(params, _blocks);
202 params.set<LinearVariableName>("variable") = _phase_2_fraction_name;
203 params.set<MooseFunctorName>("coeff") = getParam<MooseFunctorName>(NS::alpha_exchange);
205 "LinearFVReaction", prefix() + "phase_interface_reaction", params);
206 }
207 {
208 auto params = getFactory().getValidParams("LinearFVSource");
209 assignBlocks(params, _blocks);
210 params.set<LinearVariableName>("variable") = _phase_2_fraction_name;
211 params.set<MooseFunctorName>("source_density") = _phase_1_fraction_name;
212 params.set<MooseFunctorName>("scaling_factor") = getParam<MooseFunctorName>(NS::alpha_exchange);
213 getProblem().addLinearFVKernel("LinearFVSource", prefix() + "phase_interface_source", params);
214 }
215}
216
217void
219{
220 mooseError("Phase change energy source not implemented at this time for linear finite volume");
221}
222
223void
225{
226 const std::vector<std::string> components = {"x", "y", "z"};
227 for (const auto dim : make_range(dimension()))
228 {
229 const auto object_type = "LinearWCNSFV2PMomentumDriftFlux";
230 auto params = getFactory().getValidParams(object_type);
231 assignBlocks(params, _blocks);
232 params.set<LinearVariableName>("variable") = _flow_equations_physics->getVelocityNames()[dim];
233 setSlipVelocityParams(params);
234 params.set<MooseFunctorName>("rho_d") = _phase_2_density;
235 params.set<MooseFunctorName>("fraction_dispersed") = _phase_2_fraction_name;
236 params.set<MooseEnum>("momentum_component") = components[dim];
237 params.set<MooseEnum>("density_interp_method") = getParam<MooseEnum>("density_interp_method");
238 params.set<UserObjectName>("rhie_chow_user_object") = _flow_equations_physics->rhieChowUOName();
239 getProblem().addLinearFVKernel(object_type, prefix() + "drift_flux_" + components[dim], params);
240 }
241}
242
243void
245{
246 mooseError("Phase advection slip not implemented at this time for linear finite volume");
247}
248
249void
251{
252 // Add the phase fraction variable, for output purposes mostly
253 if (!getProblem().hasFunctor(_phase_1_fraction_name, /*thread_id=*/0))
254 {
255 auto params = getFactory().getValidParams("ParsedFunctorMaterial");
256 assignBlocks(params, _blocks);
257 params.set<std::string>("expression") = "1 - " + _phase_2_fraction_name;
258 params.set<std::vector<std::string>>("functor_names") = {_phase_2_fraction_name};
259 params.set<std::string>("property_name") = _phase_1_fraction_name;
260 params.set<std::vector<std::string>>("output_properties") = {_phase_1_fraction_name};
261 params.set<std::vector<OutputName>>("outputs") = {"all"};
262 getProblem().addMaterial("ParsedFunctorMaterial", prefix() + "phase_1_fraction", params);
263
264 // One of the phase fraction should exist though (either as a variable or set by a
265 // NSLiquidFractionAux)
266 if (!getProblem().hasFunctor(_phase_2_fraction_name, /*thread_id=*/0))
267 paramError("Phase 2 fraction should be defined as a variable or auxiliary variable");
268 }
269 if (!getProblem().hasFunctor(_phase_2_fraction_name, /*thread_id=*/0))
270 {
271 auto params = getFactory().getValidParams("ParsedFunctorMaterial");
272 assignBlocks(params, _blocks);
273 params.set<std::string>("expression") = "1 - " + _phase_1_fraction_name;
274 params.set<std::vector<std::string>>("functor_names") = {_phase_1_fraction_name};
275 params.set<std::string>("property_name") = _phase_2_fraction_name;
276 params.set<std::vector<std::string>>("output_properties") = {_phase_2_fraction_name};
277 params.set<std::vector<OutputName>>("outputs") = {"all"};
278 getProblem().addMaterial("ParsedFunctorMaterial", prefix() + "phase_2_fraction", params);
279 }
280
281 // Compute mixture properties
283 {
284 auto params = getFactory().getValidParams("WCNSLinearFVMixtureFunctorMaterial");
285 assignBlocks(params, _blocks);
286 params.set<std::vector<MooseFunctorName>>("prop_names") = {
287 "rho_mixture", "mu_mixture", "cp_mixture", "k_mixture"};
288 // The phase_1 and phase_2 assignments are only local to this object.
289 // We use the phase 2 variable to save a functor evaluation as we expect
290 // the phase 2 variable to be a nonlinear variable in the phase transport equation
291 params.set<std::vector<MooseFunctorName>>("phase_2_names") = {_phase_1_density,
295 params.set<std::vector<MooseFunctorName>>("phase_1_names") = {_phase_2_density,
299 params.set<MooseFunctorName>("phase_1_fraction") = _phase_2_fraction_name;
300 if (getParam<bool>("output_all_properties"))
301 params.set<std::vector<OutputName>>("outputs") = {"all"};
302 params.set<bool>("limit_phase_fraction") = true;
304 "WCNSLinearFVMixtureFunctorMaterial", prefix() + "mixture_material", params);
305 }
306
307 // Compute slip terms as functors, used by the drift flux kernels
309 {
310 mooseAssert(_flow_equations_physics, "We must have coupled to this");
311 const std::vector<std::string> vel_components = {"u", "v", "w"};
312 const std::vector<std::string> components = {"x", "y", "z"};
313 for (const auto dim : make_range(dimension()))
314 {
315 auto params = getFactory().getValidParams("WCNSFV2PSlipVelocityFunctorMaterial");
316 assignBlocks(params, _blocks);
317 params.set<MooseFunctorName>("slip_velocity_name") = "vel_slip_" + components[dim];
318 params.set<MooseEnum>("momentum_component") = components[dim];
319 for (const auto j : make_range(dimension()))
320 params.set<std::vector<VariableName>>(vel_components[j]) = {
322 params.set<MooseFunctorName>(NS::density) = _phase_1_density;
323 params.set<MooseFunctorName>(NS::mu) = "mu_mixture";
324 params.set<MooseFunctorName>("rho_d") = _phase_2_density;
325 if (getParam<bool>("add_gravity_term_in_slip_velocity"))
326 params.set<RealVectorValue>("gravity") = _flow_equations_physics->gravityVector();
327 if (isParamValid("slip_linear_friction_name"))
328 params.set<MooseFunctorName>("linear_coef_name") =
329 getParam<MooseFunctorName>("slip_linear_friction_name");
330 else if (getParam<bool>("use_dispersed_phase_drag_model"))
331 params.set<MooseFunctorName>("linear_coef_name") = "Darcy_coefficient";
333 {
335 params.set<MooseFunctorName>("linear_coef_name") =
337 else
338 params.set<MooseFunctorName>("linear_coef_name") = "0";
339 }
340 else
341 paramError("slip_linear_friction_name",
342 "WCNSFV2PSlipVelocityFunctorMaterial created by this Physics required a scalar "
343 "field linear friction factor.");
344 params.set<MooseFunctorName>("particle_diameter") =
345 getParam<MooseFunctorName>("particle_diameter");
346 if (getParam<bool>("output_all_properties"))
347 {
348 if (!isTransient())
349 params.set<std::vector<OutputName>>("outputs") = {"all"};
350 else
351 paramInfo("output_all_properties",
352 "Slip velocity functor material output currently unsupported in Physics "
353 "in transient conditions.");
354 }
356 "WCNSFV2PSlipVelocityFunctorMaterial", prefix() + "slip_" + components[dim], params);
357 }
358 }
359
360 // Add a default drag model for a dispersed phase
361 if (getParam<bool>("use_dispersed_phase_drag_model"))
362 {
363 const std::vector<std::string> vel_components = {"u", "v", "w"};
364
365 auto params = getFactory().getValidParams("NSFVDispersePhaseDragFunctorMaterial");
366 assignBlocks(params, _blocks);
367 params.set<MooseFunctorName>("drag_coef_name") = "Darcy_coefficient";
368 for (const auto j : make_range(dimension()))
369 params.set<MooseFunctorName>(vel_components[j]) = {
371 params.set<MooseFunctorName>(NS::density) = "rho_mixture";
372 params.set<MooseFunctorName>(NS::mu) = "mu_mixture";
373 params.set<MooseFunctorName>("particle_diameter") =
374 getParam<MooseFunctorName>("particle_diameter");
375 if (getParam<bool>("output_all_properties"))
376 params.set<std::vector<OutputName>>("outputs") = {"all"};
378 "NSFVDispersePhaseDragFunctorMaterial", prefix() + "dispersed_drag", params);
379 }
380}
const double tol
void mooseInfoRepeated(Args &&... args)
registerMooseAction("NavierStokesApp", WCNSLinearFVTwoPhaseMixturePhysics, "add_interpolation_method_physics")
registerNavierStokesPhysicsBaseTasks("NavierStokesApp", WCNSLinearFVTwoPhaseMixturePhysics)
registerWCNSFVScalarTransportBaseTasks("NavierStokesApp", WCNSLinearFVTwoPhaseMixturePhysics)
unsigned int dim
std::shared_ptr< FEProblemBase > & _problem
virtual void addLinearFVKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
void errorDependentParameter(const std::string &param1, const std::string &value_not_set, const std::vector< std::string > &dependent_params) const
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void paramInfo(const std::string &param, Args... args) const
const std::string & name() const
void paramError(const std::string &param, Args... args) const
bool isParamSetByUser(const std::string &name) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
virtual FEProblemBase & getProblem()
Factory & getFactory()
void assignBlocks(InputParameters &params, const std::vector< SubdomainName > &blocks) const
unsigned int dimension() const
std::string prefix() const
virtual void addFVKernels()
bool isTransient() const
std::vector< SubdomainName > _blocks
const bool _verbose
const WCNSFVFlowPhysicsBase * _flow_equations_physics
Flow physics.
const bool _porous_medium_treatment
Switch to show if porous medium treatment is requested or not.
bool hasFlowEquations() const
Whether the physics is actually creating the flow equations.
virtual MooseFunctorName getLinearFrictionCoefName() const =0
Get the name of the linear friction coefficient. Returns an empty string if no friction.
const std::vector< std::string > & getVelocityNames() const
To interface with other Physics.
RealVectorValue gravityVector() const
Return the gravity vector.
const UserObjectName & rhieChowUOName() const
Return the name of the Rhie Chow user object.
const MooseFunctorName & densityName() const
Return the name of the density functor.
const MooseFunctorName & getSpecificHeatName() const
Get the name of the specific heat material property.
bool hasEnergyEquation() const
Whether the physics is actually creating the heat equation.
std::vector< NonlinearVariableName > _passive_scalar_names
Names of the passive scalar variables.
std::vector< std::vector< MooseFunctorName > > _passive_scalar_inlet_functors
Functors describing the inlet boundary values. See passive_scalar_inlet_types for what the functors a...
static InputParameters commonMixtureParams()
static void renamePassiveScalarToMixtureParams(InputParameters &params)
Creates all the objects needed to solve the Navier Stokes scalar transport equations using the linear...
Creates all the objects needed to solve the mixture model for the weakly-compressible and incompressi...
const MooseFunctorName _phase_2_specific_heat
Name of the specific heat of the other phase.
const MooseFunctorName _phase_2_viscosity
Name of the dynamic viscosity of the other phase.
const MooseFunctorName _phase_2_fraction_name
Name of the second phase fraction (usually, dispersed or advected by the liquid)
const bool _use_advection_slip
Whether to add the advection slip term to each component of the momentum equation.
const MooseFunctorName _phase_1_thermal_conductivity
Name of the thermal conductivity of the first phase.
const MooseFunctorName _phase_1_fraction_name
Name of the first phase fraction (usually, liquid)
const MooseFunctorName _phase_2_density
Name of the density of the other phase.
const MooseFunctorName _phase_1_density
Name of the density of the first phase.
const bool _use_external_mixture_properties
Whether to define the mixture model internally or use fluid properties instead.
const bool _add_phase_equation
Convenience boolean to keep track of whether the phase transport equation is requested.
bool _has_energy_equation
Convenience boolean to keep track of whether the fluid energy equation is present.
void addPhaseInterfaceTerm()
Functions adding kernels for the other physics.
const MooseFunctorName _phase_1_specific_heat
Name of the specific heat of the first phase.
const MooseFunctorName _phase_2_thermal_conductivity
Name of the thermal conductivity of the other phase.
WCNSLinearFVTwoPhaseMixturePhysics(const InputParameters &parameters)
const MooseFunctorName _phase_1_viscosity
Name of the dynamic viscosity of the first phase.
const bool _use_drift_flux
Whether to add the drift flux momentum terms to each component momentum equation.
virtual void setSlipVelocityParams(InputParameters &params) const override
Adds the slip velocity parameters.
const WCNSLinearFVFluidHeatTransferPhysics * _fluid_energy_physics
Fluid heat transfer physics.
static const std::string density
Definition NS.h:34
static const std::string mu
Definition NS.h:127
static const std::string alpha_exchange
Definition NS.h:155