Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions applications/solvers/dfLowMachFoam/UEqn.H
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

TICK_START;
U.oldTime();
memcpy(h_u, &U.oldTime()[0][0], dfDataBase.cell_value_vec_bytes);
memcpy(h_u, &U.oldTime()[0][0], dfDataBase.cell_value_vec_bytes);
memcpy(h_p, &p[0], dfDataBase.cell_value_bytes);
memcpy(h_nu_eff, &nuEff[0], dfDataBase.cell_value_bytes);
TICK_STOP(copy to pinned memory);
Expand Down Expand Up @@ -177,30 +177,34 @@
// postProcess
TICK_START;
UEqn_GPU.postProcess(h_u);
memcpy(&U[0][0], h_u, dfDataBase.cell_value_vec_bytes);
U.correctBoundaryConditions();
K = 0.5*magSqr(U);
DEBUG_TRACE;
TICK_STOP(post process time);

// checkResult
// TODO: for temp, now we compare ldu, finally we compare csr
std::vector<double> h_internal_coeffs(dfDataBase.num_boundary_surfaces * 3);
std::vector<double> h_boundary_coeffs(dfDataBase.num_boundary_surfaces * 3);
offset = 0;
for (int patchi = 0; patchi < dfDataBase.num_patches; patchi++)
{
int patchsize = dfDataBase.patch_size[patchi];
const double* internal_coeff_ptr = &UEqn.internalCoeffs()[patchi][0][0];
const double* boundary_coeff_ptr = &UEqn.boundaryCoeffs()[patchi][0][0];
memcpy(h_internal_coeffs.data() + offset * 3, internal_coeff_ptr, patchsize * 3 * sizeof(double));
memcpy(h_boundary_coeffs.data() + offset * 3, boundary_coeff_ptr, patchsize * 3 * sizeof(double));
offset += patchsize;
}
bool printFlag = false;
UEqn_GPU.compareResult(&UEqn.lower()[0], &UEqn.upper()[0], &UEqn.diag()[0], &UEqn.source()[0][0],
h_internal_coeffs.data(), h_boundary_coeffs.data(),
// &DivTensor[0][0],
printFlag);
DEBUG_TRACE;
// std::vector<double> h_internal_coeffs(dfDataBase.num_boundary_surfaces * 3);
// std::vector<double> h_boundary_coeffs(dfDataBase.num_boundary_surfaces * 3);
// Info << "location 0 " << endl;
// offset = 0;
// for (int patchi = 0; patchi < dfDataBase.num_patches; patchi++)
// {
// int patchsize = dfDataBase.patch_size[patchi];
// const double* internal_coeff_ptr = &UEqn.internalCoeffs()[patchi][0][0];
// const double* boundary_coeff_ptr = &UEqn.boundaryCoeffs()[patchi][0][0];
// memcpy(h_internal_coeffs.data() + offset * 3, internal_coeff_ptr, patchsize * 3 * sizeof(double));
// memcpy(h_boundary_coeffs.data() + offset * 3, boundary_coeff_ptr, patchsize * 3 * sizeof(double));
// offset += patchsize;
// }
// bool printFlag = false;
// UEqn_GPU.compareResult(&UEqn.lower()[0], &UEqn.upper()[0], &UEqn.diag()[0], &UEqn.source()[0][0],
// h_internal_coeffs.data(), h_boundary_coeffs.data(),
// // &DivTensor[0][0],
// printFlag);
// DEBUG_TRACE;

#else
start1 = std::clock();
tmp<fvVectorMatrix> tUEqn
Expand Down
116 changes: 0 additions & 116 deletions applications/solvers/dfLowMachFoam/new_UEqn.H

This file was deleted.

113 changes: 0 additions & 113 deletions applications/solvers/dfLowMachFoam/new_dfLowMachFoam.C

This file was deleted.

43 changes: 43 additions & 0 deletions applications/solvers/dfLowMachFoam/pEqn.H
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,52 @@ const volScalarField psip0(psi*p);
time_monitor_UEqn_A_correctBC += double(end1 - start1) / double(CLOCKS_PER_SEC);
#endif

#ifdef GPUSolverNew_
volVectorField UEqn_H
(
IOobject
(
"H("+U.name()+')',
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector(dimensionSet(1,-2,-2,0,0,0,0), Zero),
extrapolatedCalculatedFvPatchScalarField::typeName
);
UEqn_GPU.H(&UEqn_H[0][0]);
UEqn_H.correctBoundaryConditions();

volScalarField UEqn_A
(
IOobject
(
"A("+U.name()+')',
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(dimensionSet(1,-3,-1,0,0,0,0), Zero),
extrapolatedCalculatedFvPatchScalarField::typeName
);
UEqn_GPU.A(&UEqn_A[0]);
UEqn_A.correctBoundaryConditions();
#endif


start2 = std::clock();
#ifdef GPUSolver_
volScalarField rAU(1.0/UEqn_A);
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn_H, U, p));
#elif defined GPUSolverNew_
volScalarField rAU(1.0/UEqn_A);
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn_H, U, p));
#else
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
Expand Down Expand Up @@ -179,6 +220,8 @@ K = 0.5*magSqr(U);
end1 = std::clock();
time_monitor_UEqn += double(end1 - start1) / double(CLOCKS_PER_SEC);
time_monitor_UEqn_correctBC += double(end1 - start1) / double(CLOCKS_PER_SEC);
#elif defined GPUSolverNew_
UEqn_GPU.correctPsi(&U[0][0]);
#endif

if (pimple.simpleRho())
Expand Down
1 change: 1 addition & 0 deletions src_gpu/dfMatrixDataBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ struct dfMatrixDataBase
int *d_lower_to_csr_index = nullptr;
int *d_diag_to_csr_index= nullptr;
int *d_upper_to_csr_index= nullptr;
int *d_ldu_to_csr_index = nullptr;
int *d_csr_row_index= nullptr;
int *d_csr_col_index= nullptr;

Expand Down
Loading