From 553860d965ef4bdb00b1c4fd66f3861f528b6a25 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Thu, 7 May 2009 12:49:02 +0000 Subject: [PATCH] Serializer reports error message if the file does not exists; Bugfix for bug #10. --- AMDiS/src/ResidualEstimator.cc | 12 +++++------- AMDiS/src/Serializer.h | 24 +++++++----------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/AMDiS/src/ResidualEstimator.cc b/AMDiS/src/ResidualEstimator.cc index bf8ae05b..1b1af2ba 100644 --- a/AMDiS/src/ResidualEstimator.cc +++ b/AMDiS/src/ResidualEstimator.cc @@ -218,7 +218,7 @@ namespace AMDiS { } } - if (timestep) { + if (timestep && uhOld[system]) { TEST_EXIT_DBG(uhOld[system])("no uhOld\n"); uhOld[system]->getLocalVector(el, uhOldEl[system]); @@ -278,16 +278,14 @@ namespace AMDiS { // add integral over r square val = 0.0; - for (int iq = 0; iq < nPoints; iq++) { + for (int iq = 0; iq < nPoints; iq++) val += quad->getWeight(iq) * riq[iq] * riq[iq]; - } - if (timestep != 0.0 || norm == NO_NORM || norm == L2_NORM) { + if (timestep != 0.0 || norm == NO_NORM || norm == L2_NORM) val = C0 * h2 * h2 * det * val; - } else { + else val = C0 * h2 * det * val; - } - + est_el += val; // ===== jump residuals diff --git a/AMDiS/src/Serializer.h b/AMDiS/src/Serializer.h index 49840bec..37404ab1 100644 --- a/AMDiS/src/Serializer.h +++ b/AMDiS/src/Serializer.h @@ -1,4 +1,4 @@ - +// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == @@ -34,8 +34,6 @@ namespace AMDiS { class Serializer : public FileWriterInterface { public: - MEMORY_MANAGED(Serializer); - Serializer(ProblemType *problem) : name_(""), problem_(problem), @@ -61,13 +59,13 @@ namespace AMDiS { timestepNumber_++; timestepNumber_ %= tsModulo_; - if ((timestepNumber_ != 0) && !force) { + if ((timestepNumber_ != 0) && !force) return; - } TEST_EXIT(adaptInfo)("No AdaptInfo\n"); std::ofstream out(name_.c_str()); + TEST_EXIT(out.is_open())("Cannot open serialization file!\n"); problem_->serialize(out); adaptInfo->serialize(out); out.close(); @@ -82,24 +80,16 @@ namespace AMDiS { } protected: - /** \brief - * Name of file to which the problem is serialized. - */ + /// Name of file to which the problem is serialized. std::string name_; - /** \brief - * Pointer to the problem. - */ + /// Pointer to the problem. ProblemType *problem_; - /** \brief - * The problem is serialized every tsModulo-th timestep. - */ + /// The problem is serialized every tsModulo-th timestep. int tsModulo_; - /** \brief - * Current timestep number. - */ + /// Current timestep number. int timestepNumber_; }; -- GitLab