From 3f757b4b322f98be76adb9888d130e86704710d8 Mon Sep 17 00:00:00 2001 From: Jessica Marquis Date: Thu, 13 Jun 2024 15:27:54 -0400 Subject: [PATCH] Update node based geometry find element family of functions to - properly check for nullptrs - allow user to either leave array as is or recalculate it if the array already exists --- .../Algorithms/FeatureFaceCurvature.cpp | 6 +- .../Filters/Algorithms/FindNRingNeighbors.cpp | 12 +- .../Algorithms/LabelTriangleGeometry.cpp | 2 +- .../Filters/Algorithms/LaplacianSmoothing.cpp | 5 +- .../Filters/ComputeFeatureSizesFilter.cpp | 22 +- .../DataStructure/Geometry/EdgeGeom.cpp | 80 +++-- .../DataStructure/Geometry/EdgeGeom.hpp | 8 +- .../DataStructure/Geometry/HexahedralGeom.cpp | 156 ++++++--- .../DataStructure/Geometry/HexahedralGeom.hpp | 16 +- .../DataStructure/Geometry/IGeometry.hpp | 2 +- .../Geometry/INodeGeometry1D.hpp | 7 +- .../Geometry/INodeGeometry2D.hpp | 4 +- .../Geometry/INodeGeometry3D.hpp | 4 +- .../DataStructure/Geometry/ImageGeom.cpp | 24 +- .../DataStructure/Geometry/ImageGeom.hpp | 2 +- .../DataStructure/Geometry/QuadGeom.cpp | 107 +++++-- .../DataStructure/Geometry/QuadGeom.hpp | 12 +- .../DataStructure/Geometry/RectGridGeom.cpp | 15 +- .../DataStructure/Geometry/RectGridGeom.hpp | 2 +- .../Geometry/TetrahedralGeom.cpp | 138 +++++--- .../Geometry/TetrahedralGeom.hpp | 16 +- .../DataStructure/Geometry/TriangleGeom.cpp | 110 +++++-- .../DataStructure/Geometry/TriangleGeom.hpp | 12 +- .../DataStructure/Geometry/VertexGeom.cpp | 16 +- .../DataStructure/Geometry/VertexGeom.hpp | 2 +- src/simplnx/Utilities/GeometryHelpers.hpp | 8 +- test/DataStructTest.cpp | 300 ++++++++++++++++-- 27 files changed, 798 insertions(+), 290 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FeatureFaceCurvature.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FeatureFaceCurvature.cpp index c01c7816eb..8131c041af 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FeatureFaceCurvature.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FeatureFaceCurvature.cpp @@ -56,11 +56,7 @@ Result<> FeatureFaceCurvature::operator()() // Make sure the Face Connectivity is created because the FindNRing algorithm needs this and will // assert if the data is NOT in the SurfaceMesh Data Container - const IGeometry::ElementDynamicList* vertLinks = triangleGeomPtr->getElementsContainingVert(); - if(nullptr == vertLinks) - { - triangleGeomPtr->findElementsContainingVert(); - } + triangleGeomPtr->findElementsContainingVert(false); int32_t maxFaceId = 0; for(int64_t t = 0; t < numTriangles; ++t) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp index f3e8b1cfa0..a16603dccc 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp @@ -35,16 +35,12 @@ Result<> FindNRingNeighbors::operator()(const IFilter::MessageHandler& mesgHandl m_NRingTriangles.clear(); // Make sure we have the proper connectivity built - const INodeGeometry1D::ElementDynamicList* node2TrianglePtr = triangleGeom->getElementsContainingVert(); - if(node2TrianglePtr == nullptr) + err = triangleGeom->findElementsContainingVert(false); + if(err < 0) { - err = triangleGeom->findElementsContainingVert(); - if(err < 0) - { - return MakeErrorResult(err, "Failed to find elements containing vert"); - } - node2TrianglePtr = triangleGeom->getElementsContainingVert(); + return MakeErrorResult(err, "Failed to find elements containing vert"); } + const INodeGeometry1D::ElementDynamicList* node2TrianglePtr = triangleGeom->getElementsContainingVert(); // Figure out these boolean values for a sanity check bool check0 = faceLabels[triangleId * 2] == m_InputValues->RegionId0 && faceLabels[triangleId * 2 + 1] == m_InputValues->RegionId1; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp index 51484dd467..2a2b6fee65 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp @@ -35,7 +35,7 @@ Result<> LabelTriangleGeometry::operator()() { usize numTris = triangle.getNumberOfFaces(); - auto check = triangle.findElementNeighbors(); // use auto since return time is a class declared typename + auto check = triangle.findElementNeighbors(false); // use auto since return time is a class declared typename if(check < 0) { return MakeErrorResult(check, fmt::format("Error finding element neighbors for {} geometry", triangle.getName())); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp index e7fa328c68..8f9409b3dd 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp @@ -43,10 +43,7 @@ Result<> LaplacianSmoothing::edgeBasedSmoothing() std::vector lambdas = generateLambdaArray(); // Generate the Unique Edges - if(nullptr == surfaceMesh.getEdges()) - { - err = surfaceMesh.findEdges(); - } + err = surfaceMesh.findEdges(false); if(err < 0) { return MakeErrorResult(-560, "Error retrieving the shared edge list"); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp index b182190824..c8b7be5961 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp @@ -232,14 +232,11 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co if(saveElementSizes) { - if(!imageGeom->getElementSizes()) + int32 err = imageGeom->findElementSizes(false); + if(err < 0) { - int32 err = imageGeom->findElementSizes(); - if(err < 0) - { - std::string ss = fmt::format("Error computing Element sizes for Geometry type {}", imageGeom->getTypeName()); - return {nonstd::make_unexpected(std::vector{Error{err, ss}})}; - } + std::string ss = fmt::format("Error computing Element sizes for Geometry type {}", imageGeom->getTypeName()); + return {nonstd::make_unexpected(std::vector{Error{err, ss}})}; } } } @@ -255,14 +252,11 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co usize numfeatures = volumes.getNumberOfTuples(); - if(!geom->getElementSizes()) + int32_t err = geom->findElementSizes(false); + if(err < 0) { - int32_t err = geom->findElementSizes(); - if(err < 0) - { - std::string ss = fmt::format("Error computing Element sizes for Geometry type {}", geom->getTypeName()); - return {nonstd::make_unexpected(std::vector{Error{err, ss}})}; - } + std::string ss = fmt::format("Error computing Element sizes for Geometry type {}", geom->getTypeName()); + return {nonstd::make_unexpected(std::vector{Error{err, ss}})}; } const Float32Array* elemSizes = geom->getElementSizes(); diff --git a/src/simplnx/DataStructure/Geometry/EdgeGeom.cpp b/src/simplnx/DataStructure/Geometry/EdgeGeom.cpp index a01e1eb648..7e3dd17a94 100644 --- a/src/simplnx/DataStructure/Geometry/EdgeGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/EdgeGeom.cpp @@ -137,12 +137,21 @@ std::shared_ptr EdgeGeom::deepCopy(const DataPath& copyPath) return nullptr; } -IGeometry::StatusCode EdgeGeom::findElementSizes() +IGeometry::StatusCode EdgeGeom::findElementSizes(bool recalculate) { - auto dataStore = std::make_unique>(getNumberOfCells(), 0.0f); - auto* sizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); + auto* sizes = getDataStructureRef().getDataAs(m_ElementSizesId); + if(sizes != nullptr && !recalculate) + { + return 0; + } + if(sizes == nullptr) + { + auto dataStore = std::make_unique>(getNumberOfCells(), 0.0f); + sizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); + } if(sizes == nullptr) { + m_ElementSizesId.reset(); return -1; } m_ElementSizesId = sizes->getId(); @@ -163,59 +172,78 @@ IGeometry::StatusCode EdgeGeom::findElementSizes() return 1; } -IGeometry::StatusCode EdgeGeom::findElementsContainingVert() +IGeometry::StatusCode EdgeGeom::findElementsContainingVert(bool recalculate) { - auto* containsVert = ElementDynamicList::Create(*getDataStructure(), k_EltsContainingVert, getId()); + auto* containsVert = getDataStructureRef().getDataAs(m_CellContainingVertDataArrayId); + if(containsVert != nullptr && !recalculate) + { + return 0; + } if(containsVert == nullptr) { - return -1; + containsVert = ElementDynamicList::Create(*getDataStructure(), k_EltsContainingVert, getId()); } - GeometryHelpers::Connectivity::FindElementsContainingVert(getEdges(), containsVert, getNumberOfVertices()); if(containsVert == nullptr) { m_CellContainingVertDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::FindElementsContainingVert(getEdges(), containsVert, getNumberOfVertices()); m_CellContainingVertDataArrayId = containsVert->getId(); return 1; } -IGeometry::StatusCode EdgeGeom::findElementNeighbors() +IGeometry::StatusCode EdgeGeom::findElementNeighbors(bool recalculate) { - StatusCode err = 0; - if(getElementsContainingVert() == nullptr) + auto* edgeNeighbors = getDataStructureRef().getDataAs(m_CellNeighborsDataArrayId); + if(edgeNeighbors != nullptr && !recalculate) { - err = findElementsContainingVert(); - if(err < 0) - { - return err; - } + return 0; } - auto* edgeNeighbors = ElementDynamicList::Create(*getDataStructure(), k_EltNeighbors, getId()); - if(edgeNeighbors == nullptr) + + StatusCode err = findElementsContainingVert(recalculate); + if(err < 0) { - err = -1; + m_CellNeighborsDataArrayId.reset(); return err; } + if(edgeNeighbors == nullptr) + { + edgeNeighbors = ElementDynamicList::Create(*getDataStructure(), k_EltNeighbors, getId()); + } + if(edgeNeighbors == nullptr) + { + m_CellNeighborsDataArrayId.reset(); + return -1; + } m_CellNeighborsDataArrayId = edgeNeighbors->getId(); err = GeometryHelpers::Connectivity::FindElementNeighbors(getEdges(), getElementsContainingVert(), edgeNeighbors, IGeometry::Type::Edge); - if(getElementNeighbors() == nullptr) + if(edgeNeighbors == nullptr) { m_CellNeighborsDataArrayId.reset(); - err = -1; + return -1; } - return err; + return 1; } -IGeometry::StatusCode EdgeGeom::findElementCentroids() +IGeometry::StatusCode EdgeGeom::findElementCentroids(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); - auto* edgeCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); - GeometryHelpers::Topology::FindElementCentroids(getEdges(), getVertices(), edgeCentroids); - if(getElementCentroids() == nullptr) + auto* edgeCentroids = getDataStructureRef().getDataAs(m_CellCentroidsDataArrayId); + if(edgeCentroids != nullptr && !recalculate) + { + return 0; + } + if(edgeCentroids == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); + edgeCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); + } + if(edgeCentroids == nullptr) { + m_CellCentroidsDataArrayId.reset(); return -1; } + GeometryHelpers::Topology::FindElementCentroids(getEdges(), getVertices(), edgeCentroids); m_CellCentroidsDataArrayId = edgeCentroids->getId(); return 1; } diff --git a/src/simplnx/DataStructure/Geometry/EdgeGeom.hpp b/src/simplnx/DataStructure/Geometry/EdgeGeom.hpp index ffd0f67c48..5e38c8aa09 100644 --- a/src/simplnx/DataStructure/Geometry/EdgeGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/EdgeGeom.hpp @@ -98,25 +98,25 @@ class SIMPLNX_EXPORT EdgeGeom : public INodeGeometry1D * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementsContainingVert() override; + StatusCode findElementsContainingVert(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementNeighbors() override; + StatusCode findElementNeighbors(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementCentroids() override; + StatusCode findElementCentroids(bool recalculate) override; /** * @brief diff --git a/src/simplnx/DataStructure/Geometry/HexahedralGeom.cpp b/src/simplnx/DataStructure/Geometry/HexahedralGeom.cpp index a49acfffa0..45f1886618 100644 --- a/src/simplnx/DataStructure/Geometry/HexahedralGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/HexahedralGeom.cpp @@ -191,66 +191,100 @@ usize HexahedralGeom::getNumberOfCells() const return elements.getNumberOfTuples(); } -IGeometry::StatusCode HexahedralGeom::findElementSizes() +IGeometry::StatusCode HexahedralGeom::findElementSizes(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, 0.0f); - Float32Array* hexSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); - m_ElementSizesId = hexSizes->getId(); - GeometryHelpers::Topology::FindHexVolumes(getPolyhedra(), getVertices(), hexSizes); - if(getElementSizes() == nullptr) + auto* hexSizes = getDataStructureRef().getDataAs(m_ElementSizesId); + if(hexSizes != nullptr && !recalculate) + { + return 0; + } + if(hexSizes == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, 0.0f); + hexSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); + } + if(hexSizes == nullptr) { m_ElementSizesId.reset(); return -1; } + m_ElementSizesId = hexSizes->getId(); + GeometryHelpers::Topology::FindHexVolumes(getPolyhedra(), getVertices(), hexSizes); return 1; } -IGeometry::StatusCode HexahedralGeom::findElementsContainingVert() +IGeometry::StatusCode HexahedralGeom::findElementsContainingVert(bool recalculate) { - auto* hexasControllingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); - m_CellContainingVertDataArrayId = hexasControllingVert->getId(); - GeometryHelpers::Connectivity::FindElementsContainingVert(getPolyhedra(), hexasControllingVert, getNumberOfVertices()); - if(getElementsContainingVert() == nullptr) + auto* hexasControllingVert = getDataStructureRef().getDataAs(m_CellContainingVertDataArrayId); + if(hexasControllingVert != nullptr && !recalculate) + { + return 0; + } + if(hexasControllingVert == nullptr) + { + hexasControllingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); + } + if(hexasControllingVert == nullptr) { m_CellContainingVertDataArrayId.reset(); return -1; } + m_CellContainingVertDataArrayId = hexasControllingVert->getId(); + GeometryHelpers::Connectivity::FindElementsContainingVert(getPolyhedra(), hexasControllingVert, getNumberOfVertices()); return 1; } -IGeometry::StatusCode HexahedralGeom::findElementNeighbors() +IGeometry::StatusCode HexahedralGeom::findElementNeighbors(bool recalculate) { - StatusCode err = 0; - if(getElementsContainingVert() == nullptr) + auto* hexNeighbors = getDataStructureRef().getDataAs(m_CellNeighborsDataArrayId); + if(hexNeighbors != nullptr && !recalculate) { - err = findElementsContainingVert(); - if(err < 0) - { - return err; - } + return 0; } - auto* hexNeighbors = DynamicListArray::Create(*getDataStructure(), k_EltNeighbors, getId()); - m_CellNeighborsDataArrayId = hexNeighbors->getId(); - err = GeometryHelpers::Connectivity::FindElementNeighbors(getPolyhedra(), getElementsContainingVert(), hexNeighbors, IGeometry::Type::Hexahedral); - if(getElementNeighbors() == nullptr) + + StatusCode err = findElementsContainingVert(recalculate); + if(err < 0) + { + m_CellNeighborsDataArrayId.reset(); + return err; + } + if(hexNeighbors == nullptr) + { + hexNeighbors = DynamicListArray::Create(*getDataStructure(), k_EltNeighbors, getId()); + } + if(hexNeighbors == nullptr) { m_CellNeighborsDataArrayId.reset(); return -1; } - return err; + m_CellNeighborsDataArrayId = hexNeighbors->getId(); + err = GeometryHelpers::Connectivity::FindElementNeighbors(getPolyhedra(), getElementsContainingVert(), hexNeighbors, IGeometry::Type::Hexahedral); + if(err < 0) + { + return err; + } + return 1; } -IGeometry::StatusCode HexahedralGeom::findElementCentroids() +IGeometry::StatusCode HexahedralGeom::findElementCentroids(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); - auto* hexCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); - m_CellCentroidsDataArrayId = hexCentroids->getId(); - GeometryHelpers::Topology::FindElementCentroids(getPolyhedra(), getVertices(), hexCentroids); - if(getElementCentroids() == nullptr) + auto* hexCentroids = getDataStructureRef().getDataAs(m_CellCentroidsDataArrayId); + if(hexCentroids != nullptr && !recalculate) + { + return 0; + } + if(hexCentroids == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); + hexCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); + } + if(hexCentroids == nullptr) { m_CellCentroidsDataArrayId.reset(); return -1; } + m_CellCentroidsDataArrayId = hexCentroids->getId(); + GeometryHelpers::Topology::FindElementCentroids(getPolyhedra(), getVertices(), hexCentroids); return 1; } @@ -296,56 +330,88 @@ void HexahedralGeom::getShapeFunctions(const Point3D& pCoords, float64* shape[23] = rm * pCoords[1]; } -IGeometry::StatusCode HexahedralGeom::findEdges() +IGeometry::StatusCode HexahedralGeom::findEdges(bool recalculate) { - auto* edgeList = createSharedEdgeList(0); - GeometryHelpers::Connectivity::FindHexEdges(getPolyhedra(), edgeList); - if(getEdges() == nullptr) + auto* edgeList = getDataStructureRef().getDataAs>(m_EdgeDataArrayId); + if(edgeList != nullptr && !recalculate) + { + return 0; + } + if(edgeList == nullptr) + { + edgeList = createSharedEdgeList(0); + } + if(edgeList == nullptr) { m_EdgeDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::FindHexEdges(getPolyhedra(), edgeList); m_EdgeDataArrayId = edgeList->getId(); return 1; } -IGeometry::StatusCode HexahedralGeom::findFaces() +IGeometry::StatusCode HexahedralGeom::findFaces(bool recalculate) { - auto* quadList = createSharedQuadList(0); - GeometryHelpers::Connectivity::FindHexFaces(getPolyhedra(), quadList); + auto* quadList = getDataStructureRef().getDataAs>(m_FaceListId); + if(quadList != nullptr && !recalculate) + { + return 0; + } + if(quadList == nullptr) + { + quadList = createSharedQuadList(0); + } if(quadList == nullptr) { m_FaceListId.reset(); return -1; } + GeometryHelpers::Connectivity::FindHexFaces(getPolyhedra(), quadList); m_FaceListId = quadList->getId(); return 1; } -IGeometry::StatusCode HexahedralGeom::findUnsharedEdges() +IGeometry::StatusCode HexahedralGeom::findUnsharedEdges(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); - DataArray* unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); - GeometryHelpers::Connectivity::FindUnsharedHexEdges(getPolyhedra(), unsharedEdgeList); + auto* unsharedEdgeList = getDataStructureRef().getDataAs>(m_UnsharedEdgeListId); + if(unsharedEdgeList != nullptr && !recalculate) + { + return 0; + } + if(unsharedEdgeList == nullptr) + { + auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); + unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); + } if(unsharedEdgeList == nullptr) { m_UnsharedEdgeListId.reset(); return -1; } + GeometryHelpers::Connectivity::FindUnsharedHexEdges(getPolyhedra(), unsharedEdgeList); m_UnsharedEdgeListId = unsharedEdgeList->getId(); return 1; } -IGeometry::StatusCode HexahedralGeom::findUnsharedFaces() +IGeometry::StatusCode HexahedralGeom::findUnsharedFaces(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{0}, std::vector{4}, 0); - auto* unsharedQuadList = DataArray::Create(*getDataStructure(), k_UnsharedFaces, std::move(dataStore), getId()); - GeometryHelpers::Connectivity::FindUnsharedHexFaces(getPolyhedra(), unsharedQuadList); + auto* unsharedQuadList = getDataStructureRef().getDataAs>(m_UnsharedFaceListId); + if(unsharedQuadList != nullptr && !recalculate) + { + return 0; + } + if(unsharedQuadList == nullptr) + { + auto dataStore = std::make_unique>(std::vector{0}, std::vector{4}, 0); + unsharedQuadList = DataArray::Create(*getDataStructure(), k_UnsharedFaces, std::move(dataStore), getId()); + } if(unsharedQuadList == nullptr) { m_UnsharedFaceListId.reset(); return -1; } + GeometryHelpers::Connectivity::FindUnsharedHexFaces(getPolyhedra(), unsharedQuadList); m_UnsharedFaceListId = unsharedQuadList->getId(); return 1; } diff --git a/src/simplnx/DataStructure/Geometry/HexahedralGeom.hpp b/src/simplnx/DataStructure/Geometry/HexahedralGeom.hpp index 0df3a27f3a..ed7e6c75b9 100644 --- a/src/simplnx/DataStructure/Geometry/HexahedralGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/HexahedralGeom.hpp @@ -119,24 +119,24 @@ class SIMPLNX_EXPORT HexahedralGeom : public INodeGeometry3D * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementsContainingVert() override; + StatusCode findElementsContainingVert(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementNeighbors() override; + StatusCode findElementNeighbors(bool recalculate) override; /** * @return StatusCode */ - StatusCode findElementCentroids() override; + StatusCode findElementCentroids(bool recalculate) override; /** * @brief @@ -155,25 +155,25 @@ class SIMPLNX_EXPORT HexahedralGeom : public INodeGeometry3D * @brief * @return StatusCode */ - StatusCode findEdges() override; + StatusCode findEdges(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findFaces() override; + StatusCode findFaces(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findUnsharedEdges() override; + StatusCode findUnsharedEdges(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findUnsharedFaces() override; + StatusCode findUnsharedFaces(bool recalculate) override; protected: /** diff --git a/src/simplnx/DataStructure/Geometry/IGeometry.hpp b/src/simplnx/DataStructure/Geometry/IGeometry.hpp index 1a27fd6f34..58ce9b5cbb 100644 --- a/src/simplnx/DataStructure/Geometry/IGeometry.hpp +++ b/src/simplnx/DataStructure/Geometry/IGeometry.hpp @@ -100,7 +100,7 @@ class SIMPLNX_EXPORT IGeometry : public BaseGroup * @brief * @return StatusCode */ - virtual StatusCode findElementSizes() = 0; + virtual StatusCode findElementSizes(bool recalculate) = 0; /** * @brief diff --git a/src/simplnx/DataStructure/Geometry/INodeGeometry1D.hpp b/src/simplnx/DataStructure/Geometry/INodeGeometry1D.hpp index 10d9a813cc..f542dba74f 100644 --- a/src/simplnx/DataStructure/Geometry/INodeGeometry1D.hpp +++ b/src/simplnx/DataStructure/Geometry/INodeGeometry1D.hpp @@ -93,9 +93,10 @@ class SIMPLNX_EXPORT INodeGeometry1D : public INodeGeometry0D /** * @brief + * recalculate If true, this function will recalculate the array. Otherwise, it will leave the array as is. * @return StatusCode */ - virtual StatusCode findElementsContainingVert() = 0; + virtual StatusCode findElementsContainingVert(bool recalculate) = 0; /** * @brief @@ -112,7 +113,7 @@ class SIMPLNX_EXPORT INodeGeometry1D : public INodeGeometry0D * @brief * @return StatusCode */ - virtual StatusCode findElementNeighbors() = 0; + virtual StatusCode findElementNeighbors(bool recalculate) = 0; /** * @brief @@ -129,7 +130,7 @@ class SIMPLNX_EXPORT INodeGeometry1D : public INodeGeometry0D * @brief * @return StatusCode */ - virtual StatusCode findElementCentroids() = 0; + virtual StatusCode findElementCentroids(bool recalculate) = 0; /** * @brief diff --git a/src/simplnx/DataStructure/Geometry/INodeGeometry2D.hpp b/src/simplnx/DataStructure/Geometry/INodeGeometry2D.hpp index 2f949def2b..f68283a8f9 100644 --- a/src/simplnx/DataStructure/Geometry/INodeGeometry2D.hpp +++ b/src/simplnx/DataStructure/Geometry/INodeGeometry2D.hpp @@ -107,7 +107,7 @@ class SIMPLNX_EXPORT INodeGeometry2D : public INodeGeometry1D * @brief * @return StatusCode */ - virtual StatusCode findEdges() = 0; + virtual StatusCode findEdges(bool recalculate) = 0; /** * @brief Deletes the shared edge list and removes it from the DataStructure. @@ -126,7 +126,7 @@ class SIMPLNX_EXPORT INodeGeometry2D : public INodeGeometry1D * @brief * @return StatusCode */ - virtual StatusCode findUnsharedEdges() = 0; + virtual StatusCode findUnsharedEdges(bool recalculate) = 0; /** * @brief Returns a const pointer to the unshared edge list. Returns nullptr diff --git a/src/simplnx/DataStructure/Geometry/INodeGeometry3D.hpp b/src/simplnx/DataStructure/Geometry/INodeGeometry3D.hpp index 0adb46de95..0e04d3e4f1 100644 --- a/src/simplnx/DataStructure/Geometry/INodeGeometry3D.hpp +++ b/src/simplnx/DataStructure/Geometry/INodeGeometry3D.hpp @@ -71,7 +71,7 @@ class SIMPLNX_EXPORT INodeGeometry3D : public INodeGeometry2D * @brief Creates and assigns the face list array for the current values. * @return StatusCode */ - virtual StatusCode findFaces() = 0; + virtual StatusCode findFaces(bool recalculate) = 0; /** * @brief Deletes the current face list array. @@ -93,7 +93,7 @@ class SIMPLNX_EXPORT INodeGeometry3D : public INodeGeometry2D /** * @brief Creates and assigns the unshared face list array for the current values. */ - virtual StatusCode findUnsharedFaces() = 0; + virtual StatusCode findUnsharedFaces(bool recalculate) = 0; /** * @brief Returns a pointer to the unshared face list array. diff --git a/src/simplnx/DataStructure/Geometry/ImageGeom.cpp b/src/simplnx/DataStructure/Geometry/ImageGeom.cpp index 94743edb6b..95e7187181 100644 --- a/src/simplnx/DataStructure/Geometry/ImageGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/ImageGeom.cpp @@ -145,17 +145,33 @@ usize ImageGeom::getNumberOfCells() const return (m_Dimensions[0] * m_Dimensions[1] * m_Dimensions[2]); } -IGeometry::StatusCode ImageGeom::findElementSizes() +IGeometry::StatusCode ImageGeom::findElementSizes(bool recalculate) { + auto* voxelSizes = getDataStructureRef().getDataAs(m_ElementSizesId); + if(voxelSizes != nullptr && !recalculate) + { + return 0; + } + FloatVec3 res = getSpacing(); if(res[0] <= 0.0f || res[1] <= 0.0f || res[2] <= 0.0f) { + m_ElementSizesId.reset(); + return -1; + } + + if(voxelSizes == nullptr) + { + float32 initValue = res[0] * res[1] * res[2]; + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, initValue); + voxelSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); + } + if(voxelSizes == nullptr) + { + m_ElementSizesId.reset(); return -1; } - float32 initValue = res[0] * res[1] * res[2]; - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, initValue); - auto voxelSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); m_ElementSizesId = voxelSizes->getId(); return 1; } diff --git a/src/simplnx/DataStructure/Geometry/ImageGeom.hpp b/src/simplnx/DataStructure/Geometry/ImageGeom.hpp index 63fc282cc6..b2de83bfff 100644 --- a/src/simplnx/DataStructure/Geometry/ImageGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/ImageGeom.hpp @@ -166,7 +166,7 @@ class SIMPLNX_EXPORT ImageGeom : public IGridGeometry * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief diff --git a/src/simplnx/DataStructure/Geometry/QuadGeom.cpp b/src/simplnx/DataStructure/Geometry/QuadGeom.cpp index eeeedc92dd..e29e965bd4 100644 --- a/src/simplnx/DataStructure/Geometry/QuadGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/QuadGeom.cpp @@ -166,64 +166,99 @@ usize QuadGeom::getNumberOfVerticesPerFace() const return k_NumFaceVerts; } -IGeometry::StatusCode QuadGeom::findElementSizes() +IGeometry::StatusCode QuadGeom::findElementSizes(bool recalculate) { - auto dataStore = std::make_unique>(getNumberOfCells(), 0.0f); - Float32Array* quadSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); - GeometryHelpers::Topology::Find2DElementAreas(getFaces(), getVertices(), quadSizes); + auto* quadSizes = getDataStructureRef().getDataAs(m_ElementSizesId); + if(quadSizes != nullptr && !recalculate) + { + return 0; + } + if(quadSizes == nullptr) + { + auto dataStore = std::make_unique>(getNumberOfCells(), 0.0f); + quadSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); + } if(quadSizes == nullptr) { m_ElementSizesId.reset(); return -1; } + GeometryHelpers::Topology::Find2DElementAreas(getFaces(), getVertices(), quadSizes); m_ElementSizesId = quadSizes->getId(); return 1; } -IGeometry::StatusCode QuadGeom::findElementsContainingVert() +IGeometry::StatusCode QuadGeom::findElementsContainingVert(bool recalculate) { - auto quadsContainingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); - GeometryHelpers::Connectivity::FindElementsContainingVert(getFaces(), quadsContainingVert, getNumberOfVertices()); + auto* quadsContainingVert = getDataStructureRef().getDataAs(m_CellContainingVertDataArrayId); + if(quadsContainingVert != nullptr && !recalculate) + { + return 0; + } + if(quadsContainingVert == nullptr) + { + quadsContainingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); + } if(quadsContainingVert == nullptr) { m_CellContainingVertDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::FindElementsContainingVert(getFaces(), quadsContainingVert, getNumberOfVertices()); m_CellContainingVertDataArrayId = quadsContainingVert->getId(); return 1; } -IGeometry::StatusCode QuadGeom::findElementNeighbors() +IGeometry::StatusCode QuadGeom::findElementNeighbors(bool recalculate) { - if(getElementsContainingVert() == nullptr) + auto* quadNeighbors = getDataStructureRef().getDataAs(m_CellNeighborsDataArrayId); + if(quadNeighbors != nullptr && !recalculate) { - StatusCode err = findElementsContainingVert(); - if(err < 0) - { - return err; - } + return 0; + } + + StatusCode err = findElementsContainingVert(recalculate); + if(err < 0) + { + m_CellNeighborsDataArrayId.reset(); + return err; + } + if(quadNeighbors == nullptr) + { + quadNeighbors = DynamicListArray::Create(*getDataStructure(), k_EltNeighbors, getId()); } - auto quadNeighbors = DynamicListArray::Create(*getDataStructure(), k_EltNeighbors, getId()); - StatusCode err = GeometryHelpers::Connectivity::FindElementNeighbors(getFaces(), getElementsContainingVert(), quadNeighbors, IGeometry::Type::Quad); if(quadNeighbors == nullptr) { m_CellNeighborsDataArrayId.reset(); return -1; } m_CellNeighborsDataArrayId = quadNeighbors->getId(); - return err; + err = GeometryHelpers::Connectivity::FindElementNeighbors(getFaces(), getElementsContainingVert(), quadNeighbors, IGeometry::Type::Quad); + if(err < 0) + { + return err; + } + return 1; } -IGeometry::StatusCode QuadGeom::findElementCentroids() +IGeometry::StatusCode QuadGeom::findElementCentroids(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); - auto quadCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); - GeometryHelpers::Topology::FindElementCentroids(getFaces(), getVertices(), quadCentroids); + auto* quadCentroids = getDataStructureRef().getDataAs(m_CellCentroidsDataArrayId); + if(quadCentroids != nullptr && !recalculate) + { + return 0; + } + if(quadCentroids == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); + quadCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); + } if(quadCentroids == nullptr) { m_CellCentroidsDataArrayId.reset(); return -1; } + GeometryHelpers::Topology::FindElementCentroids(getFaces(), getVertices(), quadCentroids); m_CellCentroidsDataArrayId = quadCentroids->getId(); return 1; } @@ -248,29 +283,45 @@ void QuadGeom::getShapeFunctions(const Point3D& pCoords, float64* shape shape[7] = rm; } -IGeometry::StatusCode QuadGeom::findEdges() +IGeometry::StatusCode QuadGeom::findEdges(bool recalculate) { - auto* edgeList = createSharedEdgeList(0); - GeometryHelpers::Connectivity::Find2DElementEdges(getFaces(), edgeList); + auto* edgeList = getDataStructureRef().getDataAs>(m_EdgeDataArrayId); + if(edgeList != nullptr && !recalculate) + { + return 0; + } + if(edgeList == nullptr) + { + edgeList = createSharedEdgeList(0); + } if(edgeList == nullptr) { m_EdgeDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::Find2DElementEdges(getFaces(), edgeList); m_EdgeDataArrayId = edgeList->getId(); return 1; } -IGeometry::StatusCode QuadGeom::findUnsharedEdges() +IGeometry::StatusCode QuadGeom::findUnsharedEdges(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); - auto unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); - GeometryHelpers::Connectivity::Find2DUnsharedEdges(getFaces(), unsharedEdgeList); + auto* unsharedEdgeList = getDataStructureRef().getDataAs>(m_UnsharedEdgeListId); + if(unsharedEdgeList != nullptr && !recalculate) + { + return 0; + } + if(unsharedEdgeList == nullptr) + { + auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); + unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); + } if(unsharedEdgeList == nullptr) { m_UnsharedEdgeListId.reset(); return -1; } + GeometryHelpers::Connectivity::Find2DUnsharedEdges(getFaces(), unsharedEdgeList); m_UnsharedEdgeListId = unsharedEdgeList->getId(); return 1; } diff --git a/src/simplnx/DataStructure/Geometry/QuadGeom.hpp b/src/simplnx/DataStructure/Geometry/QuadGeom.hpp index 7e4adbfd71..64dea936ad 100644 --- a/src/simplnx/DataStructure/Geometry/QuadGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/QuadGeom.hpp @@ -111,25 +111,25 @@ class SIMPLNX_EXPORT QuadGeom : public INodeGeometry2D * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementsContainingVert() override; + StatusCode findElementsContainingVert(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementNeighbors() override; + StatusCode findElementNeighbors(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementCentroids() override; + StatusCode findElementCentroids(bool recalculate) override; /** * @brief @@ -148,13 +148,13 @@ class SIMPLNX_EXPORT QuadGeom : public INodeGeometry2D * @brief * @return StatusCode */ - StatusCode findEdges() override; + StatusCode findEdges(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findUnsharedEdges() override; + StatusCode findUnsharedEdges(bool recalculate) override; protected: /** diff --git a/src/simplnx/DataStructure/Geometry/RectGridGeom.cpp b/src/simplnx/DataStructure/Geometry/RectGridGeom.cpp index 0927fbf724..79f2cf6a0a 100644 --- a/src/simplnx/DataStructure/Geometry/RectGridGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/RectGridGeom.cpp @@ -304,8 +304,14 @@ usize RectGridGeom::getNumberOfCells() const return m_Dimensions.getX() * m_Dimensions.getY() * m_Dimensions.getZ(); } -IGeometry::StatusCode RectGridGeom::findElementSizes() +IGeometry::StatusCode RectGridGeom::findElementSizes(bool recalculate) { + auto* sizeArray = getDataStructureRef().getDataAs(m_ElementSizesId); + if(sizeArray != nullptr && !recalculate) + { + return 0; + } + auto sizes = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, 0.0f); auto xBnds = getXBounds(); auto yBnds = getYBounds(); @@ -333,8 +339,11 @@ IGeometry::StatusCode RectGridGeom::findElementSizes() } } - Float32Array* sizeArray = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(sizes), getId()); - if(!sizeArray) + if(sizeArray == nullptr) + { + sizeArray = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(sizes), getId()); + } + if(sizeArray == nullptr) { m_ElementSizesId.reset(); return -1; diff --git a/src/simplnx/DataStructure/Geometry/RectGridGeom.hpp b/src/simplnx/DataStructure/Geometry/RectGridGeom.hpp index f3eb646dcc..6f542be587 100644 --- a/src/simplnx/DataStructure/Geometry/RectGridGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/RectGridGeom.hpp @@ -208,7 +208,7 @@ class SIMPLNX_EXPORT RectGridGeom : public IGridGeometry * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief diff --git a/src/simplnx/DataStructure/Geometry/TetrahedralGeom.cpp b/src/simplnx/DataStructure/Geometry/TetrahedralGeom.cpp index f3cf010063..fe7167fef2 100644 --- a/src/simplnx/DataStructure/Geometry/TetrahedralGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/TetrahedralGeom.cpp @@ -191,65 +191,99 @@ usize TetrahedralGeom::getNumberOfCells() const return tets.getNumberOfTuples(); } -IGeometry::StatusCode TetrahedralGeom::findElementSizes() +IGeometry::StatusCode TetrahedralGeom::findElementSizes(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, 0.0f); - Float32Array* tetSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); - GeometryHelpers::Topology::FindTetVolumes(getPolyhedra(), getVertices(), tetSizes); + auto* tetSizes = getDataStructureRef().getDataAs(m_ElementSizesId); + if(tetSizes != nullptr && !recalculate) + { + return 0; + } + if(tetSizes == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, 0.0f); + tetSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); + } if(tetSizes == nullptr) { m_ElementSizesId.reset(); return -1; } + GeometryHelpers::Topology::FindTetVolumes(getPolyhedra(), getVertices(), tetSizes); m_ElementSizesId = tetSizes->getId(); return 1; } -IGeometry::StatusCode TetrahedralGeom::findElementsContainingVert() +IGeometry::StatusCode TetrahedralGeom::findElementsContainingVert(bool recalculate) { - auto* tetsContainingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); - GeometryHelpers::Connectivity::FindElementsContainingVert(getPolyhedra(), tetsContainingVert, getNumberOfVertices()); + auto* tetsContainingVert = getDataStructureRef().getDataAs(m_CellContainingVertDataArrayId); + if(tetsContainingVert != nullptr && !recalculate) + { + return 0; + } + if(tetsContainingVert == nullptr) + { + tetsContainingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); + } if(tetsContainingVert == nullptr) { m_CellContainingVertDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::FindElementsContainingVert(getPolyhedra(), tetsContainingVert, getNumberOfVertices()); m_CellContainingVertDataArrayId = tetsContainingVert->getId(); return 1; } -IGeometry::StatusCode TetrahedralGeom::findElementNeighbors() +IGeometry::StatusCode TetrahedralGeom::findElementNeighbors(bool recalculate) { - StatusCode err = 0; - if(getElementsContainingVert() == nullptr) + auto* tetNeighbors = getDataStructureRef().getDataAs(m_CellNeighborsDataArrayId); + if(tetNeighbors != nullptr && !recalculate) { - err = findElementsContainingVert(); - if(err < 0) - { - return err; - } + return 0; + } + + StatusCode err = findElementsContainingVert(recalculate); + if(err < 0) + { + m_CellNeighborsDataArrayId.reset(); + return err; + } + if(tetNeighbors == nullptr) + { + tetNeighbors = DynamicListArray::Create(*getDataStructure(), k_EltNeighbors, getId()); } - auto* tetNeighbors = DynamicListArray::Create(*getDataStructure(), k_EltNeighbors, getId()); - err = GeometryHelpers::Connectivity::FindElementNeighbors(getPolyhedra(), getElementsContainingVert(), tetNeighbors, IGeometry::Type::Tetrahedral); if(tetNeighbors == nullptr) { m_CellNeighborsDataArrayId.reset(); return -1; } m_CellNeighborsDataArrayId = tetNeighbors->getId(); - return err; + err = GeometryHelpers::Connectivity::FindElementNeighbors(getPolyhedra(), getElementsContainingVert(), tetNeighbors, IGeometry::Type::Tetrahedral); + if(err < 0) + { + return err; + } + return 1; } -IGeometry::StatusCode TetrahedralGeom::findElementCentroids() +IGeometry::StatusCode TetrahedralGeom::findElementCentroids(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); - DataArray* tetCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); - GeometryHelpers::Topology::FindElementCentroids(getPolyhedra(), getVertices(), tetCentroids); + auto* tetCentroids = getDataStructureRef().getDataAs(m_CellCentroidsDataArrayId); + if(tetCentroids != nullptr && !recalculate) + { + return 0; + } + if(tetCentroids == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{3}, 0.0f); + tetCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); + } if(tetCentroids == nullptr) { m_CellCentroidsDataArrayId.reset(); return -1; } + GeometryHelpers::Topology::FindElementCentroids(getPolyhedra(), getVertices(), tetCentroids); m_CellCentroidsDataArrayId = tetCentroids->getId(); return 1; } @@ -280,56 +314,88 @@ void TetrahedralGeom::getShapeFunctions([[maybe_unused]] const Point3D& shape[11] = 1.0; } -IGeometry::StatusCode TetrahedralGeom::findEdges() +IGeometry::StatusCode TetrahedralGeom::findEdges(bool recalculate) { - auto* edgeList = createSharedEdgeList(0); - GeometryHelpers::Connectivity::FindTetEdges(getPolyhedra(), edgeList); + auto* edgeList = getDataStructureRef().getDataAs>(m_EdgeDataArrayId); + if(edgeList != nullptr && !recalculate) + { + return 0; + } + if(edgeList == nullptr) + { + edgeList = createSharedEdgeList(0); + } if(edgeList == nullptr) { m_EdgeDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::FindTetEdges(getPolyhedra(), edgeList); m_EdgeDataArrayId = edgeList->getId(); return 1; } -IGeometry::StatusCode TetrahedralGeom::findFaces() +IGeometry::StatusCode TetrahedralGeom::findFaces(bool recalculate) { - auto* triList = createSharedTriList(0); - GeometryHelpers::Connectivity::FindTetFaces(getPolyhedra(), triList); + auto* triList = getDataStructureRef().getDataAs>(m_FaceListId); + if(triList != nullptr && !recalculate) + { + return 0; + } + if(triList == nullptr) + { + triList = createSharedTriList(0); + } if(triList == nullptr) { m_FaceListId.reset(); return -1; } + GeometryHelpers::Connectivity::FindTetFaces(getPolyhedra(), triList); m_FaceListId = triList->getId(); return 1; } -IGeometry::StatusCode TetrahedralGeom::findUnsharedEdges() +IGeometry::StatusCode TetrahedralGeom::findUnsharedEdges(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); - auto* unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); - GeometryHelpers::Connectivity::FindUnsharedTetEdges(getPolyhedra(), unsharedEdgeList); + auto* unsharedEdgeList = getDataStructureRef().getDataAs>(m_UnsharedEdgeListId); + if(unsharedEdgeList != nullptr && !recalculate) + { + return 0; + } + if(unsharedEdgeList == nullptr) + { + auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); + unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); + } if(unsharedEdgeList == nullptr) { m_UnsharedEdgeListId.reset(); return -1; } + GeometryHelpers::Connectivity::FindUnsharedTetEdges(getPolyhedra(), unsharedEdgeList); m_UnsharedEdgeListId = unsharedEdgeList->getId(); return 1; } -IGeometry::StatusCode TetrahedralGeom::findUnsharedFaces() +IGeometry::StatusCode TetrahedralGeom::findUnsharedFaces(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{0}, std::vector{3}, 0); - auto* unsharedTriList = DataArray::Create(*getDataStructure(), k_UnsharedFaces, std::move(dataStore), getId()); - GeometryHelpers::Connectivity::FindUnsharedTetFaces(getPolyhedra(), unsharedTriList); + auto* unsharedTriList = getDataStructureRef().getDataAs>(m_UnsharedFaceListId); + if(unsharedTriList != nullptr && !recalculate) + { + return 0; + } + if(unsharedTriList == nullptr) + { + auto dataStore = std::make_unique>(std::vector{0}, std::vector{3}, 0); + unsharedTriList = DataArray::Create(*getDataStructure(), k_UnsharedFaces, std::move(dataStore), getId()); + } if(unsharedTriList == nullptr) { m_UnsharedFaceListId.reset(); return -1; } + GeometryHelpers::Connectivity::FindUnsharedTetFaces(getPolyhedra(), unsharedTriList); m_UnsharedFaceListId = unsharedTriList->getId(); return 1; } diff --git a/src/simplnx/DataStructure/Geometry/TetrahedralGeom.hpp b/src/simplnx/DataStructure/Geometry/TetrahedralGeom.hpp index 7f117724d0..4a6efeec5d 100644 --- a/src/simplnx/DataStructure/Geometry/TetrahedralGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/TetrahedralGeom.hpp @@ -119,25 +119,25 @@ class SIMPLNX_EXPORT TetrahedralGeom : public INodeGeometry3D * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementsContainingVert() override; + StatusCode findElementsContainingVert(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementNeighbors() override; + StatusCode findElementNeighbors(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementCentroids() override; + StatusCode findElementCentroids(bool recalculate) override; /** * @brief @@ -156,25 +156,25 @@ class SIMPLNX_EXPORT TetrahedralGeom : public INodeGeometry3D * @brief * @return StatusCode */ - StatusCode findEdges() override; + StatusCode findEdges(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findFaces() override; + StatusCode findFaces(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findUnsharedEdges() override; + StatusCode findUnsharedEdges(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findUnsharedFaces() override; + StatusCode findUnsharedFaces(bool recalculate) override; protected: /** diff --git a/src/simplnx/DataStructure/Geometry/TriangleGeom.cpp b/src/simplnx/DataStructure/Geometry/TriangleGeom.cpp index 9bec7aabeb..dda3a74923 100644 --- a/src/simplnx/DataStructure/Geometry/TriangleGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/TriangleGeom.cpp @@ -167,65 +167,99 @@ usize TriangleGeom::getNumberOfVerticesPerFace() const return k_NumFaceVerts; } -IGeometry::StatusCode TriangleGeom::findElementSizes() +IGeometry::StatusCode TriangleGeom::findElementSizes(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfFaces()}, std::vector{1}, 0.0f); - Float32Array* triangleSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); - GeometryHelpers::Topology::Find2DElementAreas(getFaces(), getVertices(), triangleSizes); + auto* triangleSizes = getDataStructureRef().getDataAs(m_ElementSizesId); + if(triangleSizes != nullptr && !recalculate) + { + return 0; + } + if(triangleSizes == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfFaces()}, std::vector{1}, 0.0f); + triangleSizes = DataArray::Create(*getDataStructure(), k_VoxelSizes, std::move(dataStore), getId()); + } if(triangleSizes == nullptr) { m_ElementSizesId.reset(); return -1; } + GeometryHelpers::Topology::Find2DElementAreas(getFaces(), getVertices(), triangleSizes); m_ElementSizesId = triangleSizes->getId(); return 1; } -IGeometry::StatusCode TriangleGeom::findElementsContainingVert() +IGeometry::StatusCode TriangleGeom::findElementsContainingVert(bool recalculate) { - auto trianglesContainingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); - GeometryHelpers::Connectivity::FindElementsContainingVert(getFaces(), trianglesContainingVert, getNumberOfVertices()); + auto* trianglesContainingVert = getDataStructureRef().getDataAs(m_CellContainingVertDataArrayId); + if(trianglesContainingVert != nullptr && !recalculate) + { + return 0; + } + if(trianglesContainingVert == nullptr) + { + trianglesContainingVert = DynamicListArray::Create(*getDataStructure(), k_EltsContainingVert, getId()); + } if(trianglesContainingVert == nullptr) { m_CellContainingVertDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::FindElementsContainingVert(getFaces(), trianglesContainingVert, getNumberOfVertices()); m_CellContainingVertDataArrayId = trianglesContainingVert->getId(); return 1; } -IGeometry::StatusCode TriangleGeom::findElementNeighbors() +IGeometry::StatusCode TriangleGeom::findElementNeighbors(bool recalculate) { - StatusCode err; - if(getElementsContainingVert() == nullptr) + auto* triangleNeighbors = getDataStructureRef().getDataAs(m_CellNeighborsDataArrayId); + if(triangleNeighbors != nullptr && !recalculate) { - err = findElementsContainingVert(); - if(err < 0) - { - return err; - } + return 0; + } + + StatusCode err = findElementsContainingVert(recalculate); + if(err < 0) + { + m_CellNeighborsDataArrayId.reset(); + return err; + } + if(triangleNeighbors == nullptr) + { + triangleNeighbors = ElementDynamicList::Create(*getDataStructure(), k_EltNeighbors, getId()); } - auto triangleNeighbors = ElementDynamicList::Create(*getDataStructure(), k_EltNeighbors, getId()); - err = GeometryHelpers::Connectivity::FindElementNeighbors(getFaces(), getElementsContainingVert(), triangleNeighbors, IGeometry::Type::Triangle); if(triangleNeighbors == nullptr) { m_CellNeighborsDataArrayId.reset(); return -1; } m_CellNeighborsDataArrayId = triangleNeighbors->getId(); - return err; + err = GeometryHelpers::Connectivity::FindElementNeighbors(getFaces(), getElementsContainingVert(), triangleNeighbors, IGeometry::Type::Triangle); + if(err < 0) + { + return err; + } + return 1; } -IGeometry::StatusCode TriangleGeom::findElementCentroids() +IGeometry::StatusCode TriangleGeom::findElementCentroids(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{getNumberOfFaces()}, std::vector{3}, 0.0f); - auto triangleCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); - GeometryHelpers::Topology::FindElementCentroids(getFaces(), getVertices(), triangleCentroids); + auto* triangleCentroids = getDataStructureRef().getDataAs(m_CellCentroidsDataArrayId); + if(triangleCentroids != nullptr && !recalculate) + { + return 0; + } + if(triangleCentroids == nullptr) + { + auto dataStore = std::make_unique>(std::vector{getNumberOfFaces()}, std::vector{3}, 0.0f); + triangleCentroids = DataArray::Create(*getDataStructure(), k_EltCentroids, std::move(dataStore), getId()); + } if(triangleCentroids == nullptr) { m_CellCentroidsDataArrayId.reset(); return -1; } + GeometryHelpers::Topology::FindElementCentroids(getFaces(), getVertices(), triangleCentroids); m_CellCentroidsDataArrayId = triangleCentroids->getId(); return 1; } @@ -248,30 +282,46 @@ void TriangleGeom::getShapeFunctions([[maybe_unused]] const Point3D& pC shape[5] = 1.0; } -IGeometry::StatusCode TriangleGeom::findEdges() +IGeometry::StatusCode TriangleGeom::findEdges(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); - DataArray* edgeList = DataArray::Create(*getDataStructure(), k_Edges, std::move(dataStore), getId()); - GeometryHelpers::Connectivity::Find2DElementEdges(getFaces(), edgeList); + auto* edgeList = getDataStructureRef().getDataAs(m_EdgeDataArrayId); + if(edgeList != nullptr && !recalculate) + { + return 0; + } + if(edgeList == nullptr) + { + auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); + edgeList = DataArray::Create(*getDataStructure(), k_Edges, std::move(dataStore), getId()); + } if(edgeList == nullptr) { m_EdgeDataArrayId.reset(); return -1; } + GeometryHelpers::Connectivity::Find2DElementEdges(getFaces(), edgeList); m_EdgeDataArrayId = edgeList->getId(); return 1; } -IGeometry::StatusCode TriangleGeom::findUnsharedEdges() +IGeometry::StatusCode TriangleGeom::findUnsharedEdges(bool recalculate) { - auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); - auto* unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); - GeometryHelpers::Connectivity::Find2DUnsharedEdges(getFaces(), unsharedEdgeList); + auto* unsharedEdgeList = getDataStructureRef().getDataAs>(m_UnsharedEdgeListId); + if(unsharedEdgeList != nullptr && !recalculate) + { + return 0; + } + if(unsharedEdgeList == nullptr) + { + auto dataStore = std::make_unique>(std::vector{0}, std::vector{2}, 0); + unsharedEdgeList = DataArray::Create(*getDataStructure(), k_UnsharedEdges, std::move(dataStore), getId()); + } if(unsharedEdgeList == nullptr) { m_UnsharedEdgeListId.reset(); return -1; } + GeometryHelpers::Connectivity::Find2DUnsharedEdges(getFaces(), unsharedEdgeList); m_UnsharedEdgeListId = unsharedEdgeList->getId(); return 1; } diff --git a/src/simplnx/DataStructure/Geometry/TriangleGeom.hpp b/src/simplnx/DataStructure/Geometry/TriangleGeom.hpp index e81df58c4b..321acce6ad 100644 --- a/src/simplnx/DataStructure/Geometry/TriangleGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/TriangleGeom.hpp @@ -115,24 +115,24 @@ class SIMPLNX_EXPORT TriangleGeom : public INodeGeometry2D * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementsContainingVert() override; + StatusCode findElementsContainingVert(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementNeighbors() override; + StatusCode findElementNeighbors(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findElementCentroids() override; + StatusCode findElementCentroids(bool recalculate) override; /** * @brief @@ -152,13 +152,13 @@ class SIMPLNX_EXPORT TriangleGeom : public INodeGeometry2D * @brief * @return StatusCode */ - StatusCode findEdges() override; + StatusCode findEdges(bool recalculate) override; /** * @brief * @return StatusCode */ - StatusCode findUnsharedEdges() override; + StatusCode findUnsharedEdges(bool recalculate) override; protected: /** diff --git a/src/simplnx/DataStructure/Geometry/VertexGeom.cpp b/src/simplnx/DataStructure/Geometry/VertexGeom.cpp index b9f515ffad..a7e9bb0a3e 100644 --- a/src/simplnx/DataStructure/Geometry/VertexGeom.cpp +++ b/src/simplnx/DataStructure/Geometry/VertexGeom.cpp @@ -110,15 +110,23 @@ std::shared_ptr VertexGeom::deepCopy(const DataPath& copyPath) return nullptr; } -IGeometry::StatusCode VertexGeom::findElementSizes() +IGeometry::StatusCode VertexGeom::findElementSizes(bool recalculate) { + auto* vertexSizes = getDataStructureRef().getDataAs(m_ElementSizesId); + if(vertexSizes != nullptr && !recalculate) + { + return 0; + } // Vertices are 0-dimensional (they have no getSize), // so simply splat 0 over the sizes array - auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, 0.0f); - - Float32Array* vertexSizes = DataArray::Create(getDataStructureRef(), k_VoxelSizes, std::move(dataStore), getId()); if(vertexSizes == nullptr) { + auto dataStore = std::make_unique>(std::vector{getNumberOfCells()}, std::vector{1}, 0.0f); + vertexSizes = DataArray::Create(getDataStructureRef(), k_VoxelSizes, std::move(dataStore), getId()); + } + if(vertexSizes == nullptr) + { + m_ElementSizesId.reset(); return -1; } m_ElementSizesId = vertexSizes->getId(); diff --git a/src/simplnx/DataStructure/Geometry/VertexGeom.hpp b/src/simplnx/DataStructure/Geometry/VertexGeom.hpp index 83a6fd2b3f..fe53d266f7 100644 --- a/src/simplnx/DataStructure/Geometry/VertexGeom.hpp +++ b/src/simplnx/DataStructure/Geometry/VertexGeom.hpp @@ -94,7 +94,7 @@ class SIMPLNX_EXPORT VertexGeom : public INodeGeometry0D * @brief * @return StatusCode */ - StatusCode findElementSizes() override; + StatusCode findElementSizes(bool recalculate) override; /** * @brief diff --git a/src/simplnx/Utilities/GeometryHelpers.hpp b/src/simplnx/Utilities/GeometryHelpers.hpp index 74bbc40b47..0785087f4b 100644 --- a/src/simplnx/Utilities/GeometryHelpers.hpp +++ b/src/simplnx/Utilities/GeometryHelpers.hpp @@ -54,9 +54,7 @@ void FindElementsContainingVert(const DataArray* elemList, DynamicListArray linkCount(numVerts, 0); // Fill out lists with number of references to cells - auto dataStore = std::make_unique>(numVerts, static_cast(0)); - DataArray* linkLocPtr = DataArray::Create(*dataStructure, "_INTERNAL_USE_ONLY_Vertices", std::move(dataStore), parentId); - auto linkLoc = *linkLocPtr; + std::vector linkLoc(numVerts, static_cast(0)); K* verts = nullptr; // vtkPolyData *pdata = static_cast(data); @@ -145,9 +143,7 @@ ErrorCode FindElementNeighbors(const DataArray* elemList, const DynamicListAr dynamicList->allocateLists(linkCount); // Allocate an array of bools that we use each iteration so that we don't put duplicates into the array - auto visitedDataStore = std::make_unique>(numElems, 0); - DataArray* visitedPtr = DataArray::Create(*dataStructure, "_INTERNAL_USE_ONLY_Visited", std::move(visitedDataStore), parentId); - auto& visited = *visitedPtr; + std::vector visited(numElems, 0); // Reuse this vector for each loop. Avoids re-allocating the memory each time through the loop std::vector loop_neighbors(32, 0); diff --git a/test/DataStructTest.cpp b/test/DataStructTest.cpp index 426dc0d177..e294f5ac60 100644 --- a/test/DataStructTest.cpp +++ b/test/DataStructTest.cpp @@ -178,7 +178,7 @@ DataStructure createTestDataStructure() (*zBoundsArray)[13] = 65; rectGeom->setBounds(xBoundsArray, yBoundsArray, zBoundsArray); - rectGeom->findElementSizes(); + rectGeom->findElementSizes(false); } // Vertex Geometry @@ -204,7 +204,7 @@ DataStructure createTestDataStructure() (*vertListArray)[11] = 3; vertexGeom->setVertices(*vertListArray); - vertexGeom->findElementSizes(); + vertexGeom->findElementSizes(false); } // Edge Geometry @@ -247,10 +247,10 @@ DataStructure createTestDataStructure() (*edgesListArray)[7] = 4; edgeGeom->setEdgeList(*edgesListArray); - edgeGeom->findElementSizes(); - edgeGeom->findElementsContainingVert(); - edgeGeom->findElementNeighbors(); - edgeGeom->findElementCentroids(); + edgeGeom->findElementSizes(false); + edgeGeom->findElementsContainingVert(false); + edgeGeom->findElementNeighbors(false); + edgeGeom->findElementCentroids(false); } // Triangle Geometry @@ -302,12 +302,12 @@ DataStructure createTestDataStructure() (*facesListArray)[14] = 1; triangleGeom->setFaceList(*facesListArray); - triangleGeom->findEdges(); - // TODO: triangleGeom->findElementSizes(); - triangleGeom->findElementsContainingVert(); - triangleGeom->findElementNeighbors(); - triangleGeom->findElementCentroids(); - triangleGeom->findUnsharedEdges(); + triangleGeom->findEdges(false); + // TODO: triangleGeom->findElementSizes(false); + triangleGeom->findElementsContainingVert(false); + triangleGeom->findElementNeighbors(false); + triangleGeom->findElementCentroids(false); + triangleGeom->findUnsharedEdges(false); } // Quad Geometry @@ -351,12 +351,12 @@ DataStructure createTestDataStructure() (*facesListArray)[7] = 2; quadGeom->setFaceList(*facesListArray); - quadGeom->findEdges(); + quadGeom->findEdges(false); // TODO: quadGeom->findElementSizes(); - quadGeom->findElementsContainingVert(); - quadGeom->findElementNeighbors(); - quadGeom->findElementCentroids(); - quadGeom->findUnsharedEdges(); + quadGeom->findElementsContainingVert(false); + quadGeom->findElementNeighbors(false); + quadGeom->findElementCentroids(false); + quadGeom->findUnsharedEdges(false); } // Tetrahedral Geometry @@ -397,14 +397,14 @@ DataStructure createTestDataStructure() (*polyListArray)[7] = 3; tetGeom->setPolyhedraList(*polyListArray); - tetGeom->findEdges(); - tetGeom->findFaces(); - tetGeom->findElementSizes(); - tetGeom->findElementsContainingVert(); - tetGeom->findElementNeighbors(); - tetGeom->findElementCentroids(); - tetGeom->findUnsharedEdges(); - tetGeom->findUnsharedFaces(); + tetGeom->findEdges(false); + tetGeom->findFaces(false); + tetGeom->findElementSizes(false); + tetGeom->findElementsContainingVert(false); + tetGeom->findElementNeighbors(false); + tetGeom->findElementCentroids(false); + tetGeom->findUnsharedEdges(false); + tetGeom->findUnsharedFaces(false); } // Hexahedral Geometry @@ -474,14 +474,14 @@ DataStructure createTestDataStructure() (*polyListArray)[15] = 3; hexGeom->setPolyhedraList(*polyListArray); - hexGeom->findEdges(); - hexGeom->findFaces(); - hexGeom->findElementSizes(); - hexGeom->findElementsContainingVert(); - hexGeom->findElementNeighbors(); - hexGeom->findElementCentroids(); - hexGeom->findUnsharedEdges(); - hexGeom->findUnsharedFaces(); + hexGeom->findEdges(false); + hexGeom->findFaces(false); + hexGeom->findElementSizes(false); + hexGeom->findElementsContainingVert(false); + hexGeom->findElementNeighbors(false); + hexGeom->findElementCentroids(false); + hexGeom->findUnsharedEdges(false); + hexGeom->findUnsharedFaces(false); } return dataStruct; @@ -1370,3 +1370,237 @@ TEST_CASE("DataObjectsDeepCopyTest") REQUIRE(copyArrayToSelfGeo == nullptr); } } + +TEST_CASE("NodeBasedGeometryFindElementsTest") +{ + DataStructure dataStruct = createTestDataStructure(); + + SECTION("Image Geometry") + { + const DataPath srcImageGeoPath({Constants::k_ImageGeometry}); + auto* geom = dataStruct.getDataAs(srcImageGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 1); + status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + } + + SECTION("Rectilinear Grid Geometry") + { + const DataPath srcRectGeoPath({k_RectGridGeo}); + auto* geom = dataStruct.getDataAs(srcRectGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + } + + SECTION("Vertex Geometry") + { + const DataPath srcGeoPath({Constants::k_VertexGeometry}); + auto* geom = dataStruct.getDataAs(srcGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + } + + SECTION("Edge Geometry") + { + const DataPath srcGeoPath({k_EdgeGeo}); + auto* geom = dataStruct.getDataAs(srcGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + + status = geom->findElementsContainingVert(false); + REQUIRE(status == 0); + status = geom->findElementsContainingVert(true); + REQUIRE(status == 1); + + status = geom->findElementNeighbors(false); + REQUIRE(status == 0); + status = geom->findElementNeighbors(true); + REQUIRE(status == 1); + + status = geom->findElementCentroids(false); + REQUIRE(status == 0); + status = geom->findElementCentroids(true); + REQUIRE(status == 1); + } + + SECTION("Triangle Geometry") + { + const DataPath srcGeoPath({Constants::k_TriangleGeometryName}); + auto* geom = dataStruct.getDataAs(srcGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 1); + status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + + status = geom->findElementsContainingVert(false); + REQUIRE(status == 0); + status = geom->findElementsContainingVert(true); + REQUIRE(status == 1); + + status = geom->findElementNeighbors(false); + REQUIRE(status == 0); + status = geom->findElementNeighbors(true); + REQUIRE(status == 1); + + status = geom->findElementCentroids(false); + REQUIRE(status == 0); + status = geom->findElementCentroids(true); + REQUIRE(status == 1); + + status = geom->findEdges(false); + REQUIRE(status == 0); + status = geom->findEdges(true); + REQUIRE(status == 1); + + status = geom->findUnsharedEdges(false); + REQUIRE(status == 0); + status = geom->findUnsharedEdges(true); + REQUIRE(status == 1); + } + + SECTION("Quad Geometry") + { + const DataPath srcGeoPath({k_QuadGeo}); + auto* geom = dataStruct.getDataAs(srcGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 1); + status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + + status = geom->findElementsContainingVert(false); + REQUIRE(status == 0); + status = geom->findElementsContainingVert(true); + REQUIRE(status == 1); + + status = geom->findElementNeighbors(false); + REQUIRE(status == 0); + status = geom->findElementNeighbors(true); + REQUIRE(status == 1); + + status = geom->findElementCentroids(false); + REQUIRE(status == 0); + status = geom->findElementCentroids(true); + REQUIRE(status == 1); + + status = geom->findEdges(false); + REQUIRE(status == 0); + status = geom->findEdges(true); + REQUIRE(status == 1); + + status = geom->findUnsharedEdges(false); + REQUIRE(status == 0); + status = geom->findUnsharedEdges(true); + REQUIRE(status == 1); + } + + SECTION("Tetrahedral Geometry") + { + const DataPath srcGeoPath({k_TetGeo}); + auto* geom = dataStruct.getDataAs(srcGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + + status = geom->findElementsContainingVert(false); + REQUIRE(status == 0); + status = geom->findElementsContainingVert(true); + REQUIRE(status == 1); + + status = geom->findElementNeighbors(false); + REQUIRE(status == 0); + status = geom->findElementNeighbors(true); + REQUIRE(status == 1); + + status = geom->findElementCentroids(false); + REQUIRE(status == 0); + status = geom->findElementCentroids(true); + REQUIRE(status == 1); + + status = geom->findEdges(false); + REQUIRE(status == 0); + status = geom->findEdges(true); + REQUIRE(status == 1); + + status = geom->findUnsharedEdges(false); + REQUIRE(status == 0); + status = geom->findUnsharedEdges(true); + REQUIRE(status == 1); + + status = geom->findFaces(false); + REQUIRE(status == 0); + status = geom->findFaces(true); + REQUIRE(status == 1); + + status = geom->findUnsharedFaces(false); + REQUIRE(status == 0); + status = geom->findUnsharedFaces(true); + REQUIRE(status == 1); + } + + SECTION("Hexahedral Geometry") + { + const DataPath srcGeoPath({k_HexGeo}); + auto* geom = dataStruct.getDataAs(srcGeoPath); + + IGeometry::StatusCode status = geom->findElementSizes(false); + REQUIRE(status == 0); + status = geom->findElementSizes(true); + REQUIRE(status == 1); + + status = geom->findElementsContainingVert(false); + REQUIRE(status == 0); + status = geom->findElementsContainingVert(true); + REQUIRE(status == 1); + + status = geom->findElementNeighbors(false); + REQUIRE(status == 0); + status = geom->findElementNeighbors(true); + REQUIRE(status == 1); + + status = geom->findElementCentroids(false); + REQUIRE(status == 0); + status = geom->findElementCentroids(true); + REQUIRE(status == 1); + + status = geom->findEdges(false); + REQUIRE(status == 0); + status = geom->findEdges(true); + REQUIRE(status == 1); + + status = geom->findUnsharedEdges(false); + REQUIRE(status == 0); + status = geom->findUnsharedEdges(true); + REQUIRE(status == 1); + + status = geom->findFaces(false); + REQUIRE(status == 0); + status = geom->findFaces(true); + REQUIRE(status == 1); + + status = geom->findUnsharedFaces(false); + REQUIRE(status == 0); + status = geom->findUnsharedFaces(true); + REQUIRE(status == 1); + } +}