Still data wrangling

This commit is contained in:
James E McClure
2018-04-08 07:29:03 -04:00
parent cabc296b10
commit bc8ee55209

View File

@@ -6,43 +6,55 @@
#include <stdexcept>
#include <fstream>
using namespace std;
int main(int argc, char **argv){
unsigned long int Bx,By,Bz;
unsigned long int Nx,Ny,Nz;
unsigned long int NX,NY,NZ;
unsigned long int i,j,k;
unsigned long int x,y,z;
unsigned long int x0,y0,z0;
unsigned long int N, N_full;
unsigned long int Z0,Zf;
printf("Aggregating block data into single file \n");
unsigned int Bx,By,Bz;
uint64_t Nx,Ny,Nz;
uint64_t N;
uint64_t NX,NY,NZ;
uint64_t i,j,k;
uint64_t x,y,z;
uint64_t x0,y0,z0;
uint64_t N_full;
//Read the block size
if (argc>9){
printf("Input arguments accepted \n");
Nx = atoi(argv[1]);
Ny = atoi(argv[2]);
Nz = atoi(argv[3]);
x0 = atoi(argv[4]);
y0 = atoi(argv[5]);
z0 = atoi(argv[6]);
NX = atoi(argv[7]);
NY = atoi(argv[8]);
NZ = atoi(argv[9]);
NX = atol(argv[7]);
NY = atol(argv[8]);
NZ = atol(argv[9]);
printf("Size %i X %i X %i \n",NX,NY,NZ);
fflush(stdout);
}
else{
printf("setting defaults \n");
Nx=Ny=Nz=1024;
x0=y0=z0=0;
NX=NY=8640;
NZ=6480;
}
//Bx = By = Bz = 9;
//Nx = Ny = Nz = 1024;
N = Nx*Ny*Nz;
N_full=NX*NY*NZ;
// compute the number of blocks to read
Bx=NX/Nx+1;
By=NY/Ny+1;
Bz=NZ/Nz+1;
printf("System size (read) is: %i x %i x %i \n",NX,NY,NZ);
printf("System size (output) is: %i x %i x %i \n",NX,NY,NZ);
printf("Block size (read) is: %i x %i x %i \n",Nx,Ny,Nz);
printf("Starting block (read) is: %i, %i, %i \n", x0,y0,z0);
printf("First z slice (write) is: %i \n", Z0);
printf("Last z slice (write) is: %i \n", Zf);
printf("Starting location (read) is: %i, %i, %i \n", x0,y0,z0);
printf("Block number (read): %i x %i x %i \n",Bx,By,Bz);
fflush(stdout);
// Filenames used
//char LocalRankString[8];
@@ -51,37 +63,43 @@ int main(int argc, char **argv){
char sy[2];
char sz[2];
char tmpstr[10];
//sprintf(LocalRankString,"%05d",rank);
N = Nx*Ny*Nz;
N_full=NX*NY*NZ;
char *id;
id = new char [N];
char *ID;
ID = new char [N_full];
for (unsigned long int bz=z0/Nz; bz<Bz; bz++){
for (unsigned long int by=y0/Ny; by<By; by++){
for (unsigned long int bx=x0/Nx; bx<Bx; bx++){
for (unsigned int bz=0; bz<Bz; bz++){
for (unsigned int by=0; by<By; by++){
for (unsigned int bx=0; bx<Bx; bx++){
sprintf(sx,"%d",bx);
sprintf(sy,"%d",by);
sprintf(sz,"%d",bz);
sprintf(LocalRankFilename,"%s%s%s%s%s%s%s","a2_x",sx,"_y",sy,"_z",sz,".gbd");
//sprintf(LocalRankFilename,"%s%s%s%s%s%s%s","a1_x",sx,"_y",sy,"_z",sz,".gbd");
sprintf(LocalRankFilename,"%s%s%s%s%s%s%s","dis_",sx,"x_",sy,"y_",sz,"z.gbd");
printf("Reading file: %s \n", LocalRankFilename);
fflush(stdout);
// Read the file
size_t readID;
FILE *IDFILE = fopen(LocalRankFilename,"rb");
readID=fread(id,1,N,IDFILE);
fclose(IDFILE);
printf("Loading data ... \n");
// Unpack the data into the main array
for ( k=0;k<Nz;k++){
for ( j=0;j<Ny;j++){
for ( i=0;i<Nx;i++){
x = bx*Nx + i -x0;
y = by*Ny + j -y0;
z = bz*Nz + k -z0;
if (!(x<0) && x<x0+NX && !(y<0) && y<y0+NY &&
!(z<0) && z<z0+NZ)
ID[z*NX*NY+y*NX+x] = ID[k*Nx*Ny+j*Nx+i];
x = bx*Nx + i;
y = by*Ny + j;
z = bz*Nz + k;
if ( x<NX && y<NY && z<NZ){
ID[z*NX*NY+y*NX+x] = id[k*Nx*Ny+j*Nx+i];
}
}
}
}
@@ -90,7 +108,7 @@ int main(int argc, char **argv){
}
// Compute porosity
unsigned long int count=0;
uint64_t count=0;
for (k=0; k<NZ; k++){
for (j=0; j<NY; j++){
for (i=0; i<NX; i++){