Merge branch 'meshing_fixes' into 'master'

Meshing fixes

See merge request jschoeberl/netgen!282
This commit is contained in:
Joachim Schöberl 2019-10-23 11:58:35 +00:00
commit df1f445c8f
8 changed files with 809 additions and 617 deletions

View File

@ -79,6 +79,12 @@ namespace netgen
p = hp; p = hp;
} }
bool CSGeometry :: ProjectPointGI(int surfind, Point<3> & p, PointGeomInfo & gi) const
{
GetSurface(surfind)->Project (p);
return true;
}
void CSGeometry :: ProjectPointEdge(int surfind, INDEX surfind2, void CSGeometry :: ProjectPointEdge(int surfind, INDEX surfind2,
Point<3> & p) const Point<3> & p) const
{ {

View File

@ -189,6 +189,7 @@ namespace netgen
virtual void SaveToMeshFile (ostream & ost) const override; virtual void SaveToMeshFile (ostream & ost) const override;
void ProjectPoint(INDEX surfind, Point<3> & p) const override; void ProjectPoint(INDEX surfind, Point<3> & p) const override;
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const override;
void ProjectPointEdge(INDEX surfind, INDEX surfind2, Point<3> & p) const override; void ProjectPointEdge(INDEX surfind, INDEX surfind2, Point<3> & p) const override;
Vec<3> GetNormal(int surfind, const Point<3> & p) const override; Vec<3> GetNormal(int surfind, const Point<3> & p) const override;
void PointBetween(const Point<3> & p1, const Point<3> & p2, void PointBetween(const Point<3> & p1, const Point<3> & p2,

View File

@ -156,6 +156,12 @@ namespace netgen
ar & materials & maxh & quadmeshing & tensormeshing & layer & bcnames & elto0; ar & materials & maxh & quadmeshing & tensormeshing & layer & bcnames & elto0;
} }
bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const override
{
p(2) = 0.0;
return true;
}
void PointBetween(const Point<3> & p1, const Point<3> & p2, double secpoint, void PointBetween(const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,

View File

@ -51,9 +51,9 @@ namespace netgen
virtual bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const {return false;} virtual bool CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const {return false;}
virtual bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const virtual bool ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const
{ {
ProjectPoint(surfind, p); throw Exception("ProjectPointGI not overloaded in class" + Demangle(typeid(*this).name()));
return CalcPointGeomInfo(surfind, gi, p);
} }
virtual Vec<3> GetNormal(int surfind, const Point<3> & p) const virtual Vec<3> GetNormal(int surfind, const Point<3> & p) const
{ return {0.,0.,1.}; } { return {0.,0.,1.}; }
virtual Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & gi) const virtual Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo & gi) const

View File

@ -969,7 +969,7 @@ namespace netgen
// NgProfiler::StopTimer (timer2); // NgProfiler::StopTimer (timer2);
Point3d origp = mesh[pi]; auto origp = mesh[pi];
int loci = 1; int loci = 1;
double fact = 1; double fact = 1;
int moveisok = 0; int moveisok = 0;
@ -1021,7 +1021,7 @@ namespace netgen
} }
else else
{ {
mesh[pi] = Point<3> (origp); mesh[pi] = origp;
} }
} }

View File

@ -185,8 +185,8 @@ DLL_HEADER void ExportNgOCC(py::module &m)
} }
geo->SetOCCParameters(occparam); geo->SetOCCParameters(occparam);
auto mesh = make_shared<Mesh>(); auto mesh = make_shared<Mesh>();
geo->GenerateMesh(mesh, mp);
mesh->SetGeometry(geo); mesh->SetGeometry(geo);
geo->GenerateMesh(mesh, mp);
SetGlobalMesh(mesh); SetGlobalMesh(mesh);
ng_geometry = geo; ng_geometry = geo;
return mesh; return mesh;

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@ import os, pytest
from netgen.meshing import meshsize, MeshingParameters, SetMessageImportance from netgen.meshing import meshsize, MeshingParameters, SetMessageImportance
import netgen.csg as csg import netgen.csg as csg
import netgen.stl as stl import netgen.stl as stl
import netgen.geom2d as geom2d
from pyngcore import TaskManager from pyngcore import TaskManager
import json import json
try: try:
@ -34,12 +35,12 @@ def checkData(mesh, mp, ref):
# get tutorials # get tutorials
def getFiles(fileEnding): def getFiles(fileEnding):
r, d, files = next(os.walk(os.path.join("..","..","tutorials"))) r, d, files = next(os.walk(os.path.join("..","..","tutorials")))
return (f for f in files if f.endswith(fileEnding)) return [f for f in files if f.endswith(fileEnding)]
# get additional tests # get additional tests
def getAdditionalFiles(fileEnding): def getAdditionalFiles(fileEnding):
r, d, files = next(os.walk("geofiles")) r, d, files = next(os.walk("geofiles"))
return (f for f in files if f.endswith(fileEnding)) return [f for f in files if f.endswith(fileEnding)]
@pytest.fixture @pytest.fixture
def refdata(): def refdata():
@ -64,13 +65,13 @@ def getMeshingparameters(filename):
return standard[0:1] + standard[2:] # very coarse does not work return standard[0:1] + standard[2:] # very coarse does not work
return standard return standard
_geofiles = [f for f in getFiles(".geo")] + [f for f in getFiles(".stl")] _geofiles = getFiles(".in2d") + getFiles(".geo") + getFiles(".stl")
if has_occ: if has_occ:
_geofiles += [f for f in getFiles(".step")] _geofiles += getFiles(".step")
_geofiles.sort() _geofiles.sort()
_additional_testfiles = [f for f in getAdditionalFiles(".stl")] _additional_testfiles = getAdditionalFiles(".stl")
if has_occ: if has_occ:
_additional_testfiles += [f for f in getAdditionalFiles(".step")] _additional_testfiles += getAdditionalFiles(".step")
_additional_testfiles.sort() _additional_testfiles.sort()
def generateMesh(filename, mp): def generateMesh(filename, mp):
@ -81,6 +82,8 @@ def generateMesh(filename, mp):
geo = stl.STLGeometry(os.path.join(folder, filename)) geo = stl.STLGeometry(os.path.join(folder, filename))
elif filename.endswith(".step"): elif filename.endswith(".step"):
geo = occ.OCCGeometry(os.path.join(folder, filename)) geo = occ.OCCGeometry(os.path.join(folder, filename))
elif filename.endswith(".in2d"):
geo = geom2d.SplineGeometry(os.path.join(folder, filename))
return geo.GenerateMesh(mp) return geo.GenerateMesh(mp)
def isSlowTest(filename): def isSlowTest(filename):