cleanup with help from valgrind
This commit is contained in:
@@ -263,7 +263,7 @@ Membrane::~Membrane() {
|
||||
delete [] membraneLinks;
|
||||
delete [] membraneTag;
|
||||
delete [] membraneDist;
|
||||
|
||||
|
||||
ScaLBL_FreeDeviceMemory( coefficient_x );
|
||||
ScaLBL_FreeDeviceMemory( coefficient_X );
|
||||
ScaLBL_FreeDeviceMemory( coefficient_y );
|
||||
@@ -274,6 +274,7 @@ Membrane::~Membrane() {
|
||||
ScaLBL_FreeDeviceMemory( NeighborList );
|
||||
ScaLBL_FreeDeviceMemory( MembraneLinks );
|
||||
ScaLBL_FreeDeviceMemory( MembraneCoef );
|
||||
ScaLBL_FreeDeviceMemory( MembraneDistance );
|
||||
|
||||
ScaLBL_FreeDeviceMemory( sendbuf_x );
|
||||
ScaLBL_FreeDeviceMemory( sendbuf_X );
|
||||
@@ -730,7 +731,6 @@ int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArra
|
||||
}
|
||||
|
||||
if (rank == 0) printf(" Create device data structures... \n");
|
||||
|
||||
/* Create device copies of data structures */
|
||||
ScaLBL_AllocateDeviceMemory((void **)&MembraneLinks, 2*mlink*sizeof(int));
|
||||
ScaLBL_AllocateDeviceMemory((void **)&MembraneCoef, 2*mlink*sizeof(double));
|
||||
@@ -995,6 +995,7 @@ int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArra
|
||||
ScaLBL_AllocateZeroCopy((void **) &coefficient_Z, (recvCount_Z - linkCount_Z[0])*sizeof(double));
|
||||
//......................................................................................
|
||||
|
||||
delete [] neighborList;
|
||||
delete [] TempBuffer;
|
||||
return mlink;
|
||||
}
|
||||
@@ -1355,40 +1356,46 @@ void Membrane::AssignCoefficients(int *Map, double *Psi, double Threshold,
|
||||
double MassFractionIn, double MassFractionOut, double ThresholdMassFractionIn,
|
||||
double ThresholdMassFractionOut){
|
||||
/* Assign mass transfer coefficients to the membrane data structure */
|
||||
|
||||
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef(MembraneLinks, Map, MembraneDistance, Psi, MembraneCoef,
|
||||
Threshold, MassFractionIn, MassFractionOut, ThresholdMassFractionIn, ThresholdMassFractionOut,
|
||||
membraneLinkCount, Nx, Ny, Nz, Np);
|
||||
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(-1,0,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_X,dvcRecvLinks_X,coefficient_X,0,linkCount_X[0],recvCount_X,
|
||||
Np,Nx,Ny,Nz);
|
||||
if (membraneLinkCount > 0)
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef(MembraneLinks, Map, MembraneDistance, Psi, MembraneCoef,
|
||||
Threshold, MassFractionIn, MassFractionOut, ThresholdMassFractionIn, ThresholdMassFractionOut,
|
||||
membraneLinkCount, Nx, Ny, Nz, Np);
|
||||
|
||||
if (linkCount_X[0] < recvCount_X)
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(-1,0,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_X,dvcRecvLinks_X,coefficient_X,0,linkCount_X[0],recvCount_X,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
if (linkCount_x[0] < recvCount_x)
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(1,0,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_x,dvcRecvLinks_x,coefficient_x,0,linkCount_x[0],recvCount_x,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
if (linkCount_Y[0] < recvCount_Y)
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,-1,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_Y,dvcRecvLinks_Y,coefficient_Y,0,linkCount_Y[0],recvCount_Y,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
if (linkCount_y[0]<recvCount_y)
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,1,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_y,dvcRecvLinks_y,coefficient_y,0,linkCount_y[0],recvCount_y,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
if (linkCount_Z[0]<recvCount_Z)
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,0,-1,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_Z,dvcRecvLinks_Z,coefficient_Z,0,linkCount_Z[0],recvCount_Z,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
if (linkCount_z[0]<recvCount_z)
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,0,1,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_z,dvcRecvLinks_z,coefficient_z,0,linkCount_z[0],recvCount_z,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(1,0,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_x,dvcRecvLinks_x,coefficient_x,0,linkCount_x[0],recvCount_x,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,-1,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_Y,dvcRecvLinks_Y,coefficient_Y,0,linkCount_Y[0],recvCount_Y,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,1,0,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_y,dvcRecvLinks_y,coefficient_y,0,linkCount_y[0],recvCount_y,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,0,-1,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_Z,dvcRecvLinks_Z,coefficient_Z,0,linkCount_Z[0],recvCount_Z,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
ScaLBL_D3Q7_Membrane_AssignLinkCoef_halo(0,0,1,Map,MembraneDistance,Psi,Threshold,
|
||||
MassFractionIn,MassFractionOut,ThresholdMassFractionIn,ThresholdMassFractionOut,
|
||||
dvcRecvDist_z,dvcRecvLinks_z,coefficient_z,0,linkCount_z[0],recvCount_z,
|
||||
Np,Nx,Ny,Nz);
|
||||
|
||||
}
|
||||
|
||||
@@ -1114,302 +1114,313 @@ void ScaLBL_Communicator::SetupBounceBackList(IntArray &Map, signed char *id, in
|
||||
}
|
||||
}
|
||||
}
|
||||
if (local_count > 0){
|
||||
|
||||
int *bb_dist_tmp = new int [local_count];
|
||||
int *bb_interactions_tmp = new int [local_count];
|
||||
ScaLBL_AllocateDeviceMemory((void **) &bb_dist, sizeof(int)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &bb_interactions, sizeof(int)*local_count);
|
||||
int *fluid_boundary_tmp;
|
||||
double *lattice_weight_tmp;
|
||||
float *lattice_cx_tmp;
|
||||
float *lattice_cy_tmp;
|
||||
float *lattice_cz_tmp;
|
||||
/* allocate memory for bounce-back sites */
|
||||
fluid_boundary_tmp = new int [local_count];
|
||||
lattice_weight_tmp = new double [local_count];
|
||||
lattice_cx_tmp = new float [local_count];
|
||||
lattice_cy_tmp = new float [local_count];
|
||||
lattice_cz_tmp = new float [local_count];
|
||||
ScaLBL_AllocateDeviceMemory((void **) &fluid_boundary, sizeof(int)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_weight, sizeof(double)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cx, sizeof(float)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cy, sizeof(float)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cz, sizeof(float)*local_count);
|
||||
int *bb_dist_tmp = new int [local_count];
|
||||
int *bb_interactions_tmp = new int [local_count];
|
||||
ScaLBL_AllocateDeviceMemory((void **) &bb_dist, sizeof(int)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &bb_interactions, sizeof(int)*local_count);
|
||||
int *fluid_boundary_tmp;
|
||||
double *lattice_weight_tmp;
|
||||
float *lattice_cx_tmp;
|
||||
float *lattice_cy_tmp;
|
||||
float *lattice_cz_tmp;
|
||||
/* allocate memory for bounce-back sites */
|
||||
fluid_boundary_tmp = new int [local_count];
|
||||
lattice_weight_tmp = new double [local_count];
|
||||
lattice_cx_tmp = new float [local_count];
|
||||
lattice_cy_tmp = new float [local_count];
|
||||
lattice_cz_tmp = new float [local_count];
|
||||
ScaLBL_AllocateDeviceMemory((void **) &fluid_boundary, sizeof(int)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_weight, sizeof(double)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cx, sizeof(float)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cy, sizeof(float)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cz, sizeof(float)*local_count);
|
||||
|
||||
local_count=0;
|
||||
for (k=1;k<Nz-1;k++){
|
||||
for (j=1;j<Ny-1;j++){
|
||||
for (i=1;i<Nx-1;i++){
|
||||
n=k*Nx*Ny+j*Nx+i;
|
||||
idx=Map(i,j,k);
|
||||
if (!(idx<0)){
|
||||
local_count=0;
|
||||
for (k=1;k<Nz-1;k++){
|
||||
for (j=1;j<Ny-1;j++){
|
||||
for (i=1;i<Nx-1;i++){
|
||||
n=k*Nx*Ny+j*Nx+i;
|
||||
idx=Map(i,j,k);
|
||||
if (!(idx<0)){
|
||||
|
||||
int neighbor; // cycle through the neighbors of lattice site idx
|
||||
neighbor=Map(i-1,j,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
int neighbor; // cycle through the neighbors of lattice site idx
|
||||
neighbor=Map(i-1,j,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 2*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
neighbor=Map(i+1,j,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++] = idx + 1*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
neighbor=Map(i,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 4*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j+1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
neighbor=Map(i,j+1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 3*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
neighbor=Map(i,j,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 6*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
neighbor=Map(i,j,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 5*Np;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
n_bb_d3q7 = local_count;
|
||||
for (k=1;k<Nz-1;k++){
|
||||
for (j=1;j<Ny-1;j++){
|
||||
for (i=1;i<Nx-1;i++){
|
||||
n=k*Nx*Ny+j*Nx+i;
|
||||
idx=Map(i,j,k);
|
||||
if (!(idx<0)){
|
||||
n_bb_d3q7 = local_count;
|
||||
for (k=1;k<Nz-1;k++){
|
||||
for (j=1;j<Ny-1;j++){
|
||||
for (i=1;i<Nx-1;i++){
|
||||
n=k*Nx*Ny+j*Nx+i;
|
||||
idx=Map(i,j,k);
|
||||
if (!(idx<0)){
|
||||
|
||||
neighbor=Map(i-1,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
neighbor=Map(i-1,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 8*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j+1,k);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
neighbor=Map(i+1,j+1,k);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 7*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i-1,j+1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
neighbor=Map(i-1,j+1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 10*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
neighbor=Map(i+1,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 9*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i-1,j,k-1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
neighbor=Map(i-1,j,k-1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 12*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
neighbor=Map(i+1,j,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 11*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i-1,j,k+1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
neighbor=Map(i-1,j,k+1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 14*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j,k-1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
neighbor=Map(i+1,j,k-1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 13*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j-1,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
neighbor=Map(i,j-1,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 16*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j+1,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
neighbor=Map(i,j+1,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 15*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j-1,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
neighbor=Map(i,j-1,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k+1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 18*Np;
|
||||
}
|
||||
}
|
||||
|
||||
neighbor=Map(i,j+1,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
neighbor=Map(i,j+1,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k-1)*Nx*Ny;
|
||||
//if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
//}
|
||||
bb_dist_tmp[local_count++]=idx + 17*Np;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
n_bb_d3q19 = local_count; // this gives the d3q19 distributions not part of d3q7 model
|
||||
ScaLBL_CopyToDevice(bb_dist, bb_dist_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(bb_interactions, bb_interactions_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(fluid_boundary, fluid_boundary_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(lattice_weight, lattice_weight_tmp, local_count*sizeof(double));
|
||||
ScaLBL_CopyToDevice(lattice_cx, lattice_cx_tmp, local_count*sizeof(float));
|
||||
ScaLBL_CopyToDevice(lattice_cy, lattice_cy_tmp, local_count*sizeof(float));
|
||||
ScaLBL_CopyToDevice(lattice_cz, lattice_cz_tmp, local_count*sizeof(float));
|
||||
ScaLBL_DeviceBarrier();
|
||||
n_bb_d3q19 = local_count; // this gives the d3q19 distributions not part of d3q7 model
|
||||
ScaLBL_CopyToDevice(bb_dist, bb_dist_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(bb_interactions, bb_interactions_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(fluid_boundary, fluid_boundary_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(lattice_weight, lattice_weight_tmp, local_count*sizeof(double));
|
||||
ScaLBL_CopyToDevice(lattice_cx, lattice_cx_tmp, local_count*sizeof(float));
|
||||
ScaLBL_CopyToDevice(lattice_cy, lattice_cy_tmp, local_count*sizeof(float));
|
||||
ScaLBL_CopyToDevice(lattice_cz, lattice_cz_tmp, local_count*sizeof(float));
|
||||
ScaLBL_DeviceBarrier();
|
||||
|
||||
delete [] bb_dist_tmp;
|
||||
delete [] bb_interactions_tmp;
|
||||
delete [] fluid_boundary_tmp;
|
||||
delete [] lattice_weight_tmp;
|
||||
delete [] lattice_cx_tmp;
|
||||
delete [] lattice_cy_tmp;
|
||||
delete [] lattice_cz_tmp;
|
||||
delete [] bb_dist_tmp;
|
||||
delete [] bb_interactions_tmp;
|
||||
delete [] fluid_boundary_tmp;
|
||||
delete [] lattice_weight_tmp;
|
||||
delete [] lattice_cx_tmp;
|
||||
delete [] lattice_cy_tmp;
|
||||
delete [] lattice_cz_tmp;
|
||||
}
|
||||
else {
|
||||
bb_dist = NULL;
|
||||
bb_interactions = NULL;
|
||||
fluid_boundary = NULL;
|
||||
lattice_weight = NULL;
|
||||
lattice_cx = NULL;
|
||||
lattice_cy = NULL;
|
||||
lattice_cz = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ScaLBL_Communicator::SolidDirichletD3Q7(double *fq, double *BoundaryValue){
|
||||
|
||||
@@ -13,7 +13,20 @@ ScaLBL_IonModel::ScaLBL_IonModel(int RANK, int NP, const Utilities::MPI &COMM)
|
||||
nprocy(0), nprocz(0), fluidVelx_dummy(0), fluidVely_dummy(0),
|
||||
fluidVelz_dummy(0), BoundaryConditionInlet(0), BoundaryConditionOutlet(0),
|
||||
BoundaryConditionSolid(0), Lx(0), Ly(0), Lz(0), comm(COMM) {}
|
||||
ScaLBL_IonModel::~ScaLBL_IonModel() {}
|
||||
|
||||
ScaLBL_IonModel::~ScaLBL_IonModel() {
|
||||
|
||||
ScaLBL_FreeDeviceMemory(NeighborList);
|
||||
ScaLBL_FreeDeviceMemory(dvcMap);
|
||||
ScaLBL_FreeDeviceMemory(fq);
|
||||
ScaLBL_FreeDeviceMemory(Ci);
|
||||
ScaLBL_FreeDeviceMemory(ChargeDensity);
|
||||
ScaLBL_FreeDeviceMemory(FluxDiffusive);
|
||||
ScaLBL_FreeDeviceMemory(FluxAdvective);
|
||||
ScaLBL_FreeDeviceMemory(FluxElectrical);
|
||||
ScaLBL_FreeDeviceMemory(IonSolid);
|
||||
ScaLBL_FreeDeviceMemory(FluidVelocityDummy);
|
||||
}
|
||||
|
||||
void ScaLBL_IonModel::ReadParams(string filename, vector<int> &num_iter) {
|
||||
|
||||
@@ -50,6 +63,8 @@ void ScaLBL_IonModel::ReadParams(string filename, vector<int> &num_iter) {
|
||||
Ez_dummy = 0.0; //for debugging, unit [V/m]
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
BoundaryConditionSolid = 0;
|
||||
|
||||
// Read domain parameters
|
||||
if (domain_db->keyExists("voxel_length")) { //default unit: um/lu
|
||||
h = domain_db->getScalar<double>("voxel_length");
|
||||
@@ -685,7 +700,6 @@ void ScaLBL_IonModel::SetDomain() {
|
||||
}
|
||||
|
||||
void ScaLBL_IonModel::SetMembrane() {
|
||||
size_t NLABELS = 0;
|
||||
|
||||
membrane_db = db->getDatabase("Membrane");
|
||||
|
||||
@@ -693,7 +707,7 @@ void ScaLBL_IonModel::SetMembrane() {
|
||||
auto MembraneLabels = membrane_db->getVector<int>("MembraneLabels");
|
||||
|
||||
IonMembrane = std::shared_ptr<Membrane>(new Membrane(Dm, NeighborList, Np));
|
||||
|
||||
size_t NLABELS = MembraneLabels.size();
|
||||
signed char LABEL = 0;
|
||||
double *label_count;
|
||||
double *label_count_global;
|
||||
@@ -1020,7 +1034,6 @@ void ScaLBL_IonModel::Create() {
|
||||
}
|
||||
ScaLBL_CopyToDevice(dvcMap, TmpMap, sizeof(int) * Np);
|
||||
ScaLBL_Comm->Barrier();
|
||||
delete[] TmpMap;
|
||||
|
||||
ScaLBL_CopyToDevice(NeighborList, neighborList, neighborSize);
|
||||
comm.barrier();
|
||||
@@ -1042,6 +1055,13 @@ void ScaLBL_IonModel::Create() {
|
||||
ScaLBL_Comm->Barrier();
|
||||
delete[] IonSolid_host;
|
||||
}
|
||||
else {
|
||||
IonSolid = NULL;
|
||||
}
|
||||
|
||||
|
||||
delete[] TmpMap;
|
||||
delete[] neighborList;
|
||||
}
|
||||
|
||||
void ScaLBL_IonModel::Initialize() {
|
||||
@@ -1444,6 +1464,7 @@ void ScaLBL_IonModel::RunMembrane(double *Velocity, double *ElectricField, doubl
|
||||
//auto t1 = std::chrono::system_clock::now();
|
||||
|
||||
for (size_t ic = 0; ic < number_ion_species; ic++) {
|
||||
|
||||
/* set the mass transfer coefficients for the membrane */
|
||||
IonMembrane->AssignCoefficients(dvcMap, Psi, ThresholdVoltage[ic],MassFractionIn[ic],
|
||||
MassFractionOut[ic],ThresholdMassFractionIn[ic],ThresholdMassFractionOut[ic]);
|
||||
@@ -1525,8 +1546,6 @@ void ScaLBL_IonModel::RunMembrane(double *Velocity, double *ElectricField, doubl
|
||||
//Compute charge density for Poisson equation
|
||||
for (size_t ic = 0; ic < number_ion_species; ic++) {
|
||||
int Valence = IonValence[ic];
|
||||
if (rank==0) printf("compute charge density for ion %i, Valence =%i \n", ic,Valence);
|
||||
|
||||
ScaLBL_D3Q7_Ion_ChargeDensity(Ci, ChargeDensity, Valence, ic,
|
||||
ScaLBL_Comm->FirstInterior(),
|
||||
ScaLBL_Comm->LastInterior(), Np);
|
||||
|
||||
@@ -32,6 +32,14 @@ ScaLBL_Poisson::ScaLBL_Poisson(int RANK, int NP, const Utilities::MPI& COMM):
|
||||
}
|
||||
ScaLBL_Poisson::~ScaLBL_Poisson()
|
||||
{
|
||||
ScaLBL_FreeDeviceMemory(NeighborList);
|
||||
ScaLBL_FreeDeviceMemory(dvcMap);
|
||||
ScaLBL_FreeDeviceMemory(Psi);
|
||||
ScaLBL_FreeDeviceMemory(Psi_BCLabel);
|
||||
ScaLBL_FreeDeviceMemory(ElectricField);
|
||||
ScaLBL_FreeDeviceMemory(ResidualError);
|
||||
ScaLBL_FreeDeviceMemory(fq);
|
||||
|
||||
if ( TIMELOG )
|
||||
fclose( TIMELOG );
|
||||
}
|
||||
@@ -416,6 +424,7 @@ void ScaLBL_Poisson::Create(){
|
||||
//ScaLBL_Comm->Barrier();
|
||||
|
||||
//Initialize solid boundary for electric potential
|
||||
// DON'T USE WITH CELLULAR SYSTEM (NO SOLID -- NEED Membrane SOLUTION)
|
||||
ScaLBL_Comm->SetupBounceBackList(Map, Mask->id.data(), Np);
|
||||
comm.barrier();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ using namespace std;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Initialize MPI and error handlers
|
||||
Utilities::startup( argc, argv );
|
||||
//Utilities::startup( argc, argv );
|
||||
Utilities::startup( argc, argv, true );
|
||||
|
||||
Utilities::MPI comm( MPI_COMM_WORLD );
|
||||
int rank = comm.getRank();
|
||||
int nprocs = comm.getSize();
|
||||
|
||||
Reference in New Issue
Block a user