Skip to content

Commit c451018

Browse files
authored
realize RK2SSP and RK3SSP in dfHighSpeedFoam and add wrate option for chemistry calculation (#309)
* realize RK2SSP and RK3SSP in dfHighSpeedFoam and add wrate opption for chemistry * a little fix
1 parent 7d51928 commit c451018

11 files changed

Lines changed: 570 additions & 243 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
start = std::clock();
2+
3+
combustion->correct();
4+
5+
label flag_mpi_init;
6+
MPI_Initialized(&flag_mpi_init);
7+
if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM);
8+
end = std::clock();
9+
time_monitor_chem += double(end - start) / double(CLOCKS_PER_SEC);
10+
11+
volScalarField Yt(0.0*Y[0]);
12+
13+
start = std::clock();
14+
forAll(Y, i)
15+
{
16+
volScalarField& Yi = Y[i];
17+
18+
if (i != inertIndex)
19+
{
20+
rhoYi[i].ref() += chemistry->RR(i)*runTime.deltaT();
21+
Info <<"max reaction rate "<< Yi.name() << " is " << max(chemistry->RR(i)).value() << endl;
22+
23+
Yi = rhoYi[i]/rho;
24+
Yi.max(0.0);
25+
26+
Yi.correctBoundaryConditions();
27+
rhoYi[i] = rho*Yi;
28+
Yt += Yi;
29+
}
30+
}
31+
32+
Y[inertIndex] = scalar(1) - Yt;
33+
Y[inertIndex].max(0.0);
34+
rhoYi[inertIndex] = rho*Y[inertIndex];
35+
36+
end = std::clock();
37+
time_monitor_Y += double(end - start) / double(CLOCKS_PER_SEC);
38+
39+
chemistry->correctThermo();
40+
Info<< "min/max(T) = "
41+
<< min(T).value() << ", " << max(T).value() << endl;
42+
43+
p.ref() = rho()/psi();
44+
p.correctBoundaryConditions();
45+
rho.boundaryFieldRef() == psi.boundaryField()*p.boundaryField();
46+
47+
48+
Info << " finish calculate Reaction" << nl << endl;
49+

applications/solvers/dfHighSpeedFoam/createFields.H

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
#include "createRDeltaT.H"
22

3+
word ddtSchemes("Euler");
4+
if (mesh.schemesDict().readIfPresent("timeScheme", ddtSchemes))
5+
{
6+
if(ddtSchemes == "RK2SSP" || ddtSchemes == "RK3SSP")
7+
{
8+
Info<< "ddtSchemes: " << ddtSchemes << endl;
9+
}
10+
}
11+
12+
word chemScheme("RR");
13+
mesh.schemesDict().readIfPresent("chemScheme", chemScheme);
14+
15+
if ((chemScheme == "wrate") || (chemScheme == "RR"))
16+
{
17+
Info<< "chemScheme: " << chemScheme << endl;
18+
}
19+
else
20+
{
21+
FatalErrorInFunction
22+
<< "chemScheme: " << chemScheme
23+
<< " is not a valid choice. "
24+
<< "Options are: wrate, RR"
25+
<< abort(FatalError);
26+
}
27+
28+
29+
if((ddtSchemes != "RK2SSP") && (ddtSchemes != "RK3SSP"))
30+
{
31+
if(chemScheme == "wrate")
32+
{
33+
FatalErrorInFunction
34+
<< "This combination is not a valid choice. "
35+
<< "If you want to use wrate for chemistry, please use RK2SSP or RK3SSP scheme."
36+
<< abort(FatalError);
37+
}
38+
}
39+
40+
41+
342
Info<< "Reading thermophysical properties\n" << endl;
443

544
// psiThermo* pThermo = new hePsiThermo<psiThermo, CanteraMixture>(mesh, word::null);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
volScalarField rho_save("rho_save",thermo.rho());
2+
3+
volVectorField rhoU_save("rhoU_save",rho*U);
4+
5+
volScalarField rhoE_save("rhoE_save",rho*(ea + 0.5*magSqr(U)));
6+
7+
PtrList<volScalarField> rhoYi_save(nspecies);
8+
forAll(rhoYi_save,i)
9+
{
10+
rhoYi_save.set
11+
(
12+
i,
13+
new volScalarField
14+
(
15+
IOobject
16+
(
17+
"rhoYi_save" + Y[i].name(),
18+
runTime.timeName(),
19+
mesh,
20+
IOobject::NO_READ,
21+
IOobject::NO_WRITE
22+
),
23+
rho*Y[i]
24+
)
25+
);
26+
}
27+

0 commit comments

Comments
 (0)