From 5ccb06646d39106c02dc40018a80a0e33cade52b Mon Sep 17 00:00:00 2001 From: James E McClure Date: Wed, 20 Feb 2019 18:33:41 -0500 Subject: [PATCH] refactor morphdrain pp --- tests/lbpm_morphdrain_pp.cpp | 368 +++++++---------------------------- 1 file changed, 73 insertions(+), 295 deletions(-) diff --git a/tests/lbpm_morphdrain_pp.cpp b/tests/lbpm_morphdrain_pp.cpp index 70798e88..3ca4c7a9 100644 --- a/tests/lbpm_morphdrain_pp.cpp +++ b/tests/lbpm_morphdrain_pp.cpp @@ -134,6 +134,8 @@ int main(int argc, char **argv) // Initialize the domain and communication Array id_solid(nx,ny,nz); DoubleArray SignDist(nx,ny,nz); + DoubleArray phase(nx,ny,nz); + IntArray phase_label(nx,ny,nz); // Solve for the position of the solid phase for (int k=0;k 1){ id[n] = 2; - count+=1.0; } } } } - // total Global is the number of nodes in the pore-space - MPI_Allreduce(&count,&totalGlobal,1,MPI_DOUBLE,MPI_SUM,comm); - double porosity=totalGlobal/(double(nprocx*nprocy*nprocz)*double(nx-2)*double(ny-2)*double(nz-2)); - if (rank==0) printf("Media Porosity: %f \n",porosity); - - double radius,Rcrit_new; - radius = 0.0; - // Layer the inlet with NWP - if (kproc == 0){ - for(j=0; j radius){ - radius=SignDist(i,j,0); - } + // calculate distance to non-wetting fluid + if (domain_db->keyExists( "HistoryLabels" )){ + if (rank==0) printf("Relabel solid components that touch fluid 1 \n"); + auto LabelList = domain_db->getVector( "ComponentLabels" ); + auto HistoryLabels = domain_db->getVector( "HistoryLabels" ); + size_t NLABELS=LabelList.size(); + if (rank==0){ + for (unsigned int idx=0; idx < NLABELS; idx++){ + char VALUE = LabelList[idx]; + char NEWVAL = HistoryLabels[idx]; + printf(" Relabel component %d as %d \n", VALUE, NEWVAL); } } - } - - MPI_Allreduce(&radius,&Rcrit_new,1,MPI_DOUBLE,MPI_MAX,comm); - - if (rank==0) printf("Starting morhpological drainage with critical radius = %f \n",Rcrit_new); - - int imin,jmin,kmin,imax,jmax,kmax; - - // Decrease the critical radius until the target saturation is met - double deltaR=0.01; // amount to change the radius in voxel units - double Rcrit_old; - double sw_old=1.0; // initial WP saturation set to one - double sw_new=1.0; // initial WP saturation set to one - double sw_diff_old = 1.0; - double sw_diff_new = 1.0; - - while (sw_new > SW && Rcrit_new > 0.99){ - - Rcrit_old = Rcrit_new; - Rcrit_new -= deltaR*Rcrit_old;// decrease critical radius - sw_old = sw_new; - sw_diff_old = sw_diff_new; - - int Window=round(Rcrit_new); - GlobalNumber = 1.0; - - while (GlobalNumber > 0){ - - //if (rank==0) printf("GlobalNumber=%f \n",GlobalNumber); - double LocalNumber=GlobalNumber=0.f; - for(k=0; k Rcrit_new){ - // loop over the window and update - imin=max(1,i-Window); - jmin=max(1,j-Window); - kmin=max(1,k-Window); - imax=min(Nx-1,i+Window); - jmax=min(Ny-1,j+Window); - kmax=min(Nz-1,k+Window); - for (kk=kmin; kk