From ccaf0fae90b840e342ae9ae8f06e3499a095f71f Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Sun, 10 Feb 2013 19:51:45 +0100
Subject: [PATCH] Kill implicitTwoStep scheme

---
 src/enum_scheme.cc       |   3 -
 src/enums.hh             |   1 -
 src/one-body-sample.cc   |   5 --
 src/timestepping.cc      | 128 ---------------------------------------
 src/timestepping.hh      |  42 -------------
 src/timestepping_tmpl.cc |   1 -
 6 files changed, 180 deletions(-)

diff --git a/src/enum_scheme.cc b/src/enum_scheme.cc
index 615d8933..ce65159c 100644
--- a/src/enum_scheme.cc
+++ b/src/enum_scheme.cc
@@ -2,9 +2,6 @@
 
 template <> struct StringToEnum<Config::scheme> {
   static Config::scheme convert(std::string const &s) {
-    if (s == "implicitTwoStep")
-      return Config::ImplicitTwoStep;
-
     if (s == "implicitEuler")
       return Config::ImplicitEuler;
 
diff --git a/src/enums.hh b/src/enums.hh
index b6ffb733..79bde17d 100644
--- a/src/enums.hh
+++ b/src/enums.hh
@@ -7,7 +7,6 @@ struct Config {
     Ruina
   };
   enum scheme {
-    ImplicitTwoStep,
     ImplicitEuler,
     Newmark,
     EulerPair
diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc
index 4525e6bb..2aa4b751 100644
--- a/src/one-body-sample.cc
+++ b/src/one-body-sample.cc
@@ -93,11 +93,6 @@ initTimeStepper(Config::scheme scheme, FunctionType const &dirichletFunction,
                 VectorType const &u_initial, VectorType const &ud_initial,
                 VectorType const &udd_initial) {
   switch (scheme) {
-    case Config::ImplicitTwoStep:
-      return Dune::make_shared<
-          ImplicitTwoStep<VectorType, MatrixType, FunctionType, dims>>(
-          stiffnessMatrix, u_initial, ud_initial, ignoreNodes,
-          dirichletFunction);
     case Config::ImplicitEuler:
       return Dune::make_shared<
           ImplicitEuler<VectorType, MatrixType, FunctionType, dims>>(
diff --git a/src/timestepping.cc b/src/timestepping.cc
index 614ed718..5e7ff6f1 100644
--- a/src/timestepping.cc
+++ b/src/timestepping.cc
@@ -100,134 +100,6 @@ ImplicitEuler<VectorType, MatrixType, FunctionType, dim>::clone() {
   return new ImplicitEuler<VectorType, MatrixType, FunctionType, dim>(*this);
 }
 template <class VectorType, class MatrixType, class FunctionType, int dim>
-ImplicitTwoStep<VectorType, MatrixType, FunctionType, dim>::ImplicitTwoStep(
-    MatrixType const &_A, VectorType const &_u_initial,
-    VectorType const &_ud_initial,
-    Dune::BitSetVector<dim> const &_dirichletNodes,
-    FunctionType const &_dirichletFunction)
-    : A(_A),
-      u(_u_initial),
-      ud(_ud_initial),
-      dirichletNodes(_dirichletNodes),
-      dirichletFunction(_dirichletFunction) {}
-
-template <class VectorType, class MatrixType, class FunctionType, int dim>
-void
-ImplicitTwoStep<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() {
-  u_old_old = u_old;
-  ud_old = ud;
-  u_old = u;
-}
-
-template <class VectorType, class MatrixType, class FunctionType, int dim>
-void ImplicitTwoStep<VectorType, MatrixType, FunctionType, dim>::setup(
-    VectorType const &ell, double _tau, double time, VectorType &problem_rhs,
-    VectorType &problem_iterate, MatrixType &problem_A) {
-  postProcessCalled = false;
-
-  tau = _tau;
-
-  switch (state) {
-    // Perform an implicit Euler step since we lack information
-    case NO_SETUP:
-      state = FIRST_SETUP;
-
-      problem_rhs = ell;
-      A.mmv(u_old, problem_rhs);
-
-      problem_A = A;
-      problem_A *= tau;
-      break;
-    case FIRST_SETUP:
-      state = SECOND_SETUP;
-    // FALLTHROUGH
-    case SECOND_SETUP:
-      problem_rhs = ell;
-      A.usmv(-4.0 / 3.0, u_old, problem_rhs);
-      A.usmv(+1.0 / 3.0, u_old_old, problem_rhs);
-
-      // For fixed tau, we'd only really have to do this once
-      problem_A = A;
-      problem_A *= 2.0 / 3.0 * tau;
-      break;
-    default:
-      assert(false);
-  }
-
-  // ud_old makes a good initial iterate; we could use anything, though
-  problem_iterate = ud_old;
-
-  for (size_t i = 0; i < dirichletNodes.size(); ++i)
-    switch (dirichletNodes[i].count()) {
-      case 0:
-        continue;
-      case dim:
-        problem_iterate[i] = 0;
-        dirichletFunction.evaluate(time, problem_iterate[i][0]);
-        break;
-      case 1:
-        if (dirichletNodes[i][0]) {
-          dirichletFunction.evaluate(time, problem_iterate[i][0]);
-          break;
-        }
-        if (dirichletNodes[i][1]) {
-          problem_iterate[i][1] = 0;
-          break;
-        }
-        assert(false);
-      default:
-        assert(false);
-    }
-}
-
-template <class VectorType, class MatrixType, class FunctionType, int dim>
-void ImplicitTwoStep<VectorType, MatrixType, FunctionType, dim>::postProcess(
-    VectorType const &problem_iterate) {
-  postProcessCalled = true;
-
-  ud = problem_iterate;
-
-  switch (state) {
-    case FIRST_SETUP:
-      u = u_old;
-      Arithmetic::addProduct(u, tau, ud);
-      break;
-    case SECOND_SETUP:
-      u = 0.0;
-      Arithmetic::addProduct(u, tau, ud);
-      Arithmetic::addProduct(u, 2.0, u_old);
-      Arithmetic::addProduct(u, -.5, u_old_old);
-      u *= 2.0 / 3.0;
-      break;
-    default:
-      assert(false);
-  }
-}
-
-template <class VectorType, class MatrixType, class FunctionType, int dim>
-void ImplicitTwoStep<VectorType, MatrixType, FunctionType,
-                     dim>::extractDisplacement(VectorType &displacement) const {
-  if (!postProcessCalled)
-    DUNE_THROW(Dune::Exception, "It seems you forgot to call postProcess!");
-
-  displacement = u;
-}
-
-template <class VectorType, class MatrixType, class FunctionType, int dim>
-void ImplicitTwoStep<VectorType, MatrixType, FunctionType,
-                     dim>::extractVelocity(VectorType &velocity) const {
-  if (!postProcessCalled)
-    DUNE_THROW(Dune::Exception, "It seems you forgot to call postProcess!");
-
-  velocity = ud;
-}
-
-template <class VectorType, class MatrixType, class FunctionType, int dim>
-TimeSteppingScheme<VectorType, MatrixType, FunctionType, dim> *
-ImplicitTwoStep<VectorType, MatrixType, FunctionType, dim>::clone() {
-  return new ImplicitTwoStep<VectorType, MatrixType, FunctionType, dim>(*this);
-}
-template <class VectorType, class MatrixType, class FunctionType, int dim>
 Newmark<VectorType, MatrixType, FunctionType, dim>::Newmark(
     MatrixType const &_A, MatrixType const &_B, VectorType const &_u_initial,
     VectorType const &_ud_initial, VectorType const &_udd_initial,
diff --git a/src/timestepping.hh b/src/timestepping.hh
index f57d67ff..7678c27f 100644
--- a/src/timestepping.hh
+++ b/src/timestepping.hh
@@ -51,48 +51,6 @@ class ImplicitEuler
   bool postProcessCalled = false;
 };
 template <class VectorType, class MatrixType, class FunctionType, int dim>
-class ImplicitTwoStep
-    : public TimeSteppingScheme<VectorType, MatrixType, FunctionType, dim> {
-public:
-  ImplicitTwoStep(MatrixType const &_A, VectorType const &_u_initial,
-                  VectorType const &_ud_initial,
-                  Dune::BitSetVector<dim> const &_dirichletNodes,
-                  FunctionType const &_dirichletFunction);
-
-  void virtual nextTimeStep();
-  void virtual setup(VectorType const &, double, double, VectorType &,
-                     VectorType &, MatrixType &);
-  void virtual postProcess(VectorType const &);
-  void virtual extractDisplacement(VectorType &) const;
-  void virtual extractVelocity(VectorType &) const;
-
-  virtual TimeSteppingScheme<VectorType, MatrixType, FunctionType, dim> *
-  clone();
-
-private:
-  MatrixType const &A;
-  VectorType u;
-  VectorType ud;
-  Dune::BitSetVector<dim> const &dirichletNodes;
-  FunctionType const &dirichletFunction;
-
-  VectorType u_old;
-  VectorType u_old_old;
-  VectorType ud_old;
-
-  double tau;
-
-  bool postProcessCalled = false;
-
-  // Handle a lack of information
-  enum state_type {
-    NO_SETUP,
-    FIRST_SETUP,
-    SECOND_SETUP
-  };
-  state_type state = NO_SETUP;
-};
-template <class VectorType, class MatrixType, class FunctionType, int dim>
 class Newmark
     : public TimeSteppingScheme<VectorType, MatrixType, FunctionType, dim> {
 public:
diff --git a/src/timestepping_tmpl.cc b/src/timestepping_tmpl.cc
index 5feceaf6..868daf5e 100644
--- a/src/timestepping_tmpl.cc
+++ b/src/timestepping_tmpl.cc
@@ -15,6 +15,5 @@ typedef Dune::BlockVector<SmallVector> VectorType;
 typedef Dune::VirtualFunction<double, double> FunctionType;
 
 template class ImplicitEuler<VectorType, MatrixType, FunctionType, DIM>;
-template class ImplicitTwoStep<VectorType, MatrixType, FunctionType, DIM>;
 template class Newmark<VectorType, MatrixType, FunctionType, DIM>;
 template class EulerPair<VectorType, MatrixType, FunctionType, DIM>;
-- 
GitLab