Skip to content
Snippets Groups Projects
Commit 4a60cae2 authored by Fanny CHOPOT's avatar Fanny CHOPOT
Browse files

ajout fonction calcul erreur L2

parent b58bbfbd
No related branches found
No related tags found
No related merge requests found
......@@ -172,9 +172,16 @@ int main(int argc, char *argv[])
++iteration;
}
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();
......@@ -190,7 +197,6 @@ int main(int argc, char *argv[])
}
}
Kokkos::finalize();
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment