diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index b12854308095f2016a5c0f8acd713ab20d04e9ff..76f51fe4d20b5778c263e170eac2146ba85789bb 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 a3e1907049604ae289d4f4f84900a71ebbcd3eeb..97cda0586452f86081b90c486b22fe844821ac35 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