diff --git a/src/main.cpp b/src/main.cpp index 1cfa843fe4cc22f753d35a6896bef956f54605e2..2bdfa752b3c2a4b53a40f1ef7ca58d8a2a1f1a64 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -171,10 +171,17 @@ int main(int argc, char *argv[]) t += dt; ++iteration; } + - std::cout << "* " << rang::style::underline << "Final time" << rang::style::reset + std::cout << "* " << rang::style::underline << "Final time" << rang::style::reset << ": " << rang::fgB::green << t << rang::fg::reset << " (" << iteration << " iterations)\n"; + double error = 0.; + error = finite_volumes_diffusion.error_L2(unknowns); + + std::cout << "* " << rang::style::underline << "Erreur L2" << rang::style::reset + << ": " << rang::fgB::green << error << rang::fg::reset << " \n"; + //method_cost_map["AcousticSolverWithMesh"] = timer.seconds(); method_cost_map["FiniteVolumesDiffusionWithMesh"] = timer.seconds(); @@ -189,7 +196,6 @@ int main(int argc, char *argv[]) } } - } diff --git a/src/scheme/FiniteVolumesDiffusion.hpp b/src/scheme/FiniteVolumesDiffusion.hpp index 67774fc988faf886413ae62d3167e74420c987e1..5a60de6965724c3ba50d7bd72ec16b8681e9c5b5 100644 --- a/src/scheme/FiniteVolumesDiffusion.hpp +++ b/src/scheme/FiniteVolumesDiffusion.hpp @@ -299,6 +299,27 @@ public: }); } + + // Calcul erreur entre solution analytique et solution numerique en norme L2 + + double error_L2(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 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); + erreur += (exacte - uj[j][0])*(exacte - uj[j][0]); + } + erreur = std::sqrt(erreur); + return erreur; + } + + }; #endif // FINITE_VOLUMES_DIFFUSION_HPP