From 67bcfa23f59f0b4acede5fc1d229d871777e395b Mon Sep 17 00:00:00 2001 From: Norihiro Watanabe <norihiro.watanabe@ufz.de> Date: Thu, 3 Nov 2016 09:41:58 +0100 Subject: [PATCH] [Mesh] fix the nonlinear node ID check --- MeshLib/Mesh.cpp | 13 ++++++++++++- MeshLib/Mesh.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index b1285430809..76f51fe4d20 100644 --- a/MeshLib/Mesh.cpp +++ b/MeshLib/Mesh.cpp @@ -42,7 +42,7 @@ Mesh::Mesh(const std::string &name, assert(n_base_nodes <= nodes.size()); this->resetNodeIDs(); this->resetElementIDs(); - if (isNonlinear()) + if ((n_base_nodes==0 && hasNonlinearElement()) || isNonlinear()) this->checkNonlinearNodeIDs(); this->setDimension(); this->setElementsConnectedToNodes(); @@ -278,6 +278,17 @@ void Mesh::checkNonlinearNodeIDs() const } } +bool Mesh::hasNonlinearElement() const +{ + for (auto* const e : _elements) + { + if (e->getNumberOfNodes() == e->getNumberOfBaseNodes()) + continue; + return true; + } + return false; +} + void scaleMeshPropertyVector(MeshLib::Mesh & mesh, std::string const& property_name, double factor) diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h index a3e19070496..97cda058645 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -165,6 +165,9 @@ protected: /// Check if all the nonlinear nodes are stored at the end of the node vector void checkNonlinearNodeIDs() const; + /// Check if the mesh contains any nonlinear element + bool hasNonlinearElement() const; + std::size_t const _id; unsigned _mesh_dimension; /// The minimal and maximal edge length over all elements in the mesh -- GitLab