Fixed bug in memory layout
This commit is contained in:
parent
ee610b0c72
commit
5f55e1c5b0
@ -389,7 +389,7 @@ int ScaLBL_Communicator::MemoryOptimizedLayoutAA(IntArray &Map, int *neighborLis
|
||||
Map(i,j,k) = -1;
|
||||
// Local index
|
||||
n = k*Nx*Ny+j*Nx+i;
|
||||
if (id[n] != 0){
|
||||
if (id[n] > 0){
|
||||
// Counts for the six faces
|
||||
if (i==1) Map(n)=idx++;
|
||||
else if (j==1) Map(n)=idx++;
|
||||
@ -415,7 +415,7 @@ int ScaLBL_Communicator::MemoryOptimizedLayoutAA(IntArray &Map, int *neighborLis
|
||||
for (i=2; i<Nx-2; i++){
|
||||
// Local index (regular layout)
|
||||
n = k*Nx*Ny + j*Nx + i;
|
||||
if (id[n] != 0 ){
|
||||
if (id[n] > 0 ){
|
||||
Map(n) = idx++;
|
||||
//neighborList[idx++] = n; // index of self in regular layout
|
||||
}
|
||||
@ -425,6 +425,7 @@ int ScaLBL_Communicator::MemoryOptimizedLayoutAA(IntArray &Map, int *neighborLis
|
||||
last_interior=idx;
|
||||
|
||||
Np = (last_interior/16 + 1)*16;
|
||||
printf(" Np=%i \n",Np);
|
||||
|
||||
// Now use Map to determine the neighbors for each lattice direction
|
||||
for (k=1;k<Nz-1;k++){
|
||||
|
@ -69,17 +69,17 @@ void ScaLBL_ColorModel::SetDomain(){
|
||||
MPI_Barrier(comm);
|
||||
Dm->CommInit();
|
||||
MPI_Barrier(comm);
|
||||
rank = Dm->rank();
|
||||
}
|
||||
|
||||
void ScaLBL_ColorModel::ReadInput(){
|
||||
int rank=Dm->rank();
|
||||
size_t readID;
|
||||
//.......................................................................
|
||||
if (rank == 0) printf("Read input media... \n");
|
||||
//.......................................................................
|
||||
Mask->ReadIDs();
|
||||
|
||||
sprintf(LocalRankString,"%05d",Dm->rank());
|
||||
sprintf(LocalRankString,"%05d",rank);
|
||||
sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
|
||||
sprintf(LocalRestartFile,"%s%s","Restart.",LocalRankString);
|
||||
|
||||
@ -95,7 +95,7 @@ void ScaLBL_ColorModel::ReadInput(){
|
||||
|
||||
// Read restart file
|
||||
if (Restart == true){
|
||||
if (Dm->rank()==0){
|
||||
if (rank==0){
|
||||
size_t readID;
|
||||
printf("Reading restart file! \n");
|
||||
ifstream restart("Restart.txt");
|
||||
@ -157,7 +157,6 @@ void ScaLBL_ColorModel::Create(){
|
||||
/*
|
||||
* This function creates the variables needed to run a LBM
|
||||
*/
|
||||
int rank=Dm->rank();
|
||||
//.........................................................
|
||||
// don't perform computations at the eight corners
|
||||
//id[0] = id[Nx-1] = id[(Ny-1)*Nx] = id[(Ny-1)*Nx + Nx-1] = 0;
|
||||
@ -175,7 +174,7 @@ void ScaLBL_ColorModel::Create(){
|
||||
ScaLBL_Comm = std::shared_ptr<ScaLBL_Communicator>(new ScaLBL_Communicator(Mask));
|
||||
|
||||
int Npad=(Np/16 + 2)*16;
|
||||
if (rank==0) printf ("Set up memory efficient layout \n");
|
||||
if (rank==0) printf ("Set up memory efficient layout, %i | %i | %i \n", Np, Npad, N);
|
||||
Map.resize(Nx,Ny,Nz); Map.fill(-2);
|
||||
auto neighborList= new int[18*Npad];
|
||||
Np = ScaLBL_Comm->MemoryOptimizedLayoutAA(Map,neighborList,Mask->id,Np);
|
||||
@ -187,8 +186,8 @@ void ScaLBL_ColorModel::Create(){
|
||||
// LBM variables
|
||||
if (rank==0) printf ("Allocating distributions \n");
|
||||
//......................device distributions.................................
|
||||
int dist_mem_size = Np*sizeof(double);
|
||||
int neighborSize=18*(Np*sizeof(int));
|
||||
dist_mem_size = Np*sizeof(double);
|
||||
neighborSize=18*(Np*sizeof(int));
|
||||
|
||||
//...........................................................................
|
||||
ScaLBL_AllocateDeviceMemory((void **) &NeighborList, neighborSize);
|
||||
@ -367,7 +366,6 @@ void ScaLBL_ColorModel::Initialize(){
|
||||
|
||||
void ScaLBL_ColorModel::Run(){
|
||||
int nprocs=nprocx*nprocy*nprocz;
|
||||
int rank=Dm->rank();
|
||||
const RankInfoStruct rank_info(rank,nprocx,nprocy,nprocz);
|
||||
|
||||
if (rank==0) printf("********************************************************\n");
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
private:
|
||||
MPI_Comm comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
|
Loading…
Reference in New Issue
Block a user