From e2bfd5bf648387caa76596de84c4dc4099757c3f Mon Sep 17 00:00:00 2001 From: of Date: Tue, 13 Sep 2022 21:49:33 +0800 Subject: [PATCH] adapt solvers with dfCombustionModel --- .../solvers/dfLowMachFoam/Make/options | 2 ++ applications/solvers/dfLowMachFoam/YEqn.H | 12 ++++----- .../solvers/dfLowMachFoam/createFields.H | 25 ++++++++++++------- .../solvers/dfLowMachFoam/dfLowMachFoam.C | 4 ++- applications/solvers/dfSprayFoam/Make/options | 2 ++ applications/solvers/dfSprayFoam/YEqn.H | 5 ++-- .../solvers/dfSprayFoam/createFields.H | 24 ++++++++++++------ .../solvers/dfSprayFoam/dfSprayFoam.C | 4 ++- 8 files changed, 50 insertions(+), 28 deletions(-) diff --git a/applications/solvers/dfLowMachFoam/Make/options b/applications/solvers/dfLowMachFoam/Make/options index 6e6f7d92..042d652c 100644 --- a/applications/solvers/dfLowMachFoam/Make/options +++ b/applications/solvers/dfLowMachFoam/Make/options @@ -14,6 +14,7 @@ EXE_INC = -std=c++14 \ -I$(LIB_SRC)/Pstream/mpi \ -I$(DF_SRC)/CanteraMixture/lnInclude \ -I$(DF_SRC)/dfChemistryModel/lnInclude \ + -I$(DF_SRC)/dfCombustionModels/lnInclude \ -I$(CANTERA_ROOT)/include \ -I$(TORCH_ROOT)/include \ -I$(TORCH_ROOT)/include/torch/csrc/api/include @@ -29,6 +30,7 @@ EXE_LIBS = \ -ldfCompressibleTurbulenceModels \ -lCanteraMixture \ -ldfChemistryModel \ + -ldfCombustionModels \ $(CANTERA_ROOT)/lib/libcantera.so \ $(TORCH_ROOT)/lib/libtorch.so \ $(TORCH_ROOT)/lib/libc10.so \ diff --git a/applications/solvers/dfLowMachFoam/YEqn.H b/applications/solvers/dfLowMachFoam/YEqn.H index 214f6d21..91dc925d 100644 --- a/applications/solvers/dfLowMachFoam/YEqn.H +++ b/applications/solvers/dfLowMachFoam/YEqn.H @@ -15,13 +15,13 @@ tmp> mvConvection forAll(Y, i) { - Derror += chemistry.rhoD(i)*fvc::grad(Y[i]); + Derror += chemistry->rhoD(i)*fvc::grad(Y[i]); } const surfaceScalarField phiUc = linearInterpolate(Derror) & mesh.Sf(); { start = std::clock(); - chemistry.solve(mesh.time().deltaTValue()); + combustion->correct(); label flag_mpi_init; MPI_Initialized(&flag_mpi_init); if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM); @@ -34,12 +34,12 @@ const surfaceScalarField phiUc = linearInterpolate(Derror) & mesh.Sf(); forAll(Y, i) { volScalarField& Yi = Y[i]; - vk += chemistry.hai(i)*(chemistry.rhoD(i)*fvc::grad(Yi) - Yi*Derror); - diffsh += fvc::laplacian(thermo.alpha()*chemistry.hai(i), Yi); + vk += chemistry->hai(i)*(chemistry->rhoD(i)*fvc::grad(Yi) - Yi*Derror); + diffsh += fvc::laplacian(thermo.alpha()*chemistry->hai(i), Yi); if (i != inertIndex) { - tmp DEff = chemistry.rhoD(i) + turbulence->mut()/Sct; + tmp DEff = chemistry->rhoD(i) + turbulence->mut()/Sct; fvScalarMatrix YiEqn ( fvm::ddt(rho, Yi) @@ -47,7 +47,7 @@ const surfaceScalarField phiUc = linearInterpolate(Derror) & mesh.Sf(); - fvm::laplacian(DEff(), Yi) + mvConvection->fvmDiv(phiUc, Yi) == - chemistry.RR(i) + combustion->R(Yi) ); YiEqn.relax(); diff --git a/applications/solvers/dfLowMachFoam/createFields.H b/applications/solvers/dfLowMachFoam/createFields.H index ac841f8b..96a92134 100644 --- a/applications/solvers/dfLowMachFoam/createFields.H +++ b/applications/solvers/dfLowMachFoam/createFields.H @@ -22,14 +22,6 @@ volScalarField rho thermo.rho() ); -dfChemistryModel chemistry(thermo); -PtrList& Y = chemistry.Y(); -const word inertSpecie(chemistry.lookup("inertSpecie")); -const label inertIndex(chemistry.species()[inertSpecie]); - -chemistry.correctThermo(); -Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; - Info<< "Reading field U\n" << endl; volVectorField U ( @@ -62,6 +54,21 @@ autoPtr turbulence ) ); +Info<< "Creating reaction model\n" << endl; +autoPtr> combustion +( + CombustionModel::New(thermo, turbulence()) +); +Info<< "end Creating reaction model\n" << endl; +dfChemistryModel* chemistry = combustion->chemistry(); +PtrList& Y = chemistry->Y(); +const word inertSpecie(chemistry->lookup("inertSpecie")); +const label inertIndex(chemistry->species()[inertSpecie]); + + +chemistry->correctThermo(); +Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; + Info<< "Creating field dpdt\n" << endl; volScalarField dpdt ( @@ -85,7 +92,7 @@ forAll(Y, i) } fields.add(thermo.he()); -const scalar Sct = chemistry.lookupOrDefault("Sct", 1.); +const scalar Sct = chemistry->lookupOrDefault("Sct", 1.); volScalarField diffsh ( IOobject diff --git a/applications/solvers/dfLowMachFoam/dfLowMachFoam.C b/applications/solvers/dfLowMachFoam/dfLowMachFoam.C index 482ee452..42232601 100644 --- a/applications/solvers/dfLowMachFoam/dfLowMachFoam.C +++ b/applications/solvers/dfLowMachFoam/dfLowMachFoam.C @@ -45,6 +45,8 @@ Description #include "localEulerDdtScheme.H" #include "fvcSmooth.H" #include "PstreamGlobals.H" +#include "basicThermo.H" +#include "CombustionModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -120,7 +122,7 @@ int main(int argc, char *argv[]) #include "YEqn.H"//added by zhangyan 20220226 #include "EEqn.H" - chemistry.correctThermo(); + chemistry->correctThermo(); Info<< "min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; // --- Pressure corrector loop diff --git a/applications/solvers/dfSprayFoam/Make/options b/applications/solvers/dfSprayFoam/Make/options index a7460794..0329a0fe 100644 --- a/applications/solvers/dfSprayFoam/Make/options +++ b/applications/solvers/dfSprayFoam/Make/options @@ -24,6 +24,7 @@ EXE_INC = -std=c++14 \ -I$(DF_SRC)/thermophysicalModels/SLGThermo/lnInclude \ -I$(DF_SRC)/CanteraMixture/lnInclude \ -I$(DF_SRC)/dfChemistryModel/lnInclude \ + -I$(DF_SRC)/dfCombustionModels/lnInclude \ -I$(CANTERA_ROOT)/include \ -I$(TORCH_ROOT)/include \ -I$(TORCH_ROOT)/include/torch/csrc/api/include @@ -49,6 +50,7 @@ EXE_LIBS = \ -ldfLagrangianSpray \ -lCanteraMixture \ -ldfChemistryModel \ + -ldfCombustionModels \ $(CANTERA_ROOT)/lib/libcantera.so \ $(TORCH_ROOT)/lib/libtorch.so \ $(TORCH_ROOT)/lib/libc10.so \ diff --git a/applications/solvers/dfSprayFoam/YEqn.H b/applications/solvers/dfSprayFoam/YEqn.H index 48f72d4a..4e31484a 100644 --- a/applications/solvers/dfSprayFoam/YEqn.H +++ b/applications/solvers/dfSprayFoam/YEqn.H @@ -10,8 +10,7 @@ tmp> mvConvection ); { - //combustion->correct(); - chemistry.solve(mesh.time().deltaTValue()); + combustion->correct(); volScalarField Yt(0.0*Y[0]); forAll(Y, i) @@ -27,7 +26,7 @@ tmp> mvConvection - fvm::laplacian(turbulence->muEff(), Yi) == parcels.SYi(i, Yi) - + chemistry.RR(i) + + combustion->R(Yi) //+ fvOptions(rho, Yi) ); diff --git a/applications/solvers/dfSprayFoam/createFields.H b/applications/solvers/dfSprayFoam/createFields.H index dc9fb0db..5758bc59 100644 --- a/applications/solvers/dfSprayFoam/createFields.H +++ b/applications/solvers/dfSprayFoam/createFields.H @@ -23,14 +23,6 @@ volScalarField rho thermo.rho() ); -dfChemistryModel chemistry(thermo); -PtrList& Y = chemistry.Y(); -const word inertSpecie(chemistry.lookup("inertSpecie")); -const label inertIndex(chemistry.species()[inertSpecie]); - -chemistry.correctThermo(); -Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; - Info<< "\nReading field U\n" << endl; volVectorField U ( @@ -83,6 +75,22 @@ autoPtr turbulence ) ); +Info<< "Creating reaction model\n" << endl; +autoPtr> combustion +( + CombustionModel::New(thermo, turbulence()) +); +Info<< "end Creating reaction model\n" << endl; +dfChemistryModel* chemistry = combustion->chemistry(); +PtrList& Y = chemistry->Y(); +const word inertSpecie(chemistry->lookup("inertSpecie")); +const label inertIndex(chemistry->species()[inertSpecie]); + + +chemistry->correctThermo(); +Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; + + Info<< "Creating field dpdt\n" << endl; volScalarField dpdt ( diff --git a/applications/solvers/dfSprayFoam/dfSprayFoam.C b/applications/solvers/dfSprayFoam/dfSprayFoam.C index cf033c4d..e3b6206a 100644 --- a/applications/solvers/dfSprayFoam/dfSprayFoam.C +++ b/applications/solvers/dfSprayFoam/dfSprayFoam.C @@ -43,6 +43,8 @@ Description #include "pimpleControl.H" #include "CorrectPhi.H" //#include "fvOptions.H" +#include "basicThermo.H" +#include "CombustionModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -134,7 +136,7 @@ int main(int argc, char *argv[]) #include "UEqn.H" #include "YEqn.H" #include "EEqn.H" - chemistry.correctThermo(); + chemistry->correctThermo(); Info<< "T gas min/max " << min(T).value() << ", " << max(T).value() << endl;