clean up morphology

This commit is contained in:
James McClure
2021-11-02 14:07:35 -04:00
parent 6b7b46dabd
commit eb6b563c6e
4 changed files with 21 additions and 71 deletions

View File

@@ -24,57 +24,10 @@ inline void UnpackID(const int *list, int count, signed char *recvbuf, signed ch
}
}
Morphology::Morphology(std::shared_ptr <Domain> Dm){
int nx = Dm->Nx;
int ny = Dm->Ny;
int nz = Dm->Nz;
int nprocx = Dm->nprocx();
int nprocy = Dm->nprocy();
int nprocz = Dm->nprocz();
int rank = Dm->rank();
Morphology::Morphology(){
/* MPI tags*/
sendtag = recvtag = 1381;
// send buffers
sendID_x = new signed char [Dm->sendCount("x")];
sendID_y = new signed char [Dm->sendCount("y")];
sendID_z = new signed char [Dm->sendCount("z")];
sendID_X = new signed char [Dm->sendCount("X")];
sendID_Y = new signed char [Dm->sendCount("Y")];
sendID_Z = new signed char [Dm->sendCount("Z")];
sendID_xy = new signed char [Dm->sendCount("xy")];
sendID_yz = new signed char [Dm->sendCount("yz")];
sendID_xz = new signed char [Dm->sendCount("xz")];
sendID_Xy = new signed char [Dm->sendCount("Xy")];
sendID_Yz = new signed char [Dm->sendCount("Yz")];
sendID_xZ = new signed char [Dm->sendCount("xZ")];
sendID_xY = new signed char [Dm->sendCount("xY")];
sendID_yZ = new signed char [Dm->sendCount("yZ")];
sendID_Xz = new signed char [Dm->sendCount("Xz")];
sendID_XY = new signed char [Dm->sendCount("XY")];
sendID_YZ = new signed char [Dm->sendCount("YZ")];
sendID_XZ = new signed char [Dm->sendCount("XZ")];
//......................................................................................
// recv buffers
recvID_x = new signed char [Dm->recvCount("x")];
recvID_y = new signed char [Dm->recvCount("y")];
recvID_z = new signed char [Dm->recvCount("z")];
recvID_X = new signed char [Dm->recvCount("X")];
recvID_Y = new signed char [Dm->recvCount("Y")];
recvID_Z = new signed char [Dm->recvCount("Z")];
recvID_xy = new signed char [Dm->recvCount("xy")];
recvID_yz = new signed char [Dm->recvCount("yz")];
recvID_xz = new signed char [Dm->recvCount("xz")];
recvID_Xy = new signed char [Dm->recvCount("Xy")];
recvID_xZ = new signed char [Dm->recvCount("xZ")];
recvID_xY = new signed char [Dm->recvCount("xY")];
recvID_yZ = new signed char [Dm->recvCount("yZ")];
recvID_Yz = new signed char [Dm->recvCount("Yz")];
recvID_Xz = new signed char [Dm->recvCount("Xz")];
recvID_XY = new signed char [Dm->recvCount("XY")];
recvID_YZ = new signed char [Dm->recvCount("YZ")];
recvID_XZ = new signed char [Dm->recvCount("XZ")];
}
Morphology::~Morphology(){
@@ -87,7 +40,6 @@ void Morphology::Initialize(std::shared_ptr <Domain> Dm, DoubleArray &Distance){
size_t Ny = Dm->Ny;
size_t Nz = Dm->Nz;
size_t N = Nx*Ny*Nz;
size_t count = 0;
int *tmpShift_x, *tmpShift_y, *tmpShift_z;
double *tmpDistance;
@@ -121,7 +73,6 @@ void Morphology::Initialize(std::shared_ptr <Domain> Dm, DoubleArray &Distance){
}
}
}
printf(" Start data exchange \n");
Dm->Comm.Irecv(&recvCount,1,Dm->rank_X(),recvtag+0);
Dm->Comm.send(&sendCount,1,Dm->rank_x(),sendtag+0);
Dm->Comm.barrier();
@@ -136,7 +87,6 @@ void Morphology::Initialize(std::shared_ptr <Domain> Dm, DoubleArray &Distance){
yShift.resize(recvLoc);
zShift.resize(recvLoc);
morphRadius.resize(recvLoc);
printf(" (x/X) Prepare to send %i recv %i \n", sendCount, recvCount);
//..............................
/* send the morphological radius */
Dm->Comm.Irecv(&morphRadius[recvOffset_X],recvCount,Dm->rank_X(),recvtag+0);
@@ -184,7 +134,6 @@ void Morphology::Initialize(std::shared_ptr <Domain> Dm, DoubleArray &Distance){
yShift.resize(recvLoc);
zShift.resize(recvLoc);
morphRadius.resize(recvLoc);
printf(" (X/x) Prepare to send %i recv %i \n", sendCount, recvCount);
//..............................
/* send the morphological radius */
Dm->Comm.Irecv(&morphRadius[recvOffset_x],recvCount,Dm->rank_x(),recvtag+0);
@@ -396,12 +345,13 @@ void Morphology::Initialize(std::shared_ptr <Domain> Dm, DoubleArray &Distance){
localID.resize(sendCount);
nonlocalID.resize(recvCount);
printf(" offset %i for send (x) %i \n", sendOffset_x, sendCount_x);
/*printf(" offset %i for send (x) %i \n", sendOffset_x, sendCount_x);
printf(" offset %i for send (X) %i \n", sendOffset_X, sendCount_X);
printf(" offset %i for send (y) %i \n", sendOffset_y, sendCount_y);
printf(" offset %i for send (Y) %i \n", sendOffset_Y, sendCount_Y);
printf(" offset %i for send (z) %i \n", sendOffset_z, sendCount_z);
printf(" offset %i for send (Z) %i \n", sendOffset_Z, sendCount_Z);
*/
}
@@ -513,7 +463,7 @@ double MorphOpen(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain>
}
Dm->Comm.barrier();
Morphology Structure(Dm);
Morphology Structure;
Structure.Initialize(Dm,SignDist);
// total Global is the number of nodes in the pore-space
@@ -653,7 +603,7 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
Array<char> ID(nx,ny,nz);
fillHalo<char> fillChar(Dm->Comm,Dm->rank_info,{nx-2,ny-2,nz-2},{1,1,1},0,1);
Morphology Structure(Dm);
Morphology Structure;
Structure.Initialize(Dm,SignDist);
int n;

View File

@@ -19,9 +19,8 @@ class Morphology{
public:
/**
* \brief Create a flow adaptor to operate on the LB model
* @param Dm Domain structure
*/
Morphology(std::shared_ptr <Domain> Dm);
Morphology();
/**
* \brief Destructor

View File

@@ -0,0 +1,5 @@
============================================
Morphology
============================================
.. doxygenfile:: morphology.h
:project: LBPM Doxygen

View File

@@ -19,16 +19,15 @@ Since the morphological operation works on the input domain, associated paramete
Domain {
Filename = "discs_3x128x128.raw"
ReadType = "16bit" // data type
ReadType = "8bit" // data type
N = 3, 128, 128 // size of original image
nproc = 1, 2, 2 // process grid
n = 3, 64, 64 // sub-domain size
voxel_length = 7.0 // voxel length (in microns)
voxel_length = 1.0 // voxel length (in microns)
ReadValues = 0, 1, 2 // labels within the original image
WriteValues = 0, 2, 2 // associated labels to be used by LBPM
InletLayers = 0, 0, 6 // specify 6 layers along the z-inlet
BC = 0 // fully periodic BC
Sw = 0.20 // target saturation for morphological tools
Sw = 0.35 // target saturation for morphological tools
}
Once this has been set, we launch lbpm_morphdrain_pp in the same way as other parallel tools
@@ -42,7 +41,8 @@ Successful output looks like the following
.. code:: bash
Performing morphological opening with target saturation 0.500000
Performing morphological opening with target saturation 0.350000
voxel length = 1.000000 micron
voxel length = 1.000000 micron
Input media: discs_3x128x128.raw
@@ -89,15 +89,11 @@ Successful output looks like the following
1.000000 35.891230
1.000000 34.096668
1.000000 32.391835
0.805149 30.772243
0.727353 29.233631
0.719791 27.771949
0.714883 26.383352
0.710861 25.064184
0.637249 23.810975
0.444570 22.620426
Final void fraction =0.444570
Final critical radius=22.620426
0.575114 30.772243
0.433119 29.233631
0.291231 27.771949
Final void fraction =0.291231
Final critical radius=27.771949
Writing ID file
Writing file to: discs_3x128x128.raw.morphdrain.raw