From 1cf3d2a21c7913605c5e7f455db985eb7aaf8d48 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Mon, 14 Jun 2021 09:15:43 +0200 Subject: [PATCH] always merge domains in separate meshes (consistent output) --- libsrc/meshing/meshfunc.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index d786a2c3..4df52fc7 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -278,6 +278,7 @@ namespace netgen void MergeMeshes( Mesh & mesh, FlatArray meshes, PointIndex first_new_pi ) { + // todo: optimize: count elements, alloc all memory, copy vol elements in parallel static Timer t("MergeMeshes"); RegionTimer rt(t); for(auto & m : meshes) { @@ -314,31 +315,23 @@ namespace netgen throw NgException ("Stop meshing since boundary mesh is overlapping"); - if(task_manager) + Array meshes(mesh3d.GetNDomains()-1); + auto first_new_pi = mesh3d.Points().Range().Next(); + + for(auto & m : meshes) { - Array meshes(mesh3d.GetNDomains()-1); - auto first_new_pi = mesh3d.Points().Range().Next(); - - for(auto & m : meshes) - { - m = mesh3d; - m.SetLocalH(mesh3d.GetLocalH()); - } - - ParallelFor(Range(1, mesh3d.GetNDomains()+1), [&](int k) - { - if(k==1) - MeshDomain(mesh3d, mp, k); - else - MeshDomain(meshes[k-2], mp, k); - }); - MergeMeshes(mesh3d, meshes, first_new_pi); + m = mesh3d; + m.SetLocalH(mesh3d.GetLocalH()); } - else - for (int k = 1; k <= mesh3d.GetNDomains(); k++) - MeshDomain(mesh3d, mp, k); - + ParallelFor(Range(1, mesh3d.GetNDomains()+1), [&](int k) + { + if(k==1) + MeshDomain(mesh3d, mp, k); + else + MeshDomain(meshes[k-2], mp, k); + }); + MergeMeshes(mesh3d, meshes, first_new_pi); MeshQuality3d (mesh3d);