DirichletBC.cc 1.9 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

  DirichletBC::DirichletBC(BoundaryType type,
23
			   DOFVectorBase<double> *vec)
24
25
    : BoundaryCondition(type, vec->getFESpace()), 
      f(NULL), 
26
27
      dofVec(vec),
      applyBC(true)
28
  {
29
    worldCoords.resize(omp_get_overall_max_threads());
30
  }
31

32
33
  void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix,
					  ElInfo* elInfo,
34
					  const DegreeOfFreedom* dofIndices,
35
36
					  const BoundaryType* localBound,
					  int nBasFcts)
37
38
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
39

40
    TEST_EXIT_DBG(matrix->getRowFESpace() == rowFESpace)("invalid row fe space\n");
41
42
  }

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

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

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

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

}