diff --git a/src/main.cpp b/src/main.cpp index 81926430be11b975371954b7b1317f46165e4463..7017de5abc0b0509955b1dadcb5ba8823300e297 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,13 @@ #include <iostream> +#include <fstream> +#include <iomanip> #include <Kokkos_Core.hpp> #include <RevisionInfo.hpp> #include <rang.hpp> #include <FPEManager.hpp> #include <SignalManager.hpp> #include <ConsoleManager.hpp> +#include <string> // #include <RawKokkosAcousticSolver.hpp> // #include <MeshLessAcousticSolver.hpp> @@ -138,7 +141,7 @@ int main(int argc, char *argv[]) const Kokkos::View<const double*> Vj = mesh_data.Vj(); const Kokkos::View<const Rd**> Cjr = mesh_data.Cjr(); - const double tmax=1.5; + const double tmax=0.5; double t=0; int itermax=std::numeric_limits<int>::max(); @@ -153,8 +156,16 @@ int main(int argc, char *argv[]) BlockPerfectGas block_eos(rhoj, ej, pj, gammaj, cj); - //double c = 0.; - //c = finite_volumes_diffusion.conservatif(unknowns); + double c = 0.; + c = finite_volumes_diffusion.conservatif(unknowns); + + // Ecriture des valeurs initiales de rho dans un fichier + const Kokkos::View<const Rd*> xj = mesh_data.xj(); + std::ofstream fout("film_rho", std::ios::trunc); + fout.precision(15); + for (size_t j=0; j<mesh.numberOfCells(); ++j) { + fout << std::fixed << xj[j][0] << ' ' << std::fixed << rhoj[j] << '\n'; + } while((t<tmax) and (iteration<itermax)) { @@ -186,7 +197,6 @@ int main(int argc, char *argv[]) t_diff += dt_diff; } } - // DIFFUSION PURE @@ -199,12 +209,26 @@ int main(int argc, char *argv[]) t += dt; */ - block_eos.updatePandCFromRhoE(); + block_eos.updatePandCFromRhoE(); ++iteration; std::cout << "temps t : " << t << std::endl; + + // Ecriture des valeurs de rho par pas de temps dans le fichier + std::ofstream fout("film_rho", std::ios::app); + fout.precision(15); + fout.clear(); + fout.seekp(0, std::ios::beg); + //int const position = 0; + for (size_t j=0; j<mesh.numberOfCells(); ++j) { + fout.seekp(35*iteration*j); + //position = fout.tellp(); + //std::cout << "Nous sommes au " << fout.tellp() << "eme caractere du fichier" << std::endl; + fout << ' ' << std::fixed << rhoj[j] << '\n'; + //std::cin.ignore(35*iteration, '\n'); + } + } - std::cout << "* " << rang::style::underline << "Final time" << rang::style::reset << ": " << rang::fgB::green << t << rang::fg::reset << " (" << iteration << " iterations)\n"; @@ -234,16 +258,16 @@ int main(int argc, char *argv[]) std::cout << "* " << rang::style::underline << "Erreur L2 E" << rang::style::reset << ": " << rang::fgB::green << error3 << rang::fg::reset << " \n"; */ - /* + std::cout << "* " << rang::style::underline << "Resultat conservativite rho E temps = 0" << rang::style::reset << ": " << rang::fgB::green << c << rang::fg::reset << " \n"; double cons = 0.; cons = finite_volumes_diffusion.conservatif(unknowns); - std::cout << "* " << rang::style::underline << "Resultat conservativite E" << rang::style::reset + std::cout << "* " << rang::style::underline << "Resultat conservativite rho E" << rang::style::reset << ": " << rang::fgB::green << cons << rang::fg::reset << " \n"; - */ + //method_cost_map["AcousticSolverWithMesh"] = timer.seconds(); method_cost_map["FiniteVolumesDiffusionWithMesh"] = timer.seconds();