From f13ceeb0903a7f97d41a3d4e7ed30a997dd4f563 Mon Sep 17 00:00:00 2001 From: gugugu Date: Sat, 19 Aug 2023 00:34:27 +0800 Subject: [PATCH 1/2] add point cell type handler Face cell element needs to be initialized even if the face type is point. Otherwise, modmesh will encounter a segmentation fault during building faces. --- cpp/modmesh/mesh/StaticMesh_interior.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cpp/modmesh/mesh/StaticMesh_interior.cpp b/cpp/modmesh/mesh/StaticMesh_interior.cpp index 1de68b16..38780e2a 100644 --- a/cpp/modmesh/mesh/StaticMesh_interior.cpp +++ b/cpp/modmesh/mesh/StaticMesh_interior.cpp @@ -46,6 +46,21 @@ struct FaceBuilder using uint_type = typename number_base::uint_type; using real_type = typename number_base::real_type; + size_t add_point(int_type icl, int_type ifc) + { + constexpr const size_t NFACE = 1; + clfcs(icl, 0) = NFACE; + for (size_t i = 0; i < NFACE; ++i) + { + fctpn(ifc + i) = CellType::NONCELLTYPE; + fcnds(ifc + i, 0) = 0; // number of nodes per face. + } + // face 1. + clfcs(icl, 1) = ifc; + fcnds(ifc, 1) = clnds(icl, 1); + return NFACE; + } + size_t add_line(int_type icl, int_type ifc) { constexpr const size_t NFACE = 2; @@ -361,6 +376,9 @@ struct FaceBuilder { switch (cltpn(icl)) { + case CellType::POINT: + ifc += static_cast(add_point(icl, ifc)); + break; case CellType::LINE: ifc += static_cast(add_line(icl, ifc)); break; From 6dd41ed6bb4cfd2ee74f639dcc6a4fddd9ea29e1 Mon Sep 17 00:00:00 2001 From: gugugu Date: Sun, 27 Aug 2023 10:49:14 +0800 Subject: [PATCH 2/2] fix ghost cell filling function index typo --- cpp/modmesh/mesh/StaticMesh_boundary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/modmesh/mesh/StaticMesh_boundary.cpp b/cpp/modmesh/mesh/StaticMesh_boundary.cpp index 3089d663..790b0f7b 100644 --- a/cpp/modmesh/mesh/StaticMesh_boundary.cpp +++ b/cpp/modmesh/mesh/StaticMesh_boundary.cpp @@ -261,7 +261,7 @@ inline void StaticMesh::fill_ghost() } for (size_t idm = 0; idm < m_ndim; ++idm) { - m_ndcrd(igcl, idm) = m_ndcrd(icl, idm) + 2 * dist * m_fcnml(ibfc, idm); + m_ndcrd(ignd, idm) = m_ndcrd(ind, idm) + 2 * dist * m_fcnml(ibfc, idm); } // decrement ghost node counter. ignd -= 1;