From 63f7af45f03939c30e642338457c5051e7c87a0b Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Thu, 24 Sep 2009 11:42:20 +0000 Subject: [PATCH] replace hand-written code to read and write 3d iterates by AmiraMesh I/O [[Imported from SVN: r4878]] --- dirneucoupling.cc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/dirneucoupling.cc b/dirneucoupling.cc index dcd5d435..23ad5d1a 100644 --- a/dirneucoupling.cc +++ b/dirneucoupling.cc @@ -471,16 +471,10 @@ int main (int argc, char *argv[]) try std::stringstream iAsAscii; iAsAscii << i; std::string iSolFilename = resultPath + "tmp/intermediate3dSolution_" + iAsAscii.str(); - - FILE* fp = fopen(iSolFilename.c_str(), "wb"); - if (!fp) - DUNE_THROW(SolverError, "Couldn't open file " << iSolFilename << " for writing"); - - for (int j=0; j<x3d.size(); j++) - for (int k=0; k<dim; k++) - fwrite(&x3d[j][k], sizeof(double), 1, fp); - fclose(fp); + LeafAmiraMeshWriter<GridType> amiraMeshWriter; + amiraMeshWriter.addVertexData(x3d, grid.leafView()); + amiraMeshWriter.write(iSolFilename); // Then the rod iSolFilename = resultPath + "tmp/intermediateRodSolution_" + iAsAscii.str(); @@ -619,19 +613,13 @@ int main (int argc, char *argv[]) try std::stringstream iAsAscii; iAsAscii << i; std::string iSolFilename = resultPath + "tmp/intermediate3dSolution_" + iAsAscii.str(); - - FILE* fpInt = fopen(iSolFilename.c_str(), "rb"); - if (!fpInt) - DUNE_THROW(IOError, "Couldn't open intermediate solution '" << iSolFilename << "'"); - for (int j=0; j<intermediateSol3d.size(); j++) - fread(&intermediateSol3d[j], sizeof(double), dim, fpInt); - - fclose(fpInt); + + AmiraMeshReader<int>::readFunction(intermediateSol3d, iSolFilename); // Read rod solution from file iSolFilename = resultPath + "tmp/intermediateRodSolution_" + iAsAscii.str(); - fpInt = fopen(iSolFilename.c_str(), "rb"); + FILE* fpInt = fopen(iSolFilename.c_str(), "rb"); if (!fpInt) DUNE_THROW(IOError, "Couldn't open intermediate solution '" << iSolFilename << "'"); for (int j=0; j<intermediateSolRod.size(); j++) { -- GitLab