Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Ein Anmelden über dieses erzeugt ein neues Konto. Das alte Konto ist über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. Logging in via this will create a new account. The old account can be accessed via the "Standard" tab. The administrators

Debug.h 7.39 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
// ============================================================================
// ==                                                                        ==
// == 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

25
#include <set>
26 27 28 29 30 31
#include "AMDiS_fwd.h"
#include "Global.h"

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

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

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

42 43 44 45 46
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    void writeLocalElementDofs(int rank, int elIdx, FiniteElemSpace *feSpace);
    
    void writeMesh(FiniteElemSpace *feSpace, int rank, std::string filename);
    
47 48 49 50 51 52 53 54 55 56
    /** \brief
     * Writes a vtu file with the mesh, where all DOFs are set to zero, and only
     * one given DOF is set to one. This can be used to easily identify DOFs in
     * a mesh.
     *
     * \param[in]  rank     If set to -1, the vtu files are written on all ranks.
     *                      Otherwise, only on the given rank the mesh is written. 
     * \param[in]  dof      Defines the DOF, which value is set to one in the mesh file.
     * \param[in]  feSpace  The FE space to be used.
     */
57 58
    void writeDofMesh(int rank, DegreeOfFreedom dof, FiniteElemSpace *feSpace);
#endif
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

    /** \brief
     * Create a vtu file with name 'dofindex.vtu'. All nodes in the mesh are colored
     * by the global dof index.
     *
     * \param[in]  feSpace  The FE space to be used.
     */
    void writeDofIndexMesh(FiniteElemSpace *feSpace);

    /** \brief
     * Creates a vtu file where all elements in the mesh are colored by the global
     * element indices.
     *
     * \param[in]  feSpace   The FE space to be used.
     * \param[in]  filename  Name of the file.
     */
75
    void writeElementIndexMesh(Mesh *mesh, std::string filename);
76

77
    void highlightElementIndexMesh(Mesh *mesh, int idx, std::string filename);
78

79 80 81 82 83 84 85 86 87
    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);
88

89 90
    Element* getLevel0ParentElement(Mesh *mesh, int elIndex);

91 92 93 94
    Element* getParentElement(Mesh *mesh, Element *el);

    Element* getParentElement(Mesh *mesh, int elIndex);

Thomas Witkowski's avatar
Thomas Witkowski committed
95 96
    Element* getElement(Mesh *mesh, int elIndex);

97
    void printElementInfo(Element *el);
98 99

    void printElementCoords(const FiniteElemSpace *feSpace, Element *el);
100 101
    
    void printInfoByDof(FiniteElemSpace *feSpace, DegreeOfFreedom dof);
Thomas Witkowski's avatar
Thomas Witkowski committed
102 103

    void printMatValuesStatistics(Matrix<DOFMatrix*> *mat);
104

105 106 107 108
    void printAllDofCoords(FiniteElemSpace *feSpace);

    void getAllDofs(FiniteElemSpace *feSpace, std::set<const DegreeOfFreedom*>& dofs);

Thomas Witkowski's avatar
Thomas Witkowski committed
109 110 111 112 113 114 115 116 117
    /** \brief
     * Creates a text file storing the value of a sparse matrix. Each line of the file
     * has three columns:
     *    row  col  value
     * This file can be used in Matlab using the command "spconvert".
     *
     * \param[in]  mat       The matrix which is used the write the text file.
     * \param[in]  filename  Name of the file to be created.
     */
118 119
    void writeMatlabMatrix(DOFMatrix &mat, std::string filename);

Thomas Witkowski's avatar
Thomas Witkowski committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    /** \brief
     * Creates a text file storing the value of a sparse matrix. Each line of the file
     * has three columns:
     *    row  col  value
     * This file can be used in Matlab using the command "spconvert". The function 
     * works only for a matrix of DOFMatrices, that are all defined from the same
     * FE spaces.
     *
     * \param[in]  mat       The matrix which is used the write the text file.
     * \param[in]  filename  Name of the file to be created.     
     */
    void writeMatlabMatrix(Matrix<DOFMatrix*> &mat, std::string filename);

    /** \brief
     *
     */
136
    void writeMatlabVector(DOFVector<double> &vec, std::string filename);
137

138 139
    void writeMatlabVector(SystemVector &vec, std::string filename);

Thomas Witkowski's avatar
Thomas Witkowski committed
140 141
    void writeCoordsFile(const FiniteElemSpace *feSpace, std::string filename);

Thomas Witkowski's avatar
Thomas Witkowski committed
142 143
    void printElementHierarchie(Mesh *mesh, int elIndex);    

Thomas Witkowski's avatar
Thomas Witkowski committed
144
    void printElementRefinementSequence(Mesh *mesh, Element *el);
145

146 147
    int getLocalNeighbourIndex(Mesh *mesh, int elIndex, int neighIndex);

148 149
    void importDofVectorByCoords(DOFVector<double>* vec, std::string filename);

150 151 152
    void exportDofVectorByCoords(const DOFVector<double>* vec, 
				 std::string filename);

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
    /** \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);    

193 194 195 196
  }
}

#endif