diff --git a/libsrc/meshing/boundarylayer.cpp b/libsrc/meshing/boundarylayer.cpp index a9407248..bd5427ef 100644 --- a/libsrc/meshing/boundarylayer.cpp +++ b/libsrc/meshing/boundarylayer.cpp @@ -410,7 +410,8 @@ namespace netgen for(SurfaceElementIndex si = 0; si < nse; si++) { - auto& sel = mesh[si]; + // copy because surfaceels array will be resized! + auto sel = mesh[si]; if(si_map[sel.GetIndex()] != -1) { Array points(sel.PNums()); @@ -436,7 +437,7 @@ namespace netgen mesh.AddSurfaceElement(newel); } if(move_boundaries.Test(sel.GetIndex())) - for(auto& p : sel.PNums()) + for(auto& p : mesh[si].PNums()) if(mapto[p].Size()) p = mapto[p].Last(); }