DirichletBC.cc 2.13 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
    worldCoords.resize(omp_get_overall_max_threads());
32
  }
33

34

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

44

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

55

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

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

66
    const BasisFunction *basFcts = rowFeSpace->getBasisFcts();
67
68
    int myRank = omp_get_thread_num();

69
    for (int i = 0; i < nBasFcts; i++) {
Thomas Witkowski's avatar
Thomas Witkowski committed
70
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
71
      if (vector->isRankDof(dofIndices[i]))
Thomas Witkowski's avatar
Thomas Witkowski committed
72
#endif
73
74
      if (localBound[i] == boundaryType) {
	if (f) {
75
          elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords[myRank]);
Thomas Witkowski's avatar
Thomas Witkowski committed
76
	  (*vector)[dofIndices[i]] = (*f)(worldCoords[myRank]);
77
	}
78
	if (dofVec)
79
80
81
82
83
84
	  (*vector)[dofIndices[i]] = (*dofVec)[dofIndices[i]];
      }
    }
  }

}