DirichletBC.cc 1.81 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
12
13
14
15
16
  DirichletBC::DirichletBC(BoundaryType type,
			   AbstractFunction<double, WorldVector<double> > *fct,
			   FiniteElemSpace *rowFESpace,
			   FiniteElemSpace *colFESpace)
    : BoundaryCondition(type, rowFESpace, colFESpace), 
      f(fct), 
      dofVec(NULL)
  {
17
    worldCoords.resize(omp_get_num_procs());
18
19
20
  };

  DirichletBC::DirichletBC(BoundaryType type,
21
			   DOFVectorBase<double> *vec)
22
23
24
    : BoundaryCondition(type, vec->getFESpace()), 
      f(NULL), 
      dofVec(vec)
25
  {
26
    worldCoords.resize(omp_get_num_procs());
27
  }
28

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

37
    TEST_EXIT_DBG(matrix->getRowFESpace() == rowFESpace)
38
39
40
      ("invalid row fe space\n");
  }

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

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

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

55
56
57
    for (int i = 0; i < nBasFcts; i++) {
      if (localBound[i] == boundaryType) {
	if (f) {
58
	  DimVec<double> *coords = basFcts->getCoords(i);
59
60
	  elInfo->coordToWorld(*coords, &(worldCoords[myRank]));
	  double fAtCoords = (*f)(worldCoords[myRank]);
61
	  (*vector)[dofIndices[i]] = fAtCoords;
62
	}
63
	if (dofVec) {
64
65
66
67
68
69
70
	  (*vector)[dofIndices[i]] = (*dofVec)[dofIndices[i]];
	}
      }
    }
  }

}