Skip to content

Commit

Permalink
Merge pull request #506 from pkuLmq/master
Browse files Browse the repository at this point in the history
integrate lagrangian source term in dfLowMachFoam and modify test
  • Loading branch information
minzhang0929 authored Aug 19, 2024
2 parents b188d16 + 5360622 commit f8cb2cb
Show file tree
Hide file tree
Showing 81 changed files with 2,111 additions and 3 deletions.
14 changes: 14 additions & 0 deletions applications/solvers/dfLowMachFoam/EEqn.H
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
volScalarField& he = thermo.he();
tmp<fvScalarMatrix> thcSource(new fvScalarMatrix(he, dimEnergy/dimTime));
fvScalarMatrix& hcSource = thcSource.ref();
forAll(Y, i)
{
hcSource.source() -= parcels.rhoTrans(i)*chemistry->mixture().Hc(i)/runTime.deltaT();
}
//hSource.source() -= parcels.hsTrans()/runTime.deltaT();// equivalent to parcels.Sh(he)

start1 = std::clock();
fvScalarMatrix EEqn
(
Expand All @@ -15,10 +23,16 @@
fvm::laplacian(turbulence->alpha(), he)
- diffAlphaD
+ fvc::div(hDiffCorrFlux)
// + rho*(U&g)
+ parcels.Sh(he)
+ hcSource
)
:
(
fvm::laplacian(turbulence->alphaEff(), he)
// + rho*(U&g)
+ parcels.Sh(he)
+ hcSource
)
)
);
Expand Down
24 changes: 24 additions & 0 deletions applications/solvers/dfLowMachFoam/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,33 @@ EXE_INC = -std=c++14 \
-Wno-unused-variable \
-Wno-unused-but-set-variable \
-Wno-old-style-cast \
-I. \
$(PFLAGS) $(PINC) \
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
-I$(FOAM_APP)/solvers/lagrangian/reactingParcelFoam \
-I$(FOAM_APP)/solvers/compressible/rhoPimpleFoam \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(FOAM_APP)/solvers/lagrangian/reactingParcelFoam \
-I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(DF_SRC)/lagrangian/intermediate/lnInclude \
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
-I$(DF_SRC)/lagrangian/spray/lnInclude \
-I$(LIB_SRC)/lagrangian/spray/lnInclude \
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
-I$(DF_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
-I$(DF_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(LIB_SRC)/Pstream/mpi \
-I$(DF_SRC)/dfCanteraMixture/lnInclude \
-I$(DF_SRC)/dfChemistryModel/lnInclude \
Expand All @@ -35,12 +50,21 @@ EXE_INC = -std=c++14 \
EXE_LIBS = \
-lcompressibleTransportModels \
-lturbulenceModels \
-llagrangian \
-lregionModels \
-ldfSurfaceFilmModels \
-lfiniteVolume \
-ltopoChangerFvMesh \
-lmeshTools \
-lsampling \
-L$(DF_LIBBIN) \
-ldfFluidThermophysicalModels \
-ldfCompressibleTurbulenceModels \
-ldfThermophysicalProperties \
-ldfSLGThermo \
-ldfLagrangianIntermediate \
-ldfLagrangianTurbulence \
-ldfLagrangianSpray \
-ldfCanteraMixture \
-ldfChemistryModel \
-ldfCombustionModels \
Expand Down
3 changes: 3 additions & 0 deletions applications/solvers/dfLowMachFoam/UEqn.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
(
fvm::ddt(rho, U) + fvm::div(phi, U)
+ turbulence->divDevRhoReff(U)
==
// rho()*g
parcels.SU(U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
end1 = std::clock();
Expand Down
4 changes: 2 additions & 2 deletions applications/solvers/dfLowMachFoam/YEqn.H
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
==
(
splitting
? fvm::laplacian(DEff(), Yi)
: (fvm::laplacian(DEff(), Yi) + combustion->R(Yi))
? (fvm::laplacian(DEff(), Yi) + parcels.SYi(i, Yi) )
: (fvm::laplacian(DEff(), Yi) + parcels.SYi(i, Yi) + combustion->R(Yi))
)
);

Expand Down
9 changes: 9 additions & 0 deletions applications/solvers/dfLowMachFoam/createClouds.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Info<< "\nConstructing reacting cloud" << endl;
basicSprayCloud parcels
(
"sprayCloud",
rho,
U,
g,
slgThermo
);
6 changes: 6 additions & 0 deletions applications/solvers/dfLowMachFoam/createFields.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "createRDeltaT.H"
#include "readGravitationalAcceleration.H"

Info<< "Reading thermophysical properties\n" << endl;

Expand All @@ -7,6 +8,8 @@ fluidThermo* pThermo = new heRhoThermo<rhoThermo, CanteraMixture>(mesh, word::nu
fluidThermo& thermo = *pThermo;
// thermo.validate(args.executable(), "ha");

SLGThermo slgThermo(mesh, thermo);

const volScalarField& psi = thermo.psi();
volScalarField& p = thermo.p();
volScalarField& T = thermo.T();
Expand Down Expand Up @@ -115,6 +118,9 @@ volScalarField K("K", 0.5*magSqr(U));

multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;

#include "createMRF.H"
#include "createClouds.H"

if(combModelName!="ESF" && combModelName!="flareFGM" && combModelName!="DeePFGM" && combModelName!="FSD")
{
forAll(Y, i)
Expand Down
21 changes: 21 additions & 0 deletions applications/solvers/dfLowMachFoam/dfLowMachFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Description
#include "basicThermo.H"
#include "CombustionModel.H"

#include "basicSprayCloud.H"
#include "SLGThermo.H"

//#define GPUSolver_
// #define TIME
// #define DEBUG_
Expand Down Expand Up @@ -153,6 +156,7 @@ int main(int argc, char *argv[])
double time_monitor_Y = 0;
double time_monitor_E = 0;
double time_monitor_p = 0;
double time_monitor_parcels=0;
double time_monitor_chemistry_correctThermo = 0;
double time_monitor_turbulence_correct = 0;
double time_monitor_chem = 0; // combustion correct
Expand Down Expand Up @@ -261,6 +265,19 @@ int main(int argc, char *argv[])
runTime++;

Info<< "Time = " << runTime.timeName() << nl << endl;

if (parcels.solution().active())
{
start = std::clock();

// Store the particle positions
parcels.storeGlobalPositions();

parcels.evolve();

end = std::clock();
time_monitor_parcels += double(end - start) / double(CLOCKS_PER_SEC);
}

// store old time fields
#ifdef GPUSolver_
Expand Down Expand Up @@ -522,6 +539,10 @@ int main(int argc, char *argv[])
Info<< "Y Equations = " << time_monitor_Y - time_monitor_chem << " s" << endl;
Info<< "E Equations = " << time_monitor_E << " s" << endl;
Info<< "p Equations = " << time_monitor_p << " s" << endl;
if (parcels.solution().active())
{
Info<< "calculate parcels = " << time_monitor_parcels << " s" << endl;
}
Info<< "chemistry correctThermo = " << time_monitor_chemistry_correctThermo << " s" << endl;
Info<< "turbulence correct = " << time_monitor_turbulence_correct << " s" << endl;
Info<< "combustion correct(in Y) = " << time_monitor_chem << " s" << endl;
Expand Down
2 changes: 2 additions & 0 deletions applications/solvers/dfLowMachFoam/rhoEqn.H
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Description
(
fvm::ddt(rho)
+ fvc::div(phi)
==
parcels.Srho(rho)
);
end1 = std::clock();
time_monitor_rhoEqn += double(end1 - start1) / double(CLOCKS_PER_SEC);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class dictionary;
location "constant";
object SprayCloudProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solution
{
active false;
coupled false;
transient no;
cellValueSourceCorrection off;
}

// ************************************************************************* //
22 changes: 22 additions & 0 deletions examples/dfLowMachFoam/fgm/twoD_SandiaD_flareFGM/constant/g
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class uniformDimensionedVectorField;
location "constant";
object g;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -2 0 0 0 0];
value (0 -9.81 0);


// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class dictionary;
location "constant";
object SprayCloudProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solution
{
active false;
coupled false;
transient no;
cellValueSourceCorrection off;
}

// ************************************************************************* //
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions examples/dfLowMachFoam/notorch/threeD_aachenBomb/Allclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

echo "Cleaning log.*"
rm log.*
echo "Cleaning processor*"
rm -r processor*
echo "Cleaning polyMesh/"
rm -r constant/polyMesh
11 changes: 11 additions & 0 deletions examples/dfLowMachFoam/notorch/threeD_aachenBomb/Allrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

application=dfSprayFoam

runApplication blockMesh
runApplication decomposePar
runApplication mpirun -np 4 --allow-run-as-root $application -parallel
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object CanteraTorchProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

chemistry on;

CanteraMechanismFile "C7_oneStep.yaml";

transportModel "Mix";

odeCoeffs
{
"relTol" 1e-6;
"absTol" 1e-10;
}

inertSpecie "N2";

splittingStrategy off;

TorchSettings
{
torch off;
GPU off;
log off;
torchModel "";
coresPerNode 4;
}

loadbalancing
{
active true;
log false;
algorithm allAverage;//headTail;
}


// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object combustionProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

combustionModel laminar;

// ************************************************************************* //
22 changes: 22 additions & 0 deletions examples/dfLowMachFoam/notorch/threeD_aachenBomb/constant/g
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class uniformDimensionedVectorField;
location "constant";
object g;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -2 0 0 0 0];
value (0 -9.81 0);


// ************************************************************************* //
Loading

0 comments on commit f8cb2cb

Please sign in to comment.