2020-04-19 23:00:06 +05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-04-19 23:00:06 +05:00
|
|
|
@pytest.mark.parametrize("outside", [True, False])
|
2020-04-23 18:44:32 +05:00
|
|
|
def test_boundarylayer(outside, capfd):
|
2020-04-19 23:00:06 +05:00
|
|
|
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
|
2020-04-19 23:00:06 +05:00
|
|
|
|