@@ -85,6 +85,24 @@ if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM);
8585 start1 = std::clock ();
8686 tmp<volScalarField> DEff = chemistry->rhoD (i) + turbulence->mut ()/Sct;
8787
88+ #ifdef ODE_GPU_SOLVER
89+ fvScalarMatrix YiEqn
90+ (
91+ fvm::ddt (rho, Yi)
92+ +
93+ (
94+ turbName == " laminar"
95+ ? (mvConvection->fvmDiv (phi, Yi) + mvConvection->fvmDiv (phiUc, Yi))
96+ : mvConvection->fvmDiv (phi, Yi)
97+ )
98+ ==
99+ (
100+ splitting
101+ ? fvm::laplacian (DEff (), Yi)
102+ : (fvm::laplacian (DEff (), Yi) + RR_GPU[i])
103+ )
104+ );
105+ #else
88106 fvScalarMatrix YiEqn
89107 (
90108 fvm::ddt (rho, Yi)
@@ -101,6 +119,7 @@ if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM);
101119 : (fvm::laplacian (DEff (), Yi) + combustion->R (Yi))
102120 )
103121 );
122+ #endif
104123
105124 end1 = std::clock ();
106125 time_monitor_YEqn_mtxAssembly += double (end1 - start1) / double (CLOCKS_PER_SEC);
@@ -264,7 +283,43 @@ if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM);
264283 if (!splitting)
265284 {
266285 std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now ();
286+
287+ #ifdef ODE_GPU_SOLVER
288+ scalar dt = runTime.deltaTValue ();
289+
290+ memcpy (h_T, &T[0 ], num_cells * sizeof (double ));
291+ memcpy (h_p, &p[0 ], num_cells * sizeof (double ));
292+
293+ forAll (Y, speciesI) {
294+ volScalarField& Yi = Y[speciesI];
295+ memcpy (h_y + speciesI * num_cells, &Yi[0 ], num_cells * sizeof (double ));
296+ }
297+
298+ for (int i = 0 ; i < num_cells; i++) {
299+ for (int j = 0 ; j < sp_num; j++) {
300+ h_y_t [j + i*sp_num] = h_y[i + j*num_cells];
301+ }
302+ }
303+
304+ opencc_ode_all (h_T, h_p, h_y_t , 1e-10 , dt, CPU);
305+
306+ for (int i = 0 ; i < num_cells; i++) {
307+ for (int j = 0 ; j < sp_num; j++) {
308+ Ynew[i + j*num_cells] = h_y_t [j + i*sp_num];
309+ }
310+ }
311+
312+ QdotGPU = Zero;
313+ forAll (QdotGPU,celli)
314+ {
315+ for (int sp = 0 ; sp < sp_num; sp++)
316+ {
317+ RRGPU[sp][celli] = (Ynew[sp*num_cells+celli]-Y[sp][celli])*rho[celli]/dt;
318+ }
319+ }
320+ #else
267321 combustion->correct ();
322+ #endif
268323 // label flag_mpi_init;
269324 // MPI_Initialized(&flag_mpi_init);
270325 if (flag_mpi_init) MPI_Barrier (PstreamGlobals::MPI_COMM_FOAM);
0 commit comments