Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of ParMesh::GenerateBoundaryElements() #4244

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions mesh/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ class Mesh
int AddBdrPoint(int v, int attr = 1);

virtual void GenerateBoundaryElements();

/// Finalize the construction of a triangular Mesh.
void FinalizeTriMesh(int generate_edges = 0, int refine = 0,
bool fix_orientation = true);
Expand Down
50 changes: 50 additions & 0 deletions mesh/pmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@ void ParMesh::Load(istream &input, int generate_edges, int refine,
pncmesh->GetConformingSharedStructures(*this);
}

// Assume FinalizeTopology() has been called in Loader
FinalizeParTopo();

Finalize(refine, fix_orientation);

EnsureParNodes();
Expand Down Expand Up @@ -3199,6 +3202,53 @@ int ParMesh::GetNFbyType(FaceType type) const
return Mesh::GetNFbyType(type);
}

void ParMesh::GenerateBoundaryElements()
{
for (auto &b : boundary)
{
FreeElement(b);
}

if (Dim == 3)
{
delete bel_to_edge;
bel_to_edge = NULL;
}

const Array<int> *s2l_face;
if (Dim == 1) { s2l_face = &svert_lvert; }
else if (Dim == 2) { s2l_face = &sedge_ledge; }
else { s2l_face = &sface_lface; }

// mark the shared local elements
Array<bool> l2s_marker(GetNumFaces());
l2s_marker = false;
for (int l : *s2l_face) { l2s_marker[l] = true; }

// count the 'NumOfBdrElements'
NumOfBdrElements = 0;
for (int i = 0; i < faces_info.Size(); i++)
{
const auto &fi = faces_info[i];
if (fi.Elem2No < 0 && !l2s_marker[i])
{ ++NumOfBdrElements; }
}

// Add the boundary elements
boundary.SetSize(NumOfBdrElements);
be_to_face.SetSize(NumOfBdrElements);
for (int i = 0, j = 0; i < faces_info.Size(); i++)
{
if (faces_info[i].Elem2No < 0 && !l2s_marker[i])
{
boundary[j] = faces[i]->Duplicate(this);
be_to_face[j++] = i;
}
}

// Note: in 3D, 'bel_to_edge' is destroyed but it's not updated.
}

// shift cyclically 3 integers a, b, c, so that the smallest of
// order[a], order[b], order[c] is first
static inline
Expand Down
3 changes: 1 addition & 2 deletions mesh/pmesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,7 @@ class ParMesh : public Mesh
shared faces) are counted excluding all master non-conforming faces. */
int GetNFbyType(FaceType type) const override;

void GenerateBoundaryElements() override
{ MFEM_ABORT("Generation of boundary elements works properly only on serial meshes."); }
void GenerateBoundaryElements() override;

/// See the remarks for the serial version in mesh.hpp
MFEM_DEPRECATED void ReorientTetMesh() override;
Expand Down