From 23ec2c99c3e2f2f784c735d3e077a3cd87a43f52 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Tue, 18 May 2010 13:38:35 +0000
Subject: [PATCH] Dirichlet BC with DOFVector instead of a function possible.

---
 AMDiS/src/DirichletBC.cc | 14 ++++++++------
 AMDiS/src/DirichletBC.h  |  3 ++-
 AMDiS/src/ProblemVec.cc  | 33 +++++++++++++++++++++++++++++----
 AMDiS/src/ProblemVec.h   |  3 +++
 4 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/AMDiS/src/DirichletBC.cc b/AMDiS/src/DirichletBC.cc
index be0b9deb..ea8fdab0 100644
--- a/AMDiS/src/DirichletBC.cc
+++ b/AMDiS/src/DirichletBC.cc
@@ -19,15 +19,16 @@ namespace AMDiS {
     worldCoords.resize(omp_get_overall_max_threads());
   }
 
+
   DirichletBC::DirichletBC(BoundaryType type,
-			   DOFVectorBase<double> *vec)
-    : BoundaryCondition(type, vec->getFESpace()), 
+			   DOFVectorBase<double> *vec,
+			   bool apply)
+    : BoundaryCondition(type, vec->getFESpace(), vec->getFESpace()), 
       f(NULL), 
       dofVec(vec),
-      applyBC(true)
-  {
-    worldCoords.resize(omp_get_overall_max_threads());
-  }
+      applyBC(apply)
+  {}
+
 
   void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix,
 					  ElInfo* elInfo,
@@ -39,6 +40,7 @@ namespace AMDiS {
     TEST_EXIT_DBG(matrix->getRowFESpace() == rowFESpace)("invalid row fe space\n");
   }
 
+
   void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>* vector,
 					  ElInfo* elInfo,
 					  const DegreeOfFreedom* dofIndices,
diff --git a/AMDiS/src/DirichletBC.h b/AMDiS/src/DirichletBC.h
index 23ae3d85..eac7566a 100644
--- a/AMDiS/src/DirichletBC.h
+++ b/AMDiS/src/DirichletBC.h
@@ -49,7 +49,8 @@ namespace AMDiS {
 
     /// Constructor.
     DirichletBC(BoundaryType type,
-		DOFVectorBase<double> *vec);
+		DOFVectorBase<double> *vec,
+		bool apply = true);
 
     /// Implementation of BoundaryCondition::fillBoundaryCondition().
     void fillBoundaryCondition(DOFMatrix* matrix,
diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc
index 76ca18b2..40b6b4ad 100644
--- a/AMDiS/src/ProblemVec.cc
+++ b/AMDiS/src/ProblemVec.cc
@@ -1189,14 +1189,39 @@ namespace AMDiS {
     DirichletBC *dirichletNotApply = 
       new DirichletBC(type, b, componentSpaces[row], componentSpaces[col], false);
 
-    for (int i = 0; i < nComponents; i++) {
-      if (systemMatrix && (*systemMatrix)[row][i]) {
+    for (int i = 0; i < nComponents; i++)
+      if (systemMatrix && (*systemMatrix)[row][i])
+	if (i == col)
+	  (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletApply);
+	else
+	  (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletNotApply);	
+
+    if (rhs)
+      rhs->getDOFVector(row)->getBoundaryManager()->addBoundaryCondition(dirichletApply);
+    if (solution)
+      solution->getDOFVector(row)->getBoundaryManager()->addBoundaryCondition(dirichletApply);
+  }
+
+
+  void ProblemVec::addDirichletBC(BoundaryType type, int row, int col,
+				  DOFVector<double> *vec)
+  {
+    FUNCNAME("ProblemVec::addDirichletBC()");
+
+    TEST_EXIT(row >= 0 && row < nComponents)("Wrong row number: %d\n", row);
+    TEST_EXIT(col >= 0 && col < nComponents)("Wrong col number: %d\n", col);
+
+    boundaryConditionSet = true;
+
+    DirichletBC *dirichletApply = new DirichletBC(type, vec, true);
+    DirichletBC *dirichletNotApply = new DirichletBC(type, vec, false);
+
+    for (int i = 0; i < nComponents; i++)
+      if (systemMatrix && (*systemMatrix)[row][i])
 	if (i == col)
 	  (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletApply);
 	else
 	  (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletNotApply);	
-      }
-    }
 
     if (rhs)
       rhs->getDOFVector(row)->getBoundaryManager()->addBoundaryCondition(dirichletApply);
diff --git a/AMDiS/src/ProblemVec.h b/AMDiS/src/ProblemVec.h
index 9aac3317..49968702 100644
--- a/AMDiS/src/ProblemVec.h
+++ b/AMDiS/src/ProblemVec.h
@@ -244,6 +244,9 @@ namespace AMDiS {
     virtual void addDirichletBC(BoundaryType type, int row, int col,
 				AbstractFunction<double, WorldVector<double> > *b);
 
+    virtual void addDirichletBC(BoundaryType type, int row, int col,
+				DOFVector<double> *vec);
+
     /// Adds neumann boundary conditions.
     virtual void addNeumannBC(BoundaryType type, int row, int col, 
 			      AbstractFunction<double, WorldVector<double> > *n);
-- 
GitLab