DirichletBC.cc 2.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


13
14
15
16
17
18
19
20
#include "DirichletBC.h"
#include "ElInfo.h"
#include "BasisFunction.h"
#include "DOFVector.h"
#include "DOFMatrix.h"

namespace AMDiS {

21
22
  DirichletBC::DirichletBC(BoundaryType type,
			   AbstractFunction<double, WorldVector<double> > *fct,
23
24
			   const FiniteElemSpace *rowFeSpace,
			   const FiniteElemSpace *colFeSpace,
25
			   bool apply)
26
    : BoundaryCondition(type, rowFeSpace, colFeSpace), 
27
      f(fct), 
28
29
      dofVec(NULL),
      applyBC(apply)
30
  {}
31

32

33
  DirichletBC::DirichletBC(BoundaryType type,
34
35
			   DOFVectorBase<double> *vec,
			   bool apply)
36
    : BoundaryCondition(type, vec->getFeSpace(), vec->getFeSpace()), 
37
      f(NULL), 
38
      dofVec(vec),
39
40
41
      applyBC(apply)
  {}

42

43
44
  void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix,
					  ElInfo* elInfo,
45
					  const DegreeOfFreedom* dofIndices,
46
47
					  const BoundaryType* localBound,
					  int nBasFcts)
48
49
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
50
    TEST_EXIT_DBG(matrix->getRowFeSpace() == rowFeSpace)("invalid row fe space\n");
51
52
  }

53

54
55
  void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>* vector,
					  ElInfo* elInfo,
56
					  const DegreeOfFreedom* dofIndices,
57
58
					  const BoundaryType* localBound,
					  int nBasFcts)
59
60
  {
    FUNCNAME("DirichletBC::fillBoundaryCondition()");
61

62
    TEST_EXIT_DBG(vector->getFeSpace() == rowFeSpace)("invalid row fe space\n");
63

64
    const BasisFunction *basFcts = rowFeSpace->getBasisFcts();
65

66
    for (int i = 0; i < nBasFcts; i++) {
67
68
69
70
71
72
73
74
75
76
      if (localBound[i] == boundaryType) {
	double value = 0.0;
	if (f) {
	  elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords);
	  value = (*f)(worldCoords);
	} else {
	  if (dofVec)
	    value = (*dofVec)[dofIndices[i]];
	  else
	    ERROR_EXIT("There is something wrong!\n");
Thomas Witkowski's avatar
Thomas Witkowski committed
77
	}
78
79
80
	vector->setDirichletDofValue(dofIndices[i], value);
	(*vector)[dofIndices[i]] = value;
      }
81
82
83
84
    }
  }

}