From dd967c3a24731f7c2ab34cf6503eb6466206f623 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Wed, 29 Apr 2009 14:12:04 +0000 Subject: [PATCH] use functionality from the base class to write iterates to disc [[Imported from SVN: r2417]] --- dune-solvers/solvers/cgsolver.cc | 16 ++-------------- dune-solvers/solvers/tcgsolver.cc | 16 ++-------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/dune-solvers/solvers/cgsolver.cc b/dune-solvers/solvers/cgsolver.cc index 7a5565b9..4e80395f 100644 --- a/dune-solvers/solvers/cgsolver.cc +++ b/dune-solvers/solvers/cgsolver.cc @@ -102,20 +102,8 @@ void CGSolver<MatrixType, VectorType>::solve() rholast = rho; // remember rho for recurrence // write iteration to file, if requested - if (this->historyBuffer_!="") { - VectorType intermediateSol = preconditioner_->getSol(); - - std::stringstream iSolFilename; - iSolFilename << this->historyBuffer_ << "/intermediatesolution_" << std::setw(4) << std::setfill('0') << i; - - std::ofstream file(iSolFilename.str().c_str(), std::ios::out|std::ios::binary); - if (not(file)) - DUNE_THROW(SolverError, "Couldn't open file " << iSolFilename << " for writing"); - - GenericVector::writeBinary(file, intermediateSol); - - file.close(); - } + if (this->historyBuffer_!="") + this->writeIterate(preconditioner_->getSol(), i); // Compute error double oldNorm = errorNorm_->operator()(oldSolution); diff --git a/dune-solvers/solvers/tcgsolver.cc b/dune-solvers/solvers/tcgsolver.cc index d905df79..187b0ba4 100644 --- a/dune-solvers/solvers/tcgsolver.cc +++ b/dune-solvers/solvers/tcgsolver.cc @@ -110,20 +110,8 @@ void TruncatedCGSolver<MatrixType, VectorType>::solve() // ///////////////////////////////////////////// // write iteration to file, if requested // ///////////////////////////////////////////// - if (this->historyBuffer_!="") { - VectorType intermediateSol = delta_j; - - std::stringstream iSolFilename; - iSolFilename << this->historyBuffer_ << "/intermediatesolution_" << std::setw(4) << std::setfill('0') << i; - - std::ofstream file(iSolFilename.str().c_str(), std::ios::out|std::ios::binary); - if (not(file)) - DUNE_THROW(SolverError, "Couldn't open file " << iSolFilename << " for writing"); - - GenericVector::writeBinary(file, intermediateSol); - - file.close(); - } + if (this->historyBuffer_!="") + this->writeIterate(delta_j, i); // Compute error double oldNorm = errorNorm_->operator()(oldSolution); -- GitLab