Skip to content

Commit 69b346d

Browse files
committed
Feature: Implement a multi-region hybrid solver for wide-range mach number flows.
- Low-mach number region: solved using dfLowMachFoam module. - For combustor geometry including injectors, liner without the transonic nozzle part - High-speed region: solved using dfHighSpeedFoam module. - For transonic laval-nozzle part (can be extent to outside plume region) - The two regions are connected using an interface (implemented at last commit)
1 parent d738b30 commit 69b346d

33 files changed

+2137
-1
lines changed

Allwmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ wmake applications/solvers/dfHighSpeedFoam
2626
wmake applications/solvers/dfSprayFoam
2727
wmake applications/solvers/dfBuoyancyFoam
2828
wmake applications/solvers/dfSteadyFoam
29+
wmake all applications/solvers/dfHybridFoam
2930

3031
wmake applications/utilities/flameSpeed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dfHybridFoam.C
2+
3+
EXE = $(DF_APPBIN)/dfHybridFoam
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
-include $(GENERAL_RULES)/mplibType
2+
3+
EXE_INC = -std=c++14 \
4+
-g \
5+
-fopenmp \
6+
-Wno-unused-variable \
7+
-Wno-unused-but-set-variable \
8+
-Wno-old-style-cast \
9+
-I. \
10+
$(PFLAGS) $(PINC) \
11+
$(if $(CANTERA_THERMO),-DCANTERA_THERMO,) \
12+
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
13+
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
14+
-I$(FOAM_APP)/solvers/lagrangian/reactingParcelFoam \
15+
-I$(FOAM_APP)/solvers/compressible/rhoPimpleFoam \
16+
-I$(FOAM_APP)/solvers/compressible/rhoCentralFoam/BCs/lnInclude \
17+
-I$(DF_SRC)/fluxSchemes/lnInclude \
18+
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
19+
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
20+
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
21+
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
22+
-I$(LIB_SRC)/finiteVolume/cfdTools \
23+
-I$(LIB_SRC)/finiteVolume/lnInclude \
24+
-I$(LIB_SRC)/meshTools/lnInclude \
25+
-I$(LIB_SRC)/sampling/lnInclude \
26+
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
27+
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
28+
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
29+
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
30+
-I$(DF_SRC)/lagrangian/intermediate/lnInclude \
31+
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
32+
-I$(DF_SRC)/lagrangian/spray/lnInclude \
33+
-I$(LIB_SRC)/lagrangian/spray/lnInclude \
34+
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
35+
-I$(DF_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
36+
-I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
37+
-I$(DF_SRC)/thermophysicalModels/SLGThermo/lnInclude \
38+
-I$(LIB_SRC)/Pstream/mpi \
39+
-I$(DF_SRC)/dfCanteraMixture/lnInclude \
40+
-I$(DF_SRC)/dfChemistryModel/lnInclude \
41+
-I$(DF_SRC)/dfCombustionModels/lnInclude \
42+
-I$(DF_SRC)/dfHybridBoundaryConditions \
43+
-I$(CANTERA_ROOT)/include \
44+
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \
45+
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \
46+
$(PYTHON_INC_DIR)
47+
48+
EXE_LIBS = \
49+
-lcompressibleTransportModels \
50+
-lturbulenceModels \
51+
-llagrangian \
52+
-lregionModels \
53+
-ldfSurfaceFilmModels \
54+
-lfiniteVolume \
55+
-ldynamicFvMesh \
56+
-ltopoChangerFvMesh \
57+
-lmeshTools \
58+
-lsampling \
59+
-L$(DF_LIBBIN) \
60+
-ldfFluidThermophysicalModels \
61+
-ldfCompressibleTurbulenceModels \
62+
-ldfThermophysicalProperties \
63+
-ldfSLGThermo \
64+
-ldfLagrangianIntermediate \
65+
-ldfLagrangianTurbulence \
66+
-ldfLagrangianSpray \
67+
-ldfCanteraMixture \
68+
-ldfChemistryModel \
69+
-ldfCombustionModels \
70+
-ldfHybridBoundaryConditions \
71+
-lfluxSchemes \
72+
$(CANTERA_ROOT)/lib/libcantera.so \
73+
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libtorch.so,) \
74+
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libc10.so,) \
75+
$(if $(LIBTORCH_ROOT),-rdynamic,) \
76+
$(if $(LIBTORCH_ROOT),-lpthread,) \
77+
$(if $(LIBTORCH_ROOT),$(DF_SRC)/dfChemistryModel/DNNInferencer/build/libDNNInferencer.so,) \
78+
$(if $(PYTHON_LIB_DIR),$(PYTHON_LIB_DIR),)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*---------------------------------------------------------------------------*\
2+
createFields.H — Dispatch field creation for each region type
3+
\*---------------------------------------------------------------------------*/
4+
5+
#include "lowMach/createLowMachFields.H"
6+
#include "highSpeed/createHighSpeedFields.H"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*---------------------------------------------------------------------------*\
2+
createMeshes.H — Read regionProperties and create meshes for all regions
3+
\*---------------------------------------------------------------------------*/
4+
5+
regionProperties rp(runTime);
6+
7+
#include "lowMach/createLowMachMeshes.H"
8+
#include "highSpeed/createHighSpeedMeshes.H"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "createMeshes.H"
2+
3+
if (!lowMachRegions.size() && !highSpeedRegions.size())
4+
{
5+
FatalErrorIn(args.executable())
6+
<< "No region meshes present" << exit(FatalError);
7+
}
8+
9+
fvMesh& mesh = lowMachRegions.size() ? lowMachRegions[0] : highSpeedRegions[0];

applications/solvers/dfHybridFoam/dfHybridBoundaryConditions/dfHybridInterfaceFvPatchField.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Class
2525
Foam::dfHybridInterfaceFvPatchField
2626
2727
Copyright
28-
Author: Teng Zhang @ AISI with help of GitHub Copilot (Claude Opus 4.6)
28+
Author: Teng Zhang @ AISI
2929
Date: 2026-03-05
3030
3131
Description
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/*---------------------------------------------------------------------------*\
2+
========= |
3+
\\ / F ield | DeepFlame: a]deep learning [empowered open-source
4+
\\ / O peration | platform for reacting flow simulations
5+
\\ / A nd | Copyright (C) 2023-2025 DeepFlame Contributors
6+
\\/ M anipulation |
7+
-------------------------------------------------------------------------------
8+
License
9+
This file is part of DeepFlame.
10+
11+
DeepFlame is free software: you can redistribute it and/or modify it
12+
under the terms of the GNU General Public License as published by
13+
the Free Software Foundation, either version 3 of the License, or
14+
(at your option) any later version.
15+
16+
DeepFlame is distributed in the hope that it will be useful, but WITHOUT
17+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19+
for more details.
20+
21+
You should have received a copy of the GNU General Public License
22+
along with DeepFlame. If not, see <http://www.gnu.org/licenses/>.
23+
24+
Application
25+
dfHybridFoam
26+
27+
Copyright
28+
Author: Teng Zhang @ AISI
29+
Date: 2026-03-05
30+
31+
Description
32+
Multi-region hybrid solver combining dfLowMachFoam (pressure-based PIMPLE)
33+
for low-Mach regions (e.g. combustor without laval nozzle) and
34+
dfHighSpeedFoam (density-based central-upwind) for high-speed regions
35+
(e.g. Laval nozzle, plume flow region).
36+
37+
Region coupling is handled via inter-region boundary conditions on the
38+
shared interface, transferring T, p, U, Yi between the two solver domains.
39+
See dfHybridBoundaryConditions for details on the implemented BCs.
40+
41+
The multi-region architecture follows the chtMultiRegionFoam pattern from
42+
OpenFOAM-7:
43+
- regionProperties defines the region names and types
44+
- Separate meshes and fields are created for each region
45+
- A time loop iterates over all regions, solving each with its
46+
appropriate algorithm
47+
48+
\*---------------------------------------------------------------------------*/
49+
50+
#include "dfChemistryModel.H"
51+
#include "CanteraMixture.H"
52+
#include "heRhoThermo.H"
53+
54+
#ifdef USE_PYTORCH
55+
#include <pybind11/embed.h>
56+
#include <pybind11/numpy.h>
57+
#include <pybind11/stl.h>
58+
#endif
59+
60+
#ifdef USE_LIBTORCH
61+
#include <torch/script.h>
62+
#include "DNNInferencer.H"
63+
#endif
64+
65+
#include "fvCFD.H"
66+
#include "dynamicFvMesh.H"
67+
#include "rhoThermo.H"
68+
#include "fluidThermo.H"
69+
#include "turbulentFluidThermoModel.H"
70+
#include "CombustionModel.H"
71+
#include "pimpleControl.H"
72+
#include "pressureControl.H"
73+
#include "localEulerDdtScheme.H"
74+
#include "fvcSmooth.H"
75+
#include "PstreamGlobals.H"
76+
#include "basicThermo.H"
77+
78+
#include "basicSprayCloud.H"
79+
#include "SLGThermo.H"
80+
81+
// For high-speed region (density-based)
82+
#include "fixedRhoFvPatchScalarField.H"
83+
#include "include/directionInterpolate.H"
84+
#include "fluxScheme.H"
85+
86+
// For multi-region support
87+
#include "regionProperties.H"
88+
#include "fixedGradientFvPatchFields.H"
89+
90+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91+
92+
int main(int argc, char *argv[])
93+
{
94+
#ifdef USE_PYTORCH
95+
pybind11::scoped_interpreter guard{};
96+
#endif
97+
98+
#define NO_CONTROL
99+
#define CREATE_MESH createMeshesPostProcess.H
100+
#include "postProcess.H"
101+
102+
#include "listOptions.H"
103+
#include "setRootCase2.H"
104+
#include "listOutput.H"
105+
106+
#include "createTime.H"
107+
108+
// ---- Multi-region mesh creation ----
109+
// Read regionProperties from constant/regionProperties
110+
// which defines "lowMach" and "highSpeed" region lists
111+
#include "createMeshes.H"
112+
113+
// ---- Create fields for each region type ----
114+
#include "createFields.H"
115+
116+
#include "initContinuityErrs.H"
117+
118+
// ---- Read time controls ----
119+
#include "include/readMultiRegionTimeControls.H"
120+
121+
// ---- Compute initial Courant numbers ----
122+
#include "include/computeMultiRegionCourantNo.H"
123+
124+
// ---- Set initial deltaT ----
125+
#include "include/setInitialMultiRegionDeltaT.H"
126+
127+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128+
129+
Info<< "\nStarting time loop\n" << endl;
130+
131+
label timeIndex = 0;
132+
133+
while (runTime.run())
134+
{
135+
timeIndex++;
136+
137+
// ---- Read time controls ----
138+
#include "include/readMultiRegionTimeControls.H"
139+
140+
// ---- Compute Courant numbers from all regions ----
141+
#include "include/computeMultiRegionCourantNo.H"
142+
143+
// ---- Adjust deltaT based on both regions ----
144+
#include "include/setMultiRegionDeltaT.H"
145+
146+
runTime++;
147+
148+
Info<< "Time = " << runTime.timeName() << nl << endl;
149+
150+
// =====================================================================
151+
// Solve low-Mach regions (pressure-based PIMPLE)
152+
// =====================================================================
153+
forAll(lowMachRegions, i)
154+
{
155+
Info<< "\nSolving for lowMach region "
156+
<< lowMachRegions[i].name() << endl;
157+
158+
#include "lowMach/setRegionLowMachFields.H"
159+
#include "lowMach/solveLowMach.H"
160+
}
161+
162+
// =====================================================================
163+
// Solve high-speed regions (density-based central-upwind)
164+
// =====================================================================
165+
forAll(highSpeedRegions, i)
166+
{
167+
Info<< "\nSolving for highSpeed region "
168+
<< highSpeedRegions[i].name() << endl;
169+
170+
#include "highSpeed/setRegionHighSpeedFields.H"
171+
#include "highSpeed/solveHighSpeed.H"
172+
}
173+
174+
runTime.write();
175+
176+
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
177+
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
178+
<< nl << endl;
179+
}
180+
181+
Info<< "End\n" << endl;
182+
183+
return 0;
184+
}
185+
186+
// ************************************************************************* //

0 commit comments

Comments
 (0)