ParallelDebug.h 7.69 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
1
2
3
4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
Thomas Witkowski's avatar
Thomas Witkowski committed
6
7
// ==                                                                        ==
// ============================================================================
8
9
10
11
12
13
14
15
16
17
18
19
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


Thomas Witkowski's avatar
Thomas Witkowski committed
20

21
/** \file ParallelDebug.h */
Thomas Witkowski's avatar
Thomas Witkowski committed
22

23
24
#ifndef AMDIS_PARALLELDEBUG_H
#define AMDIS_PARALLELDEBUG_H
Thomas Witkowski's avatar
Thomas Witkowski committed
25

26
#include "parallel/ParallelTypes.h"
27
#include "parallel/MeshDistributor.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
28
29

namespace AMDiS {
Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
30
31
32

  using namespace std;

33
  class ParallelDebug 
34
35
  {
  protected:
Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
36
    typedef vector<WorldVector<double> > CoordsVec;
37
38

    /// Defines a mapping type from rank numbers to sets of coordinates.
Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
39
    typedef map<int, CoordsVec> RankToCoords;
40

Thomas Witkowski's avatar
Thomas Witkowski committed
41
42
  public:
    /** \brief
43
44
     * Tests the interior and the periodic boundaries on all ranks if their order
     * fits together.
Thomas Witkowski's avatar
Thomas Witkowski committed
45
46
47
     *
     * \param[in]  pdb   Parallel problem definition used for debugging.
     */
48
    static void testInteriorBoundary(MeshDistributor &pdb);
Thomas Witkowski's avatar
Thomas Witkowski committed
49

50
51
52
53
54
55
56
    /** \brief
     * Test if all periodic boundaries are set in a consistent way on all ranks.
     * 
     * \param[in]  pdb   Parallel problem definition used for debugging.
     */
    static void testPeriodicBoundary(MeshDistributor &pdb);

57
58
59
60
61
62
63
64
65
    /** \brief
     * Test if all periodic boundaries are set in a consistent way on all ranks.
     * 
     * \param[in]  pdb       Parallel problem definition used for debugging.
     * \oaram[in]  feSpace   FE space for which the DOFs are tested.
     */
    static void testPeriodicBoundary(MeshDistributor &pdb, 
				     const FiniteElemSpace *feSpace);

Thomas Witkowski's avatar
Thomas Witkowski committed
66
    /** \brief
67
68
69
70
     * This function is used for debugging only. It traverses all interior
     * boundaries and compares the DOF indices on them with the DOF indices of
     * the boundarys neighbours. The function fails, when DOF indices on an
     * interior boundary do not fit together.
Thomas Witkowski's avatar
Thomas Witkowski committed
71
72
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
73
74
     * \param[in]  printCoords   If true, the coords of all common dofs are
     *                           printed to the screen.
Thomas Witkowski's avatar
Thomas Witkowski committed
75
     */
76
    static void testCommonDofs(MeshDistributor &pdb, bool printCoords = false);
Thomas Witkowski's avatar
Thomas Witkowski committed
77

78
    /** \brief
79
80
81
82
     * This function is used for debugging only. It checks if on all ranks DOFs
     * with the same coordinates have the same global index. For this, the
     * function genartes on all ranks a list of all DOFs with their coordinates
     * and global indices and  sends the list to all neighbouring ranks.
83
84
85
86
87
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     */
    static void testGlobalIndexByCoords(MeshDistributor &pdb);

88
89
90
91
92
    /** \brief
     * Tests if all elements in the macro mesh are memeber of exactly one rank.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     */
93
    static void testAllElements(MeshDistributor &pdb);
94

95
96
97
98
99
100
    /** \brief
     * Tests for all ranks simultaneously, if the number of all send and received 
     * DOFs fits together for all communication partners.
     *
     * \param[in]  pdb        Parallel problem definition used for debugging.
     */
101
    static void testDofContainerCommunication(MeshDistributor &pdb);
102

103
104
105
    /// Tests if there are multiple DOFs in mesh with the same coords.
    static void testDoubleDofs(Mesh *mesh);

Thomas Witkowski's avatar
Thomas Witkowski committed
106
107
108
109
110
111
112
113
    /** \brief
     * This function is used for debugging only. It prints all information from
     * the local to global dof mapping, see \ref mapLocalGlobalDofs.
     *
     * \param[in]  pdb     Parallel problem definition used for debugging.
     * \param[in]  rank    If specified, only the information from the given rank 
     *                     is printed.
     */
114
    static void printMapLocalGlobal(MeshDistributor &pdb, int rank = -1);
Thomas Witkowski's avatar
Thomas Witkowski committed
115
116
117
118
119
120
121
122
123

    /** \brief
     * This function is used for debugging only. It prints all information about
     * the periodic mapping of dofs, that are on periodic boundaries.
     *
     * \param[in] pdb    Parallel problem definition used for debugging.
     * \param[in] rank   If specified, only the information from the given rank 
     *                   is printed.
     */
124
    static void printMapPeriodic(MeshDistributor &pdb, int rank = -1);
Thomas Witkowski's avatar
Thomas Witkowski committed
125
126

    /** \brief
127
     * This function is used for debugging only. It prints information about DOFs
Thomas Witkowski's avatar
Thomas Witkowski committed
128
129
130
     * in rank's partition.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
131
132
133
134
     * \param[in]  rank          If specified, only the information from the
     *                           given rank is printed.
     * \param[in]  rankDofs      List of all dofs in ranks partition that are
     *                           owned by rank.
Thomas Witkowski's avatar
Thomas Witkowski committed
135
136
     * \param[in]  rankAllDofs   List of all dofs in ranks partition.
     */
137
    static void printRankDofs(MeshDistributor &pdb,
Thomas Witkowski's avatar
Thomas Witkowski committed
138
139
140
			      int rank, 
			      DofContainer& rankDofs, 
			      DofContainer& rankAllDofs);
141
142

    /** \brief
143
144
     * This functions prints all information about all interior boundaries on 
     * all ranks.
145
     *
Thomas Witkowski's avatar
Thomas Witkowski committed
146
     * \param[in]  intBoundary   The boundary object to be printed.
147
148
149
150
151
152
153
     * \param[in]  level         Mesh level number for which the boundary should
     *                           be printed.
     * \param[in]  force         If true, the information is always printed to
     *                           screen. Otherwise, this is done only if AMDiS
     *                           is compiled in debug mode or if the init file
     *                           parameter "parallel->debug->print boundary info"
     *                           is set.
154
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
155
    static void printBoundaryInfo(InteriorBoundary &intBoundary,
156
157
				  int level = 0, 
				  bool force = false);
158

Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
159
160
161
162
163

    static void writeDebugFile(const FiniteElemSpace *feSpace,
			       ParallelDofMapping &dofMap,
			       string prefix, 
			       string postfix);
164
165

    /** \brief
166
167
     * This functions create a Paraview file with the macro mesh where the
     * elements are colored by the partition they are part of.
168
169
170
171
     */
    static void writePartitioning(MeshDistributor &pdb, string filename);

    /** \brief
172
173
     * The mesh is written to a value and all values are assigned by the rank
     * number where the vertex is contained in.
174
175
     *
     * \param[in]  filename    Name of the output file without extension (.vtu).
176
177
     * \param[in]  counter     Counter index. If not negative, this number is
     *                         added to the filename.
178
179
     * \param[in]  feSpace
     */
Thomas Witkowski's avatar
Blub    
Thomas Witkowski committed
180
    static void writePartitioningFile(string filename,
181
				      int counter,
182
				      const FiniteElemSpace *feSpace);
Thomas Witkowski's avatar
Thomas Witkowski committed
183
184
185
186
187
188
189
190
191


    static bool followThisBound(int rankElIndex, int neighElIndex);

    static void followBoundary(MeshDistributor &pdb);
    
    static void followBoundary(Mesh *mesh,
			       AtomicBoundary &bound, 
			       MeshStructure &code);
192
193
194
195
196
197
198
199
200
201

	/** \brief 
	* Writes Element Map of local Rank
	* Map containes for each DOF in each Element (resulting in massive doubling of DOFs):
	* localElementNumber	elementLevel	localDOFNumber	dofType dofCoords(0-2) elementLocalDOFNumber	typeOfElement (0-2)
	*/
	static void writeCsvElementMap(const FiniteElemSpace *feSpace,
			       ParallelDofMapping &dofMap,
			       string prefix, 
			       string postfix);
Thomas Witkowski's avatar
Thomas Witkowski committed
202
203
204
205
206
  };
  
} // namespace AMDiS

#endif