netgen/tests/pytest/test_boundarylayer.py

32 lines
1.1 KiB
Python
Raw Normal View History

import pytest
from netgen.csg import *
2020-04-23 18:44:32 +05:00
def GetNSurfaceElements(mesh, boundary):
nse_in_layer = 0
for el in mesh.Elements2D():
print(el.index)
if mesh.GetBCName(el.index-1) == boundary:
nse_in_layer += 1
return nse_in_layer
@pytest.mark.parametrize("outside", [True, False])
2020-04-23 18:44:32 +05:00
def test_boundarylayer(outside, capfd):
mesh = unit_cube.GenerateMesh(maxh=0.3)
ne_before = mesh.ne
layer_surfacenames = ["right", "top"]
mesh.BoundaryLayer("|".join(layer_surfacenames), [0.01, 0.02], "layer", outside=outside, grow_edges=True)
2020-04-23 18:44:32 +05:00
should_ne = ne_before + 2 * sum([GetNSurfaceElements(mesh, surf) for surf in layer_surfacenames])
assert mesh.ne == should_ne
capture = capfd.readouterr()
assert not "elements are not matching" in capture.out
for side in ["front"]:
mesh.BoundaryLayer(side, [0.001], "layer", outside=outside, grow_edges=True)
should_ne += GetNSurfaceElements(mesh, side)
assert mesh.ne == should_ne
capture = capfd.readouterr()
assert not "elements are not matching" in capture.out