Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Always run tests/test_mf6_disu_bmi.py::test_get_grid_nodes_per_face #77

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def modflow_lib_path(tmp_path_factory):
elif sysinfo == "Darwin":
url += "mac.zip"
lib_path = tmp_path / "libmf6.dylib"
else:
raise RuntimeError(f"system not supported: {sysinfo}")

pymake.download_and_unzip(url=url, pth=str(tmp_path))
return str(lib_path)
Expand Down
43 changes: 17 additions & 26 deletions tests/test_mf6_disu_bmi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import platform

import numpy as np

from xmipy import XmiWrapper
Expand Down Expand Up @@ -54,35 +52,28 @@ def test_get_grid_node_count(flopy_disu, modflow_lib_path):

def test_get_grid_nodes_per_face(flopy_disu, modflow_lib_path):
"""Tests if the grid_nodes_per_face can be extracted"""
# TODO: Find out why test fail on UNIX-like systems
sysinfo = platform.system()
if sysinfo == "Windows":
mf6 = XmiWrapper(
lib_path=modflow_lib_path, working_directory=flopy_disu.sim_path
)
mf6 = XmiWrapper(lib_path=modflow_lib_path, working_directory=flopy_disu.sim_path)

# Write output to screen:
mf6.set_int("ISTDOUTTOFILE", 0)
# Write output to screen:
mf6.set_int("ISTDOUTTOFILE", 0)

try:
# Initialize
mf6.initialize()
try:
# Initialize
mf6.initialize()

# Rectangular grid -> nrow*ncol faces with 4 nodes each
prescribed_nodes_per_face = np.full(flopy_disu.nrow * flopy_disu.ncol, 4)
# Rectangular grid -> nrow*ncol faces with 4 nodes each
prescribed_nodes_per_face = np.full(flopy_disu.nrow * flopy_disu.ncol, 4)

# Getting the grid id from the model, requires specifying one variable
k11_tag = mf6.get_var_address("K11", flopy_disu.model_name, "NPF")
grid_id = mf6.get_var_grid(k11_tag)
face_count = mf6.get_grid_face_count(grid_id)
actual_nodes_per_face = np.empty(
shape=(face_count,), dtype=np.int32, order="F"
)
mf6.get_grid_nodes_per_face(grid_id, actual_nodes_per_face)
# Getting the grid id from the model, requires specifying one variable
k11_tag = mf6.get_var_address("K11", flopy_disu.model_name, "NPF")
grid_id = mf6.get_var_grid(k11_tag)
face_count = mf6.get_grid_face_count(grid_id)
actual_nodes_per_face = np.empty(shape=(face_count,), dtype=np.int32, order="F")
mf6.get_grid_nodes_per_face(grid_id, actual_nodes_per_face)

assert np.array_equal(prescribed_nodes_per_face, actual_nodes_per_face)
finally:
mf6.finalize()
assert np.array_equal(prescribed_nodes_per_face, actual_nodes_per_face)
finally:
mf6.finalize()


def test_get_grid_face_nodes(flopy_disu, modflow_lib_path):
Expand Down