Skip to content

Commit

Permalink
Netgen again!
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Mar 5, 2024
1 parent 210ec59 commit f848c6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
12 changes: 9 additions & 3 deletions tests/multigrid/test_netgen_gmg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from firedrake import *
import pytest

try:
import netgen
del netgen
import ngsPETSc
del ngsPETSc
except ImportError:
# Netgen is not installed
pytest.skip("Netgen not installed", allow_module_level=True)


def create_netgen_mesh_circle():
from netgen.geom2d import Circle, CSG2d
Expand All @@ -14,7 +23,6 @@ def create_netgen_mesh_circle():


@pytest.mark.skipcomplex
@pytest.mark.skipnetgen
def test_netgen_mg_circle():
ngmesh = create_netgen_mesh_circle()
mesh = Mesh(ngmesh)
Expand Down Expand Up @@ -43,7 +51,6 @@ def test_netgen_mg_circle():


@pytest.mark.skipcomplex
@pytest.mark.skipnetgeun
def test_netgen_mg_circle_non_uniform_degree():
ngmesh = create_netgen_mesh_circle()
mesh = Mesh(ngmesh)
Expand Down Expand Up @@ -73,7 +80,6 @@ def test_netgen_mg_circle_non_uniform_degree():

@pytest.mark.skipcomplex
@pytest.mark.parallel
@pytest.mark.skipnetgen
def test_netgen_mg_circle_parallel():
ngmesh = create_netgen_mesh_circle()
mesh = Mesh(ngmesh)
Expand Down
21 changes: 10 additions & 11 deletions tests/regression/test_netgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
from petsc4py import PETSc
import pytest

try:
import netgen
del netgen
import ngsPETSc
del ngsPETSc
except ImportError:
# Netgen is not installed
pytest.skip("Netgen not installed", allow_module_level=True)


printf = lambda msg: PETSc.Sys.Print(msg)


Expand Down Expand Up @@ -97,7 +107,6 @@ def poisson3D(h, degree=2):
return S


@pytest.mark.skipnetgen
def test_firedrake_Poisson_netgen():
diff = np.array([poisson(h)[0] for h in [1/2, 1/4, 1/8]])
print("l2 error norms:", diff)
Expand All @@ -106,7 +115,6 @@ def test_firedrake_Poisson_netgen():
assert (np.array(conv) > 2.8).all()


@pytest.mark.skipnetgen
@pytest.mark.parallel
def test_firedrake_Poisson_netgen_parallel():
diff = np.array([poisson(h)[0] for h in [1/2, 1/4, 1/8]])
Expand All @@ -116,7 +124,6 @@ def test_firedrake_Poisson_netgen_parallel():
assert (np.array(conv) > 2.8).all()


@pytest.mark.skipnetgen
def test_firedrake_Poisson3D_netgen():
diff = np.array([poisson3D(h) for h in [1, 1/2, 1/4]])
print("l2 error norms:", diff)
Expand All @@ -125,7 +132,6 @@ def test_firedrake_Poisson3D_netgen():
assert (np.array(conv) > 2.8).all()


@pytest.mark.skipnetgen
def test_firedrake_integral_2D_netgen():
from netgen.geom2d import SplineGeometry
import netgen
Expand All @@ -147,7 +153,6 @@ def test_firedrake_integral_2D_netgen():
assert abs(assemble(f * dx) - (5/6)) < 1.e-10


@pytest.mark.skipnetgen
def test_firedrake_integral_3D_netgen():
from netgen.csg import CSGeometry, OrthoBrick, Pnt
import netgen
Expand All @@ -172,7 +177,6 @@ def test_firedrake_integral_3D_netgen():
assert abs(assemble(f * ds) - (2 + 4 + 2 + 5 + 2 + 6)) < 1.e-10


@pytest.mark.skipnetgen
def test_firedrake_integral_ball_netgen():
from netgen.csg import CSGeometry, Pnt, Sphere
from netgen.meshing import MeshingParameters
Expand All @@ -195,7 +199,6 @@ def test_firedrake_integral_ball_netgen():
assert abs(assemble(f * dx) - 4*np.pi) < 1.e-2


@pytest.mark.skipnetgen
def test_firedrake_integral_sphere_high_order_netgen():
from netgen.csg import CSGeometry, Pnt, Sphere
import netgen
Expand All @@ -216,7 +219,6 @@ def test_firedrake_integral_sphere_high_order_netgen():
assert abs(assemble(f * dx) - (4/3)*np.pi) < 1.e-4


@pytest.mark.skipnetgen
@pytest.mark.parallel
def test_firedrake_integral_sphere_high_order_netgen_parallel():
from netgen.csg import CSGeometry, Pnt, Sphere
Expand All @@ -238,7 +240,6 @@ def test_firedrake_integral_sphere_high_order_netgen_parallel():
assert abs(assemble(f * dx) - (4/3)*np.pi) < 1.e-2


@pytest.mark.skipnetgen
@pytest.mark.skipcomplex
def test_firedrake_Adaptivity_netgen():
from netgen.occ import WorkPlane, OCCGeometry, Axes
Expand Down Expand Up @@ -313,7 +314,6 @@ def adapt(mesh, eta):
assert error_estimators[-1] < 0.05


@pytest.mark.skipnetgen
@pytest.mark.skipcomplex
@pytest.mark.parallel
def test_firedrake_Adaptivity_netgen_parallel():
Expand Down Expand Up @@ -389,7 +389,6 @@ def adapt(mesh, eta):
assert error_estimators[-1] < 0.05


@pytest.mark.skipnetgen
@pytest.mark.parallel
@pytest.mark.skipcomplex
def test_alfeld_stokes_netgen():
Expand Down

0 comments on commit f848c6f

Please sign in to comment.