From 744c781904440c5a03b7f8fff6ae20371b346503 Mon Sep 17 00:00:00 2001
From: IvBu <st116086@stud.uni-stuttgart.de>
Date: Tue, 15 Aug 2023 11:18:09 +0200
Subject: [PATCH] [groundwater] Finalize contour plot script.

---
 lecture/mhs/groundwater/CMakeLists.txt  |  1 -
 lecture/mhs/groundwater/contourPlots.py | 20 +++++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/lecture/mhs/groundwater/CMakeLists.txt b/lecture/mhs/groundwater/CMakeLists.txt
index c5ec8c6d..0439e9f3 100644
--- a/lecture/mhs/groundwater/CMakeLists.txt
+++ b/lecture/mhs/groundwater/CMakeLists.txt
@@ -1,5 +1,4 @@
 add_input_file_links()
-dune_symlink_to_source_files(FILES "${CMAKE_SOURCE_DIR}/lecture/mhs/groundwater/contourPlots.py")
 dune_symlink_to_source_files(FILES "contourPlots.py")
 
 dumux_add_test(NAME groundwater
diff --git a/lecture/mhs/groundwater/contourPlots.py b/lecture/mhs/groundwater/contourPlots.py
index f5f2b557..63438a53 100644
--- a/lecture/mhs/groundwater/contourPlots.py
+++ b/lecture/mhs/groundwater/contourPlots.py
@@ -2,6 +2,10 @@ import matplotlib.pyplot as plt
 import numpy as np
 import pandas as pd
 
+#Instructions: First execute the `groundwater` test, a file called "contourFile.txt" will be written to the respective build-cmake folder. Within the build-cmake/.../groundwater folder you can then run the python script via e.g. `python3 contourPlots.py` to plot the contour and streamlines of the given problem.
+
+plt.rcParams.update({'font.size': 10})
+
 #extra function for reading in the Dumux parameter file
 def read_parameters(filename):
     parameters = {}
@@ -41,12 +45,15 @@ X,Y = np.meshgrid(xLinspace,yLinspace)
 
 #-------CONTOUR PLOT-------
 #contour plot
+numberLevels=20
 fig, ax = plt.subplots()
-contourPlot = ax.contour(X, Y, h, levels=15)
-#contourPlot = ax.contour(X, Y, h, levels=[4,12,20,28,36,40,41,42,43,44,45,46,47,48,49,49.5,50])
-ax.clabel(contourPlot, inline=True, fontsize=10)
-#colourBar = fig.colorbar(contourPlot)
+contourPlot = ax.contour(X, Y, h, levels=numberLevels, colors='black', linewidths=0.5)
 
+#contourPlot = ax.contour(X, Y, h, levels=[4,12,20,28,36,40,41,42,43,44,45,46,47,48,49,49.5,50])
+ax.clabel(contourPlot, inline=True, fontsize=7)
+ax.set_xlabel('x')
+ax.set_ylabel('y')
+fig.savefig('isolineplot.png', dpi=300)
 
 #-------PREPARING DATA FOR STREAMLINE PLOT-------
 #read in the data for the streamlines
@@ -60,9 +67,12 @@ vy = vyArray.reshape(ny,nx)
 #streamline plot over contour plot
 fig2, ax2 = plt.subplots()
 #contour plot
-contourPlot = ax2.contour(X, Y, h, levels=15)
+contourPlot = ax2.contour(X, Y, h, levels=numberLevels, colors='black')
 ax2.clabel(contourPlot, inline=True, fontsize=10)
 #streamline plot
 streamlinePlot = ax2.streamplot(xLinspace, yLinspace, vx, vy, color='red', density=1, linewidth=0.5)
+ax2.set_xlabel('x')
+ax2.set_ylabel('y')
+fig2.savefig('streamlineplot.png', dpi=300)
 
 plt.show()
-- 
GitLab