From b18471b4b011f483da61c248793b97b90d321eb0 Mon Sep 17 00:00:00 2001
From: podlesny <podlesny@zedat.fu-berlin.de>
Date: Tue, 19 Jan 2021 22:07:33 +0100
Subject: [PATCH] ready for strikeslip computation

---
 .../spatial-solving/fixedpointiterator.cc     |  2 +-
 .../time-stepping/adaptivetimestepper.cc      | 31 ++++++++++---------
 dune/tectonic/time-stepping/step.hh           |  4 +--
 src/strikeslip/strikeslip-2D.cfg              |  2 +-
 src/strikeslip/strikeslip.cc                  |  4 +--
 src/strikeslip/strikeslip.cfg                 |  4 +--
 6 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/dune/tectonic/spatial-solving/fixedpointiterator.cc b/dune/tectonic/spatial-solving/fixedpointiterator.cc
index b3080a54..a36d76f2 100644
--- a/dune/tectonic/spatial-solving/fixedpointiterator.cc
+++ b/dune/tectonic/spatial-solving/fixedpointiterator.cc
@@ -272,7 +272,7 @@ FixedPointIterator<Factory, NBodyAssembler, Updaters, ErrorNorms>::run(
 
   //print(alpha, "alpha: ");
 
-  std::cout << "-FixedPointIteration finished with " << fixedPointIteration << " iterations, lambda " << lambda_ <<  "! " << std::endl;
+  //std::cout << "-FixedPointIteration finished with " << fixedPointIteration << " iterations, lambda " << lambda_ <<  "! " << std::endl;
 
   if (fixedPointIteration == fixedPointMaxIterations_)
     DUNE_THROW(Dune::Exception, "FPI failed to converge");
diff --git a/dune/tectonic/time-stepping/adaptivetimestepper.cc b/dune/tectonic/time-stepping/adaptivetimestepper.cc
index 52997a82..4514cade 100644
--- a/dune/tectonic/time-stepping/adaptivetimestepper.cc
+++ b/dune/tectonic/time-stepping/adaptivetimestepper.cc
@@ -50,7 +50,10 @@ AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNorms>::AdaptiveTime
       contactNetwork_(contactNetwork),
       current_(current),
       R1_(),
-      mustRefine_(mustRefine) {}
+      mustRefine_(mustRefine) {
+
+    std::cout << N_THREADS << " concurrent threads are supported." << std::endl;
+}
 
 template <class Factory, class ContactNetwork, class Updaters, class ErrorNorms>
 bool AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNorms>::reachedEnd() {
@@ -71,14 +74,14 @@ int AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNorms>::coarsen(
     const auto& currentNBodyAssembler = contactNetwork_.nBodyAssembler();
 
     while (relativeTime_ + relativeTau_ <= 1.0) {
-      std::cout << "tau: " << relativeTau_ << std::endl;
+      //std::cout << "tau: " << relativeTau_ << std::endl;
 
       setDeformation(current_);
       auto C_Step = Step(stepBase_, current_, currentNBodyAssembler, relativeTime_, 2 * relativeTau_, iterationRegister_);
-      C_Step.run(Step::Mode::newThread); //newThread
+      C_Step.run(Step::Mode::sameThread); //newThread
 
       //updateReductionFactors(reductionFactors);
-      std::cout << "AdaptiveTimeStepper C computed!" << std::endl << std::endl;
+      //std::cout << "AdaptiveTimeStepper C computed!" << std::endl << std::endl;
 
       /*using ScalarVector = typename Updaters::StateUpdater::ScalarVector;
       std::vector<ScalarVector> cAlpha(contactNetwork_.nBodies());
@@ -89,10 +92,10 @@ int AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNorms>::coarsen(
       //auto R2_linearSolver = makeLinearSolver();
       auto&& nBodyAssembler = step(currentNBodyAssembler);
       auto R2_Step = Step(stepBase_, R1_.updaters, nBodyAssembler, relativeTime_ + relativeTau_, relativeTau_, iterationRegister_);
-      R2_Step.run(Step::Mode::newThread); //newThread
+      R2_Step.run(Step::Mode::sameThread); //newThread
 
       //updateReductionFactors(reductionFactors);
-      std::cout << "AdaptiveTimeStepper R2 computed!" << std::endl << std::endl;
+      //std::cout << "AdaptiveTimeStepper R2 computed!" << std::endl << std::endl;
 
       C = C_Step.get();
       R2 = R2_Step.get();
@@ -137,7 +140,7 @@ int AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNorms>::refine(U
         F1 = F1_Step.get();
 
         //updateReductionFactors(reductionFactors);
-        std::cout << "AdaptiveTimeStepper F1 computed!" << std::endl << std::endl;
+        //std::cout << "AdaptiveTimeStepper F1 computed!" << std::endl << std::endl;
 
         setDeformation(F1.updaters);
         //auto F2_linearSolver = makeLinearSolver();
@@ -192,18 +195,18 @@ int AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNorms>::determin
     setDeformation(current_);
     //auto C_linearSolver = makeLinearSolver();
     auto C_Step = Step(stepBase_, current_, currentNBodyAssembler, relativeTime_, 2 * relativeTau_, iterationRegister_);
-    C_Step.run(Step::Mode::newThread); // newThread
+    C_Step.run(Step::Mode::sameThread); // newThread
     //updateReductionFactors(reductionFactors);
-    std::cout << "AdaptiveTimeStepper C computed!" << std::endl << std::endl;
+    //std::cout << "AdaptiveTimeStepper C computed!" << std::endl << std::endl;
 
     setDeformation(R1_.updaters);
     //auto R2_linearSolver = makeLinearSolver();
     auto&& nBodyAssembler = step(currentNBodyAssembler);
     auto R2_Step = Step(stepBase_, R1_.updaters, nBodyAssembler, relativeTime_ + relativeTau_, relativeTau_, iterationRegister_);
-    R2_Step.run(Step::Mode::newThread); //newThread
+    R2_Step.run(Step::Mode::sameThread); //newThread
 
     //updateReductionFactors(reductionFactors);
-    std::cout << "AdaptiveTimeStepper R2 computed!" << std::endl << std::endl;
+    //std::cout << "AdaptiveTimeStepper R2 computed!" << std::endl << std::endl;
 
     if (N_THREADS < 3) {
       C = C_Step.get();
@@ -218,9 +221,9 @@ int AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNorms>::determin
         setDeformation(current_);
         //auto F1_linearSolver = makeLinearSolver();
         auto F1_Step = Step(stepBase_, current_, currentNBodyAssembler, relativeTime_, relativeTau_ / 2.0, iterationRegister_);
-        F1_Step.run(Step::Mode::newThread); //newThread
+        F1_Step.run(Step::Mode::sameThread); //newThread
         //updateReductionFactors(reductionFactors);
-        std::cout << "AdaptiveTimeStepper F1 computed!" << std::endl << std::endl;
+        //std::cout << "AdaptiveTimeStepper F1 computed!" << std::endl << std::endl;
 
         if (N_THREADS > 2) {
           C = C_Step.get();
@@ -283,8 +286,6 @@ IterationRegister AdaptiveTimeStepper<Factory, ContactNetwork, Updaters, ErrorNo
 
   using Step = Step<Factory, ContactNetwork, Updaters, ErrorNorms>;
 
-  std::cout << N_THREADS << " concurrent threads are supported." << std::endl;
-
   if (R1_.updaters == Updaters()) {
       //setDeformation(current_);
       //auto R1_linearSolver = makeLinearSolver();
diff --git a/dune/tectonic/time-stepping/step.hh b/dune/tectonic/time-stepping/step.hh
index ece7019c..a6433c33 100644
--- a/dune/tectonic/time-stepping/step.hh
+++ b/dune/tectonic/time-stepping/step.hh
@@ -244,10 +244,10 @@ class Step : protected StepBase<Factory, ContactNetwork, Updaters, ErrorNorms> {
     }
 
     auto get() {
-        std::cout << "Step::get() called" << std::endl;
+        //std::cout << "Step::get() called" << std::endl;
         if (thread_.joinable()) {
             thread_.join();
-            std::cout << "Thread joined " << std::endl;
+            //std::cout << "Thread joined " << std::endl;
         }
         return future_.get();
     }
diff --git a/src/strikeslip/strikeslip-2D.cfg b/src/strikeslip/strikeslip-2D.cfg
index e360fd0b..26eb8519 100644
--- a/src/strikeslip/strikeslip-2D.cfg
+++ b/src/strikeslip/strikeslip-2D.cfg
@@ -6,7 +6,7 @@ smallestDiameter = 0.02 # 2e-3 [m]
 smallestDiameter = 0.02  # 2e-3 [m]
 
 [timeSteps]
-refinementTolerance = 5e-6 # 1e-5
+refinementTolerance = 1e-5 # 1e-5
 
 [u0.solver]
 tolerance         = 1e-8
diff --git a/src/strikeslip/strikeslip.cc b/src/strikeslip/strikeslip.cc
index eb17ed23..850efc5d 100644
--- a/src/strikeslip/strikeslip.cc
+++ b/src/strikeslip/strikeslip.cc
@@ -299,8 +299,8 @@ int main(int argc, char *argv[]) {
 
           energyNorm += stateEnergyNorms[i]->diff(fineAlpha[i], coarseAlpha[i]);
       }
-      std::cout << "energy norm: " << energyNorm << " tol: " << refinementTolerance <<  std::endl;
-      std::cout << "must refine: " << (energyNorm > refinementTolerance) <<  std::endl;
+      //std::cout << "energy norm: " << energyNorm << " tol: " << refinementTolerance <<  std::endl;
+      //std::cout << "must refine: " << (energyNorm > refinementTolerance) <<  std::endl;
       return energyNorm > refinementTolerance;
     };
 
diff --git a/src/strikeslip/strikeslip.cfg b/src/strikeslip/strikeslip.cfg
index bc5ed7cb..25e4d47c 100644
--- a/src/strikeslip/strikeslip.cfg
+++ b/src/strikeslip/strikeslip.cfg
@@ -55,7 +55,7 @@ sigmaN          = 200.0      # [Pa]
 finalVelocity   = 1e-4     # [m/s]
 
 [io]
-data.write      = false
+data.write      = true
 printProgress   = true
 restarts.first  = 0
 restarts.spacing= 1
@@ -73,7 +73,7 @@ relativeTau = 2e-4 # 1e-6
 
 [timeSteps]
 scheme = newmark
-timeSteps = 5
+timeSteps = 5000
 
 [u0.solver]
 maximumIterations = 100
-- 
GitLab