PeriodicBC.h 2.95 KB
Newer Older
1
2
3
4
5
6
7
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
8
 * Authors:
9
10
11
12
13
14
15
16
17
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
18
 *
19
 ******************************************************************************/
20
21


22
23
24
25
26
27

/** \file PeriodicBC.h */

#ifndef AMDIS_PERIODICBC_H
#define AMDIS_PERIODICBC_H

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

namespace AMDiS {

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

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

    ~PeriodicDOFMapping();

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

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

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
66
    /// Basis functions the mapping object is defined on.
67
    const BasisFunction *basFcts;
68

69
    std::map<DimVec<int>, DegreeOfFreedom*, DimVecLess<int> > dofPermutation;
70

Thomas Witkowski's avatar
Thomas Witkowski committed
71
72
    /// Maps from coordinates (in barycentric coordinates) of a local basis
    /// function to the local index of that basis function.
73
    std::map<DimVec<double>, int, DimVecLess<double> > indexOfCoords;
74

Thomas Witkowski's avatar
Thomas Witkowski committed
75
76
    /// Global array that provids for each existing basis functions a unique
    /// mapping object.
77
    static std::vector<PeriodicDOFMapping*> mappings;
78
79
80
81
82
83
84
85
86
87
88
89
  };


  /**
   * \ingroup Assembler
   *
   * \brief
   * Sub class of BoundaryCondition. Implements Periodic boundary conditions.
   */
  class PeriodicBC : public BoundaryCondition
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
90
    /// Constructor.
91
    PeriodicBC(BoundaryType type, const FiniteElemSpace *rowFeSpace, bool diagonal);
92
93
94
95
96

    ~PeriodicBC();

    void initMatrix(DOFMatrix* matrix);

97
98
    void fillBoundaryCondition(DOFMatrix *matrix,
			       ElInfo *elInfo,
99
			       const DegreeOfFreedom *dofIndices,
100
101
			       const BoundaryType *localBound,
			       int nBasFcts);
102
103
104
105
106

    void exitMatrix(DOFMatrix* matrix);

    void exitVector(DOFVectorBase<double>* vector);

107
108
109
110
111
112
    /// We are defining periodic boundary conditions, so return always true here.
    bool isPeriodic()
    {
      return true;
    }

113
  protected:
114
    VertexVector *associated;
115

116
    PeriodicDOFMapping *periodicDOFMapping;
117

118
    DOFMatrix *masterMatrix;
119
120

    bool isDiagonal;
121
122
123
124
125
  };

}

#endif