diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9d3dcc44..4bc6ed1a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -198,7 +198,7 @@ build_mac: -DUSE_NATIVE_ARCH=OFF -DUSE_CCACHE=ON -DENABLE_UNIT_TESTS=ON - -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk - make -j5 install diff --git a/cmake/external_projects/tcltk.cmake b/cmake/external_projects/tcltk.cmake index b071e495..49bc58eb 100644 --- a/cmake/external_projects/tcltk.cmake +++ b/cmake/external_projects/tcltk.cmake @@ -1,61 +1,112 @@ if(APPLE) - # use system tcl/tk - if((${PYTHON_VERSION_STRING} VERSION_EQUAL "3.7") OR (${PYTHON_VERSION_STRING} VERSION_GREATER "3.7")) - # fetch tcl/tk sources to match the one used in Python 3.7 - ExternalProject_Add(project_tcl - URL "https://prdownloads.sourceforge.net/tcl/tcl8.6.8-src.tar.gz" - URL_MD5 81656d3367af032e0ae6157eff134f89 - DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies - UPDATE_COMMAND "" # Disable update - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - ) - ExternalProject_Add(project_tk - URL "https://prdownloads.sourceforge.net/tcl/tk8.6.8-src.tar.gz" - URL_MD5 5e0faecba458ee1386078fb228d008ba - DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies - UPDATE_COMMAND "" # Disable update - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - ) - - get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARY} DIRECTORY) - find_library(TCL_LIBRARY libtcl8.6.dylib PATHS ${PYTHON_LIB_DIR} NO_DEFAULT_PATH) - find_library(TK_LIBRARY libtk8.6.dylib PATHS ${PYTHON_LIB_DIR} NO_DEFAULT_PATH) - - set(TCL_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tcl) - set(TK_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tk) - set(TCL_INCLUDE_PATH "${TCL_DIR}/generic;${TCL_DIR}/macosx") - set(TK_INCLUDE_PATH "${TK_DIR}/generic;${TK_DIR}/macosx;${TK_DIR}/xlib") - string(REPLACE ";" "$" TCL_INC "${TCL_INCLUDE_PATH}") - string(REPLACE ";" "$" TK_INC "${TK_INCLUDE_PATH}") - - ExternalProject_Add(project_tkdnd - URL "http://sourceforge.net/projects/tkdnd/files/TkDND/TkDND%202.8/tkdnd2.8-src.tar.gz" - URL_MD5 a6d47a996ea957416469b12965d4db91 - DEPENDS project_tcl project_tk - DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies - PATCH_COMMAND patch < ${CMAKE_CURRENT_LIST_DIR}/tkdnd_macosx.patch - UPDATE_COMMAND "" # Disable update - BUILD_IN_SOURCE 1 - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/Contents/MacOS - -DTCL_INCLUDE_PATH=${TCL_INC} - -DTK_INCLUDE_PATH=${TK_INC} - -DTK_LIBRARY=${TK_LIBRARY} - -DTCL_LIBRARY=${TCL_LIBRARY} - LOG_DOWNLOAD 1 - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + set(tcl_prefix ${CMAKE_INSTALL_PREFIX}) + ExternalProject_Add(project_tcl + URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tcl8.6.9-src.tar.gz" + URL_MD5 aa0a121d95a0e7b73a036f26028538d4 + DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies + UPDATE_COMMAND "" # Disable update + CONFIGURE_COMMAND ../project_tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin + BUILD_COMMAND make -j4 binaries libraries + INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers + LOG_DOWNLOAD 1 + LOG_BUILD 1 + LOG_CONFIGURE 1 + LOG_INSTALL 1 ) - -list(APPEND NETGEN_DEPENDENCIES project_tkdnd) - else() - find_package(TCL 8.5 REQUIRED) - endif() + + ExternalProject_Add(project_tk + DEPENDS project_tcl + URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tk8.6.9.1-src.tar.gz" + URL_MD5 9efe3976468352dc894dae0c4e785a8e + DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies + UPDATE_COMMAND "" # Disable update + CONFIGURE_COMMAND ../project_tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework + BUILD_COMMAND make -j4 binaries libraries + INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers + LOG_DOWNLOAD 1 + LOG_BUILD 1 + LOG_CONFIGURE 1 + LOG_INSTALL 1 + ) + + ExternalProject_Add(project_tkdnd + URL "https://sourceforge.net/projects/tkdnd/files/OS%20X%20Binaries/TkDND%202.8/tkdnd2.8-OSX-MountainLion.tar.gz" + URL_MD5 2dbb471b1d66c5f391f3c3c5b71548fb + DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}/../MacOS + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) + + list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk project_tkdnd) + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/Contents/Frameworks) + set(TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/Contents/Frameworks/Tcl.framework/Headers) + set(TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/Contents/Frameworks/Tcl.framework) + set(TK_LIBRARY ${CMAKE_INSTALL_PREFIX}/Contents/Frameworks/Tk.framework) + set(TK_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/Contents/Frameworks/Tk.framework/Headers) + +# # use system tcl/tk +# if((${PYTHON_VERSION_STRING} VERSION_EQUAL "3.7") OR (${PYTHON_VERSION_STRING} VERSION_GREATER "3.7")) +# # fetch tcl/tk sources to match the one used in Python 3.7 +# ExternalProject_Add(project_tcl +# URL "https://prdownloads.sourceforge.net/tcl/tcl8.6.8-src.tar.gz" +# URL_MD5 81656d3367af032e0ae6157eff134f89 +# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies +# UPDATE_COMMAND "" # Disable update +# CONFIGURE_COMMAND "" +# BUILD_COMMAND "" +# INSTALL_COMMAND "" +# ) +# ExternalProject_Add(project_tk +# URL "https://prdownloads.sourceforge.net/tcl/tk8.6.8-src.tar.gz" +# URL_MD5 5e0faecba458ee1386078fb228d008ba +# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies +# UPDATE_COMMAND "" # Disable update +# CONFIGURE_COMMAND "" +# BUILD_COMMAND "" +# INSTALL_COMMAND "" +# ) +# +# get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARY} DIRECTORY) +# find_library(TCL_LIBRARY libtcl8.6.dylib PATHS ${PYTHON_LIB_DIR} NO_DEFAULT_PATH) +# find_library(TK_LIBRARY libtk8.6.dylib PATHS ${PYTHON_LIB_DIR} NO_DEFAULT_PATH) +# +# set(TCL_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tcl) +# set(TK_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tk) +# set(TCL_INCLUDE_PATH "${TCL_DIR}/generic;${TCL_DIR}/macosx") +# set(TK_INCLUDE_PATH "${TK_DIR}/generic;${TK_DIR}/macosx;${TK_DIR}/xlib") +# string(REPLACE ";" "$" TCL_INC "${TCL_INCLUDE_PATH}") +# string(REPLACE ";" "$" TK_INC "${TK_INCLUDE_PATH}") +# +# ExternalProject_Add(project_tkdnd +# URL "http://sourceforge.net/projects/tkdnd/files/TkDND/TkDND%202.8/tkdnd2.8-src.tar.gz" +# URL_MD5 a6d47a996ea957416469b12965d4db91 +# DEPENDS project_tcl project_tk +# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies +# PATCH_COMMAND patch < ${CMAKE_CURRENT_LIST_DIR}/tkdnd_macosx.patch +# UPDATE_COMMAND "" # Disable update +# BUILD_IN_SOURCE 1 +# CMAKE_ARGS +# -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/Contents/MacOS +# -DTCL_INCLUDE_PATH=${TCL_INC} +# -DTK_INCLUDE_PATH=${TK_INC} +# -DTK_LIBRARY=${TK_LIBRARY} +# -DTCL_LIBRARY=${TCL_LIBRARY} +# LOG_DOWNLOAD 1 +# LOG_CONFIGURE 1 +# LOG_BUILD 1 +# LOG_INSTALL 1 +# ) +# +# list(APPEND NETGEN_DEPENDENCIES project_tkdnd) +# else() +# find_package(TCL 8.5 REQUIRED) +# endif() elseif(WIN32) diff --git a/external_dependencies/pybind11 b/external_dependencies/pybind11 index 2a150736..4ffa6cd2 160000 --- a/external_dependencies/pybind11 +++ b/external_dependencies/pybind11 @@ -1 +1 @@ -Subproject commit 2a150736601bb3113877bb673fb934bb60d46ec5 +Subproject commit 4ffa6cd2d4a277b1cc8bc10d5c73cc0ee8edfaeb diff --git a/libsrc/core/CMakeLists.txt b/libsrc/core/CMakeLists.txt index 368247ed..15198d50 100644 --- a/libsrc/core/CMakeLists.txt +++ b/libsrc/core/CMakeLists.txt @@ -10,6 +10,11 @@ add_library(ngcore SHARED utils.cpp ) +# Pybind11 2.3 Issue https://github.com/pybind/pybind11/issues/1604 +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(ngcore PUBLIC -fsized-deallocation -faligned-allocation) +endif() + if(USE_PYTHON) target_sources(ngcore PRIVATE python_ngcore.cpp) endif(USE_PYTHON) diff --git a/libsrc/core/array.hpp b/libsrc/core/array.hpp index 4e460f66..f29340bc 100644 --- a/libsrc/core/array.hpp +++ b/libsrc/core/array.hpp @@ -453,6 +453,9 @@ namespace ngcore /// the size NETGEN_INLINE size_t Size() const { return size; } + /// the data + NETGEN_INLINE T* Data() const { return data; } + /// Fill array with value val NETGEN_INLINE const FlatArray & operator= (const T & val) const { diff --git a/libsrc/core/ngcore_api.hpp b/libsrc/core/ngcore_api.hpp index dfdee659..4841eb07 100644 --- a/libsrc/core/ngcore_api.hpp +++ b/libsrc/core/ngcore_api.hpp @@ -73,6 +73,7 @@ inline void operator delete[]( void* ptr, std::align_val_t al ) noexcept else delete[] (char*)ptr; } + #endif // __MAC_OS_X_VERSION_MIN_REQUIRED #endif // __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 diff --git a/libsrc/core/python_ngcore.cpp b/libsrc/core/python_ngcore.cpp index f60e40d3..5e64d1b2 100644 --- a/libsrc/core/python_ngcore.cpp +++ b/libsrc/core/python_ngcore.cpp @@ -1,10 +1,6 @@ -#include -#include "python_ngcore.hpp" - -#include "array.hpp" -#include "flags.hpp" #include "logging.hpp" +#include "python_ngcore.hpp" namespace py = pybind11; using std::string; diff --git a/libsrc/core/python_ngcore.hpp b/libsrc/core/python_ngcore.hpp index 7b22ee79..1a071dc2 100644 --- a/libsrc/core/python_ngcore.hpp +++ b/libsrc/core/python_ngcore.hpp @@ -1,6 +1,7 @@ #ifndef NETGEN_CORE_PYTHON_NGCORE_HPP #define NETGEN_CORE_PYTHON_NGCORE_HPP +#include "ngcore_api.hpp" // for operator new #include #include "array.hpp" diff --git a/libsrc/general/ngpython.hpp b/libsrc/general/ngpython.hpp index e13533c1..ef02d19f 100644 --- a/libsrc/general/ngpython.hpp +++ b/libsrc/general/ngpython.hpp @@ -1,13 +1,13 @@ #ifdef NG_PYTHON -#include +#include + #include #include #include #include #include -#include using namespace ngcore; template diff --git a/libsrc/include/incopengl.hpp b/libsrc/include/incopengl.hpp index b3fcc71b..dc4c469f 100644 --- a/libsrc/include/incopengl.hpp +++ b/libsrc/include/incopengl.hpp @@ -5,6 +5,7 @@ #include # if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC) || defined(TOGL_NSOPENGL) +#define GL_SILENCE_DEPRECATION # include # include # else diff --git a/libsrc/meshing/curvedelems.cpp b/libsrc/meshing/curvedelems.cpp index 77a06f72..392ef0ef 100644 --- a/libsrc/meshing/curvedelems.cpp +++ b/libsrc/meshing/curvedelems.cpp @@ -1295,10 +1295,17 @@ namespace netgen Point<3> pp = xa[jj]; // ref -> ProjectToSurface (pp, mesh.GetFaceDescriptor(el.GetIndex()).SurfNr()); + /** + with MPI and an interior surface element between volume elements assigned to different + procs, only one of them has the surf-el + **/ SurfaceElementIndex sei = top.GetFace2SurfaceElement (f+1)-1; - PointGeomInfo gi = mesh[sei].GeomInfoPi(1); - - ref -> ProjectToSurface (pp, surfnr[facenr], gi); + if (sei != SurfaceElementIndex(-1)) { + PointGeomInfo gi = mesh[sei].GeomInfoPi(1); + ref -> ProjectToSurface (pp, surfnr[facenr], gi); + } + else + { ref -> ProjectToSurface (pp, surfnr[facenr]); } Vec<3> dist = pp-xa[jj]; CalcTrigShape (order1, lami[fnums[1]]-lami[fnums[0]], diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index b32068a0..db0932b1 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -236,8 +236,8 @@ namespace netgen np = 3; typ = TRIG; - for (int i = 0; i < ELEMENT2D_MAXPOINTS; i++) - pnum[i].Invalidate(); + for (int i = 3; i < ELEMENT2D_MAXPOINTS; i++) + pnum[i].Invalidate(); for (int i = 0; i < ELEMENT2D_MAXPOINTS; i++) geominfo[i].trignum = 0; diff --git a/libsrc/meshing/paralleltop.cpp b/libsrc/meshing/paralleltop.cpp index 6a5d562c..c410f425 100644 --- a/libsrc/meshing/paralleltop.cpp +++ b/libsrc/meshing/paralleltop.cpp @@ -698,6 +698,9 @@ namespace netgen // cout << "UpdateCoarseGrid - done" << endl; is_updated = true; + + MPI_Group_free(&MPI_LocalGroup); + MPI_Comm_free(&MPI_LocalComm); } } diff --git a/libsrc/meshing/python_mesh.hpp b/libsrc/meshing/python_mesh.hpp index 62a85778..cc554fc6 100644 --- a/libsrc/meshing/python_mesh.hpp +++ b/libsrc/meshing/python_mesh.hpp @@ -1,9 +1,8 @@ #ifndef NETGEN_MESHING_PYTHON_MESH_HPP #define NETGEN_MESHING_PYTHON_MESH_HPP -#include - #include + #include "meshing.hpp" namespace netgen diff --git a/libsrc/occ/occgenmesh.cpp b/libsrc/occ/occgenmesh.cpp index c46f8fc2..aa2c4b0d 100644 --- a/libsrc/occ/occgenmesh.cpp +++ b/libsrc/occ/occgenmesh.cpp @@ -989,7 +989,7 @@ namespace netgen void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh, - const MeshingParameters & mparam) + const MeshingParameters & mparam, const OCCParameters& occparam) { mesh.SetGlobalH (mparam.maxh); mesh.SetMinimalH (mparam.minh); @@ -1273,7 +1273,8 @@ namespace netgen - int OCCGenerateMesh (OCCGeometry & geom, shared_ptr & mesh, MeshingParameters & mparam) + int OCCGenerateMesh (OCCGeometry & geom, shared_ptr & mesh, MeshingParameters & mparam, + const OCCParameters& occparam) { multithread.percent = 0; @@ -1283,7 +1284,7 @@ namespace netgen mesh = make_shared(); mesh->geomtype = Mesh::GEOM_OCC; - OCCSetLocalMeshSize(geom,*mesh, mparam); + OCCSetLocalMeshSize(geom,*mesh, mparam, occparam); } if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE) diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 2209a2b5..0faf7f0a 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -1684,12 +1684,6 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a - int OCCGeometry :: GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) - { - return OCCGenerateMesh (*this, mesh, mparam); - } - - const Refinement & OCCGeometry :: GetRefinement () const @@ -1697,20 +1691,6 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a return * new OCCRefinementSurfaces (*this); } - - - - OCCParameters :: OCCParameters() - { - resthcloseedgefac = 1; - resthcloseedgeenable = 1; - resthminedgelen = 0.001; - resthminedgelenenable = 1; - } - - - - void OCCParameters :: Print(ostream & ost) const { ost << "OCC Parameters:" << endl @@ -1720,11 +1700,13 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a << ", min len = " << resthminedgelen << endl; } + DLL_HEADER extern OCCParameters occparam; + OCCParameters occparam; - - - OCCParameters occparam; - + int OCCGeometry :: GenerateMesh (shared_ptr & mesh, MeshingParameters & mparam) + { + return OCCGenerateMesh (*this, mesh, mparam, occparam); + } } diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index af76155c..5479f351 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -404,26 +404,19 @@ namespace netgen public: /// Factor for meshing close edges - double resthcloseedgefac; + double resthcloseedgefac = 2.; /// Enable / Disable detection of close edges - int resthcloseedgeenable; + int resthcloseedgeenable = true; /// Minimum edge length to be used for dividing edges to mesh points - double resthminedgelen; + double resthminedgelen = 0.001; /// Enable / Disable use of the minimum edge length (by default use 1e-4) - int resthminedgelenenable; - - /*! - Default Constructor for the OpenCascade - Mesh generation parameter set - */ - OCCParameters(); - + int resthminedgelenenable = true; /*! Dump all the OpenCascade specific meshing parameters @@ -439,16 +432,14 @@ namespace netgen DLL_HEADER OCCGeometry * LoadOCC_STEP (const char * filename); DLL_HEADER OCCGeometry * LoadOCC_BREP (const char * filename); - DLL_HEADER extern OCCParameters occparam; - - // Philippose - 31.09.2009 // External access to the mesh generation functions within the OCC // subsystem (Not sure if this is the best way to implement this....!!) DLL_HEADER extern int OCCGenerateMesh (OCCGeometry & occgeometry, shared_ptr & mesh, - MeshingParameters & mparam); + MeshingParameters & mparam, const OCCParameters& occparam); - DLL_HEADER extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh, const MeshingParameters & mparam); + DLL_HEADER extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh, const MeshingParameters & mparam, + const OCCParameters& occparam); DLL_HEADER extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend, MeshingParameters & mparam); diff --git a/libsrc/occ/occpkg.cpp b/libsrc/occ/occpkg.cpp index 0c6531ea..de9367d7 100644 --- a/libsrc/occ/occpkg.cpp +++ b/libsrc/occ/occpkg.cpp @@ -28,6 +28,7 @@ namespace netgen extern DLL_HEADER shared_ptr ng_geometry; extern DLL_HEADER shared_ptr mesh; extern DLL_HEADER MeshingParameters mparam; + extern DLL_HEADER OCCParameters occparam; char * err_needsoccgeometry = (char*) "This operation needs an OCC geometry"; extern char * err_needsmesh; diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index 3a8568ca..70d35a32 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -15,6 +15,45 @@ namespace netgen extern std::shared_ptr ng_geometry; } +static string occparameter_description = R"delimiter( +OCC Specific Meshing Parameters +------------------------------- + +closeedgefac: Optional[float] = 1. + Factor for meshing close edges, if None it is disabled. + +minedgelen: Optional[float] = 0.001 + Minimum edge length to be used for dividing edges to mesh points. If + None this is disabled. + +)delimiter"; + +void CreateOCCParametersFromKwargs(OCCParameters& occparam, py::dict kwargs) +{ + if(kwargs.contains("closeedgefac")) + { + auto val = kwargs.attr("pop")("closeedgefac"); + if(val.is_none()) + occparam.resthcloseedgeenable = false; + else + { + occparam.resthcloseedgefac = py::cast(val); + occparam.resthcloseedgeenable = true; + } + } + if(kwargs.contains("minedgelen")) + { + auto val = kwargs.attr("pop")("minedgelen"); + if(val.is_none()) + occparam.resthminedgelenenable = false; + else + { + occparam.resthminedgelen = py::cast(val); + occparam.resthminedgelenenable = true; + } + } +} + DLL_HEADER void ExportNgOCC(py::module &m) { @@ -132,20 +171,27 @@ DLL_HEADER void ExportNgOCC(py::module &m) MeshingParameters* pars, py::kwargs kwargs) { MeshingParameters mp; - if(pars) mp = *pars; + OCCParameters occparam; { py::gil_scoped_acquire aq; + if(pars) + { + auto mp_kwargs = CreateDictFromFlags(pars->geometrySpecificParameters); + CreateOCCParametersFromKwargs(occparam, mp_kwargs); + mp = *pars; + } + CreateOCCParametersFromKwargs(occparam, kwargs); CreateMPfromKwargs(mp, kwargs); } auto mesh = make_shared(); SetGlobalMesh(mesh); mesh->SetGeometry(geo); ng_geometry = geo; - geo->GenerateMesh(mesh,mp); + OCCGenerateMesh(*geo, mesh, mp, occparam); return mesh; }, py::arg("mp") = nullptr, py::call_guard(), - meshingparameter_description.c_str()) + (meshingparameter_description + occparameter_description).c_str()) ; m.def("LoadOCCGeometry",[] (const string & filename) diff --git a/libsrc/stlgeom/python_stl.cpp b/libsrc/stlgeom/python_stl.cpp index d98707ca..5c773308 100644 --- a/libsrc/stlgeom/python_stl.cpp +++ b/libsrc/stlgeom/python_stl.cpp @@ -21,15 +21,21 @@ static string stlparameter_description = R"delimiter( STL Specific Meshing Parameters ------------------------------- -yangle: float = +yangle: float = 30. Angle for edge detection -contyangle: float = +contyangle: float = 20. Edges continue if angle > contyangle -edgecornerangle: float = +edgecornerangle: float = 60. Angle of geometry edge at which the mesher should set a point. +closeedgefac: Optional[float] = 1. + Factor for meshing close edges, if None it is disabled. + +minedgelen: Optional[float] = 0.001 + Minimum edge length to be used for dividing edges to mesh points. If + None this is disabled. )delimiter"; void CreateSTLParametersFromKwargs(STLParameters& stlparam, py::dict kwargs) diff --git a/libsrc/stlgeom/stltool.hpp b/libsrc/stlgeom/stltool.hpp index 19ff12cc..f03c31dd 100644 --- a/libsrc/stlgeom/stltool.hpp +++ b/libsrc/stlgeom/stltool.hpp @@ -235,7 +235,7 @@ class DLL_HEADER STLParameters public: /// angle for edge detection double yangle = 30.; - double contyangle; //edges continued with contyangle + double contyangle = 20.; //edges continued with contyangle /// angle of geometry edge at which the mesher should set a point double edgecornerangle = 60.; /// angle inside on chart @@ -243,25 +243,25 @@ public: /// angle for overlapping parts of char double outerchartangle = 70.; /// 0 .. no, 1 .. local, (2 .. global) - int usesearchtree; + int usesearchtree = 0; /// - double resthatlasfac; - bool resthatlasenable; - double atlasminh; + double resthatlasfac = 2.; + bool resthatlasenable = true; + double atlasminh = 0.1; - double resthsurfcurvfac = 1.; + double resthsurfcurvfac = 2.; bool resthsurfcurvenable = false; - double resthchartdistfac = 1.5; + double resthchartdistfac = 1.2; bool resthchartdistenable = true; - double resthcloseedgefac = 2.; + double resthcloseedgefac = 1.; bool resthcloseedgeenable = true; double resthedgeanglefac = 1.; bool resthedgeangleenable = false; - double resthsurfmeshcurvfac = 2.; + double resthsurfmeshcurvfac = 1.; bool resthsurfmeshcurvenable = false; double resthlinelengthfac = 0.5; diff --git a/nglib/nglib.cpp b/nglib/nglib.cpp index 98e37989..0f219e39 100644 --- a/nglib/nglib.cpp +++ b/nglib/nglib.cpp @@ -21,7 +21,11 @@ #ifdef OCCGEOMETRY #include -#endif +namespace netgen +{ + DLL_HEADER extern OCCParameters occparam; +} // namespace netgen +#endif // OCCGEOMETRY #include @@ -859,7 +863,7 @@ namespace nglib // slate me->DeleteMesh(); - OCCSetLocalMeshSize(*occgeom, *me, mparam); + OCCSetLocalMeshSize(*occgeom, *me, mparam, occparam); return(NG_OK); } diff --git a/python/meshing.py b/python/meshing.py index 1af409a2..7f5193f1 100644 --- a/python/meshing.py +++ b/python/meshing.py @@ -6,61 +6,66 @@ class _MeshsizeObject: return MeshingParameters(curvaturesafety=1, segmentsperedge=0.3, grading=0.7, - resthsurfcurvfac=0.25, - resthchartdistfac=0.8, - resthlinelengthfac=0.2, - resthcloseedgefac=0.5, - resthminedgelen=0.002, - resthedgeanglefac=0.25, - resthsurfmeshcurvfac=1.) + surfcurvfac=0.25, + chartdistfac=0.8, + linelengthfac=0.2, + closeedgefac=0.5, + minedgelen=0.002, + edgeanglefac=0.25, + surfmeshcurvfac=1., + optsteps3d=5) @property def coarse(self): return MeshingParameters(curvaturesafety=1.5, segmentsperedge=0.5, grading=0.5, - resthsurfcurvfac=0.5, - resthchartdistfac=1, - resthlinelengthfac=0.35, - resthcloseedgefac=1, - resthminedgelen=0.02, - resthedgeanglefac=0.5, - resthsurfmeshcurvfac=1.5) + surfcurvfac=0.5, + chartdistfac=1, + linelengthfac=0.35, + closeedgefac=1, + minedgelen=0.02, + edgeanglefac=0.5, + surfmeshcurvfac=1.5, + optsteps3d=5) @property def moderate(self): return MeshingParameters(curvaturesafety=2, segmentsperedge=1, grading=0.3, - resthsurfcurvfac=1., - resthchartdistfac=1.5, - resthlinelengthfac=0.5, - resthcloseedgefac=2, - resthminedgelen=0.2, - resthedgeanglefac=1, - resthsurfmeshcurvfac=2.) + surfcurvfac=1., + chartdistfac=1.5, + linelengthfac=0.5, + closeedgefac=2, + minedgelen=0.2, + edgeanglefac=1, + surfmeshcurvfac=2., + optsteps3d=5) @property def fine(self): return MeshingParameters(curvaturesafety=3, segmentsperedge=2, grading=0.2, - resthsurfcurvfac=1.5, - resthchartdistfac=2, - resthlinelengthfac=1.5, - resthcloseedgefac=3.5, - resthminedgelen=1., - resthedgeanglefac=1.5, - resthsurfmeshcurvfac=3.) + surfcurvfac=1.5, + chartdistfac=2, + linelengthfac=1.5, + closeedgefac=3.5, + minedgelen=1., + edgeanglefac=1.5, + surfmeshcurvfac=3., + optsteps3d=5) @property def very_fine(self): return MeshingParameters(curvaturesafety=5, segmentsperedge=3, grading=0.1, - resthsurfcurvfac=3, - resthchartdistfac=5, - resthlinelengthfac=3, - resthcloseedgefac=5, - resthminedgelen=2., - resthedgeanglefac=3., - resthsurfmeshcurvfac=5.) + surfcurvfac=3, + chartdistfac=5, + linelengthfac=3, + closeedgefac=5, + minedgelen=2., + edgeanglefac=3., + surfmeshcurvfac=5., + optsteps3d=5) meshsize = _MeshsizeObject() diff --git a/tests/build_debug.sh b/tests/build_debug.sh index c69af43c..fe650b8e 100755 --- a/tests/build_debug.sh +++ b/tests/build_debug.sh @@ -1,6 +1,6 @@ cd mkdir -p build/netgen cd build/netgen -cmake ../../src/netgen -DUSE_CCACHE=ON -DBUILD_TYPE=DEBUG -DENABLE_UNIT_TESTS=ON +cmake ../../src/netgen -DUSE_CCACHE=ON -DBUILD_TYPE=DEBUG -DENABLE_UNIT_TESTS=ON -DUSE_OCC=ON make -j12 make install diff --git a/tests/dockerfile b/tests/dockerfile index ebed3dea..7b1b4a5d 100644 --- a/tests/dockerfile +++ b/tests/dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:18.04 ENV DEBIAN_FRONTEND=noninteractive MAINTAINER Matthias Hochsteger -RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk clang-tidy python3-distutils clang +RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk clang-tidy python3-distutils clang liboce-ocaf-dev ADD . /root/src/netgen diff --git a/tests/pytest/results.py b/tests/pytest/results.py index 125fe417..f213fda9 100644 --- a/tests/pytest/results.py +++ b/tests/pytest/results.py @@ -1,36 +1,36 @@ number_elements = {} -number_elements['fichera.geo'] = (35,18,18,35,209,496) -number_elements['shaft.geo'] = (2609,874,1775,2609,11282,64486) -number_elements['revolution.geo'] = (9143,1252,3868,9143,33305,206010) -number_elements['twocubes.geo'] = (42,22,22,42,177,595) -number_elements['boxcyl.geo'] = (843,146,366,843,3739,18882) -number_elements['ellipticcyl.geo'] = (2202,324,1106,2202,8311,55941) -number_elements['trafo.geo'] = (5154,1358,2389,5154,17998,85820) +number_elements['cylsphere.geo'] = (706,231,490,706,2797,17554) number_elements['cubeandspheres.geo'] = (98,100,98,98,366,1078) -number_elements['manyholes2.geo'] = (128420) -number_elements['cubeandring.geo'] = (2014,231,613,2014,7838,38997) -number_elements['period.geo'] = (3262,616,1380,3262,11758,69618) -number_elements['sphereincube.geo'] = (505,178,329,505,1665,14230) -number_elements['cube.geo'] = (6,6,6,6,43,177) -number_elements['sphere.geo'] = (126,56,80,126,347,2357) -number_elements['cylsphere.geo'] = (706,241,520,706,2826,17819) -number_elements['ellipticcone.geo'] = (4973,574,1774,4973,13530,71573) -number_elements['ortho.geo'] = (6,6,6,6,43,179) -number_elements['cylinder.geo'] = (404,101,282,404,1169,8164) -number_elements['twocyl.geo'] = (578,158,419,578,1899,13712) -number_elements['manyholes.geo'] = (176503,28935,70662) +number_elements['ellipsoid.geo'] = (1271,551,595,1268,5607,38173) +number_elements['manyholes2.geo'] = (128244) +number_elements['sculpture.geo'] = (477,140,260,477,1330,6769) +number_elements['ortho.geo'] = (6,6,6,6,34,180) +number_elements['ellipticcone.geo'] = (4973,573,1765,4918,13410,70483) +number_elements['cube.geo'] = (6,6,6,6,28,178) number_elements['twobricks.geo'] = (42,22,22,42,177,595) -number_elements['lshape3d.geo'] = (18,12,12,18,93,324) -number_elements['sculpture.geo'] = (477,140,260,477,1331,6816) -number_elements['ellipsoid.geo'] = (1271,661,596,1271,5572,38616) -number_elements['matrix.geo'] = (5209,1946,2817,5209,16398,102850) -number_elements['cone.geo'] = (1215,501,698,1215,4437,27682) -number_elements['cubemcyl.geo'] = (19712,3255,8345,19712,90496,536232) +number_elements['revolution.geo'] = (8310,1249,3856,8269,33078,202941) +number_elements['circle_on_cube.geo'] = (636,39,189,631,2035,12237) +number_elements['sphereincube.geo'] = (508,173,339,515,1652,13829) +number_elements['twocubes.geo'] = (42,22,22,42,177,595) number_elements['boundarycondition.geo'] = (39,22,22,39,165,508) -number_elements['torus.geo'] = (5522,2530,2740,5522,25614,180197) -number_elements['circle_on_cube.geo'] = (636,39,189,636,2056,12409) -number_elements['cubemsphere.geo'] = (4737,776,1498,4737,17815,115493) -number_elements['part1.stl'] = (1228,347,520,1804,4317,84101) -number_elements['hinge.stl'] = (1995,789,1130,2612,6945,136803) -number_elements['frame.step'] = (112262,43857,59126) -number_elements['screw.step'] = (798,1521,7252) +number_elements['ellipticcyl.geo'] = (2202,324,1106,2190,8245,55199) +number_elements['trafo.geo'] = (5154,1358,2389,5141,17948,92850) +number_elements['boxcyl.geo'] = (843,146,364,843,3700,18677) +number_elements['sphere.geo'] = (126,56,80,126,347,2342) +number_elements['torus.geo'] = (5520,2171,2739,5510,25402,177967) +number_elements['shaft.geo'] = (2609,808,1666,2594,11226,64172) +number_elements['cone.geo'] = (1215,447,678,1211,4404,27336) +number_elements['cubeandring.geo'] = (2014,231,612,1988,7671,38095) +number_elements['manyholes.geo'] = (176503,28896,70408) +number_elements['period.geo'] = (3263,574,1349,3236,11645,68523) +number_elements['lshape3d.geo'] = (18,12,12,18,93,335) +number_elements['cubemsphere.geo'] = (4708,773,1460,4667,17655,114554) +number_elements['twocyl.geo'] = (578,147,403,578,1887,13537) +number_elements['cubemcyl.geo'] = (19712,3225,8153,19438,89202,524684) +number_elements['matrix.geo'] = (5207,1888,2790,5149,16205,101146) +number_elements['fichera.geo'] = (35,18,18,35,209,496) +number_elements['cylinder.geo'] = (404,101,256,404,1161,8076) +number_elements['part1.stl'] = (1228,620,727,1216,1548,3498) +number_elements['hinge.stl'] = (1995,1399,1532,1987,2881,4621) +number_elements['frame.step'] = (195213,30333,58955) +number_elements['screw.step'] = (2021,7011,23730)