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 : #include "WCNSFVFluidHeatTransferPhysics.h"
11 : #include "WCNSFVFlowPhysics.h"
12 : #include "NSFVBase.h"
13 : #include "NS.h"
14 :
15 : registerNavierStokesPhysicsBaseTasks("NavierStokesApp", WCNSFVFluidHeatTransferPhysics);
16 : registerWCNSFVFluidHeatTransferPhysicsBaseTasks("NavierStokesApp", WCNSFVFluidHeatTransferPhysics);
17 :
18 : InputParameters
19 1325 : WCNSFVFluidHeatTransferPhysics::validParams()
20 : {
21 1325 : InputParameters params = WCNSFVFluidHeatTransferPhysicsBase::validParams();
22 1325 : params.transferParam<MooseEnum>(NSFVBase::validParams(), "energy_face_interpolation");
23 1325 : params.transferParam<Real>(NSFVBase::validParams(), "energy_scaling");
24 2650 : params.addParam<bool>(
25 : "check_bc_compatibility",
26 2650 : true,
27 : "Whether to check for known incompatibility between boundary conditions for "
28 : "the heat transport equation physics and other physics");
29 2650 : params.addParamNamesToGroup("check_bc_compatibility", "Advanced");
30 :
31 2650 : params.addParamNamesToGroup("energy_face_interpolation energy_scaling", "Numerical scheme");
32 1325 : return params;
33 0 : }
34 :
35 1325 : WCNSFVFluidHeatTransferPhysics::WCNSFVFluidHeatTransferPhysics(const InputParameters & parameters)
36 1325 : : WCNSFVFluidHeatTransferPhysicsBase(parameters)
37 : {
38 2646 : checkSecondParamNotSetIfFirstOneSet("solve_for_enthalpy", "fluid_temperature_variable");
39 1323 : }
40 :
41 : void
42 1299 : WCNSFVFluidHeatTransferPhysics::addSolverVariables()
43 : {
44 : // For compatibility with Modules/NavierStokesFV syntax
45 1299 : if (!_has_energy_equation)
46 : return;
47 :
48 : const auto & solver_variable_name =
49 726 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
50 :
51 : // Dont add if the user already defined the variable
52 726 : if (!shouldCreateVariable(solver_variable_name, _blocks, /*error if aux*/ true))
53 27 : reportPotentiallyMissedParameters({"system_names",
54 : "energy_scaling",
55 : "energy_face_interpolation",
56 : "energy_two_term_bc_expansion"},
57 : "INSFVEnergyVariable");
58 699 : else if (_define_variables)
59 : {
60 697 : auto params = getFactory().getValidParams("INSFVEnergyVariable");
61 697 : assignBlocks(params, _blocks);
62 2091 : params.set<std::vector<Real>>("scaling") = {getParam<Real>("energy_scaling")};
63 2091 : params.set<MooseEnum>("face_interp_method") = getParam<MooseEnum>("energy_face_interpolation");
64 697 : params.set<bool>("two_term_boundary_expansion") =
65 1394 : getParam<bool>("energy_two_term_bc_expansion");
66 1394 : params.set<SolverSystemName>("solver_sys") = getSolverSystem(solver_variable_name);
67 697 : getProblem().addVariable("INSFVEnergyVariable", solver_variable_name, params);
68 697 : }
69 : else
70 : // we don't let the user select the enthalpy variable name at this time
71 4 : paramError(_solve_for_enthalpy ? "solve_for_enthalpy" : "fluid_temperature_variable",
72 2 : "Variable (" + solver_variable_name +
73 : ") supplied to the WCNSFVFluidHeatTransferPhysics does not exist!");
74 : }
75 :
76 : void
77 182 : WCNSFVFluidHeatTransferPhysics::addEnergyTimeKernels()
78 : {
79 : std::string kernel_type =
80 182 : ((_compressibility == "weakly-compressible") ? "WCNSFVEnergyTimeDerivative"
81 258 : : "INSFVEnergyTimeDerivative");
82 : std::string kernel_name =
83 182 : prefix() + ((_compressibility == "weakly-compressible") ? "wcns" : "ins") + "_energy_time";
84 182 : if (_porous_medium_treatment)
85 : {
86 : kernel_type = "PINSFVEnergyTimeDerivative";
87 168 : kernel_name = prefix() + ((_compressibility == "weakly-compressible") ? "pwcns" : "pins") +
88 84 : "_energy_time";
89 : }
90 :
91 : const auto & solver_variable_name =
92 182 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
93 :
94 182 : InputParameters params = getFactory().getValidParams(kernel_type);
95 182 : assignBlocks(params, _blocks);
96 364 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
97 182 : params.set<MooseFunctorName>(NS::density) = _density_name;
98 364 : params.set<MooseFunctorName>(NS::time_deriv(NS::specific_enthalpy)) =
99 182 : NS::time_deriv(NS::specific_enthalpy);
100 182 : if (_compressibility == "weakly-compressible")
101 : {
102 424 : params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
103 212 : params.set<MooseFunctorName>(NS::specific_enthalpy) = NS::specific_enthalpy;
104 : }
105 182 : if (_porous_medium_treatment)
106 : {
107 84 : params.set<MooseFunctorName>(NS::porosity) =
108 168 : _flow_equations_physics->getPorosityFunctorName(/*smoothed=*/false);
109 168 : if (getProblem().hasFunctor(NS::time_deriv(_density_name),
110 : /*thread_id=*/0))
111 : {
112 252 : params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
113 168 : params.set<MooseFunctorName>(NS::specific_enthalpy) = NS::specific_enthalpy;
114 : }
115 :
116 84 : params.set<bool>("is_solid") = false;
117 : }
118 :
119 182 : getProblem().addFVKernel(kernel_type, kernel_name, params);
120 364 : }
121 :
122 : void
123 714 : WCNSFVFluidHeatTransferPhysics::addEnergyAdvectionKernels()
124 : {
125 714 : std::string kernel_type = "INSFVEnergyAdvection";
126 0 : std::string kernel_name = prefix() + "ins_energy_advection";
127 714 : if (_porous_medium_treatment)
128 : {
129 : kernel_type = "PINSFVEnergyAdvection";
130 438 : kernel_name = prefix() + "pins_energy_advection";
131 : }
132 :
133 : const auto & solver_variable_name =
134 714 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
135 :
136 714 : InputParameters params = getFactory().getValidParams(kernel_type);
137 1428 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
138 714 : assignBlocks(params, _blocks);
139 714 : params.set<MooseEnum>("velocity_interp_method") = _velocity_interpolation;
140 1428 : params.set<UserObjectName>("rhie_chow_user_object") = _flow_equations_physics->rhieChowUOName();
141 1428 : params.set<MooseEnum>("advected_interp_method") =
142 2142 : getParam<MooseEnum>("energy_advection_interpolation");
143 :
144 714 : getProblem().addFVKernel(kernel_type, kernel_name, params);
145 1428 : }
146 :
147 : void
148 714 : WCNSFVFluidHeatTransferPhysics::addEnergyHeatConductionKernels()
149 : {
150 714 : const auto vector_conductivity = processThermalConductivity();
151 : const auto num_blocks = _thermal_conductivity_blocks.size();
152 : const auto num_used_blocks = num_blocks ? num_blocks : 1;
153 : const auto & solver_variable_name =
154 708 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
155 :
156 1435 : for (const auto block_i : make_range(num_used_blocks))
157 : {
158 727 : std::string block_name = "";
159 727 : if (num_blocks)
160 76 : block_name = Moose::stringify(_thermal_conductivity_blocks[block_i]);
161 : else
162 : block_name = "all";
163 :
164 727 : if (_porous_medium_treatment)
165 : {
166 : const auto kernel_type =
167 236 : vector_conductivity ? "PINSFVEnergyAnisotropicDiffusion" : "PINSFVEnergyDiffusion";
168 :
169 236 : InputParameters params = getFactory().getValidParams(kernel_type);
170 472 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
171 274 : const auto block_names = num_blocks ? _thermal_conductivity_blocks[block_i] : _blocks;
172 236 : assignBlocks(params, block_names);
173 434 : const auto conductivity_name = vector_conductivity ? NS::kappa : NS::k;
174 236 : params.set<MooseFunctorName>(NS::porosity) =
175 236 : _flow_equations_physics->getPorosityFunctorName(true);
176 472 : params.set<bool>("effective_conductivity") = getParam<bool>("effective_conductivity");
177 236 : if (!_solve_for_enthalpy)
178 236 : params.set<MooseFunctorName>(conductivity_name) = _thermal_conductivity_name[block_i];
179 : else
180 0 : params.set<MooseFunctorName>(conductivity_name) =
181 0 : _thermal_conductivity_name[block_i] + "_by_cp";
182 :
183 708 : getProblem().addFVKernel(
184 472 : kernel_type, prefix() + "pins_energy_diffusion_" + block_name, params);
185 236 : }
186 : else
187 : {
188 491 : const std::string kernel_type = "FVDiffusion";
189 491 : InputParameters params = getFactory().getValidParams(kernel_type);
190 982 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
191 : std::vector<SubdomainName> block_names =
192 491 : num_blocks ? _thermal_conductivity_blocks[block_i] : _blocks;
193 491 : assignBlocks(params, block_names);
194 491 : if (!_solve_for_enthalpy)
195 868 : params.set<MooseFunctorName>("coeff") = _thermal_conductivity_name[block_i];
196 : else
197 228 : params.set<MooseFunctorName>("coeff") = _thermal_conductivity_name[block_i] + "_by_cp";
198 :
199 982 : getProblem().addFVKernel(
200 491 : kernel_type, prefix() + "ins_energy_diffusion_" + block_name, params);
201 491 : }
202 : }
203 708 : }
204 :
205 : void
206 225 : WCNSFVFluidHeatTransferPhysics::addEnergyAmbientConvection()
207 : {
208 225 : unsigned int num_convection_blocks = _ambient_convection_blocks.size();
209 : unsigned int num_used_blocks = num_convection_blocks ? num_convection_blocks : 1;
210 : const auto & solver_variable_name =
211 225 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
212 :
213 225 : const std::string kernel_type = "PINSFVEnergyAmbientConvection";
214 225 : InputParameters params = getFactory().getValidParams(kernel_type);
215 450 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
216 225 : params.set<MooseFunctorName>(NS::T_fluid) = _fluid_temperature_name;
217 225 : params.set<bool>("is_solid") = false;
218 :
219 450 : for (unsigned int block_i = 0; block_i < num_used_blocks; ++block_i)
220 : {
221 225 : std::string block_name = "";
222 225 : if (num_convection_blocks)
223 : {
224 19 : params.set<std::vector<SubdomainName>>("block") = _ambient_convection_blocks[block_i];
225 38 : block_name = Moose::stringify(_ambient_convection_blocks[block_i]);
226 : }
227 : else
228 : {
229 206 : assignBlocks(params, _blocks);
230 412 : block_name = std::to_string(block_i);
231 : }
232 :
233 450 : params.set<MooseFunctorName>("h_solid_fluid") = _ambient_convection_alpha[block_i];
234 225 : params.set<MooseFunctorName>(NS::T_solid) = _ambient_temperature[block_i];
235 :
236 675 : getProblem().addFVKernel(kernel_type, prefix() + "ambient_convection_" + block_name, params);
237 : }
238 450 : }
239 :
240 : void
241 162 : WCNSFVFluidHeatTransferPhysics::addEnergyExternalHeatSource()
242 : {
243 : const auto & solver_variable_name =
244 162 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
245 162 : const std::string kernel_type = "FVCoupledForce";
246 162 : InputParameters params = getFactory().getValidParams(kernel_type);
247 324 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
248 162 : assignBlocks(params, _blocks);
249 486 : params.set<MooseFunctorName>("v") = getParam<MooseFunctorName>("external_heat_source");
250 324 : params.set<Real>("coef") = getParam<Real>("external_heat_source_coeff");
251 :
252 324 : getProblem().addFVKernel(kernel_type, prefix() + "external_heat_source", params);
253 324 : }
254 :
255 : void
256 704 : WCNSFVFluidHeatTransferPhysics::addEnergyInletBC()
257 : {
258 704 : const auto & inlet_boundaries = _flow_equations_physics->getInletBoundaries();
259 : // These are parameter errors for now. If Components add boundaries to Physics, the error
260 : // may not be due to parameters anymore.
261 704 : if (inlet_boundaries.size() != _energy_inlet_types.size())
262 4 : paramError("energy_inlet_types",
263 2 : "Energy inlet types (size " + std::to_string(_energy_inlet_types.size()) +
264 2 : ") should be the same size as inlet_boundaries (size " +
265 2 : std::to_string(inlet_boundaries.size()) + ")");
266 702 : if (inlet_boundaries.size() != _energy_inlet_functors.size())
267 0 : paramError("energy_inlet_functors",
268 0 : "Energy inlet functors (size " + std::to_string(_energy_inlet_functors.size()) +
269 0 : ") should be the same size as inlet_boundaries (size " +
270 0 : std::to_string(inlet_boundaries.size()) + ")");
271 :
272 : const auto & solver_variable_name =
273 702 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
274 :
275 : unsigned int flux_bc_counter = 0;
276 1377 : for (const auto bc_ind : index_range(_energy_inlet_types))
277 : {
278 675 : if (_energy_inlet_types[bc_ind] == "fixed-temperature")
279 : {
280 394 : const std::string bc_type = _solve_for_enthalpy
281 : ? "FVSpecificEnthalpyFromPressureTemperatureDirichletBC"
282 769 : : "FVADFunctorDirichletBC";
283 394 : InputParameters params = getFactory().getValidParams(bc_type);
284 788 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
285 394 : if (!_solve_for_enthalpy)
286 750 : params.set<MooseFunctorName>("functor") = _energy_inlet_functors[bc_ind];
287 : else
288 : {
289 : mooseAssert(_flow_equations_physics, "Should be coupled");
290 19 : params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
291 19 : params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
292 19 : params.set<MooseFunctorName>(NS::T_fluid) = _energy_inlet_functors[bc_ind];
293 : }
294 1182 : params.set<std::vector<BoundaryName>>("boundary") = {inlet_boundaries[bc_ind]};
295 :
296 394 : getProblem().addFVBC(bc_type, solver_variable_name + "_" + inlet_boundaries[bc_ind], params);
297 :
298 : // Check the BCs for momentum
299 : const auto momentum_inlet_type =
300 394 : _flow_equations_physics->inletBoundaryType(inlet_boundaries[bc_ind]);
301 1182 : if (getParam<bool>("check_bc_compatibility") &&
302 394 : (momentum_inlet_type == NS::MomentumInletTypes::FLUX_VELOCITY ||
303 : momentum_inlet_type == NS::MomentumInletTypes::FLUX_MASS))
304 0 : paramError("energy_inlet_types",
305 0 : "At inlet '" + inlet_boundaries[bc_ind] +
306 : "', you are using a Dirichlet boundary condition on temperature, and a "
307 : "flux boundary condition on momentum. This is known to create an "
308 : "undesirable inlet source term.");
309 394 : }
310 281 : else if (_energy_inlet_types[bc_ind] == "heatflux")
311 : {
312 180 : const std::string bc_type = "FVFunctionNeumannBC";
313 180 : InputParameters params = getFactory().getValidParams(bc_type);
314 360 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
315 360 : params.set<FunctionName>("function") = _energy_inlet_functors[bc_ind];
316 540 : params.set<std::vector<BoundaryName>>("boundary") = {inlet_boundaries[bc_ind]};
317 :
318 180 : getProblem().addFVBC(bc_type, solver_variable_name + "_" + inlet_boundaries[bc_ind], params);
319 180 : }
320 101 : else if (_energy_inlet_types[bc_ind] == "flux-mass" ||
321 65 : _energy_inlet_types[bc_ind] == "flux-velocity")
322 : {
323 101 : const std::string bc_type = "WCNSFVEnergyFluxBC";
324 101 : InputParameters params = getFactory().getValidParams(bc_type);
325 202 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
326 101 : const auto & flux_inlet_directions = _flow_equations_physics->getFluxInletDirections();
327 : const auto & flux_inlet_pps = _flow_equations_physics->getFluxInletPPs();
328 :
329 101 : if (flux_inlet_pps.size() < flux_bc_counter)
330 0 : _flow_equations_physics->paramError(
331 : "flux_inlet_pps",
332 : "Should be specified for all 'flux-mass/velocity' boundary conditions");
333 :
334 101 : if (flux_inlet_directions.size())
335 : {
336 18 : if (flux_inlet_directions.size() < flux_bc_counter)
337 0 : _flow_equations_physics->paramError("flux_inlet_pps",
338 : "Should be specified for all or none of the "
339 : "'flux-mass/velocity' boundary conditions");
340 18 : params.set<Point>("direction") = flux_inlet_directions[flux_bc_counter];
341 : }
342 101 : if (_energy_inlet_types[bc_ind] == "flux-mass")
343 : {
344 36 : params.set<PostprocessorName>("mdot_pp") = flux_inlet_pps[flux_bc_counter];
345 144 : params.set<PostprocessorName>("area_pp") = "area_pp_" + inlet_boundaries[bc_ind];
346 : }
347 : else
348 130 : params.set<PostprocessorName>("velocity_pp") = flux_inlet_pps[flux_bc_counter];
349 :
350 202 : params.set<PostprocessorName>("temperature_pp") = _energy_inlet_functors[bc_ind];
351 101 : params.set<MooseFunctorName>(NS::density) = _density_name;
352 101 : params.set<MooseFunctorName>(NS::cp) = _specific_heat_name;
353 202 : params.set<MooseFunctorName>(NS::T_fluid) = _fluid_temperature_name;
354 :
355 101 : if (isParamValid(NS::fluid))
356 : {
357 38 : params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
358 76 : params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
359 : }
360 :
361 101 : if (_solve_for_enthalpy)
362 76 : params.set<MooseFunctorName>(NS::specific_enthalpy) = _fluid_enthalpy_name;
363 :
364 284 : for (const auto d : make_range(dimension()))
365 366 : params.set<MooseFunctorName>(NS::velocity_vector[d]) = _velocity_names[d];
366 :
367 303 : params.set<std::vector<BoundaryName>>("boundary") = {inlet_boundaries[bc_ind]};
368 :
369 101 : getProblem().addFVBC(bc_type, solver_variable_name + "_" + inlet_boundaries[bc_ind], params);
370 101 : flux_bc_counter += 1;
371 101 : }
372 : }
373 702 : }
374 :
375 : void
376 702 : WCNSFVFluidHeatTransferPhysics::addEnergyWallBC()
377 : {
378 1404 : const auto & wall_boundaries = isParamSetByUser("energy_wall_boundaries")
379 1442 : ? getParam<std::vector<BoundaryName>>("energy_wall_boundaries")
380 664 : : _flow_equations_physics->getWallBoundaries();
381 702 : if (wall_boundaries.size() != _energy_wall_types.size())
382 4 : paramError("energy_wall_types",
383 2 : "Energy wall types (size " + std::to_string(_energy_wall_types.size()) +
384 2 : ") should be the same size as wall_boundaries (size " +
385 2 : std::to_string(wall_boundaries.size()) + ")");
386 700 : if (wall_boundaries.size() != _energy_wall_functors.size())
387 0 : paramError("energy_wall_functors",
388 0 : "Energy wall functors (size " + std::to_string(_energy_wall_functors.size()) +
389 0 : ") should be the same size as wall_boundaries (size " +
390 0 : std::to_string(wall_boundaries.size()) + ")");
391 :
392 : const auto & solver_variable_name =
393 700 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
394 :
395 2182 : for (unsigned int bc_ind = 0; bc_ind < _energy_wall_types.size(); ++bc_ind)
396 : {
397 1482 : if (_energy_wall_types[bc_ind] == "fixed-temperature")
398 : {
399 170 : const std::string bc_type = _solve_for_enthalpy
400 : ? "FVSpecificEnthalpyFromPressureTemperatureDirichletBC"
401 264 : : "FVADFunctorDirichletBC";
402 170 : InputParameters params = getFactory().getValidParams(bc_type);
403 340 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
404 170 : if (!_solve_for_enthalpy)
405 188 : params.set<MooseFunctorName>("functor") = _energy_wall_functors[bc_ind];
406 : else
407 : {
408 76 : params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
409 76 : params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
410 76 : params.set<MooseFunctorName>(NS::T_fluid) = _energy_wall_functors[bc_ind];
411 : }
412 510 : params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
413 :
414 170 : getProblem().addFVBC(bc_type, solver_variable_name + "_" + wall_boundaries[bc_ind], params);
415 170 : }
416 1312 : else if (_energy_wall_types[bc_ind] == "heatflux")
417 : {
418 1258 : const std::string bc_type = "FVFunctorNeumannBC";
419 1258 : InputParameters params = getFactory().getValidParams(bc_type);
420 2516 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
421 2516 : params.set<MooseFunctorName>("functor") = _energy_wall_functors[bc_ind];
422 3774 : params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
423 :
424 1258 : getProblem().addFVBC(bc_type, solver_variable_name + "_" + wall_boundaries[bc_ind], params);
425 1258 : }
426 54 : else if (_energy_wall_types[bc_ind] == "convection")
427 : {
428 0 : const std::string bc_type = "FVFunctorConvectiveHeatFluxBC";
429 0 : InputParameters params = getFactory().getValidParams(bc_type);
430 0 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
431 0 : params.set<MooseFunctorName>("T_bulk") = _fluid_temperature_name;
432 0 : params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
433 0 : params.set<bool>("is_solid") = false;
434 : const auto Tinf_htc_functors =
435 0 : MooseUtils::split(_energy_wall_functors[bc_ind], /*delimiter=*/":", /*max_count=*/1);
436 0 : if (Tinf_htc_functors.size() != 2)
437 0 : paramError("energy_wall_functors",
438 : "'convective' wall types require two functors specified as "
439 : "<Tinf_functor>:<htc_functor>.");
440 0 : params.set<MooseFunctorName>("T_solid") = Tinf_htc_functors[0];
441 0 : params.set<MooseFunctorName>("heat_transfer_coefficient") = Tinf_htc_functors[1];
442 :
443 0 : getProblem().addFVBC(bc_type, solver_variable_name + "_" + wall_boundaries[bc_ind], params);
444 0 : }
445 : // We add this boundary condition here to facilitate the input of wall boundaries / functors for
446 : // energy. If there are too many turbulence options and this gets out of hand we will have to
447 : // move this to the turbulence Physics
448 54 : else if (_energy_wall_types[bc_ind] == "wallfunction")
449 : {
450 54 : if (!_turbulence_physics)
451 0 : paramError("coupled_turbulence_physics",
452 : "A coupled turbulence Physics was not found for defining the wall function "
453 0 : "boundary condition on boundary: " +
454 0 : wall_boundaries[bc_ind]);
455 54 : const std::string bc_type = "INSFVTurbulentTemperatureWallFunction";
456 54 : InputParameters params = getFactory().getValidParams(bc_type);
457 108 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
458 162 : params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
459 54 : params.set<MooseEnum>("wall_treatment") =
460 162 : _turbulence_physics->turbulenceTemperatureWallTreatment();
461 54 : params.set<MooseFunctorName>("T_w") = _energy_wall_functors[bc_ind];
462 54 : params.set<MooseFunctorName>(NS::density) = _density_name;
463 54 : params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
464 162 : params.set<MooseFunctorName>(NS::TKE) = _turbulence_physics->tkeName();
465 54 : if (_thermal_conductivity_name.size() != 1)
466 0 : mooseError("Several anisotropic thermal conductivity (kappa) regions have been specified. "
467 : "Selecting the right kappa coefficient for the turbulence boundaries is not "
468 0 : "currently implemented.\nBoundaries:\n" +
469 0 : Moose::stringify(_turbulence_physics->turbulenceWalls()) +
470 0 : "\nKappa(s) specified:\n" + Moose::stringify(_thermal_conductivity_name));
471 54 : params.set<MooseFunctorName>(NS::kappa) = _thermal_conductivity_name[0];
472 54 : params.set<MooseFunctorName>(NS::cp) = _specific_heat_name;
473 216 : const std::string u_names[3] = {"u", "v", "w"};
474 162 : for (const auto d : make_range(dimension()))
475 216 : params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
476 : // Currently only Newton method for WCNSFVFluidHeatTransferPhysics
477 54 : params.set<bool>("newton_solve") = true;
478 162 : getProblem().addFVBC(bc_type, prefix() + "wallfunction_" + wall_boundaries[bc_ind], params);
479 270 : }
480 : else
481 0 : paramError(
482 0 : "energy_wall_types", _energy_wall_types[bc_ind], " wall type is currently unsupported.");
483 : }
484 700 : }
485 :
486 : void
487 1283 : WCNSFVFluidHeatTransferPhysics::addMaterials()
488 : {
489 1283 : if (!_has_energy_equation)
490 569 : return;
491 :
492 : // Note that this material choice does not make sense for Newton-INSFV + solve_for_enthalpy since
493 : // this material explicitly computes enthalpy from temperature
494 : const auto object_type = "INSFVEnthalpyFunctorMaterial";
495 :
496 714 : InputParameters params = getFactory().getValidParams(object_type);
497 714 : assignBlocks(params, _blocks);
498 :
499 714 : params.set<MooseFunctorName>(NS::density) = _density_name;
500 714 : params.set<MooseFunctorName>(NS::cp) = _specific_heat_name;
501 :
502 714 : if (_solve_for_enthalpy)
503 : {
504 57 : params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
505 114 : params.set<MooseFunctorName>(NS::specific_enthalpy + "_in") = _fluid_enthalpy_name;
506 57 : params.set<bool>("assumed_constant_cp") = false;
507 57 : if (isParamValid(NS::fluid))
508 57 : params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
509 : else
510 0 : paramError(NS::fluid, "Required when solving for enthalpy");
511 : }
512 : // the functor material defines the temperature
513 : else
514 : {
515 1314 : params.set<MooseFunctorName>("temperature") = _fluid_temperature_name;
516 1314 : params.set<MooseFunctorName>(NS::specific_enthalpy) = _fluid_enthalpy_name;
517 657 : if (isParamValid(NS::fluid))
518 : {
519 19 : params.set<bool>("assumed_constant_cp") = false;
520 19 : params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
521 38 : params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
522 : }
523 : }
524 714 : if (_solve_for_enthalpy)
525 : {
526 171 : params.set<std::vector<std::string>>("output_properties") = {_fluid_temperature_name};
527 171 : params.set<std::vector<OutputName>>("outputs") = {"all"};
528 : }
529 :
530 2142 : getProblem().addMaterial(object_type, prefix() + "enthalpy_material", params);
531 :
532 714 : if (_solve_for_enthalpy)
533 57 : WCNSFVFluidHeatTransferPhysicsBase::defineKOverCpFunctors(/*use ad*/ true);
534 771 : }
535 :
536 : void
537 700 : WCNSFVFluidHeatTransferPhysics::addEnergySeparatorBC()
538 : {
539 700 : if (_flow_equations_physics->getHydraulicSeparators().size())
540 : {
541 : const auto & solver_variable_name =
542 19 : _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
543 :
544 19 : const std::string bc_type = "INSFVScalarFieldSeparatorBC";
545 19 : InputParameters params = getFactory().getValidParams(bc_type);
546 38 : params.set<NonlinearVariableName>("variable") = solver_variable_name;
547 38 : params.set<std::vector<BoundaryName>>("boundary") =
548 38 : _flow_equations_physics->getHydraulicSeparators();
549 38 : getProblem().addFVBC(bc_type, prefix() + solver_variable_name + "_separators", params);
550 19 : }
551 700 : }
|