Skip to content

Commit

Permalink
clean myalgo::assignedgenumbers
Browse files Browse the repository at this point in the history
  • Loading branch information
halbux committed Oct 16, 2021
1 parent 50e9387 commit 7fd4310
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
33 changes: 19 additions & 14 deletions src/mesh/myalgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,6 @@ void myalgorithm::assignedgenumbers(std::vector<bool>& isownelem, std::vector<st
int numneighbours = dt->countneighbours();
std::vector<int> neighbours = dt->getneighbours();


std::vector<int> nn(8), ne(8);
for (int i = 0; i < 8; i++)
{
Expand Down Expand Up @@ -955,15 +954,10 @@ void myalgorithm::assignedgenumbers(std::vector<bool>& isownelem, std::vector<st
removeduplicates(catcornercoords);
std::vector<int> neighboursnumownedges = appendneighbourvalues(barys, catcornercoords, numownedges);

// Remove duplicated barycenters:
// Find duplicates:
std::vector<int> renumberingvector;
int numunique = removeduplicates(barys, renumberingvector);

// Assign a unique edge number for each edge:
edgenumbers = std::vector<int>(numedges);
for (int i = 0; i < numedges; i++)
edgenumbers[i] = renumberingvector[i];

// Calculate which edges must be split:
std::vector<bool> isanodeatnum(numunique, false);
for (int i = 0; i < barys.size()/3-numedges; i++)
Expand All @@ -972,10 +966,21 @@ void myalgorithm::assignedgenumbers(std::vector<bool>& isownelem, std::vector<st
isbarycenteronnode = std::vector<bool>(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<int>(numedges);
for (int i = 0; i < numedges; i++)
edgenumbers[i] = renumberingvector[i];

// Make the edges numbers continuous:
std::vector<int> 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;
Expand All @@ -988,15 +993,15 @@ void myalgorithm::assignedgenumbers(std::vector<bool>& isownelem, std::vector<st
std::vector<double> ownbarys(3*numownedges);
selectcoordinates(isownedge, barys, ownbarys.data());

// Get edges count on all ranks to create unique edge numbers:
std::vector<int> fragment = {numedges};
std::vector<int> allnumedges;
slmpi::allgather(fragment, allnumedges);
// Get the edges count on all ranks to create unique global edge numbers:
std::vector<int> fragment = {numuniqueedges};
std::vector<int> 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<int> 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];
Expand Down
3 changes: 2 additions & 1 deletion src/mesh/myalgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>& isownelem, std::vector<std::vector<double>>& cornercoords, std::vector<int>& edgenumbers, std::vector<bool>& 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]] ...].
Expand Down

0 comments on commit 7fd4310

Please sign in to comment.