From f2b9251032360f9f1fc2b8e5250b6f7ae82cbb55 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Fri, 28 Aug 2020 17:28:35 +0200 Subject: [PATCH] csg2d - tests --- tests/pytest/test_csg2d.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/pytest/test_csg2d.py diff --git a/tests/pytest/test_csg2d.py b/tests/pytest/test_csg2d.py new file mode 100644 index 00000000..3afc29ef --- /dev/null +++ b/tests/pytest/test_csg2d.py @@ -0,0 +1,33 @@ +from netgen.geom2d import * +import pytest +import math +from pytest import approx + +def test_two_circles(): + c1 = Circle(center=(0,0), radius=1) + c2 = c1.Rotate(deg=45) + s = c1*c2 + geo = CSG2d() + geo.Add(s) + m = geo.GenerateMesh() + assert m.ne > 0 + + ngs = pytest.importorskip("ngsolve") + mesh = ngs.Mesh(m) + mesh.Curve(5) + assert ngs.Integrate(1.0, mesh) == approx(math.pi) + +def test_two_edge(): + s = Solid2d( [(-1,0), cp(0,1), (1,0), cp(0,2)] ) + geo = CSG2d() + geo.Add(s) + m = geo.GenerateMesh() + assert m.ne > 0 + + ngs = pytest.importorskip("ngsolve") + g = geo.GenerateSplineGeometry() + ngs.Draw(g) + +if __name__ == "__main__": + test_two_circles() + test_two_edge()