From dec901f64912de4f455a4e06a49b5483f44cd87c Mon Sep 17 00:00:00 2001
From: Fanny CHOPOT <fanny.chopot.ocre@cea.fr>
Date: Wed, 2 May 2018 10:53:31 +0200
Subject: [PATCH] ajout fonction calcul erreur L infini

---
 src/main.cpp                          |  6 ++++++
 src/scheme/FiniteVolumesDiffusion.hpp | 25 ++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/main.cpp b/src/main.cpp
index 2bdfa752b..443dcc37f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -182,6 +182,12 @@ int main(int argc, char *argv[])
     std::cout << "* " << rang::style::underline << "Erreur L2" << rang::style::reset
 	      << ":  " << rang::fgB::green << error << rang::fg::reset << " \n";
 
+    double error2 = 0.;
+    error2 = finite_volumes_diffusion.error_Linf(unknowns);
+
+    std::cout << "* " << rang::style::underline << "Erreur L infini" << rang::style::reset
+	      << ":  " << rang::fgB::green << error2 << rang::fg::reset << " \n";
+
     //method_cost_map["AcousticSolverWithMesh"] = timer.seconds();
     method_cost_map["FiniteVolumesDiffusionWithMesh"] = timer.seconds();
     
diff --git a/src/scheme/FiniteVolumesDiffusion.hpp b/src/scheme/FiniteVolumesDiffusion.hpp
index 5a60de696..554879eac 100644
--- a/src/scheme/FiniteVolumesDiffusion.hpp
+++ b/src/scheme/FiniteVolumesDiffusion.hpp
@@ -301,6 +301,7 @@ public:
   }
 
   // Calcul erreur entre solution analytique et solution numerique en norme L2
+  // (quand la solution exacte est connue)
 
   double error_L2(UnknownsType& unknowns) {
 
@@ -312,13 +313,35 @@ public:
     double erreur = 0.;
     double exacte = 0.;
     for (size_t j=0; j<m_mesh.numberOfCells(); ++j) {
-      exacte = std::sin(pi*xj[j][0])*std::exp(-0.2);
+      exacte = std::sin(pi*xj[j][0])*std::exp(-0.2); // solution exacte
       erreur += (exacte - uj[j][0])*(exacte - uj[j][0]);
     }
     erreur = std::sqrt(erreur);
     return erreur;
   }
 
+  double error_Linf(UnknownsType& unknowns) {
+
+    Kokkos::View<Rd*> uj = unknowns.uj();
+
+    const Kokkos::View<const Rd*> xj = m_mesh_data.xj();
+
+    double pi = 4.*std::atan(1.);
+    double exacte = std::sin(pi*xj[0][0])*std::exp(-0.2); 
+    double erreur = std::abs(exacte - uj[0][0]);
+
+    for (size_t j=1; j<m_mesh.numberOfCells(); ++j) {
+      exacte = std::sin(pi*xj[j][0])*std::exp(-0.2); 
+
+      if (std::abs(exacte - uj[j][0]) > erreur) {
+	erreur = std::abs(exacte - uj[j][0]);
+      }
+
+    }
+
+    return erreur;
+  }
+
   
 };
 
-- 
GitLab