From 7ce6cd85ee43da4cf0a98576d15ce1e5641ae264 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Thu, 11 Oct 2012 16:47:36 +0200
Subject: [PATCH] Allow X-only Dirichlet conditions

---
 dune/tectonic/myblockproblem.hh | 17 +++++++++----
 src/timestepping.org            | 45 ++++++++++++++++++++-------------
 2 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/dune/tectonic/myblockproblem.hh b/dune/tectonic/myblockproblem.hh
index fa727174..a55141c0 100644
--- a/dune/tectonic/myblockproblem.hh
+++ b/dune/tectonic/myblockproblem.hh
@@ -289,15 +289,22 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject {
       LocalVectorType &ui, int m,
       typename Dune::BitSetVector<block_size>::const_reference ignore) {
     {
-      int ignore_component =
-          block_size; // Special value that indicates nothing should be ignored
+      int ignore_component = block_size;
+      // Special value that indicates nothing should be ignored
       switch (ignore.count()) {
         case 0: // Full problem
           break;
         case 1: // 1 Dimension is fixed
-          assert(
-              ignore[1]); // Only the second component is allowed to stay fixed
-          ignore_component = 1;
+          // Only the X and Y components are allowed to be fixed in this manner
+          if (ignore[0]) {
+            ignore_component = 0;
+            break;
+          }
+          if (ignore[1]) {
+            ignore_component = 1;
+            break;
+          }
+          assert(false);
           break;
         case block_size: // Ignore the whole node
           return;
diff --git a/src/timestepping.org b/src/timestepping.org
index ced45917..074f2ad0 100644
--- a/src/timestepping.org
+++ b/src/timestepping.org
@@ -26,6 +26,30 @@
   void virtual extractDisplacement(VectorType &) const;
   void virtual extractVelocity(VectorType &) const;
 #+end_src
+#+name: dirichletCondition
+#+begin_src c++
+  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);
+    }
+#+end_src
 * Abstract TimeSteppingScheme
 #+name: TimeSteppingScheme.hh
 #+begin_src c++
@@ -119,12 +143,7 @@
     // 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)
-      if (dirichletNodes[i].count() == dim) {
-        problem_iterate[i] = 0;
-        dirichletFunction.evaluate(time, problem_iterate[i][0]);
-      } else if (dirichletNodes[i][1])
-        problem_iterate[i][1] = 0; // Y direction prescribed
+    <<dirichletCondition>>
   }
   
   template <class VectorType, class MatrixType, class FunctionType, int dim>
@@ -281,12 +300,7 @@
     // 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)
-      if (dirichletNodes[i].count() == dim) {
-        problem_iterate[i] = 0;
-        dirichletFunction.evaluate(time, problem_iterate[i][0]);
-      } else if (dirichletNodes[i][1])
-        problem_iterate[i][1] = 0; // Y direction prescribed
+    <<dirichletCondition>>
   }
   
   template <class VectorType, class MatrixType, class FunctionType, int dim>
@@ -454,12 +468,7 @@
     // 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)
-      if (dirichletNodes[i].count() == dim) {
-        problem_iterate[i] = 0;
-        dirichletFunction.evaluate(time, problem_iterate[i][0]);
-      } else if (dirichletNodes[i][1])
-        problem_iterate[i][1] = 0; // Y direction prescribed
+    <<dirichletCondition>>
   }
   
   template <class VectorType, class MatrixType, class FunctionType, int dim>
-- 
GitLab