From 8397b9244cb426f706e8122b3a1714a21971c050 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chi-Tu=C3=A2n=20Pham?= <chi-tuan.pham@edf.fr>
Date: Thu, 23 Jan 2025 13:32:41 +0100
Subject: [PATCH] [VnV][telemac3d] Update culvert example with better choices
 for a few keywords - NERD for the advection of velocities (as for tracers)
 rather than characteristics to decrease differences between sequential and
 parallel runs - use of the non-hydrostatic version (but more CPU time
 consuming) and conjugate gradient + preconditiong = 34 = 2*17 to solve PPE
 (more efficient choice than GMRES here) - use of preconditioning 34 = 2*17
 for the diffusion of tracers + velocities so that accuracy for the diffusion
 of tracers can be 1.E-15 without significant increase of CPU time - increase
 of MAXIMUM NUMBER OF ITERATIONS FOR ADVECTION SCHEMES to 100

Update of epsilons (1 order of magnitude less than before for tracers)
Smaller GRAPHIC PRINTOUT PERIOD to draw time series for figure
---
 examples/telemac3d/culvert/doc/culvert.tex | 16 +++++++++++++---
 examples/telemac3d/culvert/f3d_culvert.slf |  2 +-
 examples/telemac3d/culvert/t3d_culvert.cas | 16 ++++++++++------
 examples/telemac3d/culvert/vnv_culvert.py  | 21 +++++++++++++++++----
 4 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/examples/telemac3d/culvert/doc/culvert.tex b/examples/telemac3d/culvert/doc/culvert.tex
index 720b7c6df8..3386990a90 100644
--- a/examples/telemac3d/culvert/doc/culvert.tex
+++ b/examples/telemac3d/culvert/doc/culvert.tex
@@ -114,6 +114,16 @@ The characteristics of the culverts are presented in Table \ref{tab:culvert_tabl
 \hline
 \textbf{circ}	& 0	 & 0 \\
 \hline
+\textbf{D1}	& 0	 & 0 \\
+\hline
+\textbf{D2}	& 0	 & 0 \\
+\hline
+\textbf{A1}	& 0	 & 0 \\
+\hline
+\textbf{A2}	& 0	 & 0 \\
+\hline
+\textbf{AA}	& 1	 & 1 \\
+\hline
 \end{tabular}\end{center}
 \end{table}
 
@@ -121,16 +131,16 @@ The characteristics of the culverts are presented in Table \ref{tab:culvert_tabl
 
 \begin{figure}[h]
 \begin{center}
-  \includegraphicsmaybe{[scale=0.14]}{img/figure2.png}
+  \includegraphicsmaybe{[width=0.9\textwidth]}{../img/FreeSurfaceTimeSeries.png}
 \end{center}
 \caption{Schematic culvert test case: results of two tidal cycles.
-The blue line gives the water level in the estuarine river part and the red line gives the water level in the floodplain.}
+The red line gives the water level in the estuarine river part and the blue line gives the water level in the floodplain.}
 \label{fig:culvert_figure2}
 \end{figure}
 
 Figure \ref{fig:culvert_figure2} shows the results of a short simulation with
 the schematic scenario.
-The blue line gives the water level in the estuarine river part and the red line
+The red line gives the water level in the estuarine river part and the blue line
 gives the water level in the floodplain.
 From the characteristics of the two culverts, we can see that only culvert 1
 allows flow in both directions (CLP = 0)
diff --git a/examples/telemac3d/culvert/f3d_culvert.slf b/examples/telemac3d/culvert/f3d_culvert.slf
index 5a783b66fc..c10fc53fe3 100644
--- a/examples/telemac3d/culvert/f3d_culvert.slf
+++ b/examples/telemac3d/culvert/f3d_culvert.slf
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:ca0a9e7278cba42e0d72051746f9c89553dc0782c16dbef4a63c1b5ff9f056eb
+oid sha256:095a9711f365c71e5ecbb85b5e4b0c227f21c600afd10a9cdd35c5395af6cb39
 size 331724
diff --git a/examples/telemac3d/culvert/t3d_culvert.cas b/examples/telemac3d/culvert/t3d_culvert.cas
index 6f86440558..314a29efc8 100644
--- a/examples/telemac3d/culvert/t3d_culvert.cas
+++ b/examples/telemac3d/culvert/t3d_culvert.cas
@@ -22,7 +22,7 @@ TIME STEP                             =1.
 INITIAL TIME SET TO ZERO              =YES
 NUMBER OF TIME STEPS                  =100000
 
-GRAPHIC PRINTOUT PERIOD               =100000
+GRAPHIC PRINTOUT PERIOD               =1000
 LISTING PRINTOUT PERIOD               =5000
 VARIABLES FOR 2D GRAPHIC PRINTOUTS    =U,V,S,H,B,TA1
 VARIABLES FOR 3D GRAPHIC PRINTOUTS    =Z,U,V,W,TA1
@@ -52,6 +52,9 @@ MESH TRANSFORMATION                     =2
 
 INITIAL ELEVATION                       =3.
 INITIAL CONDITIONS                      ='CONSTANT ELEVATION'
+
+SOLVER FOR PPE                          = 1
+PRECONDITIONING FOR PPE                 = 34
 /---------------------------------------------------------------------/
 /                               TURBULENCE                            /
 /---------------------------------------------------------------------/
@@ -60,13 +63,15 @@ COEFFICIENT FOR VERTICAL DIFFUSION OF VELOCITIES     =1.E-2
 MIXING LENGTH MODEL                                  =3
 HORIZONTAL TURBULENCE MODEL                          =4
 COEFFICIENT FOR HORIZONTAL DIFFUSION OF VELOCITIES   =1.E-2
+PRECONDITIONING FOR DIFFUSION OF VELOCITIES          = 34
 /----------------------------------------------------------------------/
 /                            ADVECTION                                 /
 /----------------------------------------------------------------------/
-SCHEME FOR ADVECTION OF VELOCITIES              =1
+SCHEME FOR ADVECTION OF VELOCITIES              =13
+SCHEME OPTION FOR ADVECTION OF VELOCITIES       = 1
 SCHEME FOR ADVECTION OF TRACERS                 =13
 TREATMENT OF NEGATIVE DEPTHS  =2
-MAXIMUM NUMBER OF ITERATIONS FOR ADVECTION SCHEMES = 30
+MAXIMUM NUMBER OF ITERATIONS FOR ADVECTION SCHEMES = 100
 MASS-LUMPING FOR DEPTH =1.
 FREE SURFACE GRADIENT COMPATIBILITY             =0.9
 /----------------------------------------------------------------------/
@@ -76,6 +81,8 @@ NUMBER OF TRACERS  =1
 NAMES OF TRACERS   ='TRACER'
 INITIAL VALUES OF TRACERS =2.
 PRESCRIBED TRACERS VALUES  =1000.
+PRECONDITIONING FOR DIFFUSION OF TRACERS = 34
+ACCURACY FOR DIFFUSION OF TRACERS = 1.E-15
 /----------------------------------------------------------------------/
 /                       TIDAL FLATS                                    /
 /----------------------------------------------------------------------/
@@ -85,8 +92,5 @@ TIDAL FLATS                                     =YES
 / WITH MURD 13, SHOULD BE CHANGED IN 1 OR 2
 SCHEME OPTION FOR ADVECTION OF TRACERS = 1
 /
-/ DEFAULT VALUES UNTIL V7P3 KEPT FOR NON REGRESSION
-NON-HYDROSTATIC VERSION : NO
-/
 / DEFAULT VALUES UNTIL V8P0 KEPT FOR NON REGRESSION
 IMPLICITATION FOR VELOCITIES = 1.
diff --git a/examples/telemac3d/culvert/vnv_culvert.py b/examples/telemac3d/culvert/vnv_culvert.py
index e0c19a317c..5cdbf1be35 100644
--- a/examples/telemac3d/culvert/vnv_culvert.py
+++ b/examples/telemac3d/culvert/vnv_culvert.py
@@ -50,27 +50,29 @@ class VnvStudy(AbstractVnvStudy):
         # Comparison with the last time frame of the reference file.
         self.check_epsilons('vnv_1:T3DRES',
                             'f3d_culvert.slf',
-                            eps=[7.E-4, 1.E-6, 1.E-6, 1.E-5, 3.8])
+                            eps=[1e-7, 1e-6, 1e-6, 1e-6, 0.45])
 
         # Comparison with the last time frame of the reference file.
         self.check_epsilons('vnv_2:T3DRES',
                             'f3d_culvert.slf',
-                            eps=[6.E-4, 1.E-6, 1.E-6, 1.E-5, 4.2])
+                            eps=[1e-6, 1e-6, 1e-6, 1e-6, 0.43])
 
         # Comparison between sequential and parallel run.
         self.check_epsilons('vnv_1:T3DRES',
                             'vnv_2:T3DRES',
-                            eps=[7.E-4, 1.E-6, 1.E-6, 1.E-5, 6.3])
+                            eps=[1e-6, 1e-6, 1e-6, 1e-6, 0.40])
 
 
     def _post(self):
         """
         Post-treatment processes
         """
-        from postel.plot_vnv import vnv_plot2d
+        from postel.plot_vnv import vnv_plot2d, vnv_plot1d_history
                 # Getting files
         vnv_1_t3dgeo = self.get_study_file('vnv_1:T3DGEO')
         res_vnv_1_t3dgeo = TelemacFile(vnv_1_t3dgeo)
+        vnv_1_t3dhyd = self.get_study_file('vnv_1:T3DHYD')
+        res_vnv_1_t3dhyd = TelemacFile(vnv_1_t3dhyd)
 
         #Plotting mesh
         vnv_plot2d('BOTTOM',
@@ -79,4 +81,15 @@ class VnvStudy(AbstractVnvStudy):
                    fig_size=(12, 7),
                    fig_name='img/mesh')
 
+        #Plotting FREE SURFACE
+        vnv_plot1d_history('FREE SURFACE',
+                           res_vnv_1_t3dhyd,
+                           legend_labels='FREE SURFACE',
+                           points=[[5., 10.], [35., 10.]],
+                           x_label='$t$ (h)', y_label='$z$ (m)',
+                           x_factor=1./3600.,
+                           fig_size=(12, 7),
+                           fig_name='img/FreeSurfaceTimeSeries')
+
         res_vnv_1_t3dgeo.close()
+        res_vnv_1_t3dhyd.close()
-- 
GitLab