diff --git a/dune-solvers/solvers/cgsolver.cc b/dune-solvers/solvers/cgsolver.cc index 7a5565b9518ec6beb17ff00f6943794f9bab958d..4e80395f7626832dfbfcd75dbcf08781f85267f2 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 d905df79f1ebbd7f1a43d43bd2814b185bd5f372..187b0ba4f83e054a9623d7218fc4a1b64d531176 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);