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

namespace AMDiS {

  DirichletBC::DirichletBC(BoundaryType       type,
			   DOFVectorBase<double> *vec)
11
12
13
    : BoundaryCondition(type, vec->getFESpace()), 
      f(NULL), 
      dofVec(vec)
14
15
16
17
18
19
20
21
22
  {}

  void DirichletBC::fillBoundaryCondition(DOFMatrix*             matrix,
					  ElInfo*                elInfo,
					  const DegreeOfFreedom* dofIndices,
					  const BoundaryType*    localBound,
					  int                    nBasFcts)
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
23

24
    TEST_EXIT_DBG(matrix->getRowFESpace() == rowFESpace)
25
26
27
28
29
30
31
32
33
34
      ("invalid row fe space\n");
  }

  void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>*     vector,
					  ElInfo*                elInfo,
					  const DegreeOfFreedom* dofIndices,
					  const BoundaryType*    localBound,
					  int                    nBasFcts)
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
35

36
    TEST_EXIT_DBG(vector->getFESpace() == rowFESpace)
37
38
39
      ("invalid row fe space\n");

    const BasisFunction *basFcts = rowFESpace->getBasisFcts();
40
41
42
    for (int i = 0; i < nBasFcts; i++) {
      if (localBound[i] == boundaryType) {
	if (f) {
43
44
45
46
47
	  DimVec<double> *coords = basFcts->getCoords(i);
	  const WorldVector<double> *worldCoords = elInfo->coordToWorld(*coords, NULL);
	  double fAtCoords = f ? (*f)(*worldCoords) : 0;
	  (*vector)[dofIndices[i]] = fAtCoords;
	} 
48
	if (dofVec) {
49
50
51
52
53
54
55
	  (*vector)[dofIndices[i]] = (*dofVec)[dofIndices[i]];
	}
      }
    }
  }

}