DirichletBC.cc 1.84 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
57
58
    for (int i = 0; i < nBasFcts; i++) {
      if (localBound[i] == boundaryType) {
	if (f) {
59
          elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords[myRank]);
60
	  double fAtCoords = (*f)(worldCoords[myRank]);
61
	  (*vector)[dofIndices[i]] = fAtCoords;
62
	}
63
	if (dofVec)
64
65
66
67
68
69
	  (*vector)[dofIndices[i]] = (*dofVec)[dofIndices[i]];
      }
    }
  }

}