diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index 5e703ece..53c33e3b 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -587,6 +587,7 @@ namespace netgen mp.optsteps2d = hsteps; mesh->Compress(); + mesh->OrderElements(); mesh -> SetNextMajorTimeStamp(); mp.Render(); diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 3cb06060..cc160acd 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -3245,6 +3245,24 @@ namespace netgen timestamp = NextTimeStamp(); } + void Mesh :: OrderElements() + { + for (auto & el : surfelements) + { + if (el.GetType() == TRIG) + while (el[0] > el[1] || el[0] > el[2]) + { // rotate element + auto hp = el[0]; + el[0] = el[1]; + el[1] = el[2]; + el[2] = hp; + auto hgi = el.GeomInfoPi(1); + el.GeomInfoPi(1) = el.GeomInfoPi(2); + el.GeomInfoPi(2) = el.GeomInfoPi(3); + el.GeomInfoPi(3) = hgi; + } + } + } int Mesh :: CheckConsistentBoundary () const { diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index faf185c1..8d6ca794 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -470,6 +470,9 @@ namespace netgen */ DLL_HEADER void Compress (); + /// first vertex has lowest index + void OrderElements(); + /// DLL_HEADER void Save (ostream & outfile) const; ///