Skip to content

Commit 20af5cb

Browse files
authored
Merge pull request deepmodeling#539 from chenzhenyi-123/master
add dfBuoyancyFoam
2 parents da65873 + 28c1b65 commit 20af5cb

17 files changed

+801
-0
lines changed

Allwmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ wmake applications/solvers/df0DFoam
2424
wmake applications/solvers/dfLowMachFoam
2525
wmake applications/solvers/dfHighSpeedFoam
2626
wmake applications/solvers/dfSprayFoam
27+
wmake applications/solvers/dfBuoyancyFoam
2728

2829
wmake applications/utilities/flameSpeed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dfBuoyancyFoam.C
2+
3+
EXE = $(DF_APPBIN)/dfBuoyancyFoam
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
-I$(LIB_SRC)/finiteVolume/lnInclude \
12+
-I$(LIB_SRC)/meshTools/lnInclude \
13+
-I$(LIB_SRC)/sampling/lnInclude \
14+
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
15+
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
16+
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
17+
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
18+
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
19+
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
20+
-I$(LIB_SRC)/regionModels/pyrolysisModels/lnInclude \
21+
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
22+
-I$(DF_SRC)/lagrangian/intermediate/lnInclude \
23+
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
24+
-I$(DF_SRC)/lagrangian/spray/lnInclude \
25+
-I$(LIB_SRC)/lagrangian/spray/lnInclude \
26+
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
27+
-I$(LIB_SRC)/ODE/lnInclude \
28+
-I$(DF_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
29+
-I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
30+
-I$(DF_SRC)/thermophysicalModels/SLGThermo/lnInclude \
31+
-I$(LIB_SRC)/Pstream/mpi \
32+
-I$(DF_SRC)/dfCanteraMixture/lnInclude \
33+
-I$(DF_SRC)/dfChemistryModel/lnInclude \
34+
-I$(DF_SRC)/dfCombustionModels/lnInclude \
35+
-I$(CANTERA_ROOT)/include \
36+
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \
37+
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \
38+
$(PYTHON_INC_DIR) \
39+
$(if $(AMGX_DIR), -I$(DF_ROOT)/src_gpu,) \
40+
$(if $(AMGX_DIR), -I/usr/local/cuda/include,) \
41+
$(if $(AMGX_DIR), -I$(AMGX_DIR)/include,) \
42+
$(if $(ODE_GPU_SOLVER), -I$(OPENCC_PATH)/include,) \
43+
$(if $(ODE_GPU_SOLVER), -DODE_GPU_SOLVER,)
44+
45+
EXE_LIBS = \
46+
-lfiniteVolume \
47+
-lmeshTools \
48+
-lsampling \
49+
-lturbulenceModels \
50+
-lcompressibleTransportModels \
51+
-llagrangian \
52+
-lregionModels \
53+
-L$(DF_LIBBIN) \
54+
-ldfSurfaceFilmModels \
55+
-ldfSLGThermo \
56+
-ldfLagrangianIntermediate \
57+
-ldfLagrangianTurbulence \
58+
-ldfLagrangianSpray \
59+
-ldfFluidThermophysicalModels \
60+
-ldfCompressibleTurbulenceModels \
61+
-ldfThermophysicalProperties \
62+
-ldfCanteraMixture \
63+
-ldfChemistryModel \
64+
-ldfCombustionModels \
65+
$(CANTERA_ROOT)/lib/libcantera.so \
66+
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libtorch.so,) \
67+
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libc10.so,) \
68+
$(if $(LIBTORCH_ROOT),-rdynamic,) \
69+
$(if $(LIBTORCH_ROOT),-lpthread,) \
70+
$(if $(LIBTORCH_ROOT),$(DF_SRC)/dfChemistryModel/DNNInferencer/build/libDNNInferencer.so,) \
71+
$(if $(PYTHON_LIB_DIR),$(PYTHON_LIB_DIR),) \
72+
$(if $(AMGX_DIR), /usr/local/cuda/lib64/libcudart.so,) \
73+
$(if $(AMGX_DIR), /usr/local/cuda/lib64/libnccl.so,) \
74+
$(if $(AMGX_DIR), $(DF_ROOT)/src_gpu/build/libdfMatrix.so,) \
75+
$(if $(AMGX_DIR), $(AMGX_DIR)/build/libamgxsh.so,) \
76+
$(if $(ODE_GPU_SOLVER), $(ODE_GPU_SOLVER)/lib/libopencc.so,)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
MRF.correctBoundaryVelocity(U);
2+
3+
fvVectorMatrix UEqn
4+
(
5+
fvm::ddt(rho, U) + fvm::div(phi, U)
6+
+ MRF.DDt(rho, U)
7+
+ turbulence->divDevRhoReff(U)
8+
==
9+
parcels.SU(U)
10+
// + fvOptions(rho, U)
11+
);
12+
13+
UEqn.relax();
14+
15+
// fvOptions.constrain(UEqn);
16+
17+
if (pimple.momentumPredictor())
18+
{
19+
solve
20+
(
21+
UEqn
22+
==
23+
fvc::reconstruct
24+
(
25+
(
26+
- ghf*fvc::snGrad(rho)
27+
- fvc::snGrad(p_rgh)
28+
)*mesh.magSf()
29+
)
30+
);
31+
32+
// fvOptions.correct(U);
33+
K = 0.5*magSqr(U);
34+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
tmp<fv::convectionScheme<scalar>> mvConvection
2+
(
3+
fv::convectionScheme<scalar>::New
4+
(
5+
mesh,
6+
fields,
7+
phi,
8+
mesh.divScheme("div(phi,Yi_h)")
9+
)
10+
);
11+
{
12+
// radiation->correct();
13+
combustion->correct();
14+
15+
HRR = combustion->Qdot();
16+
17+
volScalarField Yt(0.0*Y[0]);
18+
19+
forAll(Y, i)
20+
{
21+
if (i != inertIndex)
22+
{
23+
volScalarField& Yi = Y[i];
24+
25+
fvScalarMatrix YiEqn
26+
(
27+
fvm::ddt(rho, Yi)
28+
+ mvConvection->fvmDiv(phi, Yi)
29+
- fvm::laplacian(turbulence->alphaEff(), Yi)
30+
==
31+
parcels.SYi(i, Yi)
32+
// + surfaceFilm.Srho(i)
33+
+ combustion->R(Yi)
34+
// + fvOptions(rho, Yi)
35+
);
36+
YiEqn.relax();
37+
38+
// fvOptions.constrain(YiEqn);
39+
40+
YiEqn.solve("Yi");
41+
42+
// fvOptions.correct(Yi);
43+
44+
Yi.max(0.0);
45+
Yt += Yi;
46+
}
47+
}
48+
49+
Y[inertIndex] = scalar(1) - Yt;
50+
Y[inertIndex].max(0.0);
51+
52+
volScalarField& he = thermo.he();
53+
54+
fvScalarMatrix EEqn
55+
(
56+
fvm::ddt(rho, he) + mvConvection->fvmDiv(phi, he)
57+
+ fvc::ddt(rho, K) + fvc::div(phi, K)
58+
+ (
59+
he.name() == "e"
60+
? fvc::div
61+
(
62+
fvc::absolute(phi/fvc::interpolate(rho), U),
63+
p,
64+
"div(phiv,p)"
65+
)
66+
: -dpdt
67+
)
68+
- fvm::laplacian(turbulence->alphaEff(), he)
69+
==
70+
// combustion->Qdot() // ha Eqn has no reaction source
71+
// + radiation->Sh(thermo, he)
72+
parcels.Sh(he)
73+
// + surfaceFilm.Sh()
74+
// + fvOptions(rho, he)
75+
);
76+
77+
EEqn.relax();
78+
79+
// fvOptions.constrain(EEqn);
80+
81+
EEqn.solve();
82+
83+
// fvOptions.correct(he);
84+
85+
// thermo.correct();
86+
chemistry->correctThermo();
87+
88+
Info<< "min/max(T) = "
89+
<< min(T).value() << ", " << max(T).value() << endl;
90+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Info<< "\nConstructing reacting cloud" << endl;
2+
basicReactingCloud parcels
3+
(
4+
"reactingCloud1",
5+
rho,
6+
U,
7+
g,
8+
slgThermo
9+
);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const volScalarField& psi = thermo.psi();
2+
const volScalarField& T = thermo.T();
3+
// regionModels::surfaceFilmModel& surfaceFilm = tsurfaceFilm();
4+
const word inertSpecie(chemistry->lookup("inertSpecie"));
5+
const label inertIndex(chemistry->species()[inertSpecie]);
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
Info<< "Reading thermophysical properties\n" << endl;
2+
//autoPtr<psiReactionThermo> pThermo(psiReactionThermo::New(mesh));
3+
//psiReactionThermo& thermo = pThermo();
4+
//thermo.validate(args.executable(), "h", "e");
5+
6+
CanteraMixture::setEnergyName("ha");
7+
// fluidThermo* pThermo = new heRhoThermo<rhoThermo, CanteraMixture>(mesh, word::null);
8+
fluidThermo* pThermo = new heRhoThermo<rhoThermo, dfSingleStepReactingMixture>(mesh, word::null);
9+
fluidThermo& thermo = *pThermo;
10+
SLGThermo slgThermo(mesh, thermo);
11+
12+
// basicSpecieMixture& composition = thermo.composition();
13+
// PtrList<volScalarField>& Y = composition.Y();
14+
15+
// const word inertSpecie(thermo.lookup("inertSpecie"));
16+
// if (!composition.species().found(inertSpecie))
17+
// {
18+
// FatalIOErrorIn(args.executable().c_str(), thermo)
19+
// << "Inert specie " << inertSpecie << " not found in available species "
20+
// << composition.species()
21+
// << exit(FatalIOError);
22+
// }
23+
24+
Info<< "Creating field rho\n" << endl;
25+
volScalarField rho
26+
(
27+
IOobject
28+
(
29+
"rho",
30+
runTime.timeName(),
31+
mesh,
32+
IOobject::NO_READ,
33+
IOobject::AUTO_WRITE
34+
),
35+
thermo.rho()
36+
);
37+
38+
volScalarField& p = thermo.p();
39+
40+
Info<< "\nReading field U\n" << endl;
41+
volVectorField U
42+
(
43+
IOobject
44+
(
45+
"U",
46+
runTime.timeName(),
47+
mesh,
48+
IOobject::MUST_READ,
49+
IOobject::AUTO_WRITE
50+
),
51+
mesh
52+
);
53+
54+
#include "compressibleCreatePhi.H"
55+
56+
#include "createMRF.H"
57+
58+
59+
Info<< "Creating turbulence model\n" << endl;
60+
autoPtr<compressible::turbulenceModel> turbulence
61+
(
62+
compressible::turbulenceModel::New
63+
(
64+
rho,
65+
U,
66+
phi,
67+
thermo
68+
)
69+
);
70+
71+
Info<< "Creating combustion model\n" << endl;
72+
autoPtr<CombustionModel<basicThermo>> combustion
73+
(
74+
CombustionModel<basicThermo>::New(thermo, turbulence())
75+
);
76+
77+
dfChemistryModel<basicThermo>* chemistry = combustion->chemistry();
78+
PtrList<volScalarField>& Y = chemistry->Y();
79+
80+
#include "readGravitationalAcceleration.H"
81+
#include "readhRef.H"
82+
#include "gh.H"
83+
#include "readpRef.H"
84+
85+
volScalarField p_rgh
86+
(
87+
IOobject
88+
(
89+
"p_rgh",
90+
runTime.timeName(),
91+
mesh,
92+
IOobject::MUST_READ,
93+
IOobject::AUTO_WRITE
94+
),
95+
mesh
96+
);
97+
98+
mesh.setFluxRequired(p_rgh.name());
99+
100+
#include "phrghEqn.H"
101+
102+
103+
multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;
104+
105+
forAll(Y, i)
106+
{
107+
fields.add(Y[i]);
108+
}
109+
fields.add(thermo.he());
110+
111+
volScalarField HRR
112+
(
113+
IOobject
114+
(
115+
"HRR",
116+
runTime.timeName(),
117+
mesh,
118+
IOobject::READ_IF_PRESENT,
119+
IOobject::AUTO_WRITE
120+
),
121+
mesh,
122+
dimensionedScalar(dimEnergy/dimVolume/dimTime, 0)
123+
);
124+
125+
IOdictionary additionalControlsDict
126+
(
127+
IOobject
128+
(
129+
"additionalControls",
130+
runTime.constant(),
131+
mesh,
132+
IOobject::MUST_READ_IF_MODIFIED,
133+
IOobject::NO_WRITE
134+
)
135+
);
136+
137+
Switch solvePrimaryRegion
138+
(
139+
additionalControlsDict.lookup("solvePrimaryRegion")
140+
);
141+
142+
Switch solvePyrolysisRegion
143+
(
144+
additionalControlsDict.lookupOrDefault<bool>("solvePyrolysisRegion", true)
145+
);
146+
147+
148+
Info<< "Creating field dpdt\n" << endl;
149+
volScalarField dpdt
150+
(
151+
IOobject
152+
(
153+
"dpdt",
154+
runTime.timeName(),
155+
mesh
156+
),
157+
mesh,
158+
dimensionedScalar(p.dimensions()/dimTime, 0)
159+
);
160+
161+
Info<< "Creating field kinetic energy K\n" << endl;
162+
volScalarField K("K", 0.5*magSqr(U));
163+
164+
#include "createClouds.H"
165+
#include "createSurfaceFilmModel.H"
166+
// #include "createPyrolysisModel.H"
167+
// #include "createRadiationModel.H"
168+
// #include "createFvOptions.H"

0 commit comments

Comments
 (0)