DualTraverse.h 5.28 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
25
26
// ==                                                                        ==
// ============================================================================

/** \file DualTraverse.h */

#ifndef AMDIS_DUALTRAVERSE_H
#define AMDIS_DUALTRAVERSE_H

#include "Traverse.h"
#include "Flag.h"
27
#include "AMDiS_fwd.h"
28
29
30

namespace AMDiS {

31
32
33
34
35
36
37
38
39
40
41
42
  /** \brief
   * Stores the four pointers to element info structures, that are required for the
   * dual mesh traverse.
   */
  struct DualElInfo 
  {
    ElInfo *rowElInfo;
    ElInfo *colElInfo;
    ElInfo *smallElInfo;
    ElInfo *largeElInfo;
  };

43
  /// Parallel traversal of two meshes. 
44
45
46
  class DualTraverse
  {
  public:
47
    DualTraverse() 
48
49
      : fillSubElemMat(false),
	basisFcts(NULL)
50
    {}
51

52
    virtual ~DualTraverse() {}
53

54
    /// Start dual traversal
55
56
57
58
59
60
    bool traverseFirst(Mesh *mesh1, 
		       Mesh *mesh2, 
		       int level1, 
		       int level2, 
		       Flag flag1,
		       Flag flag2,
61
62
63
64
65
		       ElInfo **elInfo1,
		       ElInfo **elInfo2,
		       ElInfo **elInfoSmall,
		       ElInfo **elInfoLarge);

66
67
68
69
70
71
72
73
74
75
76
77
78
    /// Alternative use for starting dual traversal.
    inline bool traverseFirst(Mesh *mesh1, Mesh *mesh2,
			      int level1, int level2,
			      Flag flag1, Flag flag2,
			      DualElInfo &dualElInfo)
    {
      return traverseFirst(mesh1, mesh2, level1, level2, flag1, flag2,
			   &(dualElInfo.rowElInfo), 
			   &(dualElInfo.colElInfo),
			   &(dualElInfo.smallElInfo),
			   &(dualElInfo.largeElInfo));
    }

79
    /// Get next ElInfo combination
80
81
82
83
84
    bool traverseNext(ElInfo **elInfoNext1,
		      ElInfo **elInfoNext2,
		      ElInfo **elInfoSmall,
		      ElInfo **elInfoLarge);

85
86
87
88
89
90
91
92
93
    /// Alternative use for getting the next elements in the dual traversal.
    inline bool traverseNext(DualElInfo &dualElInfo)
    {
      return traverseNext(&(dualElInfo.rowElInfo), 
			  &(dualElInfo.colElInfo),
			  &(dualElInfo.smallElInfo),
			  &(dualElInfo.largeElInfo));
    }

94
95
96
97
    bool check(ElInfo **elInfo1,
	       ElInfo **elInfo2,
	       ElInfo **elInfoSmall,
	       ElInfo **elInfoLarge) 
98
99
100
    {
      prepareNextStep(elInfo1, elInfo2, elInfoSmall, elInfoLarge);
      return true;
101
    }
Naumann, Andreas's avatar
Naumann, Andreas committed
102
    
Thomas Witkowski's avatar
Thomas Witkowski committed
103
104
    virtual bool skipEl1(ElInfo *elInfo) 
    {
105
106
      return false;
    }
Naumann, Andreas's avatar
Naumann, Andreas committed
107

Thomas Witkowski's avatar
Thomas Witkowski committed
108
109
    virtual bool skipEl2(ElInfo *elInfo) 
    {
110
111
      return false;
    }
Naumann, Andreas's avatar
Naumann, Andreas committed
112
    
Thomas Witkowski's avatar
Thomas Witkowski committed
113
114
    inline void setFillSubElemMat(bool b, const BasisFunction *fcts) 
    {
115
      fillSubElemMat = b;
116
      basisFcts = fcts;
117
118
    }
      
119
120
121
122
123
124
125
126
127
128
  protected:
    /** \brief
     * Determines smaller and larger element, determines which element(s) has to 
     * be incremented in the next step 
     */
    void prepareNextStep(ElInfo **elInfo1,
			 ElInfo **elInfo2,
			 ElInfo **elInfoSmall,
			 ElInfo **elInfoLarge);

129
130
131
132
133
    void fillSubElInfo(ElInfo *elInfo1, 
		       ElInfo *elInfo2,
		       ElInfo *elInfoSmall,
		       ElInfo *elInfoLarge);

134
  protected:
135
    /// Stack for mesh 1
136
137
    TraverseStack stack1;

138
    /// Stack for mesh 2
139
140
141
142
143
144
    TraverseStack stack2;

    /** \brief
     * used to determine whether all small elements belonging to the large
     * element are traversed.
     */
145
    double rest;
146

147
    /// true if element 1 should be incremented (set in prepareNextStep())
148
    bool inc1;
149

150
    /// true if element 2 should be incremented (set in prepareNextStep())
151
    bool inc2;
152

153
    /// for level traverse of mesh 1
154
155
    int level1_;

156
    /// for level traverse of mesh 2
157
158
    int level2_;

159
    /// for leaf element level traverse of mesh 1
160
161
    bool callLeafElLevel1_;

162
    /// for leaf element level traverse of mesh 2
163
    bool callLeafElLevel2_;
164

165
166
167
168
169
170
    /** \brief
     * If true, during dual mesh traverse for the smaller element the transformation
     * matrix will be computed. This matrix defines the transformation mapping for 
     * points defined on the larger element to the coordinates of the smaller element.
     */
    bool fillSubElemMat;
171
172
173
174
175
176

    /** \brief
     * If \ref fillSubElemMat is set to true, the corresponding transformation
     * matrices are computed. These depend on the basis functions that are used.
     */
    const BasisFunction *basisFcts;
177
178
179
180
181
182
  };

}

#endif