From 319ad697a598ddaa1dcc67def7f2037832da8d7a Mon Sep 17 00:00:00 2001
From: Feliks Kiszkurno <feliks-kuba.kiszkurno@ufz.de>
Date: Wed, 8 Jan 2025 10:23:29 +0100
Subject: [PATCH] Apply feedback from review

---
 .../MandelCryer/mandelcryer.py                | 18 +++---
 .../Data/Mechanics/Linear/SimpleMechanics.py  | 61 +++++--------------
 2 files changed, 23 insertions(+), 56 deletions(-)

diff --git a/Tests/Data/HydroMechanics/StaggeredScheme/MandelCryer/mandelcryer.py b/Tests/Data/HydroMechanics/StaggeredScheme/MandelCryer/mandelcryer.py
index c99dc180ab6..dd201b0ab68 100644
--- a/Tests/Data/HydroMechanics/StaggeredScheme/MandelCryer/mandelcryer.py
+++ b/Tests/Data/HydroMechanics/StaggeredScheme/MandelCryer/mandelcryer.py
@@ -63,7 +63,6 @@
 import os
 from pathlib import Path
 
-import numpy as np
 import ogstools as ot
 
 # %%
@@ -93,22 +92,19 @@ model.run_model(logfile=f"{out_dir}/out.txt", args=f"-o {out_dir} -m .")
 
 # %%
 # Load the result
-results = ot.MeshSeries(f"{out_dir}/results_MandelCryerStaggered.pvd")
-pressure_var = ot.variables.pressure
+ms = ot.MeshSeries(f"{out_dir}/results_MandelCryerStaggered.pvd")
+
+# %% [markdown]
+# Available point data in the results:
 
 # %%
-# Get point field names
-fields = results[0].point_data.keys()
-print(fields)
+print(ms[0].point_data.keys())
 
 # %%
 # Plot soil temperature at observation points
-observation_points = {"center": (0, 0, 0)}
-
-fig = results.plot_probe(
-    np.array(observation_points["center"]), pressure_var, labels=["Center"]
-)
+center_point = [0, 0, 0]
 
+fig = ms.plot_probe(center_point, ot.variables.pressure, labels=["Center"])
 
 # %% [markdown]
 # As predicted, the pressure in the center exceeds the applied load and then levels out.
diff --git a/Tests/Data/Mechanics/Linear/SimpleMechanics.py b/Tests/Data/Mechanics/Linear/SimpleMechanics.py
index 1ec7e161fc5..114b78fe066 100644
--- a/Tests/Data/Mechanics/Linear/SimpleMechanics.py
+++ b/Tests/Data/Mechanics/Linear/SimpleMechanics.py
@@ -159,56 +159,27 @@ except Exception as inst:
 print(datetime.now())
 
 # %%
-pvdfile = ot.MeshSeries(f"{out_dir}/{prj_name}.pvd")
-time = pvdfile.timesteps
+ms = ot.MeshSeries(f"{out_dir}/{prj_name}.pvd")
 points_coords = np.array([[0.3, 0.5, 0.0], [0.24, 0.21, 0.0]])
 points_labels = ["pt0", "pt1"]
 
 # %%
 fig, ax = plt.subplots(nrows=1, ncols=1)
 
-pvdfile.plot_probe(
-    points_coords,
-    ot.variables.displacement["x"],
-    labels=[f"$u_x$ {label} linear_interp" for label in points_labels],
-    time_unit="a",
-    interp_method="linear",
-    ax=fig.axes[0],
-    colors=["b", "r"],
-    linestyles=["-", "-"],
-)
-
-pvdfile.plot_probe(
-    points_coords,
-    ot.variables.displacement["y"],
-    labels=[f"$u_y$ {label} linear_interp" for label in points_labels],
-    time_unit="a",
-    interp_method="linear",
-    ax=fig.axes[0],
-    colors=["g", "m"],
-    linestyles=["-", "-"],
-)
+colors = {"x": ["b", "r"], "y": ["g", "m"]}
+linestyles = {"linear": ["-", "-"], "nearest": ["--", "--"]}
 
-pvdfile.plot_probe(
-    points_coords,
-    ot.variables.displacement["x"],
-    labels=[f"$u_x$ {label} nearest" for label in points_labels],
-    time_unit="a",
-    interp_method="nearest",
-    ax=fig.axes[0],
-    colors=["b", "r"],
-    linestyles=["--", "--"],
-)
-
-pvdfile.plot_probe(
-    points_coords,
-    ot.variables.displacement["y"],
-    labels=[f"$u_y$ {label} nearest" for label in points_labels],
-    time_unit="a",
-    interp_method="nearest",
-    ax=fig.axes[0],
-    colors=["g", "m"],
-    linestyles=["--", "--"],
-)
+for component in ["x", "y"]:
+    for interp_method in ["linear", "nearest"]:
+        labels = [f"$u_{component}$ {label} {interp_method}" for label in points_labels]
 
-fig.suptitle(f"{ot.variables.displacement.get_label()} - linear interpolation")
+        ms.plot_probe(
+            points_coords,
+            ot.variables.displacement[component],
+            labels=labels,
+            time_unit="a",
+            interp_method=interp_method,
+            ax=fig.axes[0],
+            colors=colors[component],
+            linestyles=linestyles[interp_method],
+        )
-- 
GitLab