DirichletBC.cc 1.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "DirichletBC.h"
#include "ElInfo.h"
#include "BasisFunction.h"
#include "DOFVector.h"
#include "DOFMatrix.h"

namespace AMDiS {

  DirichletBC::DirichletBC(BoundaryType       type,
			   DOFVectorBase<double> *vec)
    : BoundaryCondition(type, vec->getFESpace()), f(NULL), dofVec(vec)
  {}

  void DirichletBC::fillBoundaryCondition(DOFMatrix*             matrix,
					  ElInfo*                elInfo,
					  const DegreeOfFreedom* dofIndices,
					  const BoundaryType*    localBound,
					  int                    nBasFcts)
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
    TEST_EXIT(matrix->getRowFESpace() == rowFESpace)
      ("invalid row fe space\n");
    TEST_EXIT(matrix->getColFESpace() == colFESpace)
      ("invalid col fe space\n");
  }

  void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>*     vector,
					  ElInfo*                elInfo,
					  const DegreeOfFreedom* dofIndices,
					  const BoundaryType*    localBound,
					  int                    nBasFcts)
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
    TEST_EXIT(vector->getFESpace() == rowFESpace)
      ("invalid row fe space\n");

    const BasisFunction *basFcts = rowFESpace->getBasisFcts();
    int i;
    for(i=0; i < nBasFcts; i++) {
      if(localBound[i] == boundaryType) {
	if(f) {
	  DimVec<double> *coords = basFcts->getCoords(i);
	  const WorldVector<double> *worldCoords = elInfo->coordToWorld(*coords, NULL);
	  double fAtCoords = f ? (*f)(*worldCoords) : 0;
	  (*vector)[dofIndices[i]] = fAtCoords;
	} 
	if(dofVec) {
	  (*vector)[dofIndices[i]] = (*dofVec)[dofIndices[i]];
	}
      }
    }
  }

}