diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c63aa16e4e0cd1164dff621f651e9830b70d817..4123ae92ebbeec90836c8ce35cbe7e6472c66ab3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ v4.4.1 - Remove the duplicate output of errorutil (!756) **NekMesh**: -- Fix memory consumption issue with Gmsh output (!747) +- Fix memory consumption issue with Gmsh output (!747, !762) - Rework meshing control so that if possible viewable meshes will be dumped when some part of the system fails (!756) - Add manifold meshing option (!756) diff --git a/library/NekMeshUtils/MeshElements/Edge.h b/library/NekMeshUtils/MeshElements/Edge.h index 9ecda28f3c1bf84dfc39ce2f6f1b2f877fabe6b3..252e43959e2ad2ffe8c4843c11f3d6f4b9a51a54 100644 --- a/library/NekMeshUtils/MeshElements/Edge.h +++ b/library/NekMeshUtils/MeshElements/Edge.h @@ -73,8 +73,9 @@ public: /// Copies an existing edge. NEKMESHUTILS_EXPORT Edge(const Edge &pSrc) - : m_n1(pSrc.m_n1), m_n2(pSrc.m_n2), m_edgeNodes(pSrc.m_edgeNodes), - m_curveType(pSrc.m_curveType), m_geom(pSrc.m_geom) + : m_id(pSrc.m_id), m_n1(pSrc.m_n1), m_n2(pSrc.m_n2), + m_edgeNodes(pSrc.m_edgeNodes), m_curveType(pSrc.m_curveType), + m_elLink(pSrc.m_elLink), m_parentCAD(pSrc.m_parentCAD) { } diff --git a/library/NekMeshUtils/MeshElements/Face.h b/library/NekMeshUtils/MeshElements/Face.h index ef1b67b4020b5ba8e79dd768b959edd6335f5b7f..d653b5a879ab2fddbc32bc08d753ec0c6b50d8e5 100644 --- a/library/NekMeshUtils/MeshElements/Face.h +++ b/library/NekMeshUtils/MeshElements/Face.h @@ -67,13 +67,18 @@ public: std::vector pEdgeList, LibUtilities::PointsType pCurveType) : m_vertexList(pVertexList), m_edgeList(pEdgeList), - m_faceNodes(pFaceNodes), m_curveType(pCurveType), m_geom(){} + m_faceNodes(pFaceNodes), m_curveType(pCurveType), m_geom() + { + } /// Copy an existing face. NEKMESHUTILS_EXPORT Face(const Face &pSrc) - : m_vertexList(pSrc.m_vertexList), m_edgeList(pSrc.m_edgeList), - m_faceNodes(pSrc.m_faceNodes), m_curveType(pSrc.m_curveType), - m_geom(pSrc.m_geom){} + : m_id(pSrc.m_id), m_vertexList(pSrc.m_vertexList), + m_edgeList(pSrc.m_edgeList), m_faceNodes(pSrc.m_faceNodes), + m_curveType(pSrc.m_curveType), m_geom(pSrc.m_geom), + m_parentCAD(pSrc.m_parentCAD) + { + } NEKMESHUTILS_EXPORT ~Face() { diff --git a/library/NekMeshUtils/MeshElements/Mesh.cpp b/library/NekMeshUtils/MeshElements/Mesh.cpp index e84618693ae7c818bdd02876a07f5064aae19e30..3f5dc6855794b728dbd66a97327ce5da575c59bf 100644 --- a/library/NekMeshUtils/MeshElements/Mesh.cpp +++ b/library/NekMeshUtils/MeshElements/Mesh.cpp @@ -98,12 +98,10 @@ unsigned int Mesh::GetNumEntities() */ void Mesh::MakeOrder(int order, LibUtilities::PointsType distType) { - - // going to make a copy of the curavture information - // cheaper that geom objects - // currently the geometry objects which make up a 3D element - // dont use the volume nodes, they are just stored, - // so we can get away without copying them + // Going to make a copy of the curavture information, since this is cheaper + // than using Nektar's Geometry objects. Currently, the geometry objects + // which make up a 3D element dont use the volume nodes, they are just + // stored, so we can get away without copying them. int id = m_vertexSet.size(); @@ -141,19 +139,47 @@ void Mesh::MakeOrder(int order, LibUtilities::PointsType distType) ASSERTL1(false, "Mesh::MakeOrder does not support this points type."); } - // Begin by coping mesh objects for edges, faces - // so that we don't affect any neighbouring elements in the mesh as - // we process each element. - // at the same time we delete the curvature from the original edge + // Begin by copying mesh objects for edges and faces so that we don't affect + // any neighbouring elements in the mesh as we process each element. At the + // same time we delete the curvature from the original edge and face, which + // will be re-added with the MakeOrder routine. + + // First, we fill in the volume-interior nodes. This preserves the original + // curvature of the mesh. + const int nElmt = m_element[m_expDim].size(); + int tmpId = 0; + for (int i = 0; i < nElmt; ++i) + { + if (m_verbose) + { + LibUtilities::PrintProgressbar(i, nElmt, "MakeOrder: Elements: "); + } + ElementSharedPtr el = m_element[m_expDim][i]; + SpatialDomains::GeometrySharedPtr geom = el->GetGeom(m_spaceDim); + geom->FillGeom(); + el->MakeOrder(order, geom, pTypes[el->GetConf().m_e], m_spaceDim, tmpId); + } + + // Now make copies of each of the edges. for (eit = m_edgeSet.begin(); eit != m_edgeSet.end(); eit++) { edgeCopies[(*eit)->m_id] = EdgeSharedPtr(new Edge(*(*eit))); (*eit)->m_edgeNodes.clear(); } + // Now copy faces. Make sure that this is a "deep copy", so that the face's + // edge list corresponds to the copied edges, otherwise we end up in a + // non-consistent state. for (fit = m_faceSet.begin(); fit != m_faceSet.end(); fit++) { - faceCopies[(*fit)->m_id] = FaceSharedPtr(new Face(*(*fit))); + FaceSharedPtr tmpFace = FaceSharedPtr(new Face(*(*fit))); + + for (int i = 0; i < tmpFace->m_edgeList.size(); ++i) + { + tmpFace->m_edgeList[i] = edgeCopies[tmpFace->m_edgeList[i]->m_id]; + } + + faceCopies[(*fit)->m_id] = tmpFace; (*fit)->m_faceNodes.clear(); } @@ -249,18 +275,13 @@ void Mesh::MakeOrder(int order, LibUtilities::PointsType distType) el->SetVolumeNodes(face->m_faceNodes); } - // Finally, fill in volumes. - const int nElmt = m_element[m_expDim].size(); for (int i = 0; i < nElmt; ++i) { - if (m_verbose) + vector tmp = m_element[m_expDim][i]->GetVolumeNodes(); + for (int j = 0; j < tmp.size(); ++j) { - LibUtilities::PrintProgressbar(i, nElmt, "MakeOrder: Elements: "); + tmp[j]->m_id = id++; } - ElementSharedPtr el = m_element[m_expDim][i]; - SpatialDomains::GeometrySharedPtr geom = el->GetGeom(m_spaceDim); - geom->FillGeom(); - el->MakeOrder(order, geom, pTypes[el->GetConf().m_e], m_spaceDim, id); } if (m_verbose)