DirichletBC.cc 2.5 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 68

#if 1
Thomas Witkowski's avatar
Thomas Witkowski committed
69
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
70
      if (vector->isRankDof(dofIndices[i]))
Thomas Witkowski's avatar
Thomas Witkowski committed
71
#endif
Thomas Witkowski's avatar
Thomas Witkowski committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
	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");
	  }

	  (*vector)[dofIndices[i]] = value;
	}
#else
87
      if (localBound[i] == boundaryType) {
88
	double value = 0.0;
89
	if (f) {
90
          elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords);
91
	  value = (*f)(worldCoords);
92
	}
93
	if (dofVec)
94 95
	  value = (*dofVec)[dofIndices[i]];

Thomas Witkowski's avatar
Thomas Witkowski committed
96 97 98
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
	vector->setDirichletDofValue(dofIndices[i], value);
#else
99
	(*vector)[dofIndices[i]] = value;
Thomas Witkowski's avatar
Thomas Witkowski committed
100
#endif
101
      }
Thomas Witkowski's avatar
Thomas Witkowski committed
102 103
#endif

104
    }
Thomas Witkowski's avatar
Thomas Witkowski committed
105

106 107 108
  }

}