Factored random phase initialization into pre-processor tests/lbpm_random_pp

This commit is contained in:
James E McClure
2015-06-19 22:29:33 -04:00
parent b551af3764
commit bb1d2658d6
4 changed files with 324 additions and 103 deletions

View File

@@ -1127,102 +1127,6 @@ inline void SignedDistance(double *Distance, int nspheres, double *List_cx, doub
for (n=0; n<N; n++) Distance[n] = Distance[n]/hx;
}
inline void GenerateResidual(char *ID, int Nx, int Ny, int Nz, double Saturation)
{
//.......................................................................
int i,j,k,n,Number,N;
int x,y,z,ii,jj,kk;
int sizeX,sizeY,sizeZ;
int *SizeX, *SizeY, *SizeZ;
#ifdef NORANDOM
srand(10009);
#else
srand(time(NULL));
#endif
// float bin;
//.......................................................................
N = Nx*Ny*Nz;
int bin, binCount;
ifstream Dist("BlobSize.in");
Dist >> binCount;
// printf("Number of blob sizes: %i \n",binCount);
SizeX = new int [binCount];
SizeY = new int [binCount];
SizeZ = new int [binCount];
for (bin=0; bin<binCount; bin++){
Dist >> SizeX[bin];
Dist >> SizeY[bin];
Dist >> SizeZ[bin];
// printf("Blob %i dimension: %i x %i x %i \n",bin, SizeX[bin], SizeY[bin], SizeZ[bin]);
}
Dist.close();
//.......................................................................
// cout << "Generating blocks... " << endl;
// Count for the total number of oil nodes
int count = 0;
// Count the total number of non-solid nodes
int total = 0;
for (i=0;i<N;i++){
if (ID[i] != 0) total++;
}
float sat = 0.f;
Number = 0; // number of features
while (sat < Saturation){
Number++;
// Randomly generate a point in the domain
x = Nx*float(rand())/float(RAND_MAX);
y = Ny*float(rand())/float(RAND_MAX);
z = Nz*float(rand())/float(RAND_MAX);
bin = int(floor(binCount*float(rand())/float(RAND_MAX)));
sizeX = SizeX[bin];
sizeY = SizeY[bin];
sizeZ = SizeZ[bin];
// cout << "Sampling from bin no. " << floor(bin) << endl;
// cout << "Feature size is: " << sizeX << "x" << sizeY << "x" << sizeZ << endl;
for (k=z;k<z+sizeZ;k++){
for (j=y;j<y+sizeY;j++){
for (i=x;i<x+sizeX;i++){
// Identify nodes in the domain (periodic BC)
ii = i;
jj = j;
kk = k;
if (ii < 1) ii+=(Nx-2);
if (jj < 1) jj+=(Ny-2);
if (kk < 1) kk+=(Nz-2);
if (!(ii < Nx-1)) ii-=(Nx-2);
if (!(jj < Ny-1)) jj-=(Ny-2);
if (!(kk < Nz-1)) kk-=(Nz-2);
n = kk*Nx*Ny+jj*Nx+ii;
if (ID[n] == 2){
ID[n] = 1;
count++;
}
}
}
}
sat = float(count)/total;
}
//.......................................................................
}
inline void FlipID(char *ID, int N)
{
for (int n=0; n<N; n++){
if (ID[n] == 1) ID[n] = 2;
else if (ID[n] == 2) ID[n] = 1;
}
}
inline void WriteLocalSolidID(char *FILENAME, char *ID, int N)
{
char value;