PeriodicBC.h 3.34 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17
18
19
20
21
22
23
24
// ==                                                                        ==
// ============================================================================

/** \file PeriodicBC.h */

#ifndef AMDIS_PERIODICBC_H
#define AMDIS_PERIODICBC_H

Thomas Witkowski's avatar
Thomas Witkowski committed
25
26
#include <map>
#include <vector>
27
#include "AMDiS_fwd.h"
28
29
30
31
32
33
34
35
36
#include "BoundaryCondition.h"
#include "FixVec.h"

namespace AMDiS {

  template<typename T>
  class DimVecLess 
  {
  public:
37
38
    bool operator()(const DimVec<T> &v1, const DimVec<T> &v2) 
    {
39
40
41
42
43
44
      int  size = v1.getSize();
      for (int i = 0; i < size; i++) {
	if (v1[i] < v2[i]) 
	  return true;
	if (v1[i] > v2[i]) 
	  return false;
45
46
      }
      return false;
47
    }
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  };

  class PeriodicDOFMapping
  {
  public:
    PeriodicDOFMapping(const BasisFunction *basFcts);

    ~PeriodicDOFMapping();

  public:
    static PeriodicDOFMapping* providePeriodicDOFMapping(const BasisFunction *basFcts);

    const DegreeOfFreedom *getDOFPermutation(const DimVec<int> &vertexPermutation);

  protected:
63
    const BasisFunction *basFcts;
64

65
    std::map<DimVec<int>, DegreeOfFreedom*, DimVecLess<int> > dofPermutation;
66

67
    std::map<DimVec<double>, int, DimVecLess<double> > indexOfCoords;
68

69
    static std::vector<PeriodicDOFMapping*> mappings;
70
71
72
73
74
75
76
77
78
79
80
81
  };


  /**
   * \ingroup Assembler
   *
   * \brief
   * Sub class of BoundaryCondition. Implements Periodic boundary conditions.
   */
  class PeriodicBC : public BoundaryCondition
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
82
    /// Constructor.
83
    PeriodicBC(BoundaryType type, FiniteElemSpace *rowFESpace);
84
85
86
87
88

    ~PeriodicBC();

    void initMatrix(DOFMatrix* matrix);

89
90
    void fillBoundaryCondition(DOFMatrix *matrix,
			       ElInfo *elInfo,
91
			       const DegreeOfFreedom *dofIndices,
92
93
			       const BoundaryType *localBound,
			       int nBasFcts);
94
95
96
97
98

    void exitMatrix(DOFMatrix* matrix);

    void exitVector(DOFVectorBase<double>* vector);

99
100
101
102
103
104
    /// We are defining periodic boundary conditions, so return always true here.
    bool isPeriodic()
    {
      return true;
    }

105
  protected:
106
    VertexVector *associated;
107

108
    PeriodicDOFMapping *periodicDOFMapping;
109

110
    DOFMatrix *masterMatrix;
111
112
113
114
115
  };

}

#endif