diff --git a/applications/solvers/dfLowMachFoam/YEqn.H b/applications/solvers/dfLowMachFoam/YEqn.H index 01dd085b..7e16f4ec 100644 --- a/applications/solvers/dfLowMachFoam/YEqn.H +++ b/applications/solvers/dfLowMachFoam/YEqn.H @@ -287,9 +287,6 @@ if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM); #ifdef ODE_GPU_SOLVER scalar dt = runTime.deltaTValue(); - memcpy(h_T, &T[0], num_cells * sizeof(double)); - memcpy(h_p, &p[0], num_cells * sizeof(double)); - forAll(Y, speciesI) { volScalarField& Yi = Y[speciesI]; memcpy(h_y + speciesI * num_cells, &Yi[0], num_cells * sizeof(double)); @@ -301,7 +298,7 @@ if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM); } } - opencc_ode_all(h_T, h_p, h_y_t, 1e-10, dt, CPU); + opencc_ode_all(&T[0], &p[0], h_y_t, 1e-10, dt, CPU); for (int i = 0; i < num_cells; i++) { for (int j = 0; j < sp_num; j++) { diff --git a/applications/solvers/dfLowMachFoam/createFields_GPU.H b/applications/solvers/dfLowMachFoam/createFields_GPU.H index fc115f80..78058253 100755 --- a/applications/solvers/dfLowMachFoam/createFields_GPU.H +++ b/applications/solvers/dfLowMachFoam/createFields_GPU.H @@ -44,28 +44,20 @@ forAll(RRGPU, fieldi) int num_cells = T.size(); int num_species = Y.size(); -double* h_T = new double[num_cells]; -double* h_p = new double[num_cells]; -double* h_y = new double[num_cells * num_species]; -double* h_y_t = new double[num_cells * num_species]; -int* h_size = new int[1]; - -memcpy(h_T, &T[0], num_cells * sizeof(double)); -memcpy(h_p, &p[0], num_cells * sizeof(double)); +std::unique_ptr unique_y(new double[num_cells * num_species]); double* h_y = unique_y.get(); +std::unique_ptr unique_y_t(new double[num_cells * num_species]); double* h_y_t = unique_y_t.get(); forAll(Y, speciesI) { volScalarField& Yi = Y[speciesI]; memcpy(h_y + speciesI * num_cells, &Yi[0], num_cells * sizeof(double)); } -h_size[0] = num_cells; - int sp_num = num_species; string mechanismFile = CanteraTorchProperties.lookupOrDefault("CanteraMechanismFile", string("")); char target_mechanismFile[100]; std::strcpy(target_mechanismFile, mechanismFile.c_str()); -opencc_ode_init(target_mechanismFile, num_cells, h_T, h_p, h_y); +opencc_ode_init(target_mechanismFile, num_cells, &T[0], &p[0], h_y); double* Ynew = new double[num_cells * num_species];