DualTraverse.h 5.24 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * 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.
 * 
 ******************************************************************************/
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
38
39
  /** \brief
   * Stores the four pointers to element info structures, that are required for the
   * dual mesh traverse.
   */
  struct DualElInfo 
  {
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
62
63
    bool traverseFirst(Mesh *mesh1, 
		       Mesh *mesh2, 
		       int level1, 
		       int level2, 
		       Flag flag1,
		       Flag flag2,
64
65
66
67
68
		       ElInfo **elInfo1,
		       ElInfo **elInfo2,
		       ElInfo **elInfoSmall,
		       ElInfo **elInfoLarge);

69
70
71
72
73
74
75
76
77
78
79
80
81
    /// 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));
    }

82
    /// Get next ElInfo combination
83
84
85
86
87
    bool traverseNext(ElInfo **elInfoNext1,
		      ElInfo **elInfoNext2,
		      ElInfo **elInfoSmall,
		      ElInfo **elInfoLarge);

88
89
90
91
92
93
94
95
96
    /// 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));
    }

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

Thomas Witkowski's avatar
Thomas Witkowski committed
111
112
    virtual bool skipEl2(ElInfo *elInfo) 
    {
113
114
      return false;
    }
Naumann, Andreas's avatar
Naumann, Andreas committed
115
    
Thomas Witkowski's avatar
Thomas Witkowski committed
116
117
    inline void setFillSubElemMat(bool b, const BasisFunction *fcts) 
    {
118
      fillSubElemMat = b;
119
      basisFcts = fcts;
120
    }
121
122
123
124
125
126
127
128
129
130

    /** \brief
     * Checks if the small element has an edge/face which is part of a given edge/face
     * of the large element. If this is the case, it returns the local number of the 
     * 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.
     */
    static int getFace(DualElInfo *dualElInfo, int largeFace);    
131
      
132
133
134
135
136
137
138
139
140
141
  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);

142
143
144
145
146
    void fillSubElInfo(ElInfo *elInfo1, 
		       ElInfo *elInfo2,
		       ElInfo *elInfoSmall,
		       ElInfo *elInfoLarge);

147
  protected:
148
    /// Stack for mesh 1
149
150
    TraverseStack stack1;

151
    /// Stack for mesh 2
152
153
154
155
156
157
    TraverseStack stack2;

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

160
    /// true if element 1 should be incremented (set in prepareNextStep())
161
    bool inc1;
162

163
    /// true if element 2 should be incremented (set in prepareNextStep())
164
    bool inc2;
165

166
    /// for level traverse of mesh 1
167
168
    int level1_;

169
    /// for level traverse of mesh 2
170
171
    int level2_;

172
    /// for leaf element level traverse of mesh 1
173
174
    bool callLeafElLevel1_;

175
    /// for leaf element level traverse of mesh 2
176
    bool callLeafElLevel2_;
177

178
179
180
181
182
183
    /** \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;
184
185
186
187
188
189

    /** \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;
190
191
192
193
194
195
  };

}

#endif