Merging
This commit is contained in:
@@ -7,6 +7,7 @@ INSTALL_LBPM_EXE( lbpm_random_pp )
|
||||
INSTALL_LBPM_EXE( lbpm_segmented_pp )
|
||||
INSTALL_LBPM_EXE( lbpm_segmented_decomp )
|
||||
INSTALL_LBPM_EXE( lbpm_disc_pp )
|
||||
INSTALL_LBPM_EXE( lbpm_captube_pp )
|
||||
INSTALL_LBPM_EXE( lbpm_BlobAnalysis )
|
||||
INSTALL_LBPM_EXE( TestBubble )
|
||||
INSTALL_LBPM_EXE( BasicSimulator )
|
||||
|
||||
217
tests/lbpm_captube_pp.cpp
Normal file
217
tests/lbpm_captube_pp.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
|
||||
#include "ScaLBL.h"
|
||||
#include "Communication.h"
|
||||
#include "TwoPhase.h"
|
||||
#include "common/MPI_Helpers.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//*****************************************
|
||||
// ***** MPI STUFF ****************
|
||||
//*****************************************
|
||||
// Initialize MPI
|
||||
int rank,nprocs;
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
|
||||
// parallel domain size (# of sub-domains)
|
||||
int nprocx,nprocy,nprocz;
|
||||
int iproc,jproc,kproc;
|
||||
int sendtag,recvtag;
|
||||
//*****************************************
|
||||
// MPI ranks for all 18 neighbors
|
||||
//**********************************
|
||||
int rank_x,rank_y,rank_z,rank_X,rank_Y,rank_Z;
|
||||
int rank_xy,rank_XY,rank_xY,rank_Xy;
|
||||
int rank_xz,rank_XZ,rank_xZ,rank_Xz;
|
||||
int rank_yz,rank_YZ,rank_yZ,rank_Yz;
|
||||
//**********************************
|
||||
MPI_Request req1[18],req2[18];
|
||||
MPI_Status stat1[18],stat2[18];
|
||||
|
||||
double TubeRadius =15.0;
|
||||
int BC;
|
||||
TubeRadius=strtod(argv[1],NULL);
|
||||
BC=atoi(argv[2]);
|
||||
|
||||
if (rank == 0){
|
||||
printf("********************************************************\n");
|
||||
printf("Generate 3D cylindrical capillary tube geometry with radius = %f voxels \n",TubeRadius);
|
||||
printf("********************************************************\n");
|
||||
}
|
||||
|
||||
// Variables that specify the computational domain
|
||||
string FILENAME;
|
||||
int Nx,Ny,Nz; // local sub-domain size
|
||||
int nspheres; // number of spheres in the packing
|
||||
double Lx,Ly,Lz; // Domain length
|
||||
int i,j,k,n;
|
||||
|
||||
// pmmc threshold values
|
||||
double fluid_isovalue,solid_isovalue;
|
||||
fluid_isovalue = 0.0;
|
||||
solid_isovalue = 0.0;
|
||||
|
||||
if (rank==0){
|
||||
//.......................................................................
|
||||
// Reading the domain information file
|
||||
//.......................................................................
|
||||
ifstream domain("Domain.in");
|
||||
domain >> nprocx;
|
||||
domain >> nprocy;
|
||||
domain >> nprocz;
|
||||
domain >> Nx;
|
||||
domain >> Ny;
|
||||
domain >> Nz;
|
||||
domain >> nspheres;
|
||||
domain >> Lx;
|
||||
domain >> Ly;
|
||||
domain >> Lz;
|
||||
//.......................................................................
|
||||
}
|
||||
// **************************************************************
|
||||
// Broadcast simulation parameters from rank 0 to all other procs
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
// Computational domain
|
||||
MPI_Bcast(&Nx,1,MPI_INT,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&Ny,1,MPI_INT,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&Nz,1,MPI_INT,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&nprocx,1,MPI_INT,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&nprocy,1,MPI_INT,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&nprocz,1,MPI_INT,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&nspheres,1,MPI_INT,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&Lx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&Ly,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
|
||||
MPI_Bcast(&Lz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
|
||||
//.................................................
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
|
||||
// **************************************************************
|
||||
if (nprocs != nprocx*nprocy*nprocz){
|
||||
printf("nprocx = %i \n",nprocx);
|
||||
printf("nprocy = %i \n",nprocy);
|
||||
printf("nprocz = %i \n",nprocz);
|
||||
INSIST(nprocs == nprocx*nprocy*nprocz,"Fatal error in processor count!");
|
||||
}
|
||||
|
||||
if (rank==0){
|
||||
printf("********************************************************\n");
|
||||
printf("Sub-domain size = %i x %i x %i\n",Nz,Nz,Nz);
|
||||
printf("Parallel domain size = %i x %i x %i\n",nprocx,nprocy,nprocz);
|
||||
printf("********************************************************\n");
|
||||
}
|
||||
|
||||
// Initialized domain and averaging framework for Two-Phase Flow
|
||||
Domain Dm(Nx,Ny,Nz,rank,nprocx,nprocy,nprocz,Lx,Ly,Lz,BC);
|
||||
Dm.CommInit(MPI_COMM_WORLD);
|
||||
TwoPhase Averages(Dm);
|
||||
|
||||
InitializeRanks( rank, nprocx, nprocy, nprocz, iproc, jproc, kproc,
|
||||
rank_x, rank_y, rank_z, rank_X, rank_Y, rank_Z,
|
||||
rank_xy, rank_XY, rank_xY, rank_Xy, rank_xz, rank_XZ, rank_xZ, rank_Xz,
|
||||
rank_yz, rank_YZ, rank_yZ, rank_Yz );
|
||||
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
|
||||
Nz += 2;
|
||||
Nx = Ny = Nz; // Cubic domain
|
||||
|
||||
int N = Nx*Ny*Nz;
|
||||
int dist_mem_size = N*sizeof(double);
|
||||
|
||||
//.......................................................................
|
||||
// Filenames used
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
char tmpstr[10];
|
||||
sprintf(LocalRankString,"%05d",rank);
|
||||
sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
|
||||
sprintf(LocalRestartFile,"%s%s","Restart.",LocalRankString);
|
||||
|
||||
// printf("Local File Name = %s \n",LocalRankFilename);
|
||||
// .......... READ THE INPUT FILE .......................................
|
||||
// char value;
|
||||
char *id;
|
||||
id = new char[N];
|
||||
int sum = 0;
|
||||
double sum_local;
|
||||
double iVol_global = 1.0/(1.0*(Nx-2)*(Ny-2)*(Nz-2)*nprocs);
|
||||
//if (pBC) iVol_global = 1.0/(1.0*(Nx-2)*nprocx*(Ny-2)*nprocy*((Nz-2)*nprocz-6));
|
||||
double porosity, pore_vol;
|
||||
|
||||
// Initializes a constrained bubble test
|
||||
double BubbleBot = 20.0; // How big to make the NWP bubble
|
||||
double BubbleTop = 60.0; // How big to make the NWP bubble
|
||||
//double TubeRadius = 15.5; // Radius of the capillary tube
|
||||
sum=0;
|
||||
for (k=0;k<Nz;k++){
|
||||
for (j=0;j<Ny;j++){
|
||||
for (i=0;i<Nx;i++){
|
||||
n = k*Nx*Ny + j*Nz + i;
|
||||
// Cylindrical capillary tube aligned with the z direction
|
||||
Averages.SDs(i,j,k) = TubeRadius-sqrt(1.0*((i-Nx/2)*(i-Nx/2)
|
||||
+ (j-Ny/2)*(j-Ny/2)));
|
||||
// Initialize phase positions field
|
||||
if (Averages.SDs(i,j,k) < 0.0){
|
||||
id[n] = 0;
|
||||
}
|
||||
/* else if (k<BubbleBot){
|
||||
id[n] = 2;
|
||||
sum++;
|
||||
}
|
||||
else if (k<BubbleTop && rank == 0 && pBC == 0){
|
||||
id[n] = 1;
|
||||
sum++;
|
||||
}
|
||||
*/
|
||||
else{
|
||||
id[n] = 2;
|
||||
sum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
porosity = double(sum)/double(1.0*N);
|
||||
// Compute the pore volume
|
||||
sum_local = 0.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;
|
||||
if (id[n] > 0){
|
||||
sum_local += 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MPI_Allreduce(&sum_local,&pore_vol,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
|
||||
|
||||
//.........................................................
|
||||
// don't perform computations at the eight corners
|
||||
id[0] = id[Nx-1] = id[(Ny-1)*Nx] = id[(Ny-1)*Nx + Nx-1] = 0;
|
||||
id[(Nz-1)*Nx*Ny] = id[(Nz-1)*Nx*Ny+Nx-1] = id[(Nz-1)*Nx*Ny+(Ny-1)*Nx] = id[(Nz-1)*Nx*Ny+(Ny-1)*Nx + Nx-1] = 0;
|
||||
//.........................................................
|
||||
|
||||
sprintf(LocalRankFilename,"SignDist.%05i",rank);
|
||||
FILE *DIST = fopen(LocalRankFilename,"wb");
|
||||
fwrite(Averages.SDs.get(),8,Averages.SDs.length(),DIST);
|
||||
fclose(DIST);
|
||||
|
||||
sprintf(LocalRankFilename,"ID.%05i",rank);
|
||||
FILE *ID = fopen(LocalRankFilename,"wb");
|
||||
fwrite(id,1,N,ID);
|
||||
fclose(ID);
|
||||
|
||||
// ****************************************************
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
MPI_Finalize();
|
||||
// ****************************************************
|
||||
}
|
||||
@@ -126,9 +126,9 @@ int main(int argc, char **argv)
|
||||
printf("********************************************************\n");
|
||||
}
|
||||
|
||||
PROFILE_ENABLE(1);
|
||||
PROFILE_ENABLE_TRACE();
|
||||
PROFILE_ENABLE_MEMORY();
|
||||
PROFILE_ENABLE(0);
|
||||
//PROFILE_ENABLE_TRACE();
|
||||
//PROFILE_ENABLE_MEMORY();
|
||||
PROFILE_SYNCHRONIZE();
|
||||
PROFILE_START("Main");
|
||||
|
||||
@@ -286,7 +286,7 @@ int main(int argc, char **argv)
|
||||
if (BoundaryCondition==1) printf("Pressure boundary conditions will be applied \n");
|
||||
if (BoundaryCondition==2) printf("Velocity boundary conditions will be applied \n");
|
||||
if (InitialCondition==0) printf("Initial conditions assigned from phase ID file \n");
|
||||
if (InitialCondition==1) printf("Initial conditions asdsigned from restart file \n");
|
||||
if (InitialCondition==1) printf("Initial conditions assigned from restart file \n");
|
||||
printf("********************************************************\n");
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ int main(int argc, char **argv)
|
||||
fread(id,1,N,IDFILE);
|
||||
fclose(IDFILE);
|
||||
|
||||
for ( k=0;k<Nz;k++){
|
||||
/* for ( k=0;k<Nz;k++){
|
||||
for ( j=0;j<Ny;j++){
|
||||
for ( i=0;i<Nx;i++){
|
||||
int n = k*Nx*Ny+j*Nx+i;
|
||||
@@ -401,13 +401,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// Set up kstart, kfinish so that the reservoirs are excluded from averaging
|
||||
int kstart,kfinish;
|
||||
kstart = 1;
|
||||
kfinish = Nz-1;
|
||||
if (BoundaryCondition > 0 && kproc==0) kstart = 4;
|
||||
if (BoundaryCondition > 0 && kproc==nprocz-1) kfinish = Nz-4;
|
||||
if (BoundaryCondition > 0 && Dm.kproc==0) kstart = 4;
|
||||
if (BoundaryCondition > 0 && Dm.kproc==nprocz-1) kfinish = Nz-4;
|
||||
|
||||
// Compute the pore volume
|
||||
sum_local = 0.0;
|
||||
@@ -427,7 +427,7 @@ int main(int argc, char **argv)
|
||||
if (rank==0) printf("Media porosity = %f \n",porosity);
|
||||
//.........................................................
|
||||
// If external boundary conditions are applied remove solid
|
||||
if (BoundaryCondition > 0 && kproc == 0){
|
||||
if (BoundaryCondition > 0 && Dm.kproc == 0){
|
||||
for (k=0; k<3; k++){
|
||||
for (j=0;j<Ny;j++){
|
||||
for (i=0;i<Nx;i++){
|
||||
@@ -438,7 +438,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (BoundaryCondition > 0 && kproc == nprocz-1){
|
||||
if (BoundaryCondition > 0 && Dm.kproc == nprocz-1){
|
||||
for (k=Nz-3; k<Nz; k++){
|
||||
for (j=0;j<Ny;j++){
|
||||
for (i=0;i<Nx;i++){
|
||||
@@ -470,10 +470,10 @@ int main(int argc, char **argv)
|
||||
for ( j=0;j<Ny;j++){
|
||||
for ( i=0;i<Nx;i++){
|
||||
int n = k*Nx*Ny+j*Nx+i;
|
||||
if (kproc==0 && k==0) id[n]=1;
|
||||
if (kproc==0 && k==1) id[n]=1;
|
||||
if (kproc==nprocz-1 && k==Nz-2) id[n]=2;
|
||||
if (kproc==nprocz-1 && k==Nz-1) id[n]=2;
|
||||
if (Dm.kproc==0 && k==0) id[n]=1;
|
||||
if (Dm.kproc==0 && k==1) id[n]=1;
|
||||
if (Dm.kproc==nprocz-1 && k==Nz-2) id[n]=2;
|
||||
if (Dm.kproc==nprocz-1 && k==Nz-1) id[n]=2;
|
||||
Dm.id[n] = id[n];
|
||||
}
|
||||
}
|
||||
@@ -591,12 +591,12 @@ int main(int argc, char **argv)
|
||||
printf("Setting inlet pressure = %f \n", din);
|
||||
printf("Setting outlet pressure = %f \n", dout);
|
||||
}
|
||||
if (BoundaryCondition==1 && kproc == 0) {
|
||||
if (BoundaryCondition==1 && Dm.kproc == 0) {
|
||||
PressureBC_inlet(f_even,f_odd,din,Nx,Ny,Nz);
|
||||
ColorBC_inlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
}
|
||||
|
||||
if (BoundaryCondition==1 && kproc == nprocz-1){
|
||||
if (BoundaryCondition==1 && Dm.kproc == nprocz-1){
|
||||
PressureBC_outlet(f_even,f_odd,dout,Nx,Ny,Nz,Nx*Ny*(Nz-2));
|
||||
ColorBC_outlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
}
|
||||
@@ -605,13 +605,13 @@ int main(int argc, char **argv)
|
||||
printf("Setting inlet velocity = %f \n", din);
|
||||
printf("Setting outlet velocity = %f \n", dout);
|
||||
}
|
||||
if (BoundaryCondition==2 && kproc == 0) {
|
||||
if (BoundaryCondition==2 && Dm.kproc == 0) {
|
||||
ScaLBL_D3Q19_Velocity_BC_z(f_even,f_odd,din,Nx,Ny,Nz);
|
||||
//ColorBC_inlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
SetPhiSlice_z(Phi,1.0,Nx,Ny,Nz,0);
|
||||
}
|
||||
|
||||
if (BoundaryCondition==2 && kproc == nprocz-1){
|
||||
if (BoundaryCondition==2 && Dm.kproc == nprocz-1){
|
||||
ScaLBL_D3Q19_Velocity_BC_Z(f_even,f_odd,dout,Nx,Ny,Nz,Nx*Ny*(Nz-2));
|
||||
//ColorBC_outlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
SetPhiSlice_z(Phi,-1.0,Nx,Ny,Nz,Nz-1);
|
||||
@@ -620,6 +620,18 @@ int main(int argc, char **argv)
|
||||
ComputePressureD3Q19(ID,f_even,f_odd,Pressure,Nx,Ny,Nz);
|
||||
ComputeVelocityD3Q19(ID,f_even,f_odd,Velocity,Nx,Ny,Nz);
|
||||
|
||||
/* if (BoundaryCondition==1 && Dm.kproc == 0){
|
||||
for (n=Nx*Ny; n<2*Nx*Ny; n++){
|
||||
if (Dm.id[n]>0 && 3.0*Pressure[n] != din) printf("Inlet pBC error: %f != %f \n",3.0*Pressure[n],din);
|
||||
}
|
||||
}
|
||||
|
||||
if (BoundaryCondition==1 && Dm.kproc == nprocz-1){
|
||||
for (n=Nx*Ny*(Nz-2); n<Nx*Ny*(Nz-1); n++){
|
||||
if (Dm.id[n]>0 && 3.0*Pressure[n] != dout) printf("Outlet pBC error: %f != %f \n",3.0*Pressure[n],din);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//...........................................................................
|
||||
// Copy the phase indicator field for the earlier timestep
|
||||
DeviceBarrier();
|
||||
@@ -734,22 +746,22 @@ int main(int argc, char **argv)
|
||||
DeviceBarrier();
|
||||
|
||||
// Pressure boundary conditions
|
||||
if (BoundaryCondition==1 && kproc == 0) {
|
||||
if (BoundaryCondition==1 && Dm.kproc == 0) {
|
||||
PressureBC_inlet(f_even,f_odd,din,Nx,Ny,Nz);
|
||||
ColorBC_inlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
}
|
||||
if (BoundaryCondition==1 && kproc == nprocz-1){
|
||||
if (BoundaryCondition==1 && Dm.kproc == nprocz-1){
|
||||
PressureBC_outlet(f_even,f_odd,dout,Nx,Ny,Nz,Nx*Ny*(Nz-2));
|
||||
ColorBC_outlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
}
|
||||
|
||||
// Velocity boundary conditions
|
||||
if (BoundaryCondition==2 && kproc == 0) {
|
||||
if (BoundaryCondition==2 && Dm.kproc == 0) {
|
||||
ScaLBL_D3Q19_Velocity_BC_z(f_even,f_odd,din,Nx,Ny,Nz);
|
||||
//ColorBC_inlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
SetPhiSlice_z(Phi,1.0,Nx,Ny,Nz,0);
|
||||
}
|
||||
if (BoundaryCondition==2 && kproc == nprocz-1){
|
||||
if (BoundaryCondition==2 && Dm.kproc == nprocz-1){
|
||||
ScaLBL_D3Q19_Velocity_BC_Z(f_even,f_odd,dout,Nx,Ny,Nz,Nx*Ny*(Nz-2));
|
||||
//ColorBC_outlet(Phi,Den,A_even,A_odd,B_even,B_odd,Nx,Ny,Nz);
|
||||
SetPhiSlice_z(Phi,-1.0,Nx,Ny,Nz,Nz-1);
|
||||
@@ -787,7 +799,7 @@ int main(int argc, char **argv)
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
PROFILE_STOP("Copy phase");
|
||||
}
|
||||
if ( timestep%100 == 0){
|
||||
if ( timestep%1000 == 0){
|
||||
// Compute the global blob id and compare to the previous version
|
||||
PROFILE_START("Identify blobs and maps");
|
||||
DeviceBarrier();
|
||||
@@ -797,7 +809,10 @@ int main(int argc, char **argv)
|
||||
int nblobs2 = ComputeGlobalBlobIDs(Nx-2,Ny-2,Nz-2,rank_info,
|
||||
Averages.Phase,Averages.SDs,vF,vS,GlobalBlobID2);
|
||||
if ( !GlobalBlobID.empty() ) {
|
||||
// Compute the timestep-timestep map
|
||||
ID_map_struct map = computeIDMap(GlobalBlobID,GlobalBlobID2);
|
||||
// Renumber the current timestep's ids
|
||||
|
||||
}
|
||||
std::swap(GlobalBlobID,GlobalBlobID2);
|
||||
PROFILE_STOP("Identify blobs and maps");
|
||||
@@ -882,6 +897,7 @@ int main(int argc, char **argv)
|
||||
meshData[0].meshName = "domain";
|
||||
meshData[0].mesh = std::shared_ptr<IO::DomainMesh>( new IO::DomainMesh(Dm.rank_info,Nx-2,Ny-2,Nz-2,Lx,Ly,Lz) );
|
||||
std::shared_ptr<IO::Variable> PhaseVar( new IO::Variable() );
|
||||
std::shared_ptr<IO::Variable> PressVar( new IO::Variable() );
|
||||
std::shared_ptr<IO::Variable> SignDistVar( new IO::Variable() );
|
||||
std::shared_ptr<IO::Variable> BlobIDVar( new IO::Variable() );
|
||||
PhaseVar->name = "phase";
|
||||
@@ -889,6 +905,11 @@ int main(int argc, char **argv)
|
||||
PhaseVar->dim = 1;
|
||||
PhaseVar->data.resize(Nx-2,Ny-2,Nz-2);
|
||||
meshData[0].vars.push_back(PhaseVar);
|
||||
PressVar->name = "Pressure";
|
||||
PressVar->type = IO::VolumeVariable;
|
||||
PressVar->dim = 1;
|
||||
PressVar->data.resize(Nx-2,Ny-2,Nz-2);
|
||||
meshData[0].vars.push_back(PressVar);
|
||||
SignDistVar->name = "SignDist";
|
||||
SignDistVar->type = IO::VolumeVariable;
|
||||
SignDistVar->dim = 1;
|
||||
|
||||
@@ -144,7 +144,7 @@ int main(int argc, char **argv)
|
||||
MeanFilter(Averages.SDs);
|
||||
|
||||
if (rank==0) printf("Initialized solid phase -- Converting to Signed Distance function \n");
|
||||
SSO(Averages.SDs,id,Dm,20);
|
||||
SSO(Averages.SDs,id,Dm,25);
|
||||
|
||||
sprintf(LocalRankFilename,"SignDist.%05i",rank);
|
||||
FILE *DIST = fopen(LocalRankFilename,"wb");
|
||||
@@ -175,18 +175,24 @@ int main(int argc, char **argv)
|
||||
MeanFilter(Averages.Phase);
|
||||
|
||||
if (rank==0) printf("Initialized non-wetting phase -- Converting to Signed Distance function \n");
|
||||
SSO(Averages.Phase,id,Dm,20);
|
||||
SSO(Averages.Phase,id,Dm,25);
|
||||
|
||||
sprintf(LocalRankFilename,"Phase.%05i",rank);
|
||||
FILE *PHASE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(Averages.Phase.get(),8,Averages.Phase.length(),PHASE);
|
||||
fclose(PHASE);
|
||||
/*
|
||||
for (k=0;k<nz;k++){
|
||||
for (j=0;j<ny;j++){
|
||||
for (i=0;i<nx;i++){
|
||||
n=k*nx*ny+j*nx+i;
|
||||
Averages.Phase(i,j,k) += 1.0;
|
||||
Averages.Phase(i,j,k) -= 1.0;
|
||||
// Initialize distance to +/- 1
|
||||
// Dilation of the non-wetting phase
|
||||
Averages.SDn(i,j,k) = -Averages.Phase(i,j,k);
|
||||
Averages.Phase(i,j,k) = Averages.SDn(i,j,k);
|
||||
Averages.Phase_tplus(i,j,k) = Averages.SDn(i,j,k);
|
||||
Averages.Phase_tminus(i,j,k) = Averages.SDn(i,j,k);
|
||||
Averages.DelPhi(i,j,k) = 0.0;
|
||||
Averages.Press(i,j,k) = 0.0;
|
||||
Averages.Vel_x(i,j,k) = 0.0;
|
||||
Averages.Vel_y(i,j,k) = 0.0;
|
||||
Averages.Vel_z(i,j,k) = 0.0;
|
||||
if (Averages.SDs(i,j,k) > 0.0){
|
||||
if (Averages.Phase(i,j,k) > 0.0){
|
||||
Dm.id[n] = 2;
|
||||
@@ -198,106 +204,62 @@ int main(int argc, char **argv)
|
||||
else{
|
||||
Dm.id[n] = 0;
|
||||
}
|
||||
// Initialize distance to +/- 1
|
||||
// Dilation of the non-wetting phase
|
||||
Averages.SDn(i,j,k) = Averages.Phase(i,j,k)+1.0;
|
||||
Averages.Phase(i,j,k) = Averages.SDn(i,j,k);
|
||||
Averages.Phase_tplus(i,j,k) = Averages.SDn(i,j,k);
|
||||
Averages.Phase_tminus(i,j,k) = Averages.SDn(i,j,k);
|
||||
Averages.DelPhi(i,j,k) = 0.0;
|
||||
Averages.Press(i,j,k) = 0.0;
|
||||
Averages.Vel_x(i,j,k) = 0.0;
|
||||
Averages.Vel_y(i,j,k) = 0.0;
|
||||
Averages.Vel_z(i,j,k) = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the MeshDataStruct
|
||||
fillHalo<double> fillData(Dm.rank_info,Nx-2,Ny-2,Nz-2,1,1,1,0,1);
|
||||
std::vector<IO::MeshDataStruct> meshData(1);
|
||||
meshData[0].meshName = "domain";
|
||||
meshData[0].mesh = std::shared_ptr<IO::DomainMesh>( new IO::DomainMesh(Dm.rank_info,Nx-2,Ny-2,Nz-2,Lx,Ly,Lz) );
|
||||
std::shared_ptr<IO::Variable> PhaseVar( new IO::Variable() );
|
||||
std::shared_ptr<IO::Variable> SignDistVar( new IO::Variable() );
|
||||
std::shared_ptr<IO::Variable> BlobIDVar( new IO::Variable() );
|
||||
PhaseVar->name = "phase";
|
||||
PhaseVar->type = IO::VolumeVariable;
|
||||
PhaseVar->dim = 1;
|
||||
PhaseVar->data.resize(Nx-2,Ny-2,Nz-2);
|
||||
meshData[0].vars.push_back(PhaseVar);
|
||||
SignDistVar->name = "SignDist";
|
||||
SignDistVar->type = IO::VolumeVariable;
|
||||
SignDistVar->dim = 1;
|
||||
SignDistVar->data.resize(Nx-2,Ny-2,Nz-2);
|
||||
meshData[0].vars.push_back(SignDistVar);
|
||||
BlobIDVar->name = "BlobID";
|
||||
BlobIDVar->type = IO::VolumeVariable;
|
||||
BlobIDVar->dim = 1;
|
||||
BlobIDVar->data.resize(Nx-2,Ny-2,Nz-2);
|
||||
meshData[0].vars.push_back(BlobIDVar);
|
||||
|
||||
fillData.copy(Averages.SDn,PhaseVar->data);
|
||||
fillData.copy(Averages.SDs,SignDistVar->data);
|
||||
fillData.copy(Averages.Label_NWP,BlobIDVar->data);
|
||||
IO::writeData( 0, meshData, 2 );
|
||||
|
||||
// sprintf(LocalRankFilename,"Phase.%05i",rank);
|
||||
// FILE *PHASE = fopen(LocalRankFilename,"wb");
|
||||
// fwrite(Averages.Phase.get(),8,Averages.Phase.length(),PHASE);
|
||||
// fclose(PHASE);
|
||||
|
||||
double vF,vS;
|
||||
vF = vS = 0.0;
|
||||
|
||||
double beta = 0.95;
|
||||
if (rank==0) printf("initializing the system \n");
|
||||
Averages.SetupCubes(Dm);
|
||||
Averages.UpdateSolid();
|
||||
Averages.Initialize();
|
||||
Averages.UpdateMeshValues();
|
||||
Dm.CommunicateMeshHalo(Averages.Phase);
|
||||
Dm.CommunicateMeshHalo(Averages.SDn);
|
||||
Dm.CommunicateMeshHalo(Averages.SDs);
|
||||
|
||||
if (rank==0) printf("computing blobs \n");
|
||||
// int nblobs_global = ComputeGlobalBlobIDs(Dm.Nx-2,Dm.Ny-2,Dm.Nz-2,Dm.rank_info,
|
||||
// Averages.Phase,Averages.SDs,vF,vS,Averages.BlobLabel);
|
||||
// if (Dm.rank==0) printf("Number of blobs is %i \n",nblobs_global);
|
||||
|
||||
// int nblobs_global = ComputeGlobalBlobIDs(Dm.Nx-2,Dm.Ny-2,Dm.Nz-2,Dm.rank_info,
|
||||
// Averages.SDn,Averages.SDs,vF,vS,Averages.BlobLabel);
|
||||
|
||||
if (rank==0) printf("computing local averages \n");
|
||||
Averages.ComputeLocalBlob();
|
||||
if (rank==0) printf("reducing averages \n");
|
||||
Averages.Reduce();
|
||||
|
||||
if (rank==0) printf("Writing blobs \n");
|
||||
// Write the local blob ids
|
||||
sprintf(LocalRankFilename,"BlobLabel.%05i",rank);
|
||||
FILE *BLOBLOCAL = fopen(LocalRankFilename,"wb");
|
||||
fwrite(Averages.BlobLabel.get(),4,Averages.BlobLabel.length(),BLOBLOCAL);
|
||||
fclose(BLOBLOCAL);
|
||||
printf("Wrote BlobLabel.%05i \n",rank);
|
||||
|
||||
if (rank==0) printf("Sorting averages \n");
|
||||
// Blobs.Set(Averages.BlobAverages.NBLOBS);
|
||||
int dimx = (int)Averages.BlobAverages.size(0);
|
||||
int dimy = (int)Averages.BlobAverages.size(1);
|
||||
int TotalBlobInfoSize=dimx*dimy;
|
||||
|
||||
// BlobContainer Blobs;
|
||||
DoubleArray RecvBuffer(dimx);
|
||||
// MPI_Allreduce(&Averages.BlobAverages.get(),&Blobs.get(),1,MPI_DOUBLE,MPI_SUM,Dm.Comm);
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
if (rank==0) printf("Number of components is %i \n",dimy);
|
||||
|
||||
for (int b=0; b<dimy; b++){
|
||||
|
||||
MPI_Allreduce(&Averages.BlobAverages(0,b),&RecvBuffer(0),dimx,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
|
||||
for (int idx=0; idx<dimx-1; idx++) Averages.BlobAverages(idx,b)=RecvBuffer(idx);
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
|
||||
if (Averages.BlobAverages(0,b) > 0.0){
|
||||
double Vn,pn,awn,ans,Jwn,Kwn,lwns,cwns,trawn,trJwn;
|
||||
Vn = Averages.BlobAverages(1,b);
|
||||
pn = Averages.BlobAverages(2,b)/Averages.BlobAverages(0,b);
|
||||
awn = Averages.BlobAverages(3,b);
|
||||
ans = Averages.BlobAverages(4,b);
|
||||
if (awn != 0.0){
|
||||
Jwn = Averages.BlobAverages(5,b)/Averages.BlobAverages(3,b);
|
||||
Kwn = Averages.BlobAverages(6,b)/Averages.BlobAverages(3,b);
|
||||
}
|
||||
else Jwn=Kwn=0.0;
|
||||
|
||||
trawn = Averages.BlobAverages(12,b);
|
||||
if (trawn != 0.0){
|
||||
trJwn = Averages.BlobAverages(13,b)/trawn;
|
||||
}
|
||||
else trJwn=0.0;
|
||||
|
||||
lwns = Averages.BlobAverages(7,b);
|
||||
if (lwns != 0.0) cwns = Averages.BlobAverages(8,b)/Averages.BlobAverages(7,b);
|
||||
else cwns=0.0;
|
||||
Averages.BlobAverages(2,b) = pn;
|
||||
Averages.BlobAverages(5,b) = trJwn;
|
||||
Averages.BlobAverages(6,b) = Kwn;
|
||||
Averages.BlobAverages(8,b) = cwns;
|
||||
// Averages.BlobAverages(13,b) = trJwn;
|
||||
}
|
||||
}
|
||||
|
||||
if (rank==0) printf("Sorting blobs by volume \n");
|
||||
Averages.SortBlobs();
|
||||
|
||||
if (rank==0) WriteBlobs(Averages);
|
||||
*/
|
||||
int timestep=5;
|
||||
Averages.Initialize();
|
||||
if (rank==0) printf("computing phase components \n");
|
||||
Averages.ComponentAverages();
|
||||
if (rank==0) printf("sorting phase components \n");
|
||||
Averages.SortBlobs();
|
||||
Averages.PrintComponents(timestep);
|
||||
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
MPI_Finalize();
|
||||
|
||||
Reference in New Issue
Block a user