Skip to content

Commit

Permalink
WIP - Removed all boundary elements that have two elments on both sid…
Browse files Browse the repository at this point in the history
…es (not considering interior BEs).
  • Loading branch information
LeilaGhaffari committed Aug 13, 2024
1 parent bd9cb22 commit ca9c1e5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 28 deletions.
6 changes: 1 addition & 5 deletions palace/fem/libceed/restriction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void InitNativeRestr(const mfem::FiniteElementSpace &fespace,
// Find the dofs
mfem::real_t tol = 1E-5;
mfem::Array<int> elem_dofs;
fespace.GetElementDofs(elem_id, elem_dofs, dof_trans); // TODO: Check if passing dof_trans is OK
fespace.GetElementDofs(elem_id, elem_dofs, dof_trans);
dofs.SetSize(P);
for (int l=0; l< P; l++)
{
Expand All @@ -226,10 +226,6 @@ void InitNativeRestr(const mfem::FiniteElementSpace &fespace,
{
dofs[l] = elem_dofs[m];
}
else
{
continue;
}
}
else
{
Expand Down
72 changes: 49 additions & 23 deletions palace/utils/geodata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2175,14 +2175,31 @@ std::map<int, std::array<int, 2>> CheckMesh(std::unique_ptr<mfem::Mesh> &orig_me
bdr_elem_delete(orig_mesh->GetNBE(), false);
std::unordered_map<int, int> face_to_be, new_face_be;
face_to_be.reserve(orig_mesh->GetNBE());
//for (int be = 0; be < orig_mesh->GetNBE(); be++) // TODO: need to fix this!
//{
// int f, o;
// orig_mesh->GetBdrElementFace(be, &f, &o);
// MFEM_VERIFY(face_to_be.find(f) == face_to_be.end(),
// "Mesh should not define boundary elements multiple times!");
// face_to_be[f] = be;
//}
for (int be = 0; be < orig_mesh->GetNBE(); be++)
{
int attr = orig_mesh->GetBdrAttribute(be);
bool periodic_be = false;
for (auto &data : iodata.boundaries.periodic)
{
for (auto d_attr : data.donor_attributes) if (d_attr == attr) periodic_be = true;
for (auto r_attr : data.receiver_attributes) if (r_attr == attr) periodic_be = true;
}
int face, o, e1, e2;
orig_mesh->GetBdrElementFace(be, &face, &o);
orig_mesh->GetFaceElements(face, &e1, &e2);
// If there are two elements associated with the face on the boundary, then the mesh is periodic.
if ((e1 >= 0) && (e2 >= 0))
{
periodic_be = true;
}
if (!periodic_be) {
int f, o;
orig_mesh->GetBdrElementFace(be, &f, &o);
MFEM_VERIFY(face_to_be.find(f) == face_to_be.end(),
"Mesh should not define boundary elements multiple times!");
face_to_be[f] = be;
}
}

if (clean_elem)
{
Expand Down Expand Up @@ -2215,23 +2232,32 @@ std::map<int, std::array<int, 2>> CheckMesh(std::unique_ptr<mfem::Mesh> &orig_me
}
}
// Remove any boundary element that is on the periodic surfaces.
if (!iodata.boundaries.periodic.empty()) {
for (int be = 0; be < orig_mesh->GetNBE(); be++)
for (int be = 0; be < orig_mesh->GetNBE(); be++)
{
bool periodic_be = false;
int attr = orig_mesh->GetBdrAttribute(be);
for (auto &data : iodata.boundaries.periodic)
{
int attr = orig_mesh->GetBdrAttribute(be);
for (auto &data : iodata.boundaries.periodic)
{
bool periodic_be = false;
for (auto d_attr : data.donor_attributes) if (d_attr == attr) periodic_be = true;
for (auto r_attr : data.receiver_attributes) if (r_attr == attr) periodic_be = true;
if (periodic_be)
{
bdr_elem_delete[be] = true;
new_nbe--;
}
}
for (auto d_attr : data.donor_attributes) if (d_attr == attr) periodic_be = true;
for (auto r_attr : data.receiver_attributes) if (r_attr == attr) periodic_be = true;
}
int face, o, e1, e2;
orig_mesh->GetBdrElementFace(be, &face, &o);
orig_mesh->GetFaceElements(face, &e1, &e2);
bool elem1 = !(e1 < 0 || elem_delete[e1]);
bool elem2 = !(e2 < 0 || elem_delete[e2]);
// If there are two elements associated with the face on the boundary, then the mesh is periodic.
if (elem1 && elem2)
{
periodic_be = true;
}
if (periodic_be)
{
bdr_elem_delete[be] = true;
new_nbe--;
}
}

if (new_ne < orig_mesh->GetNE())
{
Mpi::Print("Removed {:d} unmarked domain elements from the mesh\n",
Expand All @@ -2255,7 +2281,7 @@ std::map<int, std::array<int, 2>> CheckMesh(std::unique_ptr<mfem::Mesh> &orig_me
int new_nbe_ext = 0, new_nbe_int = 0;
for (int f = 0; f < orig_mesh->GetNumFaces(); f++)
{
if (face_to_be.find(f) != face_to_be.end() || !iodata.boundaries.periodic.empty()) // TODO: I might need to fix this
if (face_to_be.find(f) != face_to_be.end())
{
continue;
}
Expand Down

0 comments on commit ca9c1e5

Please sign in to comment.