Merge branch 'occ_parameters_from_python' into 'master'

occ parameters from python, gui and meshsize parameters now the same

See merge request jschoeberl/netgen!218
This commit is contained in:
Joachim Schöberl 2019-08-27 09:38:26 +00:00
commit eb77dd284d
12 changed files with 165 additions and 129 deletions

View File

@ -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> & mesh, MeshingParameters & mparam)
int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
const OCCParameters& occparam)
{
multithread.percent = 0;
@ -1283,7 +1284,7 @@ namespace netgen
mesh = make_shared<Mesh>();
mesh->geomtype = Mesh::GEOM_OCC;
OCCSetLocalMeshSize(geom,*mesh, mparam);
OCCSetLocalMeshSize(geom,*mesh, mparam, occparam);
}
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
@ -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> & mesh, MeshingParameters & mparam)
{
return OCCGenerateMesh (*this, mesh, mparam, occparam);
}
}

View File

@ -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> & 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);

View File

@ -28,6 +28,7 @@ namespace netgen
extern DLL_HEADER shared_ptr<NetgenGeometry> ng_geometry;
extern DLL_HEADER shared_ptr<Mesh> 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;

View File

@ -15,6 +15,45 @@ namespace netgen
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)
{
@ -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<Mesh>();
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<py::gil_scoped_release>(),
meshingparameter_description.c_str())
(meshingparameter_description + occparameter_description).c_str())
;
m.def("LoadOCCGeometry",[] (const string & filename)

View File

@ -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)

View File

@ -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;

View File

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

View File

@ -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()

View File

@ -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

View File

@ -1,5 +1,5 @@
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
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

View File

@ -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)