From eb84ac8d753dcdeebead1e22062e7ef3306857c3 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Mon, 4 Feb 2013 13:31:42 +0100
Subject: [PATCH] Write damping to a file

---
 src/one-body-sample.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc
index e25b11c3..64916565 100644
--- a/src/one-body-sample.cc
+++ b/src/one-body-sample.cc
@@ -332,6 +332,8 @@ int main(int argc, char *argv[]) {
     ;
     std::fstream iteration_writer("iterations", std::fstream::out);
     ;
+    std::fstream damping_writer("damping", std::fstream::out);
+    ;
 
     auto timeSteppingScheme =
         initTimeStepper(parset.get<Config::scheme>("timeSteppingScheme"),
@@ -411,11 +413,13 @@ int main(int argc, char *argv[]) {
           stateUpdater->extractState(computed_state);
           double const correction = diff_two_norm(computed_state, alpha);
           if (state_fpi <= 2 // Let the first two steps pass through unchanged
-              || correction < minimalCorrectionReduction * lastCorrection)
+              || correction < minimalCorrectionReduction * lastCorrection) {
             alpha = computed_state;
-          else {
+            damping_writer << "N ";
+          } else {
             alpha *= damping;
             alpha.axpy(1.0 - damping, computed_state);
+            damping_writer << "Y ";
           }
           lastCorrection = correction;
         }
@@ -463,6 +467,7 @@ int main(int argc, char *argv[]) {
       velocity_writer << std::endl;
       coefficient_writer << std::endl;
       iteration_writer << std::endl;
+      damping_writer << std::endl;
 
       if (parset.get<bool>("writeVTK")) {
         SingletonVectorType vonMisesStress;
@@ -488,6 +493,7 @@ int main(int argc, char *argv[]) {
     velocity_writer.close();
     coefficient_writer.close();
     iteration_writer.close();
+    damping_writer.close();
 
     Python::stop();
   }
-- 
GitLab