forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSFVAction.C
2759 lines (2383 loc) · 112 KB
/
NSFVAction.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//* 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
// Navier-Stokes includes
#include "NSFVAction.h"
#include "NS.h"
// MOOSE includes
#include "FEProblem.h"
#include "MooseObject.h"
#include "NonlinearSystemBase.h"
#include "RelationshipManager.h"
#include "AuxiliarySystem.h"
registerMooseAction("NavierStokesApp", NSFVAction, "add_navier_stokes_variables");
registerMooseAction("NavierStokesApp", NSFVAction, "add_navier_stokes_user_objects");
registerMooseAction("NavierStokesApp", NSFVAction, "add_navier_stokes_ics");
registerMooseAction("NavierStokesApp", NSFVAction, "add_navier_stokes_kernels");
registerMooseAction("NavierStokesApp", NSFVAction, "add_navier_stokes_bcs");
registerMooseAction("NavierStokesApp", NSFVAction, "add_material");
registerMooseAction("NavierStokesApp", NSFVAction, "add_navier_stokes_pps");
registerMooseAction("NavierStokesApp", NSFVAction, "add_navier_stokes_materials");
registerMooseAction("NavierStokesApp", NSFVAction, "navier_stokes_check_copy_nodal_vars");
registerMooseAction("NavierStokesApp", NSFVAction, "navier_stokes_copy_nodal_vars");
InputParameters
NSFVAction::validParams()
{
InputParameters params = Action::validParams();
params.addClassDescription("This class allows us to set up Navier-Stokes equations for porous "
"medium or clean fluid flows using incompressible or weakly "
"compressible approximations with a finite volume discretization.");
/**
* General parameters used to set up the simulation.
*/
params.addParam<std::vector<SubdomainName>>(
"block", "The list of blocks on which NS equations are defined on");
MooseEnum comp_type("incompressible weakly-compressible", "incompressible");
params.addParam<MooseEnum>(
"compressibility", comp_type, "Compressibility constraint for the Navier-Stokes equations.");
params.addParam<bool>(
"porous_medium_treatment", false, "Whether to use porous medium kernels or not.");
params.addParam<bool>("initialize_variables_from_mesh_file",
false,
"Determines if the variables that are added by the action are initialized "
"from the mesh file (only for Exodus format)");
params.addParam<std::string>(
"initial_from_file_timestep",
"LATEST",
"Gives the timestep (or \"LATEST\") for which to read a solution from a file "
"for a given variable. (Default: LATEST)");
MooseEnum turbulence_type("mixing-length none", "none");
params.addParam<MooseEnum>(
"turbulence_handling",
turbulence_type,
"The way additional diffusivities are determined in the turbulent regime.");
params.addParam<bool>("add_flow_equations", true, "True to add mass and momentum equations");
params.addParam<bool>("add_energy_equation", false, "True to add energy equation");
params.addParam<bool>("add_scalar_equation", false, "True to add advected scalar(s) equation");
params.addParamNamesToGroup("compressibility porous_medium_treatment turbulence_handling "
"add_flow_equations add_energy_equation add_scalar_equation ",
"General control");
params.addParam<std::vector<std::string>>(
"velocity_variable",
"If supplied, the system checks for available velocity variables. "
"Otherwise, they are created within the action.");
params.addParam<NonlinearVariableName>("pressure_variable",
"If supplied, the system checks for available pressure "
"variable. Otherwise, it is created within the action.");
params.addParam<NonlinearVariableName>(
"fluid_temperature_variable",
"If supplied, the system checks for available fluid "
"temperature variable. Otherwise, it is created within the action.");
params.addParamNamesToGroup("velocity_variable pressure_variable fluid_temperature_variable",
"External variable");
/**
* Parameters influencing the porous medium treatment.
*/
params.addParam<MooseFunctorName>(
"porosity", NS::porosity, "The name of the auxiliary variable for the porosity field.");
params.addParam<unsigned short>(
"porosity_smoothing_layers",
"The number of interpolation-reconstruction operations to perform on the porosity.");
params.addParam<bool>("use_friction_correction",
"If friction correction should be applied in the momentum equation.");
params.addParam<Real>(
"consistent_scaling",
"Scaling parameter for the friction correction in the momentum equation (if requested).");
params.addParamNamesToGroup(
"porosity porosity_smoothing_layers use_friction_correction consistent_scaling",
"Porous medium treatment");
/**
* Parameters used to define the boundaries of the domain.
*/
params.addParam<std::vector<BoundaryName>>(
"inlet_boundaries", std::vector<BoundaryName>(), "Names of inlet boundaries");
params.addParam<std::vector<BoundaryName>>(
"outlet_boundaries", std::vector<BoundaryName>(), "Names of outlet boundaries");
params.addParam<std::vector<BoundaryName>>(
"wall_boundaries", std::vector<BoundaryName>(), "Names of wall boundaries");
/**
* Parameters used to define the handling of the momentum-mass equations.
*/
std::vector<FunctionName> default_initial_velocity = {"1e-15", "1e-15", "1e-15"};
params.addParam<std::vector<FunctionName>>("initial_velocity",
default_initial_velocity,
"The initial velocity, assumed constant everywhere");
params.addParam<FunctionName>(
"initial_pressure", "1e5", "The initial pressure, assumed constant everywhere");
params.addParam<MooseFunctorName>(
"dynamic_viscosity", NS::mu, "The name of the dynamic viscosity");
params.addParam<MooseFunctorName>("density", NS::density, "The name of the density");
params.addParam<RealVectorValue>(
"gravity", RealVectorValue(0, 0, 0), "The gravitational acceleration vector.");
MultiMooseEnum mom_inlet_types("fixed-velocity flux-velocity flux-mass fixed-pressure");
params.addParam<MultiMooseEnum>("momentum_inlet_types",
mom_inlet_types,
"Types of inlet boundaries for the momentum equation.");
params.addParam<std::vector<std::vector<FunctionName>>>(
"momentum_inlet_function",
std::vector<std::vector<FunctionName>>(),
"Functions for inlet boundary velocities or pressures (for fixed-pressure option). Provide a "
"double vector where the leading dimension corresponds to the number of fixed-velocity and "
"fixed-pressure entries in momentum_inlet_types and the second index runs either over "
"dimensions for fixed-velocity boundaries or is a single function name for pressure inlets.");
params.addParam<std::vector<PostprocessorName>>(
"flux_inlet_pps",
std::vector<PostprocessorName>(),
"The name of the postprocessors which compute the mass flow/normal velocity magnitude. "
"Mainly used for coupling between different applications.");
MultiMooseEnum mom_outlet_types("fixed-pressure zero-gradient fixed-pressure-zero-gradient");
params.addParam<MultiMooseEnum>("momentum_outlet_types",
mom_outlet_types,
"Types of outlet boundaries for the momentum equation");
params.addParam<std::vector<FunctionName>>("pressure_function",
std::vector<FunctionName>(),
"Functions for boundary pressures at outlets.");
MultiMooseEnum mom_wall_types("symmetry noslip slip wallfunction", "noslip");
params.addParam<MultiMooseEnum>(
"momentum_wall_types", mom_wall_types, "Types of wall boundaries for the momentum equation");
params.addParam<bool>(
"pin_pressure", false, "Switch to enable pressure shifting for incompressible simulations.");
MooseEnum s_type("average point-value", "average");
params.addParam<MooseEnum>(
"pinned_pressure_type",
s_type,
"Types for shifting (pinning) the pressure in case of incompressible simulations.");
params.addParam<Point>(
"pinned_pressure_point",
Point(),
"The XYZ coordinates where pressure needs to be pinned for incompressible simulations.");
params.addParam<Real>("pinned_pressure_value",
1e5,
"The value used for pinning the pressure (point value/domain average).");
params.addParam<bool>("boussinesq_approximation", false, "True to have Boussinesq approximation");
params.addRangeCheckedParam<Real>(
"ref_temperature",
273.15,
"ref_temperature > 0.0",
"Value for reference temperature in case of Boussinesq approximation");
params.addParam<MooseFunctorName>(
"thermal_expansion",
NS::alpha,
"The name of the thermal expansion coefficient in the Boussinesq approximation");
params.addParamNamesToGroup(
"pin_pressure pinned_pressure_type pinned_pressure_point pinned_pressure_value "
"ref_temperature boussinesq_approximation gravity",
"Momentum equation");
/**
* Equations used to set up the energy equation/enthalpy equation if it is required.
*/
params.addParam<FunctionName>(
"initial_temperature", "300", "The initial temperature, assumed constant everywhere");
params.addParam<std::vector<std::vector<SubdomainName>>>(
"thermal_conductivity_blocks",
"The blocks where the user wants define different thermal conductivities.");
params.addParam<std::vector<MooseFunctorName>>(
"thermal_conductivity",
std::vector<MooseFunctorName>({NS::k}),
"The name of the fluid thermal conductivity for each block");
params.addParam<MooseFunctorName>("specific_heat", NS::cp, "The name of the specific heat");
MultiMooseEnum en_inlet_types("fixed-temperature flux-mass flux-velocity heatflux");
params.addParam<MultiMooseEnum>("energy_inlet_types",
en_inlet_types,
"Types for the inlet boundaries for the energy equation.");
params.addParam<std::vector<std::string>>(
"energy_inlet_function",
std::vector<std::string>(),
"Functions for fixed-value boundaries in the energy equation.");
MultiMooseEnum en_wall_types("fixed-temperature heatflux", "heatflux");
params.addParam<MultiMooseEnum>(
"energy_wall_types", en_wall_types, "Types for the wall boundaries for the energy equation.");
params.addParam<std::vector<FunctionName>>(
"energy_wall_function",
std::vector<FunctionName>(),
"Functions for Dirichlet/Neumann boundaries in the energy equation.");
params.addParam<std::vector<std::vector<SubdomainName>>>(
"ambient_convection_blocks",
std::vector<std::vector<SubdomainName>>(),
"The blocks where the ambient convection is present.");
params.addParam<std::vector<MooseFunctorName>>(
"ambient_convection_alpha",
std::vector<MooseFunctorName>(),
"The heat exchange coefficients for each block in 'ambient_convection_blocks'.");
params.addParam<std::vector<MooseFunctorName>>(
"ambient_temperature",
std::vector<MooseFunctorName>(),
"The ambient temperature for each block in 'ambient_convection_blocks'.");
params.addParam<CoupledName>(
"external_heat_source",
"The name of a functor which contains the external heat source for the energy equation.");
params.addParam<Real>(
"external_heat_source_coeff", 1.0, "Multiplier for the coupled heat source term.");
params.addParam<bool>("use_external_enthalpy_material",
false,
"To indicate if the enthalpy material is set up outside of the action.");
params.addParamNamesToGroup("ambient_convection_alpha ambient_convection_blocks "
"ambient_temperature external_heat_source external_heat_source_coeff",
"Energy equation");
/**
* Parameters controlling the friction terms in case of porous medium simulations.
*/
params.addParam<std::vector<std::vector<SubdomainName>>>(
"friction_blocks",
"The blocks where the friction factors are applied to emulate flow resistances.");
params.addParam<std::vector<std::vector<std::string>>>(
"friction_types", "The types of friction forces for every block in 'friction_blocks'.");
params.addParam<std::vector<std::vector<std::string>>>(
"friction_coeffs",
"The friction coefficients for every item in 'friction_types'. Note that if "
"'porous_medium_treatment' is enabled, the coefficients already contain a velocity "
"multiplier but they are not multiplied with density yet!");
params.addParamNamesToGroup("friction_blocks friction_types friction_coeffs", "Friction control");
/**
* Parameters describing the handling of advected scalar fields
*/
params.addParam<std::vector<NonlinearVariableName>>(
"passive_scalar_names",
std::vector<NonlinearVariableName>(),
"Vector containing the names of the advected scalar variables.");
params.addParam<std::vector<FunctionName>>("initial_scalar_variables",
"Initial values of the passive scalar variables.");
params.addParam<std::vector<MooseFunctorName>>(
"passive_scalar_diffusivity",
std::vector<MooseFunctorName>(),
"Functor names for the diffusivities used for the passive scalar fields.");
params.addParam<std::vector<Real>>("passive_scalar_schmidt_number",
std::vector<Real>(),
"Schmidt numbers used for the passive scalar fields.");
params.addParam<std::vector<MooseFunctorName>>(
"passive_scalar_source",
std::vector<MooseFunctorName>(),
"Functor names for the sources used for the passive scalar fields.");
params.addParam<std::vector<CoupledName>>(
"passive_scalar_coupled_source",
std::vector<CoupledName>(),
"Coupled variable names for the sources used for the passive scalar fields. If multiple "
"sources for each equation are specified, major (outer) ordering by equation.");
params.addParam<std::vector<std::vector<Real>>>(
"passive_scalar_coupled_source_coeff",
std::vector<std::vector<Real>>(),
"Coupled variable multipliers for the sources used for the passive scalar fields. If multiple"
" sources for each equation are specified, major (outer) ordering by equation.");
MultiMooseEnum ps_inlet_types("fixed-value flux-mass flux-velocity", "fixed-value");
params.addParam<MultiMooseEnum>(
"passive_scalar_inlet_types",
ps_inlet_types,
"Types for the inlet boundaries for the passive scalar equation.");
params.addParam<std::vector<std::vector<std::string>>>(
"passive_scalar_inlet_function",
std::vector<std::vector<std::string>>(),
"Functions for inlet boundaries in the passive scalar equations.");
params.addParamNamesToGroup("passive_scalar_names passive_scalar_diffusivity "
"passive_scalar_schmidt_number passive_scalar_source "
"passive_scalar_coupled_source passive_scalar_coupled_source_coeff",
"Passive scalar control");
/**
* Parameters allowing the control over numerical schemes for different terms in the
* Navier-Stokes + energy equations.
*/
MooseEnum adv_interpol_types("average upwind skewness-corrected min_mod vanLeer", "average");
params.addParam<MooseEnum>("mass_advection_interpolation",
adv_interpol_types,
"The numerical scheme to use for interpolating density, "
"as an advected quantity, to the face.");
params.addParam<MooseEnum>("momentum_advection_interpolation",
adv_interpol_types,
"The numerical scheme to use for interpolating momentum/velocity, "
"as an advected quantity, to the face.");
params.addParam<MooseEnum>("energy_advection_interpolation",
adv_interpol_types,
"The numerical scheme to use for interpolating energy/temperature, "
"as an advected quantity, to the face.");
params.addParam<MooseEnum>("passive_scalar_advection_interpolation",
adv_interpol_types,
"The numerical scheme to use for interpolating passive scalar field, "
"as an advected quantity, to the face.");
MooseEnum face_interpol_types("average skewness-corrected", "average");
params.addParam<MooseEnum>("pressure_face_interpolation",
face_interpol_types,
"The numerical scheme to interpolate the pressure to the "
"face (separate from the advected quantity interpolation).");
params.addParam<MooseEnum>("momentum_face_interpolation",
face_interpol_types,
"The numerical scheme to interpolate the velocity/momentum to the "
"face (separate from the advected quantity interpolation).");
params.addParam<MooseEnum>("energy_face_interpolation",
face_interpol_types,
"The numerical scheme to interpolate the temperature/energy to the "
"face (separate from the advected quantity interpolation).");
params.addParam<MooseEnum>(
"passive_scalar_face_interpolation",
face_interpol_types,
"The numerical scheme to interpolate the passive scalar field variables to the "
"face (separate from the advected quantity interpolation).");
MooseEnum velocity_interpolation("average rc", "rc");
params.addParam<MooseEnum>(
"velocity_interpolation",
velocity_interpolation,
"The interpolation to use for the velocity. Options are "
"'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow.");
params.addParam<bool>(
"pressure_two_term_bc_expansion",
true,
"If a two-term Taylor expansion is needed for the determination of the boundary values"
"of the pressure.");
params.addParam<bool>(
"momentum_two_term_bc_expansion",
true,
"If a two-term Taylor expansion is needed for the determination of the boundary values"
"of the velocity/momentum.");
params.addParam<bool>(
"energy_two_term_bc_expansion",
true,
"If a two-term Taylor expansion is needed for the determination of the boundary values"
"of the temperature/energy.");
params.addParam<bool>(
"passive_scalar_two_term_bc_expansion",
true,
"If a two-term Taylor expansion is needed for the determination of the boundary values"
"of the advected passive scalar field.");
params.addParam<bool>(
"mixing_length_two_term_bc_expansion",
true,
"If a two-term Taylor expansion is needed for the determination of the boundary values"
"of the mixing length field.");
params.addRangeCheckedParam<Real>(
"mass_scaling",
1.0,
"mass_scaling > 0.0",
"The scaling factor for the mass variables (for incompressible simulation "
"this is pressure scaling).");
params.addRangeCheckedParam<Real>("momentum_scaling",
1.0,
"momentum_scaling > 0.0",
"The scaling factor for the momentum variables.");
params.addRangeCheckedParam<Real>(
"energy_scaling", 1.0, "energy_scaling > 0.0", "The scaling factor for the energy variable.");
params.addRangeCheckedParam<Real>("passive_scalar_scaling",
1.0,
"passive_scalar_scaling > 0.0",
"The scaling factor for the passive scalar field variables.");
params.addParamNamesToGroup(
"momentum_advection_interpolation energy_advection_interpolation "
"passive_scalar_advection_interpolation mass_advection_interpolation "
"momentum_face_interpolation energy_face_interpolation passive_scalar_face_interpolation "
"pressure_face_interpolation momentum_two_term_bc_expansion "
"energy_two_term_bc_expansion passive_scalar_two_term_bc_expansion "
"mixing_length_two_term_bc_expansion pressure_two_term_bc_expansion",
"Numerical scheme");
params.addParamNamesToGroup("momentum_scaling energy_scaling mass_scaling passive_scalar_scaling",
"Scaling");
/**
* Parameter controlling the turbulence handling used for the equations.
*/
params.addParam<std::vector<BoundaryName>>(
"mixing_length_walls",
std::vector<BoundaryName>(),
"Walls where the mixing length model should be utilized.");
ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
params.addParam<ExecFlagEnum>("mixing_length_aux_execute_on",
exec_enum,
"When the mixing length aux kernels should be executed.");
params.addRangeCheckedParam<Real>("von_karman_const",
0.41,
"von_karman_const > 0.0",
"Von Karman parameter for the mixing length model");
params.addRangeCheckedParam<Real>(
"von_karman_const_0", 0.09, "von_karman_const_0 > 0.0", "'Escudier' model parameter");
params.addRangeCheckedParam<Real>(
"mixing_length_delta",
1.0,
"mixing_length_delta > 0.0",
"Tunable parameter related to the thickness of the boundary layer."
"When it is not specified, Prandtl's original unbounded wall distance mixing length model is"
"retrieved.");
params.addRangeCheckedParam<Real>("turbulent_prandtl",
1,
"turbulent_prandtl > 0",
"Turbulent Prandtl number for energy turbulent diffusion");
params.addParamNamesToGroup("mixing_length_walls mixing_length_aux_execute_on von_karman_const "
"von_karman_const_0 mixing_length_delta turbulent_prandtl",
"Turbulence");
// Create input parameter groups
params.addParamNamesToGroup("dynamic_viscosity density thermal_expansion "
"thermal_conductivity_blocks thermal_conductivity specific_heat",
"Material property");
params.addParamNamesToGroup(
"inlet_boundaries momentum_inlet_types momentum_inlet_function energy_inlet_types "
"energy_inlet_function wall_boundaries momentum_wall_types energy_wall_types "
"energy_wall_function outlet_boundaries momentum_outlet_types pressure_function "
"passive_scalar_inlet_types passive_scalar_inlet_function flux_inlet_pps",
"Boundary condition");
params.addParamNamesToGroup(
"initial_pressure initial_velocity initial_temperature initial_scalar_variables "
"initialize_variables_from_mesh_file initial_from_file_timestep",
"Initial condition");
return params;
}
NSFVAction::NSFVAction(const InputParameters & parameters)
: Action(parameters),
_blocks(getParam<std::vector<SubdomainName>>("block")),
_compressibility(getParam<MooseEnum>("compressibility")),
_has_flow_equations(getParam<bool>("add_flow_equations")),
_has_energy_equation(getParam<bool>("add_energy_equation")),
_has_scalar_equation(getParam<bool>("add_scalar_equation")),
_boussinesq_approximation(getParam<bool>("boussinesq_approximation")),
_turbulence_handling(getParam<MooseEnum>("turbulence_handling")),
_porous_medium_treatment(getParam<bool>("porous_medium_treatment")),
_porosity_name(getParam<MooseFunctorName>("porosity")),
_use_friction_correction(isParamValid("use_friction_correction")
? getParam<bool>("use_friction_correction")
: false),
_velocity_name(
isParamValid("velocity_variable")
? getParam<std::vector<std::string>>("velocity_variable")
: (_porous_medium_treatment
? std::vector<std::string>(NS::superficial_velocity_vector,
NS::superficial_velocity_vector + 3)
: std::vector<std::string>(NS::velocity_vector, NS::velocity_vector + 3))),
_pressure_name(isParamValid("pressure_variable")
? getParam<NonlinearVariableName>("pressure_variable")
: NS::pressure),
_fluid_temperature_name(isParamValid("fluid_temperature_variable")
? getParam<NonlinearVariableName>("fluid_temperature_variable")
: NS::T_fluid),
_inlet_boundaries(getParam<std::vector<BoundaryName>>("inlet_boundaries")),
_outlet_boundaries(getParam<std::vector<BoundaryName>>("outlet_boundaries")),
_wall_boundaries(getParam<std::vector<BoundaryName>>("wall_boundaries")),
_momentum_inlet_types(getParam<MultiMooseEnum>("momentum_inlet_types")),
_flux_inlet_pps(getParam<std::vector<PostprocessorName>>("flux_inlet_pps")),
_momentum_inlet_function(
getParam<std::vector<std::vector<FunctionName>>>("momentum_inlet_function")),
_momentum_outlet_types(getParam<MultiMooseEnum>("momentum_outlet_types")),
_momentum_wall_types(getParam<MultiMooseEnum>("momentum_wall_types")),
_energy_inlet_types(getParam<MultiMooseEnum>("energy_inlet_types")),
_energy_inlet_function(getParam<std::vector<std::string>>("energy_inlet_function")),
_energy_wall_types(getParam<MultiMooseEnum>("energy_wall_types")),
_energy_wall_function(getParam<std::vector<FunctionName>>("energy_wall_function")),
_pressure_function(getParam<std::vector<FunctionName>>("pressure_function")),
_ambient_convection_blocks(
getParam<std::vector<std::vector<SubdomainName>>>("ambient_convection_blocks")),
_ambient_convection_alpha(getParam<std::vector<MooseFunctorName>>("ambient_convection_alpha")),
_ambient_temperature(getParam<std::vector<MooseFunctorName>>("ambient_temperature")),
_friction_blocks(isParamValid("friction_blocks")
? getParam<std::vector<std::vector<SubdomainName>>>("friction_blocks")
: std::vector<std::vector<SubdomainName>>()),
_friction_types(isParamValid("friction_types")
? getParam<std::vector<std::vector<std::string>>>("friction_types")
: std::vector<std::vector<std::string>>()),
_friction_coeffs(isParamValid("friction_coeffs")
? getParam<std::vector<std::vector<std::string>>>("friction_coeffs")
: std::vector<std::vector<std::string>>()),
_density_name(getParam<MooseFunctorName>("density")),
_dynamic_viscosity_name(getParam<MooseFunctorName>("dynamic_viscosity")),
_specific_heat_name(getParam<MooseFunctorName>("specific_heat")),
_thermal_conductivity_blocks(
isParamValid("thermal_conductivity_blocks")
? getParam<std::vector<std::vector<SubdomainName>>>("thermal_conductivity_blocks")
: std::vector<std::vector<SubdomainName>>()),
_thermal_conductivity_name(getParam<std::vector<MooseFunctorName>>("thermal_conductivity")),
_thermal_expansion_name(getParam<MooseFunctorName>("thermal_expansion")),
_passive_scalar_names(getParam<std::vector<NonlinearVariableName>>("passive_scalar_names")),
_passive_scalar_diffusivity(
getParam<std::vector<MooseFunctorName>>("passive_scalar_diffusivity")),
_passive_scalar_schmidt_number(getParam<std::vector<Real>>("passive_scalar_schmidt_number")),
_passive_scalar_source(getParam<std::vector<MooseFunctorName>>("passive_scalar_source")),
_passive_scalar_coupled_source(
getParam<std::vector<CoupledName>>("passive_scalar_coupled_source")),
_passive_scalar_coupled_source_coeff(
getParam<std::vector<std::vector<Real>>>("passive_scalar_coupled_source_coeff")),
_passive_scalar_inlet_types(getParam<MultiMooseEnum>("passive_scalar_inlet_types")),
_passive_scalar_inlet_function(
getParam<std::vector<std::vector<std::string>>>("passive_scalar_inlet_function")),
_mass_advection_interpolation(getParam<MooseEnum>("mass_advection_interpolation")),
_momentum_advection_interpolation(getParam<MooseEnum>("momentum_advection_interpolation")),
_energy_advection_interpolation(getParam<MooseEnum>("energy_advection_interpolation")),
_passive_scalar_advection_interpolation(
getParam<MooseEnum>("passive_scalar_advection_interpolation")),
_pressure_face_interpolation(getParam<MooseEnum>("pressure_face_interpolation")),
_momentum_face_interpolation(getParam<MooseEnum>("momentum_face_interpolation")),
_energy_face_interpolation(getParam<MooseEnum>("energy_face_interpolation")),
_passive_scalar_face_interpolation(getParam<MooseEnum>("passive_scalar_face_interpolation")),
_velocity_interpolation(getParam<MooseEnum>("velocity_interpolation")),
_pressure_two_term_bc_expansion(getParam<bool>("pressure_two_term_bc_expansion")),
_momentum_two_term_bc_expansion(getParam<bool>("momentum_two_term_bc_expansion")),
_energy_two_term_bc_expansion(getParam<bool>("energy_two_term_bc_expansion")),
_passive_scalar_two_term_bc_expansion(getParam<bool>("passive_scalar_two_term_bc_expansion")),
_mass_scaling(getParam<Real>("mass_scaling")),
_momentum_scaling(getParam<Real>("momentum_scaling")),
_energy_scaling(getParam<Real>("energy_scaling")),
_passive_scalar_scaling(getParam<Real>("passive_scalar_scaling")),
_create_velocity(!isParamValid("velocity_variable")),
_create_pressure(!isParamValid("pressure_variable")),
_create_fluid_temperature(!isParamValid("fluid_temperature_variable")),
_use_external_enthalpy_material(getParam<bool>("use_external_enthalpy_material"))
{
// Running the general checks, the rest are run after we already know some
// geometry-related parameters.
checkGeneralControlErrors();
}
void
NSFVAction::act()
{
if (_current_task == "add_navier_stokes_variables")
{
// We process parameters necesary to handle block-restriction
processBlocks();
// We check if we need to create variables
processVariables();
// The condition is used because this action will incorporate compressible simulations in the
// future. The same applied to the other conditions below.
if (_compressibility == "weakly-compressible" || _compressibility == "incompressible")
addINSVariables();
}
if (_current_task == "add_navier_stokes_user_objects")
{
if (_compressibility == "incompressible" || _compressibility == "weakly-compressible")
addRhieChowUserObjects();
}
if (_current_task == "add_navier_stokes_ics")
{
// Check initial condition related user input errors
checkICParameterErrors();
if (_compressibility == "incompressible" || _compressibility == "weakly-compressible")
addINSInitialConditions();
}
if (_current_task == "add_navier_stokes_kernels")
{
// Check if the user made mistakes in the definition of friction parameters
checkFrictionParameterErrors();
// Check if the user made mistakes in the definition of ambient convection parameters
checkAmbientConvectionParameterErrors();
// Check if the user made mistakes in the definition of scalar kernel parameters
checkPassiveScalarParameterErrors();
if (_has_flow_equations)
{
if (_compressibility == "incompressible")
{
if (_problem->isTransient())
{
addINSMomentumTimeKernels();
if (_has_energy_equation)
addINSEnergyTimeKernels();
}
if (_boussinesq_approximation)
addINSMomentumBoussinesqKernels();
}
else
{
if (_problem->isTransient())
{
addWCNSMassTimeKernels();
addWCNSMomentumTimeKernels();
if (_has_energy_equation)
addWCNSEnergyTimeKernels();
}
}
}
if (_compressibility == "incompressible" || _compressibility == "weakly-compressible")
{
// If the material properties are not constant, we can use the same kernels
// for weakly-compressible simulations.
if (_has_flow_equations)
{
addINSMassKernels();
addINSMomentumAdvectionKernels();
addINSMomentumViscousDissipationKernels();
addINSMomentumPressureKernels();
addINSMomentumGravityKernels();
if (_friction_types.size())
addINSMomentumFrictionKernels();
if (_turbulence_handling == "mixing-length")
addINSMomentumMixingLengthKernels();
}
if (_has_energy_equation)
{
addINSEnergyAdvectionKernels();
addINSEnergyHeatConductionKernels();
if (_ambient_temperature.size())
addINSEnergyAmbientConvection();
if (isParamValid("external_heat_source"))
addINSEnergyExternalHeatSource();
if (_turbulence_handling == "mixing-length")
addWCNSEnergyMixingLengthKernels();
}
if (_has_scalar_equation)
{
if (_problem->isTransient())
addScalarTimeKernels();
addScalarAdvectionKernels();
if (_passive_scalar_diffusivity.size())
addScalarDiffusionKernels();
if (_turbulence_handling == "mixing-length")
addScalarMixingLengthKernels();
if (_passive_scalar_source.size())
addScalarSourceKernels();
if (_passive_scalar_coupled_source.size())
addScalarCoupledSourceKernels();
}
}
}
if (_current_task == "add_navier_stokes_bcs")
{
if (_compressibility == "incompressible" || _compressibility == "weakly-compressible")
{
addINSInletBC();
addINSOutletBC();
if (_has_flow_equations)
addINSWallBC();
if (_has_energy_equation)
{
addINSEnergyInletBC();
addINSEnergyWallBC();
}
if (_has_scalar_equation)
addScalarInletBC();
}
}
if (_current_task == "add_navier_stokes_materials")
{
if (_compressibility == "incompressible" || _compressibility == "weakly-compressible")
{
if (_has_energy_equation && !_use_external_enthalpy_material)
addEnthalpyMaterial();
if (_porous_medium_treatment)
addPorousMediumSpeedMaterial();
if (_turbulence_handling == "mixing-length")
addMixingLengthMaterial();
}
}
if (_current_task == "add_navier_stokes_pps")
{
// Check if the user defined the boundary conditions in a sensible way
checkBoundaryParameterErrors();
addBoundaryPostprocessors();
}
if (getParam<bool>("initialize_variables_from_mesh_file"))
{
if (_current_task == "navier_stokes_check_copy_nodal_vars")
_app.setExodusFileRestart(true);
else if (_current_task == "navier_stokes_copy_nodal_vars")
{
SystemBase & system = _problem->getNonlinearSystemBase();
if (_create_pressure)
system.addVariableToCopy(
_pressure_name, _pressure_name, getParam<std::string>("initial_from_file_timestep"));
if (_create_velocity)
for (unsigned int d = 0; d < _dim; ++d)
system.addVariableToCopy(_velocity_name[d],
_velocity_name[d],
getParam<std::string>("initial_from_file_timestep"));
if (getParam<bool>("pin_pressure"))
system.addVariableToCopy(
"lambda", "lambda", getParam<std::string>("initial_from_file_timestep"));
if (_turbulence_handling == "mixing-length")
_problem->getAuxiliarySystem().addVariableToCopy(
NS::mixing_length,
NS::mixing_length,
getParam<std::string>("initial_from_file_timestep"));
if (_has_energy_equation && _create_fluid_temperature)
system.addVariableToCopy(_fluid_temperature_name,
_fluid_temperature_name,
getParam<std::string>("initial_from_file_timestep"));
if (_has_scalar_equation)
for (unsigned int name_i = 0; name_i < _passive_scalar_names.size(); ++name_i)
{
bool create_me = true;
if (_create_scalar_variable.size())
if (!_create_scalar_variable[name_i])
create_me = false;
if (create_me)
system.addVariableToCopy(_passive_scalar_names[name_i],
_passive_scalar_names[name_i],
getParam<std::string>("initial_from_file_timestep"));
}
}
}
}
void
NSFVAction::addINSVariables()
{
// Add velocity variable
if (_create_velocity)
{
std::string variable_type = "INSFVVelocityVariable";
if (_porous_medium_treatment)
variable_type = "PINSFVSuperficialVelocityVariable";
auto params = _factory.getValidParams(variable_type);
params.set<std::vector<SubdomainName>>("block") = _blocks;
params.set<std::vector<Real>>("scaling") = {_momentum_scaling};
params.set<MooseEnum>("face_interp_method") = _momentum_face_interpolation;
params.set<bool>("two_term_boundary_expansion") = _momentum_two_term_bc_expansion;
for (unsigned int d = 0; d < _dim; ++d)
_problem->addVariable(variable_type, _velocity_name[d], params);
}
// Add pressure variable
if (_create_pressure)
{
auto params = _factory.getValidParams("INSFVPressureVariable");
params.set<std::vector<SubdomainName>>("block") = _blocks;
params.set<std::vector<Real>>("scaling") = {_mass_scaling};
params.set<MooseEnum>("face_interp_method") = _pressure_face_interpolation;
params.set<bool>("two_term_boundary_expansion") = _pressure_two_term_bc_expansion;
_problem->addVariable("INSFVPressureVariable", _pressure_name, params);
}
// Add lagrange multiplier for pinning pressure, if needed
if (getParam<bool>("pin_pressure"))
{
auto lm_params = _factory.getValidParams("MooseVariableScalar");
lm_params.set<MooseEnum>("family") = "scalar";
lm_params.set<MooseEnum>("order") = "first";
_problem->addVariable("MooseVariableScalar", "lambda", lm_params);
}
// Add turbulence-related variables
if (_turbulence_handling == "mixing-length")
{
auto params = _factory.getValidParams("MooseVariableFVReal");
params.set<std::vector<SubdomainName>>("block") = _blocks;
params.set<bool>("two_term_boundary_expansion") =
getParam<bool>("mixing_length_two_term_bc_expansion");
_problem->addAuxVariable("MooseVariableFVReal", NS::mixing_length, params);
}
// Add energy variables if needed
if (_has_energy_equation)
{
if (_create_fluid_temperature)
{
auto params = _factory.getValidParams("INSFVEnergyVariable");
params.set<std::vector<SubdomainName>>("block") = _blocks;
params.set<std::vector<Real>>("scaling") = {_energy_scaling};
params.set<MooseEnum>("face_interp_method") = _energy_face_interpolation;
params.set<bool>("two_term_boundary_expansion") = _energy_two_term_bc_expansion;
_problem->addVariable("INSFVEnergyVariable", _fluid_temperature_name, params);
}
}
// Add passive scalar variables is needed
if (_has_scalar_equation)
{
auto params = _factory.getValidParams("MooseVariableFVReal");
params.set<std::vector<SubdomainName>>("block") = _blocks;
params.set<std::vector<Real>>("scaling") = {_passive_scalar_scaling};
params.set<MooseEnum>("face_interp_method") = _passive_scalar_face_interpolation;
params.set<bool>("two_term_boundary_expansion") = _passive_scalar_two_term_bc_expansion;
for (unsigned int name_i = 0; name_i < _passive_scalar_names.size(); ++name_i)
{
bool create_me = true;
if (_create_scalar_variable.size())
if (!_create_scalar_variable[name_i])
create_me = false;
if (create_me)
_problem->addVariable("MooseVariableFVReal", _passive_scalar_names[name_i], params);
}
}
}
void
NSFVAction::addRhieChowUserObjects()
{
const std::string u_names[3] = {"u", "v", "w"};
if (_porous_medium_treatment)
{
auto params = _factory.getValidParams("PINSFVRhieChowInterpolator");
params.set<std::vector<SubdomainName>>("block") = _blocks;
for (unsigned int d = 0; d < _dim; ++d)
params.set<VariableName>(u_names[d]) = _velocity_name[d];
params.set<VariableName>("pressure") = _pressure_name;
params.set<MooseFunctorName>(NS::porosity) = _porosity_name;
unsigned short smoothing_layers = isParamValid("porosity_smoothing_layers")
? getParam<unsigned short>("porosity_smoothing_layers")
: 0;
params.set<unsigned short>("smoothing_layers") = smoothing_layers;
_problem->addUserObject("PINSFVRhieChowInterpolator", "pins_rhie_chow_interpolator", params);
}
else
{
auto params = _factory.getValidParams("INSFVRhieChowInterpolator");
params.set<std::vector<SubdomainName>>("block") = _blocks;
for (unsigned int d = 0; d < _dim; ++d)
params.set<VariableName>(u_names[d]) = _velocity_name[d];
params.set<VariableName>("pressure") = _pressure_name;
// Set RhieChow coefficients
if (!_has_flow_equations)
{
checkRhieChowFunctorsDefined();
params.set<MooseFunctorName>("a_u") = "ax";
params.set<MooseFunctorName>("a_v") = "ay";
params.set<MooseFunctorName>("a_w") = "az";
}
_problem->addUserObject("INSFVRhieChowInterpolator", "ins_rhie_chow_interpolator", params);
}
}
void
NSFVAction::addINSInitialConditions()
{
// do not set initial conditions if we load from file
if (getParam<bool>("initialize_variables_from_mesh_file"))
return;
InputParameters params = _factory.getValidParams("FunctionIC");
auto vvalue = getParam<std::vector<FunctionName>>("initial_velocity");
if (_create_velocity)
for (unsigned int d = 0; d < _dim; ++d)
{
params.set<VariableName>("variable") = _velocity_name[d];
params.set<FunctionName>("function") = vvalue[d];
_problem->addInitialCondition("FunctionIC", _velocity_name[d] + "_ic", params);
}
if (_create_pressure)
{
params.set<VariableName>("variable") = _pressure_name;
params.set<FunctionName>("function") = getParam<FunctionName>("initial_pressure");
_problem->addInitialCondition("FunctionIC", _pressure_name + "_ic", params);
}
if (_has_energy_equation)
{
if (_create_fluid_temperature)
{
params.set<VariableName>("variable") = _fluid_temperature_name;
params.set<FunctionName>("function") = getParam<FunctionName>("initial_temperature");
_problem->addInitialCondition("FunctionIC", _fluid_temperature_name + "_ic", params);
}
}
if (_has_scalar_equation)
{
unsigned int ic_counter = 0;
for (unsigned int name_i = 0; name_i < _passive_scalar_names.size(); ++name_i)
{
bool initialize_me = true;
if (_create_scalar_variable.size())
if (!_create_scalar_variable[name_i])
initialize_me = false;
if (initialize_me)
{
params.set<VariableName>("variable") = _passive_scalar_names[name_i];
if (isParamValid("initial_scalar_variables"))
params.set<FunctionName>("function") =
getParam<std::vector<FunctionName>>("initial_scalar_variables")[ic_counter];
else