InteriorBoundary.h 4.71 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut für 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
25
// ==                                                                        ==
// ============================================================================

/** \file InteriorBoundary.h */

#ifndef AMDIS_INTERIORBOUNDARY_H
#define AMDIS_INTERIORBOUNDARY_H

#include <vector>
Thomas Witkowski's avatar
Thomas Witkowski committed
26
#include <map>
27

28
#include "AMDiS_fwd.h"
29
30
#include "MacroElement.h"
#include "Element.h"
31
32
33

namespace AMDiS {

34
35
  typedef std::vector<std::pair<GeoIndex, int> > ExcludeList;

36
37
  /// Defines the geometrical objects that forms the boundary;
  struct BoundaryObject {
38

39
    BoundaryObject()
40
      : reverseMode(false),
41
	excludedSubstructures(0)
42
43
44
45
46
47
48
49
50
    {}

    BoundaryObject(Element *e, int eType, GeoIndex sObj, int iObj)
      : el(e),
	elIndex(e->getIndex()),
	elType(eType),
	subObj(sObj),
	ithObj(iObj),
	reverseMode(false),
51
	excludedSubstructures(0)
52
    {}
53

54
55
56
57
58
59
    void setReverseMode(BoundaryObject &otherBound, FiniteElemSpace *feSpace);

    bool operator==(const BoundaryObject& other) const;
    
    bool operator!=(const BoundaryObject& other) const;

60
    /// The macro element to which the boundary element corresponds to.
Thomas Witkowski's avatar
Thomas Witkowski committed
61
    Element* el;
62

63
64
65
    /// Index of the macro element.
    int elIndex;

66
67
68
    /// Element type index, only used in 3d.
    int elType;

69
70
71
72
    /** \brief
     * Defines the geometrical object at the boundary. It must be "a part" of the
     * macro element \ref el, i.e., either 1 (a vertex), 2 (an edge) or 3 (a face).
     */
73
    GeoIndex subObj;
74
75
76
77
78

    /** \brief
     * Defines which of vertix, edge or face of the macro element is part of the
     * boundary.
     *
79
80
81
     * Example: If the macro element is a triangle, than \ref subObj may be either
     * 1 (vertex) or 2 (edge). Assume its the last one. So this variable defines
     * which of the three possible edges of the triangle is at the interior
82
83
     * boundary.
     */
84
    int ithObj;
85
86
87

    bool reverseMode;

88
89
90
91
92
93
94
95
96
    /** \brief
     * In many situations it may be necessary to exclude some parts of the element to
     * be part of the boundary. In 3d, when a face is part of the boundary, an edge or
     * an vertex may be exludeded. In 2d only vertices may be exluded to be part of
     * an edge boundary. This list contains pairs of exludeded structures. The first
     * component of every pair denotes if it is a vertex or an edge, and the second
     * component denotes the local index of the structure.
     */
    ExcludeList excludedSubstructures;
97
98
99
100
101
102
103
104
  };

  /** \brief 
   * Defines one atomic part of the boundary, i.e., two boundary objects where the
   * boundary goes through.
   */
  struct AtomicBoundary {
    /// The rank's part of the boundary.
105
    BoundaryObject rankObj;
106
107

    /// The object on the other side of the boundary.
108
    BoundaryObject neighObj;
109
110
111
112
113
114
115
  };

  /** \brief
   * Defines the interior boundary, i.e. a bound within the domain. It is used for
   * the classical domain decomposition parallelization.
   */
  class InteriorBoundary {
Thomas Witkowski's avatar
Thomas Witkowski committed
116
117
118
  public:
    typedef std::map<int, std::vector<AtomicBoundary> > RankToBoundMap;

119
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
120
121
    InteriorBoundary() {}

122
    AtomicBoundary& getNewAtomic(int rank);
Thomas Witkowski's avatar
Thomas Witkowski committed
123

124
    /// Writes this object to a file.
125
126
    void serialize(std::ostream &out);

127
128
    /// Reads the state of an interior boundary from a file.
    void deserialize(std::istream &in, std::map<int, Element*> &elIndexMap);
129

130
131
132
133
134
  protected:
    void serializeExcludeList(std::ostream &out, ExcludeList &list);

    void deserializeExcludeList(std::istream &in, ExcludeList &list);

Thomas Witkowski's avatar
Thomas Witkowski committed
135
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
136
    RankToBoundMap boundary;
137
138
139
140
  };
}

#endif // AMDIS_INTERIORBOUNDARY_H