DualTraverse.h 5.7 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
28
29

/** \file DualTraverse.h */

#ifndef AMDIS_DUALTRAVERSE_H
#define AMDIS_DUALTRAVERSE_H

#include "Traverse.h"
#include "Flag.h"
30
#include "AMDiS_fwd.h"
31
32
33

namespace AMDiS {

34
35
36
37
  /** \brief
   * Stores the four pointers to element info structures, that are required for the
   * dual mesh traverse.
   */
38
  struct DualElInfo
39
  {
40
41
42
43
    ElInfo *rowElInfo;    ///< elInfo related to testfunction
    ElInfo *colElInfo;    ///< elInfo related to trialfunction
    ElInfo *smallElInfo;  ///< the smaller element of (rowElInfo, colElInfo) with refinementPath relative to largeElInfo
    ElInfo *largeElInfo;  ///< the larger element of (rowElInfo, colElInfo)
44
45
  };

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

55
    virtual ~DualTraverse() {}
56

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

69
70
71
72
73
74
75
    /// 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,
76
			   &(dualElInfo.rowElInfo),
77
78
79
80
			   &(dualElInfo.colElInfo),
			   &(dualElInfo.smallElInfo),
			   &(dualElInfo.largeElInfo));
    }
Praetorius, Simon's avatar
Praetorius, Simon committed
81
82
83
84
85
86
87
88
89
90
91
92
    
    bool traverseFirstOneMacro(Mesh *mesh1,
                              Mesh *mesh2,
                              int macroIndex,
                              int level1,
                              int level2,
                              Flag flag1,
                              Flag flag2,
                              ElInfo **elInfo1,
                              ElInfo **elInfo2,
                              ElInfo **elInfoSmall,
                              ElInfo **elInfoLarge);
93

94
    /// Get next ElInfo combination
95
96
97
98
99
    bool traverseNext(ElInfo **elInfoNext1,
		      ElInfo **elInfoNext2,
		      ElInfo **elInfoSmall,
		      ElInfo **elInfoLarge);

100
101
102
    /// Alternative use for getting the next elements in the dual traversal.
    inline bool traverseNext(DualElInfo &dualElInfo)
    {
103
      return traverseNext(&(dualElInfo.rowElInfo),
104
105
106
107
108
			  &(dualElInfo.colElInfo),
			  &(dualElInfo.smallElInfo),
			  &(dualElInfo.largeElInfo));
    }

109
110
111
    bool check(ElInfo **elInfo1,
	       ElInfo **elInfo2,
	       ElInfo **elInfoSmall,
112
	       ElInfo **elInfoLarge)
113
114
115
    {
      prepareNextStep(elInfo1, elInfo2, elInfoSmall, elInfoLarge);
      return true;
116
    }
117
118

    virtual bool skipEl1(ElInfo *elInfo)
Thomas Witkowski's avatar
Thomas Witkowski committed
119
    {
120
121
      return false;
    }
Naumann, Andreas's avatar
Naumann, Andreas committed
122

123
    virtual bool skipEl2(ElInfo *elInfo)
Thomas Witkowski's avatar
Thomas Witkowski committed
124
    {
125
126
      return false;
    }
127
128

    inline void setFillSubElemMat(bool b, const BasisFunction *fcts)
Thomas Witkowski's avatar
Thomas Witkowski committed
129
    {
130
      fillSubElemMat = b;
131
      basisFcts = fcts;
132
    }
133
134
135

    /** \brief
     * Checks if the small element has an edge/face which is part of a given edge/face
136
     * of the large element. If this is the case, it returns the local number of the
137
138
139
140
141
     * small edge/face, and -1 otherwise.
     *
     * \param[in]  dualElInfo    Dual element info with large and small element infos.
     * \param[in]  largeFace     A local edge/face number on the large element.
     */
142
143
    static int getFace(DualElInfo *dualElInfo, int largeFace);

144
145
  protected:
    /** \brief
146
147
     * Determines smaller and larger element, determines which element(s) has to
     * be incremented in the next step
148
149
150
151
152
153
     */
    void prepareNextStep(ElInfo **elInfo1,
			 ElInfo **elInfo2,
			 ElInfo **elInfoSmall,
			 ElInfo **elInfoLarge);

154
    void fillSubElInfo(ElInfo *elInfo1,
155
156
157
158
		       ElInfo *elInfo2,
		       ElInfo *elInfoSmall,
		       ElInfo *elInfoLarge);

159
  protected:
160
    /// Stack for mesh 1
161
162
    TraverseStack stack1;

163
    /// Stack for mesh 2
164
165
166
167
168
169
    TraverseStack stack2;

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

172
    /// true if element 1 should be incremented (set in prepareNextStep())
173
    bool inc1;
174

175
    /// true if element 2 should be incremented (set in prepareNextStep())
176
    bool inc2;
177

178
    /// for level traverse of mesh 1
179
180
    int level1_;

181
    /// for level traverse of mesh 2
182
183
    int level2_;

184
    /// for leaf element level traverse of mesh 1
185
186
    bool callLeafElLevel1_;

187
    /// for leaf element level traverse of mesh 2
188
    bool callLeafElLevel2_;
189

190
191
    /** \brief
     * If true, during dual mesh traverse for the smaller element the transformation
192
     * matrix will be computed. This matrix defines the transformation mapping for
193
194
195
     * points defined on the larger element to the coordinates of the smaller element.
     */
    bool fillSubElemMat;
196
197
198
199
200
201

    /** \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;
202
203
204
205
206
207
  };

}

#endif