Skip to content
Snippets Groups Projects
Verified Commit 3c047b9a authored by Julian Heinze's avatar Julian Heinze Committed by Lars Bilke
Browse files

moved tests and updated example

parent 2f5b860a
No related branches found
No related tags found
No related merge requests found
"""
Conversion of Feflow data to vtk-format and many other things to happen and see.
================================================================================
How to work with FEFLOW data.
=============================
.. sectionauthor:: Julian Heinze (Helmholtz Centre for Environmental Research GmbH - UFZ)
Discribtion of what the converter can do and how it is used and so on.
In this example we show how a simple FEFLOW model consisting of two layers can be converted.
"""
# %%
# 1. Let us convert only the points and cells of a Feflow model.
# 1. Let us convert only the points and cells at first.
from importlib.util import find_spec
# Check for Feflow Python setup
......@@ -26,7 +26,7 @@ from ogstools.fe2vtu import (
)
from ogstools.propertylib import ScalarProperty
doc = ifm.loadDocument("../../../ogstools/fe2vtu/tests/test.fem")
doc = ifm.loadDocument("../../../tests/data/fe2vtu/2layers_model.fem")
mesh = get_geo_mesh(doc)
......@@ -39,7 +39,10 @@ if "linux" in sys.platform:
pv.start_xvfb()
# sphinx_gallery_end_ignore
mesh.plot(show_edges=True, color=True, off_screen=True)
pl = pv.Plotter(off_screen=True)
actor = pl.add_mesh(mesh, show_edges=True)
pl.show()
# mesh.plot(show_edges=True, color=True, off_screen=True)
# %%
# 2. To this mesh we add point and cell data.
......@@ -56,4 +59,4 @@ fig = mpl.plot(mesh, ScalarProperty("P_HEAD"))
slices = np.reshape(list(mesh.slice_along_axis(n=4, axis="z")), (2, 2))
fig = mpl.plot(slices, ScalarProperty("P_HEAD"))
for ax, slice in zip(fig.axes, np.ravel(slices)):
ax.set_title(f"z = {slice.center[2]:.1f} {mpl.setup.length.data_unit}")
\ No newline at end of file
ax.set_title(f"z = {slice.center[2]:.1f} {mpl.setup.length.data_unit}")
import subprocess
import pytest
pytest.importorskip("ifm")
def test_cli():
subprocess.run(["fe2vtu", "--help"], check=True)
......@@ -59,7 +59,7 @@ docs = [
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = ["error"]
#filterwarnings = ["error"]
log_cli_level = "info"
testpaths = ["tests"]
......
File moved
import subprocess
import unittest
from pathlib import Path
......@@ -7,14 +8,21 @@ import pyvista as pv
pytest.importorskip("ifm")
import ifm_contrib as ifm # noqa: E402
from ogstools.fe2vtu import get_pts_cells # noqa: E402
from ogstools.fe2vtu.fe2vtu import get_pts_cells # noqa: E402
def test_cli():
subprocess.run(["fe2vtu", "--help"], check=True)
current_dir = Path(__file__).parent
class TestConverter(unittest.TestCase):
def test_converter(self):
doc = ifm.loadDocument(str(Path(current_dir / "test.fem")))
doc = ifm.loadDocument(
str(Path(current_dir / "data/fe2vtu/2layers_model.fem"))
)
points, cells, celltypes = get_pts_cells(doc)
assert len(points) == 75
assert len(celltypes) == 32
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment