From 7fd43101c8d6c7e6a7cf87ef99de4ff3d458f3f5 Mon Sep 17 00:00:00 2001 From: Alexandre Halbach Date: Sat, 16 Oct 2021 21:45:05 +0300 Subject: [PATCH] clean myalgo::assignedgenumbers --- src/mesh/myalgorithm.cpp | 33 +++++++++++++++++++-------------- src/mesh/myalgorithm.h | 3 ++- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/mesh/myalgorithm.cpp b/src/mesh/myalgorithm.cpp index d4aa451c..ad42d225 100755 --- a/src/mesh/myalgorithm.cpp +++ b/src/mesh/myalgorithm.cpp @@ -898,7 +898,6 @@ void myalgorithm::assignedgenumbers(std::vector& isownelem, std::vectorcountneighbours(); std::vector neighbours = dt->getneighbours(); - std::vector nn(8), ne(8); for (int i = 0; i < 8; i++) { @@ -955,15 +954,10 @@ void myalgorithm::assignedgenumbers(std::vector& isownelem, std::vector neighboursnumownedges = appendneighbourvalues(barys, catcornercoords, numownedges); - // Remove duplicated barycenters: + // Find duplicates: std::vector renumberingvector; int numunique = removeduplicates(barys, renumberingvector); - // Assign a unique edge number for each edge: - edgenumbers = std::vector(numedges); - for (int i = 0; i < numedges; i++) - edgenumbers[i] = renumberingvector[i]; - // Calculate which edges must be split: std::vector isanodeatnum(numunique, false); for (int i = 0; i < barys.size()/3-numedges; i++) @@ -972,10 +966,21 @@ void myalgorithm::assignedgenumbers(std::vector& isownelem, std::vector(numedges, false); for (int i = 0; i < numedges; i++) { - if (isanodeatnum[edgenumbers[i]]) + if (isanodeatnum[renumberingvector[i]]) isbarycenteronnode[i] = true; } + // Assign a unique edge number for each edge: + edgenumbers = std::vector(numedges); + for (int i = 0; i < numedges; i++) + edgenumbers[i] = renumberingvector[i]; + + // Make the edges numbers continuous: + std::vector edgerenum; + int numuniqueedges = squeeze(edgenumbers, numunique, edgerenum); + for (int i = 0; i < numedges; i++) + edgenumbers[i] = edgerenum[edgenumbers[i]]; + // Harmonize the edges numbers across neighbour ranks: if (dt->isdefined() == false || numranks == 1) return; @@ -988,15 +993,15 @@ void myalgorithm::assignedgenumbers(std::vector& isownelem, std::vector ownbarys(3*numownedges); selectcoordinates(isownedge, barys, ownbarys.data()); - // Get edges count on all ranks to create unique edge numbers: - std::vector fragment = {numedges}; - std::vector allnumedges; - slmpi::allgather(fragment, allnumedges); + // Get the edges count on all ranks to create unique global edge numbers: + std::vector fragment = {numuniqueedges}; + std::vector allnumuniqueedges; + slmpi::allgather(fragment, allnumuniqueedges); - // Use long long int to allow more edges in the mesh. + // USE LONG LONG INT TO ALLOW MORE EDGES IN THE MESH. std::vector edgenumshift(numranks, 0); for (int i = 1; i < numranks; i++) - edgenumshift[i] = edgenumshift[i-1] + allnumedges[i-1]; + edgenumshift[i] = edgenumshift[i-1] + allnumuniqueedges[i-1]; for (int i = 0; i < numedges; i++) edgenumbers[i] += edgenumshift[rank]; diff --git a/src/mesh/myalgorithm.h b/src/mesh/myalgorithm.h index 98168bcc..81a30e6e 100755 --- a/src/mesh/myalgorithm.h +++ b/src/mesh/myalgorithm.h @@ -137,7 +137,8 @@ namespace myalgorithm // Provide the corner coordinates of each element concatenated in each element type. // This function returns (flattened from lowest type to highest) the edge number of // each edge in an element as well as a bool whose value is true if the edge barycenter - // is close enough to any node in the corner coordinates. + // is close enough to any node in the corner coordinates. In the DDM framework the own + // elements must include at least one layer of inner cells touching the no-overlap interface. void assignedgenumbers(std::vector& isownelem, std::vector>& cornercoords, std::vector& edgenumbers, std::vector& isbarycenteronnode); // For a vector 'vec' of repeating blocks [b0 b1 b2 ...] the output is [b0[sel[0]] b1[sel[0]] ... b0[sel[1]] b1[sel[1]] ...].