DualTraverse.h 4.55 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file DualTraverse.h */

#ifndef AMDIS_DUALTRAVERSE_H
#define AMDIS_DUALTRAVERSE_H

#include "Traverse.h"
#include "Flag.h"
#include "MemoryManager.h"

namespace AMDiS {

  class Mesh;
  class ElInfo;

  // ====================================================================
  // === class DualTraverse =============================================
  // ====================================================================

  /** \brief
   * Parallel traversal of two meshes. 
   */
  class DualTraverse
  {
  public:
    MEMORY_MANAGED(DualTraverse);

46
    DualTraverse() 
47
48
      : fillSubElemMat(false)
    {}
49

50
51
    ~DualTraverse() 
    {}
52
53
54
55

    /** \brief
     * Start dual traversal
     */
56
57
58
59
60
61
    bool traverseFirst(Mesh *mesh1, 
		       Mesh *mesh2, 
		       int level1, 
		       int level2, 
		       Flag flag1,
		       Flag flag2,
62
63
64
65
66
67
68
69
70
71
72
73
74
		       ElInfo **elInfo1,
		       ElInfo **elInfo2,
		       ElInfo **elInfoSmall,
		       ElInfo **elInfoLarge);

    /** \brief
     * Get next ElInfo combination
     */
    bool traverseNext(ElInfo **elInfoNext1,
		      ElInfo **elInfoNext2,
		      ElInfo **elInfoSmall,
		      ElInfo **elInfoLarge);

75
76
77
78
    bool check(ElInfo **elInfo1,
	       ElInfo **elInfo2,
	       ElInfo **elInfoSmall,
	       ElInfo **elInfoLarge) 
79
80
81
    {
      prepareNextStep(elInfo1, elInfo2, elInfoSmall, elInfoLarge);
      return true;
82
    }
Naumann, Andreas's avatar
Naumann, Andreas committed
83
84
85
86
87
88
89
90
91
    
    virtual bool skipEl1(ElInfo *elInfo) {
	    return false;
    };

    virtual bool skipEl2(ElInfo *elInfo) {
	    return false;
    };
    
92
93
    inline void setFillSubElemMat(bool b) {
      fillSubElemMat = b;
94
95
    }
      
96
97
98
99
100
101
102
103
104
105
  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);

106
107
108
109
110
    void fillSubElInfo(ElInfo *elInfo1, 
		       ElInfo *elInfo2,
		       ElInfo *elInfoSmall,
		       ElInfo *elInfoLarge);

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  protected:
    /** \brief
     * stack for mesh 1
     */
    TraverseStack stack1;

    /** \brief
     * stack for mesh 2
     */
    TraverseStack stack2;

    /** \brief
     * used to determine whether all small elements belonging to the large
     * element are traversed.
     */
126
    double rest;
127
128
129
130

    /** \brief
     * true is element 1 should be incremented (set in prepareNextStep())
     */
131
    bool inc1;
132
133
134
135

    /** \brief
     * true is element 2 should be incremented (set in prepareNextStep())
     */
136
    bool inc2;
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

    /** \brief
     * for level traverse of mesh 1
     */
    int level1_;

    /** \brief
     * for level traverse of mesh 2
     */
    int level2_;

    /** \brief
     * for leaf element level traverse of mesh 1
     */
    bool callLeafElLevel1_;

    /** \brief
     * for leaf element level traverse of mesh 2
     */
    bool callLeafElLevel2_;
157

158
159
160
161
162
163
    /** \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;
164
165
166
167
168
169
  };

}

#endif