From 5adcf2a835ad4d07a474ba9ef55ef6b59d1bf363 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chi-Tu=C3=A2n=20Pham?= <chi-tuan.pham@edf.fr>
Date: Sun, 29 Dec 2024 18:54:35 +0100
Subject: [PATCH] [VnV][telemac3d] Update Viollet example with better choices
 for a few keywords  - TREATMENT OF NEGATIVE DEPTHS = 2 (new default value
 since release 9.0) and TIDAL FLATS = YES (default value) to improve mass
 conservation - use of gradient conjugate + preconditioning 34 = 2*17 to solve
 PPE, more efficient than GMRES for this example - use of preconditioning 34
 for diffusion of every variable (more efficient) - accuracy for PPE and
 propagation decreased from 10^-10 to 10^-12

---
 examples/telemac3d/Viollet/doc/Viollet.tex | 17 ++++++++++++++---
 examples/telemac3d/Viollet/f3d_viollet.slf |  2 +-
 examples/telemac3d/Viollet/t3d_viollet.cas | 18 +++++++-----------
 examples/telemac3d/Viollet/vnv_Viollet.py  |  6 +++---
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/examples/telemac3d/Viollet/doc/Viollet.tex b/examples/telemac3d/Viollet/doc/Viollet.tex
index 8745800965..5601fdf5f2 100644
--- a/examples/telemac3d/Viollet/doc/Viollet.tex
+++ b/examples/telemac3d/Viollet/doc/Viollet.tex
@@ -121,11 +121,22 @@ The non-hydrostatic version is used.
 To solve the advection, the N-type MURD (scheme 4) is used for the velocities,
 temperature and $k$-$\epsilon$.
 
-The default solvers (GMRES for propagation and PPE, conjugate gradient for
-diffusion of velocities, tracers and $k$-$\epsilon$) are used.
+The default solvers (GMRES for propagation, conjugate gradient for
+diffusion of velocities, tracers and $k$-$\epsilon$) are used
+except for PPE for which conjugate gradient is chosen for more efficiency.
+To accelerate computation, preconditioning 34 = 2 $\times$ 17 (i.e. diagonal
+combined with direct solver on the vertical) is chosen for every operation
+solved by conjugate gradient and for which it is enabled (diffusion of
+velocities, tracers, $k$-$\epsilon$, PPE).
 For every solving operation, asked accuracy is quite fine
-(from 10$^{-16}$ for temperature and $k$-$\epsilon$ to 10$^{-16}$ for PPE and
+(from 10$^{-16}$ for temperature and $k$-$\epsilon$ to 10$^{-12}$ for PPE and
 propagation steps).
+\\
+
+Mass conservation is improved (up to machine precision for water depth) by using
+default values for keywords \telkey{TIDAL FLATS} (= YES) and
+\telkey{TREATMENT OF NEGATIVE DEPTHS} (= 2), contrary to choices for this
+example until 9.0 (NO and 1).
 
 \subsection{Physical parameters}
 
diff --git a/examples/telemac3d/Viollet/f3d_viollet.slf b/examples/telemac3d/Viollet/f3d_viollet.slf
index 07545973c2..c10f9c5c8c 100644
--- a/examples/telemac3d/Viollet/f3d_viollet.slf
+++ b/examples/telemac3d/Viollet/f3d_viollet.slf
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:f222b0da0e59ade952b882525d5af8d4e34755d11da55a41a0d194d057ddf5cb
+oid sha256:e210a02958f5f85413e63701d445595fcda11553f0bc8aa07a020e307036436e
 size 1778040
diff --git a/examples/telemac3d/Viollet/t3d_viollet.cas b/examples/telemac3d/Viollet/t3d_viollet.cas
index 02f457791a..44a1bd63d7 100644
--- a/examples/telemac3d/Viollet/t3d_viollet.cas
+++ b/examples/telemac3d/Viollet/t3d_viollet.cas
@@ -39,8 +39,6 @@ PRESCRIBED ELEVATIONS : 0.19995;0.
 /LOGARITHMIC PROFILE
 VELOCITY VERTICAL PROFILES = 2;2
 /
-TIDAL FLATS = NO
-/
 VARIABLES FOR 2D GRAPHIC PRINTOUTS = U,V,H,B,S
 VARIABLES FOR 3D GRAPHIC PRINTOUTS = Z,U,V,W,RI,NUZ,TA1,NAZ1,EPS,K
 MASS-BALANCE = YES
@@ -81,16 +79,18 @@ LAW OF BOTTOM FRICTION = 1 / HAALAND
 /----------------------------
 /     PROPAGATION
 /----------------------------
-/MAXIMUM NUMBER OF ITERATIONS FOR PROPAGATION             = 500
-/MAXIMUM NUMBER OF ITERATIONS FOR DIFFUSION OF VELOCITIES = 200
+SOLVER FOR PPE = 1
 MAXIMUM NUMBER OF ITERATIONS FOR PPE = 300
 ACCURACY FOR DIFFUSION OF VELOCITIES = 1.E-14
 ACCURACY FOR DIFFUSION OF K-EPSILON  = 1.E-16
 ACCURACY FOR DIFFUSION OF TRACERS    = 1.E-16
-ACCURACY FOR PROPAGATION             = 1.E-10
-ACCURACY FOR PPE                     = 1.E-10
+ACCURACY FOR PROPAGATION             = 1.E-12
+ACCURACY FOR PPE                     = 1.E-12
+PRECONDITIONING FOR DIFFUSION OF VELOCITIES = 34
+PRECONDITIONING FOR DIFFUSION OF K-EPSILON  = 34
+PRECONDITIONING FOR DIFFUSION OF TRACERS    = 34
+PRECONDITIONING FOR PPE                     = 34
 /
-IMPLICITATION FOR DEPTH      = 1.
 /----------------------------
 /          SEDIMENT
 /----------------------------
@@ -115,9 +115,5 @@ IMPLICITATION FOR DIFFUSION : 2.
 /
 / DEFAULT VALUES UNTIL V8P0 KEPT FOR NON REGRESSION
 SCHEME OPTION FOR ADVECTION OF VELOCITIES = 1
-IMPLICITATION FOR VELOCITIES = 1.
 SCHEME OPTION FOR ADVECTION OF TRACERS = 1
 SCHEME OPTION FOR ADVECTION OF K-EPSILON = 1
-/
-/ DEFAULT VALUE UNTIL V8P5 KEPT FOR NON REGRESSION
-TREATMENT OF NEGATIVE DEPTHS = 1
diff --git a/examples/telemac3d/Viollet/vnv_Viollet.py b/examples/telemac3d/Viollet/vnv_Viollet.py
index 9dbf3fbd0c..99f2f31a05 100644
--- a/examples/telemac3d/Viollet/vnv_Viollet.py
+++ b/examples/telemac3d/Viollet/vnv_Viollet.py
@@ -50,17 +50,17 @@ class VnvStudy(AbstractVnvStudy):
         # Comparison with the last time frame of the reference file.
         self.check_epsilons('vnv_1:T3DRES',
                             'f3d_viollet.slf',
-                            eps=[1.E-7, 1.E-8, 1.E-9, 1.E-8, 1.E-11, 1.E-11, 1.E-11, 2.E-4, 1.E-5, 1.E-11])
+                            eps=[1.E-15, 1.E-8, 1.E-12, 1.E-11, 1.E-12, 1.E-12, 1.E-14, 1.E-5, 1.E-15, 1.E-15])
 
         # Comparison with the last time frame of the reference file.
         self.check_epsilons('vnv_2:T3DRES',
                             'f3d_viollet.slf',
-                            eps=[1.E-7, 1.E-8, 1.E-9, 1.E-8, 1.E-11, 1.E-11, 1.E-11, 3.E-4, 1.E-5, 1.E-11])
+                            eps=[1.E-15, 1.E-8, 1.E-12, 1.E-11, 1.E-12, 1.E-12, 1.E-14, 1.E-5, 1.E-15, 1.E-15])
 
         # Comparison between sequential and parallel run.
         self.check_epsilons('vnv_1:T3DRES',
                             'vnv_2:T3DRES',
-                            eps=[1.E-7, 1.E-8, 1.E-9, 1.E-8, 1.E-11, 1.E-11, 1.E-11, 3.E-4, 1.E-5, 1.E-11])
+                            eps=[1.E-15, 1.E-8, 1.E-12, 1.E-11, 1.E-12, 1.E-12, 1.E-14, 1.E-5, 1.E-15, 1.E-15])
 
 
     def _post(self):
-- 
GitLab