mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
some more tests for csg2d
This commit is contained in:
parent
ea7f6c1e94
commit
ccc686830a
@ -3,6 +3,19 @@ import pytest
|
||||
import math
|
||||
from pytest import approx
|
||||
|
||||
|
||||
def check_area(geo, area):
|
||||
if isinstance(geo, Solid2d):
|
||||
g = CSG2d()
|
||||
g.Add(geo)
|
||||
geo = g
|
||||
|
||||
m = geo.GenerateMesh()
|
||||
ngs = pytest.importorskip("ngsolve")
|
||||
mesh = ngs.Mesh(m)
|
||||
mesh.Curve(5)
|
||||
assert ngs.Integrate(1.0, mesh) == approx(area)
|
||||
|
||||
def test_two_circles():
|
||||
c1 = Circle(center=(0,0), radius=1)
|
||||
c2 = c1.Rotate(45)
|
||||
@ -82,6 +95,17 @@ def test_circle_plus_rect1():
|
||||
mesh.Curve(5)
|
||||
assert ngs.Integrate(1.0, mesh) == approx(math.pi)
|
||||
|
||||
def test_circle_and_rect():
|
||||
c = Circle(center=(0,0),radius=1)
|
||||
r = Rectangle((0,0),(1,1))
|
||||
|
||||
pi = math.pi
|
||||
check_area(c-r, 3/4*pi)
|
||||
check_area(c*r, 1/4*pi)
|
||||
check_area(c+r, 3/4*pi+1)
|
||||
check_area(r*c, 1/4*pi)
|
||||
check_area(r+c, 3/4*pi+1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_two_circles()
|
||||
|
Loading…
Reference in New Issue
Block a user