DirichletBC.cc 1.88 KB
Newer Older
1
2
3
4
5
6
7
8
#include "DirichletBC.h"
#include "ElInfo.h"
#include "BasisFunction.h"
#include "DOFVector.h"
#include "DOFMatrix.h"

namespace AMDiS {

9
10
11
  DirichletBC::DirichletBC(BoundaryType type,
			   AbstractFunction<double, WorldVector<double> > *fct,
			   FiniteElemSpace *rowFESpace,
12
13
			   FiniteElemSpace *colFESpace,
			   bool apply)
14
15
    : BoundaryCondition(type, rowFESpace, colFESpace), 
      f(fct), 
16
17
      dofVec(NULL),
      applyBC(apply)
18
  {
19
    worldCoords.resize(omp_get_overall_max_threads());
20
  }
21

22

23
  DirichletBC::DirichletBC(BoundaryType type,
24
25
26
			   DOFVectorBase<double> *vec,
			   bool apply)
    : BoundaryCondition(type, vec->getFESpace(), vec->getFESpace()), 
27
      f(NULL), 
28
      dofVec(vec),
29
30
31
      applyBC(apply)
  {}

32

33
34
  void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix,
					  ElInfo* elInfo,
35
					  const DegreeOfFreedom* dofIndices,
36
37
					  const BoundaryType* localBound,
					  int nBasFcts)
38
39
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
40
    TEST_EXIT_DBG(matrix->getRowFESpace() == rowFESpace)("invalid row fe space\n");
41
42
  }

43

44
45
  void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>* vector,
					  ElInfo* elInfo,
46
					  const DegreeOfFreedom* dofIndices,
47
48
					  const BoundaryType* localBound,
					  int nBasFcts)
49
50
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
51

52
    TEST_EXIT_DBG(vector->getFESpace() == rowFESpace)("invalid row fe space\n");
53
54

    const BasisFunction *basFcts = rowFESpace->getBasisFcts();
55
56
    int myRank = omp_get_thread_num();

57
    for (int i = 0; i < nBasFcts; i++) {
Thomas Witkowski's avatar
Thomas Witkowski committed
58
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
59
      if (vector->isRankDof(dofIndices[i]))
Thomas Witkowski's avatar
Thomas Witkowski committed
60
#endif
61
62
      if (localBound[i] == boundaryType) {
	if (f) {
63
          elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords[myRank]);
Thomas Witkowski's avatar
Thomas Witkowski committed
64
	  (*vector)[dofIndices[i]] = (*f)(worldCoords[myRank]);
65
	}
66
	if (dofVec)
67
68
69
70
71
72
	  (*vector)[dofIndices[i]] = (*dofVec)[dofIndices[i]];
      }
    }
  }

}