Merge remote-tracking branch 'origin/master' into subcomm

This commit is contained in:
Lukas 2019-08-27 13:32:25 +02:00
commit bca0f6a2ea
26 changed files with 304 additions and 201 deletions

View File

@ -198,7 +198,7 @@ build_mac:
-DUSE_NATIVE_ARCH=OFF -DUSE_NATIVE_ARCH=OFF
-DUSE_CCACHE=ON -DUSE_CCACHE=ON
-DENABLE_UNIT_TESTS=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 -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
- make -j5 install - make -j5 install

View File

@ -1,61 +1,112 @@
if(APPLE) if(APPLE)
# use system tcl/tk set(tcl_prefix ${CMAKE_INSTALL_PREFIX})
if((${PYTHON_VERSION_STRING} VERSION_EQUAL "3.7") OR (${PYTHON_VERSION_STRING} VERSION_GREATER "3.7")) ExternalProject_Add(project_tcl
# fetch tcl/tk sources to match the one used in Python 3.7 URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tcl8.6.9-src.tar.gz"
ExternalProject_Add(project_tcl URL_MD5 aa0a121d95a0e7b73a036f26028538d4
URL "https://prdownloads.sourceforge.net/tcl/tcl8.6.8-src.tar.gz" DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
URL_MD5 81656d3367af032e0ae6157eff134f89 UPDATE_COMMAND "" # Disable update
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies 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
UPDATE_COMMAND "" # Disable update BUILD_COMMAND make -j4 binaries libraries
CONFIGURE_COMMAND "" INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
BUILD_COMMAND "" LOG_DOWNLOAD 1
INSTALL_COMMAND "" LOG_BUILD 1
) LOG_CONFIGURE 1
ExternalProject_Add(project_tk LOG_INSTALL 1
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 ";" "$<SEMICOLON>" TCL_INC "${TCL_INCLUDE_PATH}")
string(REPLACE ";" "$<SEMICOLON>" 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) ExternalProject_Add(project_tk
else() DEPENDS project_tcl
find_package(TCL 8.5 REQUIRED) URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tk8.6.9.1-src.tar.gz"
endif() 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 ";" "$<SEMICOLON>" TCL_INC "${TCL_INCLUDE_PATH}")
# string(REPLACE ";" "$<SEMICOLON>" 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) elseif(WIN32)

@ -1 +1 @@
Subproject commit 2a150736601bb3113877bb673fb934bb60d46ec5 Subproject commit 4ffa6cd2d4a277b1cc8bc10d5c73cc0ee8edfaeb

View File

@ -10,6 +10,11 @@ add_library(ngcore SHARED
utils.cpp 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) if(USE_PYTHON)
target_sources(ngcore PRIVATE python_ngcore.cpp) target_sources(ngcore PRIVATE python_ngcore.cpp)
endif(USE_PYTHON) endif(USE_PYTHON)

View File

@ -453,6 +453,9 @@ namespace ngcore
/// the size /// the size
NETGEN_INLINE size_t Size() const { return size; } NETGEN_INLINE size_t Size() const { return size; }
/// the data
NETGEN_INLINE T* Data() const { return data; }
/// Fill array with value val /// Fill array with value val
NETGEN_INLINE const FlatArray & operator= (const T & val) const NETGEN_INLINE const FlatArray & operator= (const T & val) const
{ {

View File

@ -73,6 +73,7 @@ inline void operator delete[]( void* ptr, std::align_val_t al ) noexcept
else else
delete[] (char*)ptr; delete[] (char*)ptr;
} }
#endif // __MAC_OS_X_VERSION_MIN_REQUIRED #endif // __MAC_OS_X_VERSION_MIN_REQUIRED
#endif // __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED < 101300

View File

@ -1,10 +1,6 @@
#include <pybind11/pybind11.h>
#include "python_ngcore.hpp"
#include "array.hpp"
#include "flags.hpp"
#include "logging.hpp" #include "logging.hpp"
#include "python_ngcore.hpp"
namespace py = pybind11; namespace py = pybind11;
using std::string; using std::string;

View File

@ -1,6 +1,7 @@
#ifndef NETGEN_CORE_PYTHON_NGCORE_HPP #ifndef NETGEN_CORE_PYTHON_NGCORE_HPP
#define NETGEN_CORE_PYTHON_NGCORE_HPP #define NETGEN_CORE_PYTHON_NGCORE_HPP
#include "ngcore_api.hpp" // for operator new
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include "array.hpp" #include "array.hpp"

View File

@ -1,13 +1,13 @@
#ifdef NG_PYTHON #ifdef NG_PYTHON
#include <pybind11/pybind11.h> #include <core/python_ngcore.hpp>
#include <pybind11/operators.h> #include <pybind11/operators.h>
#include <pybind11/numpy.h> #include <pybind11/numpy.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <core/python_ngcore.hpp>
using namespace ngcore; using namespace ngcore;
template <typename T> template <typename T>

View File

@ -5,6 +5,7 @@
#include <mydefs.hpp> #include <mydefs.hpp>
# if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC) || defined(TOGL_NSOPENGL) # if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC) || defined(TOGL_NSOPENGL)
#define GL_SILENCE_DEPRECATION
# include <OpenGL/gl.h> # include <OpenGL/gl.h>
# include <OpenGL/glu.h> # include <OpenGL/glu.h>
# else # else

View File

@ -1295,10 +1295,17 @@ namespace netgen
Point<3> pp = xa[jj]; Point<3> pp = xa[jj];
// ref -> ProjectToSurface (pp, mesh.GetFaceDescriptor(el.GetIndex()).SurfNr()); // 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; SurfaceElementIndex sei = top.GetFace2SurfaceElement (f+1)-1;
PointGeomInfo gi = mesh[sei].GeomInfoPi(1); if (sei != SurfaceElementIndex(-1)) {
PointGeomInfo gi = mesh[sei].GeomInfoPi(1);
ref -> ProjectToSurface (pp, surfnr[facenr], gi); ref -> ProjectToSurface (pp, surfnr[facenr], gi);
}
else
{ ref -> ProjectToSurface (pp, surfnr[facenr]); }
Vec<3> dist = pp-xa[jj]; Vec<3> dist = pp-xa[jj];
CalcTrigShape (order1, lami[fnums[1]]-lami[fnums[0]], CalcTrigShape (order1, lami[fnums[1]]-lami[fnums[0]],

View File

@ -236,8 +236,8 @@ namespace netgen
np = 3; np = 3;
typ = TRIG; typ = TRIG;
for (int i = 0; i < ELEMENT2D_MAXPOINTS; i++) for (int i = 3; i < ELEMENT2D_MAXPOINTS; i++)
pnum[i].Invalidate(); pnum[i].Invalidate();
for (int i = 0; i < ELEMENT2D_MAXPOINTS; i++) for (int i = 0; i < ELEMENT2D_MAXPOINTS; i++)
geominfo[i].trignum = 0; geominfo[i].trignum = 0;

View File

@ -698,6 +698,9 @@ namespace netgen
// cout << "UpdateCoarseGrid - done" << endl; // cout << "UpdateCoarseGrid - done" << endl;
is_updated = true; is_updated = true;
MPI_Group_free(&MPI_LocalGroup);
MPI_Comm_free(&MPI_LocalComm);
} }
} }

View File

@ -1,9 +1,8 @@
#ifndef NETGEN_MESHING_PYTHON_MESH_HPP #ifndef NETGEN_MESHING_PYTHON_MESH_HPP
#define NETGEN_MESHING_PYTHON_MESH_HPP #define NETGEN_MESHING_PYTHON_MESH_HPP
#include <pybind11/pybind11.h>
#include <core/python_ngcore.hpp> #include <core/python_ngcore.hpp>
#include "meshing.hpp" #include "meshing.hpp"
namespace netgen namespace netgen

View File

@ -989,7 +989,7 @@ namespace netgen
void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh, void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh,
const MeshingParameters & mparam) const MeshingParameters & mparam, const OCCParameters& occparam)
{ {
mesh.SetGlobalH (mparam.maxh); mesh.SetGlobalH (mparam.maxh);
mesh.SetMinimalH (mparam.minh); mesh.SetMinimalH (mparam.minh);
@ -1273,7 +1273,8 @@ namespace netgen
int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam) int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
const OCCParameters& occparam)
{ {
multithread.percent = 0; multithread.percent = 0;
@ -1283,7 +1284,7 @@ namespace netgen
mesh = make_shared<Mesh>(); mesh = make_shared<Mesh>();
mesh->geomtype = Mesh::GEOM_OCC; mesh->geomtype = Mesh::GEOM_OCC;
OCCSetLocalMeshSize(geom,*mesh, mparam); OCCSetLocalMeshSize(geom,*mesh, mparam, occparam);
} }
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE) if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE)

View File

@ -1684,12 +1684,6 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
return OCCGenerateMesh (*this, mesh, mparam);
}
const Refinement & OCCGeometry :: GetRefinement () const const Refinement & OCCGeometry :: GetRefinement () const
@ -1697,20 +1691,6 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
return * new OCCRefinementSurfaces (*this); return * new OCCRefinementSurfaces (*this);
} }
OCCParameters :: OCCParameters()
{
resthcloseedgefac = 1;
resthcloseedgeenable = 1;
resthminedgelen = 0.001;
resthminedgelenenable = 1;
}
void OCCParameters :: Print(ostream & ost) const void OCCParameters :: Print(ostream & ost) const
{ {
ost << "OCC Parameters:" << endl ost << "OCC Parameters:" << endl
@ -1720,11 +1700,13 @@ void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * a
<< ", min len = " << resthminedgelen << endl; << ", min len = " << resthminedgelen << endl;
} }
DLL_HEADER extern OCCParameters occparam;
OCCParameters occparam;
int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
OCCParameters occparam; return OCCGenerateMesh (*this, mesh, mparam, occparam);
}
} }

View File

@ -404,26 +404,19 @@ namespace netgen
public: public:
/// Factor for meshing close edges /// Factor for meshing close edges
double resthcloseedgefac; double resthcloseedgefac = 2.;
/// Enable / Disable detection of close edges /// Enable / Disable detection of close edges
int resthcloseedgeenable; int resthcloseedgeenable = true;
/// Minimum edge length to be used for dividing edges to mesh points /// 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) /// Enable / Disable use of the minimum edge length (by default use 1e-4)
int resthminedgelenenable; int resthminedgelenenable = true;
/*!
Default Constructor for the OpenCascade
Mesh generation parameter set
*/
OCCParameters();
/*! /*!
Dump all the OpenCascade specific meshing parameters 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_STEP (const char * filename);
DLL_HEADER OCCGeometry * LoadOCC_BREP (const char * filename); DLL_HEADER OCCGeometry * LoadOCC_BREP (const char * filename);
DLL_HEADER extern OCCParameters occparam;
// Philippose - 31.09.2009 // Philippose - 31.09.2009
// External access to the mesh generation functions within the OCC // External access to the mesh generation functions within the OCC
// subsystem (Not sure if this is the best way to implement this....!!) // subsystem (Not sure if this is the best way to implement this....!!)
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry & occgeometry, shared_ptr<Mesh> & mesh, DLL_HEADER extern int OCCGenerateMesh (OCCGeometry & occgeometry, shared_ptr<Mesh> & 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); DLL_HEADER extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend, MeshingParameters & mparam);

View File

@ -28,6 +28,7 @@ namespace netgen
extern DLL_HEADER shared_ptr<NetgenGeometry> ng_geometry; extern DLL_HEADER shared_ptr<NetgenGeometry> ng_geometry;
extern DLL_HEADER shared_ptr<Mesh> mesh; extern DLL_HEADER shared_ptr<Mesh> mesh;
extern DLL_HEADER MeshingParameters mparam; extern DLL_HEADER MeshingParameters mparam;
extern DLL_HEADER OCCParameters occparam;
char * err_needsoccgeometry = (char*) "This operation needs an OCC geometry"; char * err_needsoccgeometry = (char*) "This operation needs an OCC geometry";
extern char * err_needsmesh; extern char * err_needsmesh;

View File

@ -15,6 +15,45 @@ namespace netgen
extern std::shared_ptr<NetgenGeometry> ng_geometry; extern std::shared_ptr<NetgenGeometry> 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<double>(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<double>(val);
occparam.resthminedgelenenable = true;
}
}
}
DLL_HEADER void ExportNgOCC(py::module &m) DLL_HEADER void ExportNgOCC(py::module &m)
{ {
@ -132,20 +171,27 @@ DLL_HEADER void ExportNgOCC(py::module &m)
MeshingParameters* pars, py::kwargs kwargs) MeshingParameters* pars, py::kwargs kwargs)
{ {
MeshingParameters mp; MeshingParameters mp;
if(pars) mp = *pars; OCCParameters occparam;
{ {
py::gil_scoped_acquire aq; 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); CreateMPfromKwargs(mp, kwargs);
} }
auto mesh = make_shared<Mesh>(); auto mesh = make_shared<Mesh>();
SetGlobalMesh(mesh); SetGlobalMesh(mesh);
mesh->SetGeometry(geo); mesh->SetGeometry(geo);
ng_geometry = geo; ng_geometry = geo;
geo->GenerateMesh(mesh,mp); OCCGenerateMesh(*geo, mesh, mp, occparam);
return mesh; return mesh;
}, py::arg("mp") = nullptr, }, py::arg("mp") = nullptr,
py::call_guard<py::gil_scoped_release>(), py::call_guard<py::gil_scoped_release>(),
meshingparameter_description.c_str()) (meshingparameter_description + occparameter_description).c_str())
; ;
m.def("LoadOCCGeometry",[] (const string & filename) m.def("LoadOCCGeometry",[] (const string & filename)

View File

@ -21,15 +21,21 @@ static string stlparameter_description = R"delimiter(
STL Specific Meshing Parameters STL Specific Meshing Parameters
------------------------------- -------------------------------
yangle: float = yangle: float = 30.
Angle for edge detection Angle for edge detection
contyangle: float = contyangle: float = 20.
Edges continue if angle > contyangle Edges continue if angle > contyangle
edgecornerangle: float = edgecornerangle: float = 60.
Angle of geometry edge at which the mesher should set a point. 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"; )delimiter";
void CreateSTLParametersFromKwargs(STLParameters& stlparam, py::dict kwargs) void CreateSTLParametersFromKwargs(STLParameters& stlparam, py::dict kwargs)

View File

@ -235,7 +235,7 @@ class DLL_HEADER STLParameters
public: public:
/// angle for edge detection /// angle for edge detection
double yangle = 30.; 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 /// angle of geometry edge at which the mesher should set a point
double edgecornerangle = 60.; double edgecornerangle = 60.;
/// angle inside on chart /// angle inside on chart
@ -243,25 +243,25 @@ public:
/// angle for overlapping parts of char /// angle for overlapping parts of char
double outerchartangle = 70.; double outerchartangle = 70.;
/// 0 .. no, 1 .. local, (2 .. global) /// 0 .. no, 1 .. local, (2 .. global)
int usesearchtree; int usesearchtree = 0;
/// ///
double resthatlasfac; double resthatlasfac = 2.;
bool resthatlasenable; bool resthatlasenable = true;
double atlasminh; double atlasminh = 0.1;
double resthsurfcurvfac = 1.; double resthsurfcurvfac = 2.;
bool resthsurfcurvenable = false; bool resthsurfcurvenable = false;
double resthchartdistfac = 1.5; double resthchartdistfac = 1.2;
bool resthchartdistenable = true; bool resthchartdistenable = true;
double resthcloseedgefac = 2.; double resthcloseedgefac = 1.;
bool resthcloseedgeenable = true; bool resthcloseedgeenable = true;
double resthedgeanglefac = 1.; double resthedgeanglefac = 1.;
bool resthedgeangleenable = false; bool resthedgeangleenable = false;
double resthsurfmeshcurvfac = 2.; double resthsurfmeshcurvfac = 1.;
bool resthsurfmeshcurvenable = false; bool resthsurfmeshcurvenable = false;
double resthlinelengthfac = 0.5; double resthlinelengthfac = 0.5;

View File

@ -21,7 +21,11 @@
#ifdef OCCGEOMETRY #ifdef OCCGEOMETRY
#include <occgeom.hpp> #include <occgeom.hpp>
#endif namespace netgen
{
DLL_HEADER extern OCCParameters occparam;
} // namespace netgen
#endif // OCCGEOMETRY
#include <nginterface.h> #include <nginterface.h>
@ -859,7 +863,7 @@ namespace nglib
// slate // slate
me->DeleteMesh(); me->DeleteMesh();
OCCSetLocalMeshSize(*occgeom, *me, mparam); OCCSetLocalMeshSize(*occgeom, *me, mparam, occparam);
return(NG_OK); return(NG_OK);
} }

View File

@ -6,61 +6,66 @@ class _MeshsizeObject:
return MeshingParameters(curvaturesafety=1, return MeshingParameters(curvaturesafety=1,
segmentsperedge=0.3, segmentsperedge=0.3,
grading=0.7, grading=0.7,
resthsurfcurvfac=0.25, surfcurvfac=0.25,
resthchartdistfac=0.8, chartdistfac=0.8,
resthlinelengthfac=0.2, linelengthfac=0.2,
resthcloseedgefac=0.5, closeedgefac=0.5,
resthminedgelen=0.002, minedgelen=0.002,
resthedgeanglefac=0.25, edgeanglefac=0.25,
resthsurfmeshcurvfac=1.) surfmeshcurvfac=1.,
optsteps3d=5)
@property @property
def coarse(self): def coarse(self):
return MeshingParameters(curvaturesafety=1.5, return MeshingParameters(curvaturesafety=1.5,
segmentsperedge=0.5, segmentsperedge=0.5,
grading=0.5, grading=0.5,
resthsurfcurvfac=0.5, surfcurvfac=0.5,
resthchartdistfac=1, chartdistfac=1,
resthlinelengthfac=0.35, linelengthfac=0.35,
resthcloseedgefac=1, closeedgefac=1,
resthminedgelen=0.02, minedgelen=0.02,
resthedgeanglefac=0.5, edgeanglefac=0.5,
resthsurfmeshcurvfac=1.5) surfmeshcurvfac=1.5,
optsteps3d=5)
@property @property
def moderate(self): def moderate(self):
return MeshingParameters(curvaturesafety=2, return MeshingParameters(curvaturesafety=2,
segmentsperedge=1, segmentsperedge=1,
grading=0.3, grading=0.3,
resthsurfcurvfac=1., surfcurvfac=1.,
resthchartdistfac=1.5, chartdistfac=1.5,
resthlinelengthfac=0.5, linelengthfac=0.5,
resthcloseedgefac=2, closeedgefac=2,
resthminedgelen=0.2, minedgelen=0.2,
resthedgeanglefac=1, edgeanglefac=1,
resthsurfmeshcurvfac=2.) surfmeshcurvfac=2.,
optsteps3d=5)
@property @property
def fine(self): def fine(self):
return MeshingParameters(curvaturesafety=3, return MeshingParameters(curvaturesafety=3,
segmentsperedge=2, segmentsperedge=2,
grading=0.2, grading=0.2,
resthsurfcurvfac=1.5, surfcurvfac=1.5,
resthchartdistfac=2, chartdistfac=2,
resthlinelengthfac=1.5, linelengthfac=1.5,
resthcloseedgefac=3.5, closeedgefac=3.5,
resthminedgelen=1., minedgelen=1.,
resthedgeanglefac=1.5, edgeanglefac=1.5,
resthsurfmeshcurvfac=3.) surfmeshcurvfac=3.,
optsteps3d=5)
@property @property
def very_fine(self): def very_fine(self):
return MeshingParameters(curvaturesafety=5, return MeshingParameters(curvaturesafety=5,
segmentsperedge=3, segmentsperedge=3,
grading=0.1, grading=0.1,
resthsurfcurvfac=3, surfcurvfac=3,
resthchartdistfac=5, chartdistfac=5,
resthlinelengthfac=3, linelengthfac=3,
resthcloseedgefac=5, closeedgefac=5,
resthminedgelen=2., minedgelen=2.,
resthedgeanglefac=3., edgeanglefac=3.,
resthsurfmeshcurvfac=5.) surfmeshcurvfac=5.,
optsteps3d=5)
meshsize = _MeshsizeObject() meshsize = _MeshsizeObject()

View File

@ -1,6 +1,6 @@
cd cd
mkdir -p build/netgen mkdir -p build/netgen
cd 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 -j12
make install make install

View File

@ -1,5 +1,5 @@
FROM ubuntu:18.04 FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
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 ADD . /root/src/netgen

View File

@ -1,36 +1,36 @@
number_elements = {} number_elements = {}
number_elements['fichera.geo'] = (35,18,18,35,209,496) number_elements['cylsphere.geo'] = (706,231,490,706,2797,17554)
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['cubeandspheres.geo'] = (98,100,98,98,366,1078) number_elements['cubeandspheres.geo'] = (98,100,98,98,366,1078)
number_elements['manyholes2.geo'] = (128420) number_elements['ellipsoid.geo'] = (1271,551,595,1268,5607,38173)
number_elements['cubeandring.geo'] = (2014,231,613,2014,7838,38997) number_elements['manyholes2.geo'] = (128244)
number_elements['period.geo'] = (3262,616,1380,3262,11758,69618) number_elements['sculpture.geo'] = (477,140,260,477,1330,6769)
number_elements['sphereincube.geo'] = (505,178,329,505,1665,14230) number_elements['ortho.geo'] = (6,6,6,6,34,180)
number_elements['cube.geo'] = (6,6,6,6,43,177) number_elements['ellipticcone.geo'] = (4973,573,1765,4918,13410,70483)
number_elements['sphere.geo'] = (126,56,80,126,347,2357) number_elements['cube.geo'] = (6,6,6,6,28,178)
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['twobricks.geo'] = (42,22,22,42,177,595) number_elements['twobricks.geo'] = (42,22,22,42,177,595)
number_elements['lshape3d.geo'] = (18,12,12,18,93,324) number_elements['revolution.geo'] = (8310,1249,3856,8269,33078,202941)
number_elements['sculpture.geo'] = (477,140,260,477,1331,6816) number_elements['circle_on_cube.geo'] = (636,39,189,631,2035,12237)
number_elements['ellipsoid.geo'] = (1271,661,596,1271,5572,38616) number_elements['sphereincube.geo'] = (508,173,339,515,1652,13829)
number_elements['matrix.geo'] = (5209,1946,2817,5209,16398,102850) number_elements['twocubes.geo'] = (42,22,22,42,177,595)
number_elements['cone.geo'] = (1215,501,698,1215,4437,27682)
number_elements['cubemcyl.geo'] = (19712,3255,8345,19712,90496,536232)
number_elements['boundarycondition.geo'] = (39,22,22,39,165,508) number_elements['boundarycondition.geo'] = (39,22,22,39,165,508)
number_elements['torus.geo'] = (5522,2530,2740,5522,25614,180197) number_elements['ellipticcyl.geo'] = (2202,324,1106,2190,8245,55199)
number_elements['circle_on_cube.geo'] = (636,39,189,636,2056,12409) number_elements['trafo.geo'] = (5154,1358,2389,5141,17948,92850)
number_elements['cubemsphere.geo'] = (4737,776,1498,4737,17815,115493) number_elements['boxcyl.geo'] = (843,146,364,843,3700,18677)
number_elements['part1.stl'] = (1228,347,520,1804,4317,84101) number_elements['sphere.geo'] = (126,56,80,126,347,2342)
number_elements['hinge.stl'] = (1995,789,1130,2612,6945,136803) number_elements['torus.geo'] = (5520,2171,2739,5510,25402,177967)
number_elements['frame.step'] = (112262,43857,59126) number_elements['shaft.geo'] = (2609,808,1666,2594,11226,64172)
number_elements['screw.step'] = (798,1521,7252) 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)