Debug.h 4.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  TU Dresden                                                            ==
// ==                                                                        ==
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
// ==                                                                        ==
// ============================================================================

/** \file Debug.h */

#ifndef AMDIS_DEBUG_H
#define AMDIS_DEBUG_H

#include "AMDiS_fwd.h"
#include "Global.h"

namespace AMDiS {
  
  namespace debug {
31
32
33
34
35
36
37
38
39
40

    struct DofPtrSortFct {
      bool operator() (const DegreeOfFreedom *dof0, const DegreeOfFreedom *dof1) 
      {
	return (*dof0 < *dof1);
      }
    };

    typedef std::map<int, DofContainer> ElementIdxToDofs;

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    void writeLocalElementDofs(int rank, int elIdx, FiniteElemSpace *feSpace);
    
    void writeMesh(FiniteElemSpace *feSpace, int rank, std::string filename);
    
    void writeDofMesh(int rank, DegreeOfFreedom dof, FiniteElemSpace *feSpace);
#endif
    
    void colorDofVectorByLocalElementDofs(DOFVector<double>& vec, Element *el);
    
    bool colorDofVectorByLocalElementDofs(DOFVector<double>& vec, 
					  Mesh *mesh, 
					  int elIndex);
    
    Element* getDofIndexElement(FiniteElemSpace *feSpace, DegreeOfFreedom dof);
    
    Element* getLevel0ParentElement(Mesh *mesh, Element *el);
    
    void printInfoByDof(FiniteElemSpace *feSpace, DegreeOfFreedom dof);
Thomas Witkowski's avatar
Thomas Witkowski committed
60
61

    void printMatValuesStatistics(Matrix<DOFMatrix*> *mat);
62
63

    void writeElementIndexMesh(FiniteElemSpace *feSpace, std::string filename);
64
65
66
67

    void writeMatlabMatrix(DOFMatrix &mat, std::string filename);

    void writeMatlabVector(DOFVector<double> &vec, std::string filename);
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

    /** \brief
     * Traverse a mesh and store for each element all its vertex DOFs in local sorted 
     * order (by values).
     *
     * \param[in]   mesh    Mesh to be traversed.
     * \param[out]  elMap   Stores to each element the vertex DOFs in sorted order.
     */
    void createSortedDofs(Mesh *mesh, ElementIdxToDofs &elMap);

    /** \brief
     * Takes a map from element indices to lists of DOFs. Checks, if for each element
     * in the mesh the vertex value order is still valid.
     *
     * The element index map must be created by the function \createSortedDofs. Using
     * both functions it can be checked if a renumbering of dofs does not changes the
     * local vertex value order (which is required by AMDiS to be always equal on each
     * element).
     *
     * If the test fails, the function prints some debug information to screen and
     * terminates the programm.
     *
     * \param[in]  mesh   Mesh to be traversed.
     * \param[in]  elMap  Map from element indices to lists of DOFs. It is used to check
     *                    the validaty as described above.
     */
    void testSortedDofs(Mesh *mesh, ElementIdxToDofs &elMap);

    /// Takes tree dofs and returns a list with the dofs sorted by their values.
    void sortDofs(const DegreeOfFreedom* dof0,
		  const DegreeOfFreedom* dof1,
		  const DegreeOfFreedom* dof2,
		  DofContainer &vec);

    /// Takes four dofs and returns a list with the dofs sorted by their values.
    void sortDofs(const DegreeOfFreedom* dof0,
		  const DegreeOfFreedom* dof1,
		  const DegreeOfFreedom* dof2,
		  const DegreeOfFreedom* dof3,
		  DofContainer &vec);    

109
110
111
112
  }
}

#endif