diff --git a/src/main.cpp b/src/main.cpp index 2bdfa752b3c2a4b53a40f1ef7ca58d8a2a1f1a64..443dcc37f8c31decf8b7f90fa76ebd0906224577 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 5a60de6965724c3ba50d7bd72ec16b8681e9c5b5..554879eac359b5962a0fdb246540ea0cab8a6178 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; + } + };