ParallelDebug.h 6.71 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 30

namespace AMDiS {
   
31
  class ParallelDebug 
32 33
  {
  protected:
34 35 36 37 38
    typedef std::vector<WorldVector<double> > CoordsVec;

    /// Defines a mapping type from rank numbers to sets of coordinates.
    typedef std::map<int, CoordsVec> RankToCoords;

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

48 49 50 51 52 53 54
    /** \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);

55 56 57 58 59 60 61 62 63
    /** \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
64 65
    /** \brief
     * This function is used for debugging only. It traverses all interior boundaries
66 67
     * 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
Thomas Witkowski's avatar
Thomas Witkowski committed
68 69 70 71 72 73
     * not fit together.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     * \param[in]  printCoords   If true, the coords of all common dofs are printed
     *                           to the screen.
     */
74
    static void testCommonDofs(MeshDistributor &pdb, bool printCoords = false);
Thomas Witkowski's avatar
Thomas Witkowski committed
75

76 77 78 79 80 81 82 83 84 85
    /** \brief
     * 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.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     */
    static void testGlobalIndexByCoords(MeshDistributor &pdb);

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

93 94 95 96 97 98
    /** \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.
     */
99
    static void testDofContainerCommunication(MeshDistributor &pdb);
100

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

Thomas Witkowski's avatar
Thomas Witkowski committed
104 105 106 107 108 109 110 111
    /** \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.
     */
112
    static void printMapLocalGlobal(MeshDistributor &pdb, int rank = -1);
Thomas Witkowski's avatar
Thomas Witkowski committed
113 114 115 116 117 118 119 120 121

    /** \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.
     */
122
    static void printMapPeriodic(MeshDistributor &pdb, int rank = -1);
Thomas Witkowski's avatar
Thomas Witkowski committed
123 124 125 126 127 128 129 130 131 132 133 134

    /** \brief
     * This function is used for debugging only. It prints information about dofs
     * in rank's partition.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     * \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.
     * \param[in]  rankAllDofs   List of all dofs in ranks partition.
     */
135
    static void printRankDofs(MeshDistributor &pdb,
Thomas Witkowski's avatar
Thomas Witkowski committed
136 137 138
			      int rank, 
			      DofContainer& rankDofs, 
			      DofContainer& rankAllDofs);
139 140 141 142 143 144

    /** \brief
     * This functions prints all information about all interior boundaries on all ranks.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     */
145
    static void printBoundaryInfo(MeshDistributor &pdb);
146

147 148
    static void writeDebugFile(MeshDistributor &pdb,
			       std::string prefix, std::string postfix);
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

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

    /** \brief
     * The mesh is written to a value and all values are assigned by the rank number
     * where the vertex is contained in.
     *
     * \param[in]  filename    Name of the output file without extension (.vtu).
     * \param[in]  counter     Counter index. If not negative, this number is added
     *                         to the filename.
     * \param[in]  feSpace
     */
    static void writePartitioningFile(std::string filename,
				      int counter,
167
				      const FiniteElemSpace *feSpace);
Thomas Witkowski's avatar
Thomas Witkowski committed
168 169 170 171 172 173 174 175 176


    static bool followThisBound(int rankElIndex, int neighElIndex);

    static void followBoundary(MeshDistributor &pdb);
    
    static void followBoundary(Mesh *mesh,
			       AtomicBoundary &bound, 
			       MeshStructure &code);
Thomas Witkowski's avatar
Thomas Witkowski committed
177 178 179 180 181
  };
  
} // namespace AMDiS

#endif