BoundaryManager.hh 3.76 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "FiniteElemSpace.h"
#include "DOFIndexed.h"
#include "DOFVector.h"
#include "Traverse.h"
#include "BasisFunction.h"
#include "ElInfo.h"
#include "BoundaryCondition.h"
#include <list>

namespace AMDiS {

  template<typename T>
  double BoundaryManager<T>::boundResidual(ElInfo *elInfo, Estimator<T> *estimator)
  {
    double result = 0;
16
    typename std::list<LocalBC<T>*>::iterator it;
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    for(it = localBCs.begin(); it != localBCs.end(); ++it) {
      result += (*it)->boundResidual(elInfo, estimator);
    }
    return result;
  }

  template<typename T>
  void BoundaryManager<T>::fillGlobalBoundVector(DOFVector<BoundaryType> *globalBound)
  {
    int i;
    TraverseStack  stack;
    const FiniteElemSpace *feSpace = globalBound->getFESpace();

    const BasisFunction *basisFcts = feSpace->getBasisFcts();
    int                  nBasFcts = basisFcts->getNumber();
    Mesh                *mesh = feSpace->getMesh();
    DOFAdmin            *admin = feSpace->getAdmin();

    const BoundaryType *localBound = NULL;
    const DegreeOfFreedom *dofIndices = NULL;

    ElInfo *elInfo = 
      stack.traverseFirst(mesh, -1, 
			  Mesh::CALL_LEAF_EL | 
			  Mesh::FILL_BOUND | 
			  Mesh::FILL_COORDS);

    // for all elements ...
    while(elInfo) {
      // get boundaries of all DOFs
      localBound = basisFcts->getBound(elInfo, NULL);
    
      // get dof indices
      dofIndices = basisFcts->getLocalIndices(elInfo->getElement(),
					      admin, NULL);

      // for all DOFs
      for(i=0; i < nBasFcts; i++) {
	(*globalBound)[dofIndices[i]] = localBound[i];
      }

      elInfo = stack.traverseNext(elInfo);
    }
  }

  template<typename T>
  void BoundaryManager<T>::fillLocalBCs(ElInfo *elInfo, 
					DOFVector<T> *vec)
  {
    int i;

    // ===== fill local conditions ==============================================
    const FiniteElemSpace *feSpace = vec->getFESpace();
    const BoundaryType    *localBound = NULL;
    const DegreeOfFreedom *dofIndices = NULL;
    Mesh                  *mesh = feSpace->getMesh();
    const BasisFunction   *basisFcts = feSpace->getBasisFcts();
    int                    nBasFcts = basisFcts->getNumber();
    LocalBC<T>            *localBC;
    DOFAdmin              *admin = feSpace->getAdmin();

78
    typename std::list<LocalBC<T>*>::iterator it;
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

    if(localBCs.size() > 0) {

      // get boundaries of all DOFs
      localBound = basisFcts->getBound(elInfo, NULL);

      // get dof indices
      dofIndices = basisFcts->getLocalIndices(elInfo->getElement(),
					      admin, NULL);

      // apply boundary conditions
      for(it = localBCs.begin(); it != localBCs.end(); ++it) {
	(*it)->fillLocalBC(vec, elInfo, dofIndices, localBound, nBasFcts);
      }
    }
  }

  template<typename T>
  void BoundaryManager<T>::fillLocalBCs(ElInfo *elInfo, 
					DOFMatrix *mat)
  {
    int i;

    // ===== fill local conditions ==============================================
    const FiniteElemSpace *feSpace = mat->getRowFESpace();
    const BoundaryType    *localBound = NULL;
    const DegreeOfFreedom *dofIndices = NULL;
    Mesh                  *mesh = feSpace->getMesh();
    const BasisFunction   *basisFcts = feSpace->getBasisFcts();
    int                    nBasFcts = basisFcts->getNumber();
    LocalBC<T>            *localBC;
    DOFAdmin              *admin = feSpace->getAdmin();

112
    typename std::list<LocalBC<T>*>::iterator it;
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

    if(localBCs.size() > 0) {

      // get boundaries of all DOFs
      localBound = basisFcts->getBound(elInfo, NULL);

      // get dof indices
      dofIndices = basisFcts->getLocalIndices(elInfo->getElement(),
					      admin, NULL);

      // apply boundary conditions
      for(it = localBCs.begin(); it != localBCs.end(); ++it) {
	(*it)->fillLocalBC(mat, elInfo, dofIndices, localBound, nBasFcts);
      }
    }
  }

}