Skip to content
Snippets Groups Projects
ParallelDebug.h 6.99 KiB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
Thomas Witkowski's avatar
Thomas Witkowski committed
// ==                                                                        ==
// ============================================================================
//
// 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.


#ifndef AMDIS_PARALLELDEBUG_H
#define AMDIS_PARALLELDEBUG_H
#include "parallel/ParallelTypes.h"
Thomas Witkowski's avatar
Thomas Witkowski committed

namespace AMDiS {
   
    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
  public:
    /** \brief
     * Tests the interior and the periodic boundaries on all ranks if their order
     * fits together.
Thomas Witkowski's avatar
Thomas Witkowski committed
     *
     * \param[in]  pdb   Parallel problem definition used for debugging.
     */
    static void testInteriorBoundary(MeshDistributor &pdb);
    /** \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);

    /** \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
    /** \brief
     * 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
Thomas Witkowski's avatar
Thomas Witkowski committed
     * neighbours. The function fails, when dof indices on an interior boundary do
     * 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.
     */
    static void testCommonDofs(MeshDistributor &pdb, bool printCoords = false);
    /** \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);

    /** \brief
     * Tests if all elements in the macro mesh are memeber of exactly one rank.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     */
    static void testAllElements(MeshDistributor &pdb);
    /** \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.
     * \param[in]  sendDofs   The map of all DOFs the rank will send.
     * \param[in]  recvDofs   The map of all DOFs the rank will receive.
     */
    static void testDofContainerCommunication(MeshDistributor &pdb, 
					      map<int, map<const FiniteElemSpace*, DofContainer> > &sendDofs,
					      map<int, map<const FiniteElemSpace*, DofContainer> > &recvDofs);
    /// Tests if there are multiple DOFs in mesh with the same coords.
    static void testDoubleDofs(Mesh *mesh);

Thomas Witkowski's avatar
Thomas Witkowski committed
    /** \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.
     */
    static void printMapLocalGlobal(MeshDistributor &pdb, int rank = -1);
Thomas Witkowski's avatar
Thomas Witkowski committed

    /** \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.
     */
    static void printMapPeriodic(MeshDistributor &pdb, int rank = -1);
Thomas Witkowski's avatar
Thomas Witkowski committed

    /** \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.
     */
    static void printRankDofs(MeshDistributor &pdb,
Thomas Witkowski's avatar
Thomas Witkowski committed
			      int rank, 
			      DofContainer& rankDofs, 
			      DofContainer& rankAllDofs);

    /** \brief
     * This functions prints all information about all interior boundaries on all ranks.
     *
     * \param[in]  pdb           Parallel problem definition used for debugging.
     */
    static void printBoundaryInfo(MeshDistributor &pdb);
    static void writeDebugFile(MeshDistributor &pdb,
			       std::string prefix, std::string postfix);

    /** \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,


    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
  };
  
} // namespace AMDiS

#endif