DirichletBC.cc 2.02 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
			   FiniteElemSpace *rowFeSpace,
			   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++) {
Thomas Witkowski's avatar
Thomas Witkowski committed
67
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
68
      if (vector->isRankDof(dofIndices[i]))
Thomas Witkowski's avatar
Thomas Witkowski committed
69
#endif
70
71
      if (localBound[i] == boundaryType) {
	if (f) {
72
73
          elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords);
	  (*vector)[dofIndices[i]] = (*f)(worldCoords);
74
	}
75
	if (dofVec)
76
77
78
79
80
81
	  (*vector)[dofIndices[i]] = (*dofVec)[dofIndices[i]];
      }
    }
  }

}