From 7f127e48118b67b04e1c335eafa99300a423a0dd Mon Sep 17 00:00:00 2001 From: Fanny CHOPOT <fanny.chopot.ocre@cea.fr> Date: Wed, 30 May 2018 15:00:19 +0200 Subject: [PATCH] construction fichier colonne par colonne (ok) --- src/main.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7017de5ab..84adbade6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,11 +161,12 @@ int main(int argc, char *argv[]) // 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); + std::ofstream fout("inter"); fout.precision(15); for (size_t j=0; j<mesh.numberOfCells(); ++j) { fout << std::fixed << xj[j][0] << ' ' << std::fixed << rhoj[j] << '\n'; } + fout.close(); while((t<tmax) and (iteration<itermax)) { @@ -214,19 +215,32 @@ int main(int argc, char *argv[]) ++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); + // ECRITURE DANS UN FICHIER + + std::ifstream fint("inter"); + std::ofstream fout("film_rho", std::ios::trunc); + fout.precision(15); + //fout.clear(); + //fout.seekp(0, std::ios::beg); + std::string ligne; + for (size_t j = 0; j<mesh.numberOfCells(); ++j) { + getline(fint, ligne); + fout << ligne << ' ' << std::fixed << rhoj[j] << '\n'; + } + fint.close(); + fout.close(); + + std::ifstream rint("film_rho"); + std::ofstream rout("inter", std::ios::trunc); 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'); + //fout.clear(); + //fout.seekp(0, std::ios::beg); + for (size_t j = 0; j<mesh.numberOfCells(); ++j) { + getline(rint, ligne); + rout << ligne << '\n'; } + rint.close(); + rout.close(); } -- GitLab