Skip to content

Commit

Permalink
Merge pull request mfem#3363 from mfem/mesh-reflect
Browse files Browse the repository at this point in the history
Mesh reflector miniapp
  • Loading branch information
pazner authored Feb 21, 2023
2 parents d3d3b6b + 92e11e4 commit 1f89a88
Show file tree
Hide file tree
Showing 8 changed files with 1,130 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ miniapps/meshing/mesh-explorer
miniapps/meshing/shaper
miniapps/meshing/extruder
miniapps/meshing/trimmer
miniapps/meshing/reflector
miniapps/meshing/mesh-optimizer
miniapps/meshing/pmesh-optimizer
miniapps/meshing/minimal-surface
Expand All @@ -219,6 +220,7 @@ miniapps/meshing/mesh-explorer-paraview/
miniapps/meshing/shaper.mesh
miniapps/meshing/extruder.mesh
miniapps/meshing/trimmer.mesh
miniapps/meshing/reflected.mesh
miniapps/meshing/optimized*
miniapps/meshing/perturbed*
miniapps/meshing/polar-nc.mesh
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Linear and nonlinear solvers

New and updated examples and miniapps
-------------------------------------
- Added a new meshing miniapp, reflector, which reflects a high-order or NURBS
hexahedral mesh about a plane.

- The mesh-explorer miniapp can now save mesh files in the VisIt or ParaView
formats using the corresponding DataCollection objects. See option 'D' in the
main menu.
Expand Down
8 changes: 6 additions & 2 deletions fem/gridfunc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class GridFunction : public Vector

void SaveSTLTri(std::ostream &out, double p1[], double p2[], double p3[]);

void GetVectorGradientHat(ElementTransformation &T, DenseMatrix &gh) const;

// Project the delta coefficient without scaling and return the (local)
// integral of the projection.
void ProjectDeltaCoefficient(DeltaCoefficient &delta_coeff,
Expand Down Expand Up @@ -338,8 +336,14 @@ class GridFunction : public Vector
DenseMatrix &grad) const
{ GetGradients(*fes->GetElementTransformation(elem), ir, grad); }

/** @brief Compute the vector gradient with respect to the physical element
variable. */
void GetVectorGradient(ElementTransformation &tr, DenseMatrix &grad) const;

/** @brief Compute the vector gradient with respect to the reference element
variable. */
void GetVectorGradientHat(ElementTransformation &T, DenseMatrix &gh) const;

/** Compute \f$ (\int_{\Omega} (*this) \psi_i)/(\int_{\Omega} \psi_i) \f$,
where \f$ \psi_i \f$ are the basis functions for the FE space of avgs.
Both FE spaces should be scalar and on the same mesh. */
Expand Down
35 changes: 35 additions & 0 deletions mesh/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ void Mesh::InitTables()
{
el_to_edge =
el_to_face = el_to_el = bel_to_edge = face_edge = edge_vertex = NULL;
face_to_elem = NULL;
}

void Mesh::SetEmpty()
Expand All @@ -1489,6 +1490,9 @@ void Mesh::DestroyTables()

delete face_edge;
delete edge_vertex;

delete face_to_elem;
face_to_elem = NULL;
}

void Mesh::DestroyPointers()
Expand Down Expand Up @@ -1550,6 +1554,7 @@ void Mesh::ResetLazyData()
{
delete el_to_el; el_to_el = NULL;
delete face_edge; face_edge = NULL;
delete face_to_elem; face_to_elem = NULL;
delete edge_vertex; edge_vertex = NULL;
DeleteGeometricFactors();
nbInteriorFaces = -1;
Expand Down Expand Up @@ -3632,6 +3637,7 @@ Mesh::Mesh(const Mesh &mesh, bool copy_nodes)

// Do NOT copy the face-to-edge Table, face_edge
face_edge = NULL;
face_to_elem = NULL;

// Copy the edge-to-vertex Table, edge_vertex
edge_vertex = (mesh.edge_vertex) ? new Table(*mesh.edge_vertex) : NULL;
Expand Down Expand Up @@ -6175,6 +6181,34 @@ void Mesh::GetElementFaces(int i, Array<int> &el_faces, Array<int> &ori) const
}
}

Array<int> Mesh::FindFaceNeighbors(const int elem) const
{
if (face_to_elem == NULL)
{
face_to_elem = GetFaceToElementTable();
}

Array<int> elem_faces;
Array<int> ori;
GetElementFaces(elem, elem_faces, ori);

Array<int> nghb;
for (auto f : elem_faces)
{
Array<int> row;
face_to_elem->GetRow(f, row);
for (auto r : row)
{
nghb.Append(r);
}
}

nghb.Sort();
nghb.Unique();

return nghb;
}

void Mesh::GetBdrElementFace(int i, int *f, int *o) const
{
const int *bv, *fv;
Expand Down Expand Up @@ -9318,6 +9352,7 @@ void Mesh::Swap(Mesh& other, bool non_geometry)
mfem::Swap(bel_to_edge, other.bel_to_edge);
mfem::Swap(be_to_face, other.be_to_face);
mfem::Swap(face_edge, other.face_edge);
mfem::Swap(face_to_elem, other.face_to_elem);
mfem::Swap(edge_vertex, other.edge_vertex);

mfem::Swap(attributes, other.attributes);
Expand Down
13 changes: 11 additions & 2 deletions mesh/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,13 @@ class Mesh
Array<int> be_to_edge; // for 2D
Table *bel_to_edge; // for 3D
Array<int> be_to_face;
mutable Table *face_edge;
mutable Table *edge_vertex;

// Note that the following tables are owned by this class and should not be
// deleted by the caller. Of these three tables, only face_edge and
// edge_vertex are returned by access functions.
mutable Table *face_to_elem; // Used by FindFaceNeighbors, not returned.
mutable Table *face_edge; // Returned by GetFaceEdgeTable().
mutable Table *edge_vertex; // Returned by GetEdgeVertexTable().

IsoparametricTransformation Transformation, Transformation2;
IsoparametricTransformation BdrTransformation;
Expand Down Expand Up @@ -1182,6 +1187,10 @@ class Mesh
/// Return the indices and the orientations of all faces of element i.
void GetElementFaces(int i, Array<int> &faces, Array<int> &ori) const;

/** @brief Returns the sorted, unique indices of elements sharing a face with
element @a elem, including @a elem. */
Array<int> FindFaceNeighbors(const int elem) const;

/// Return the index and the orientation of the face of bdr element i. (3D)
void GetBdrElementFace(int i, int *f, int *o) const;

Expand Down
4 changes: 4 additions & 0 deletions miniapps/meshing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ add_mfem_miniapp(minimal-surface
MAIN minimal-surface.cpp
LIBRARIES mfem)

add_mfem_miniapp(reflector
MAIN reflector.cpp
LIBRARIES mfem)

add_mfem_miniapp(toroid
MAIN toroid.cpp
LIBRARIES mfem)
Expand Down
8 changes: 5 additions & 3 deletions miniapps/meshing/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MFEM_LIB_FILE = mfem_is_not_built
-include $(CONFIG_MK)

SEQ_MINIAPPS = mobius-strip klein-bottle toroid trimmer twist mesh-explorer\
shaper extruder mesh-optimizer minimal-surface polar-nc
shaper extruder mesh-optimizer minimal-surface polar-nc reflector
PAR_MINIAPPS = pmesh-optimizer pminimal-surface
ifeq ($(MFEM_USE_MPI),NO)
MINIAPPS = $(SEQ_MINIAPPS)
Expand Down Expand Up @@ -91,6 +91,8 @@ minimal-surface-test-seq: minimal-surface
@$(call mfem-test,$<,, Meshing miniapp)
pminimal-surface-test-par: pminimal-surface
@$(call mfem-test,$<, $(RUN_MPI), Parallel meshing miniapp)
reflector-test-seq: reflector
@$(call mfem-test-file,$<,, Meshing miniapp,reflected.mesh)

# Testing: Specific execution options
mesh-explorer-test-seq:
Expand All @@ -108,14 +110,14 @@ clean: clean-build clean-exec

clean-build:
rm -f *.o *~ mobius-strip klein-bottle toroid twist
rm -f mesh-explorer shaper extruder trimmer
rm -f mesh-explorer shaper extruder trimmer reflector
rm -f mesh-optimizer pmesh-optimizer polar-nc
rm -f minimal-surface pminimal-surface
rm -rf *.dSYM *.TVD.*breakpoints

clean-exec:
@rm -f mobius-strip.mesh klein-bottle.mesh mesh-explorer.mesh
@rm -f toroid-*.mesh twist-*.mesh trimmer.mesh
@rm -f toroid-*.mesh twist-*.mesh trimmer.mesh reflected.mesh
@rm -f partitioning.txt shaper.mesh extruder.mesh
@rm -f optimized* perturbed* polar-nc.mesh
@rm -rf mesh-explorer-{visit,paraview}*
Loading

0 comments on commit 1f89a88

Please sign in to comment.