diff --git a/src/main.cpp b/src/main.cpp index 67ea80d135ebb922e9108033c92eaaef6f01c5e2..56fd09d0bf753961c2baeb5049e9b03e92e9b140 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ #include <SignalManager.hpp> #include <ConsoleManager.hpp> #include <string> +#include <cmath> // #include <RawKokkosAcousticSolver.hpp> // #include <MeshLessAcousticSolver.hpp> @@ -159,22 +160,41 @@ int main(int argc, char *argv[]) double c = 0.; c = finite_volumes_diffusion.conservatif(unknowns); - /* + // Ecriture des valeurs initiales dans un fichier + const Kokkos::View<const Rd*> xj = mesh_data.xj(); - std::ofstream fout("inter", std::ios::trunc); - fout.precision(15); + + // rho + std::ofstream fout1("inter1", std::ios::trunc); + fout1.precision(15); + for (size_t j=0; j<mesh.numberOfCells(); ++j) { + fout1 << std::fixed << xj[j][0] << ' ' << std::fixed << rhoj[j] << '\n'; + } + fout1.close(); + + // u + std::ofstream fout2("inter2", std::ios::trunc); + fout2.precision(15); + for (size_t j=0; j<mesh.numberOfCells(); ++j) { + fout2 << std::fixed << xj[j][0] << ' ' << std::fixed << uj[j][0] << '\n'; + } + fout2.close(); + + // e + std::ofstream fout3("inter3", std::ios::trunc); + fout3.precision(15); for (size_t j=0; j<mesh.numberOfCells(); ++j) { - fout << std::fixed << xj[j][0] << ' ' << std::fixed << rhoj[j] << '\n'; + fout3 << std::fixed << xj[j][0] << ' ' << std::fixed << ej[j] << '\n'; } - fout.close(); + fout3.close(); // Fichier temps std::ofstream tempo("temps"); tempo.precision(5); tempo << std::fixed << t << '\n'; tempo.close(); - */ + while((t<tmax) and (iteration<itermax)) { @@ -243,37 +263,81 @@ int main(int argc, char *argv[]) std::cout << "temps t : " << t << std::endl; // ECRITURE DANS UN FICHIER - /* - std::ifstream fint("inter"); - std::ofstream fout("film", std::ios::trunc); - fout.precision(15); + + if ((std::fmod(t,0.001) < 0.0001) or (t == tmax)) { + std::string ligne; + + // rho + std::ifstream fint1("inter1"); + std::ofstream fout1("film1", std::ios::trunc); + fout1.precision(15); for (size_t j = 0; j<mesh.numberOfCells(); ++j) { - getline(fint, ligne); - fout << ligne << ' ' << std::fixed << xj[j][0] << ' ' << std::fixed << rhoj[j] << '\n'; + getline(fint1, ligne); + fout1 << ligne << ' ' << std::fixed << xj[j][0] << ' ' << std::fixed << rhoj[j] << '\n'; } - fint.close(); - fout.close(); + fint1.close(); + fout1.close(); - std::ifstream rint("film"); - std::ofstream rout("inter", std::ios::trunc); - fout.precision(15); + std::ifstream rint1("film1"); + std::ofstream rout1("inter1", std::ios::trunc); for (size_t j = 0; j<mesh.numberOfCells(); ++j) { - getline(rint, ligne); - rout << ligne << '\n'; + getline(rint1, ligne); + rout1 << ligne << '\n'; } - rint.close(); - rout.close(); + rint1.close(); + rout1.close(); + // u + std::ifstream fint2("inter2"); + std::ofstream fout2("film2", std::ios::trunc); + fout2.precision(15); + for (size_t j = 0; j<mesh.numberOfCells(); ++j) { + getline(fint2, ligne); + fout2 << ligne << ' ' << std::fixed << xj[j][0] << ' ' << std::fixed << uj[j][0] << '\n'; + } + fint2.close(); + fout2.close(); + + std::ifstream rint2("film2"); + std::ofstream rout2("inter2", std::ios::trunc); + for (size_t j = 0; j<mesh.numberOfCells(); ++j) { + getline(rint2, ligne); + rout2 << ligne << '\n'; + } + rint2.close(); + rout2.close(); + + // e + std::ifstream fint3("inter3"); + std::ofstream fout3("film3", std::ios::trunc); + fout3.precision(15); + for (size_t j = 0; j<mesh.numberOfCells(); ++j) { + getline(fint3, ligne); + fout3 << ligne << ' ' << std::fixed << xj[j][0] << ' ' << std::fixed << ej[j] << '\n'; + } + fint3.close(); + fout3.close(); + + std::ifstream rint3("film3"); + std::ofstream rout3("inter3", std::ios::trunc); + for (size_t j = 0; j<mesh.numberOfCells(); ++j) { + getline(rint3, ligne); + rout3 << ligne << '\n'; + } + rint3.close(); + rout3.close(); + // Fichier temps std::ofstream tempo("temps", std::ios::app); tempo.precision(5); tempo << std::fixed << t << '\n'; tempo.close(); - */ + + } // ENTROPY TEST - finite_volumes_diffusion.entropie(unknowns); + //finite_volumes_diffusion.entropie(unknowns); }