Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind ü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. The accounts of external users can be accessed via the "Standard" tab.
The administrators

ComponentTraverseInfo.h 6.54 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 22 23 24 25

/** \file ComponentTraverseInfo.h */

#ifndef AMDIS_COMPONENTTRAVERSEINFO_H
#define AMDIS_COMPONENTTRAVERSEINFO_H

26
#include <set>
27
#include "Global.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
28 29 30 31 32 33 34 35
#include "FiniteElemSpace.h"

namespace AMDiS {

  class SingleComponentInfo
  {      
  public:
    SingleComponentInfo()
36 37
      : rowFeSpace(NULL),
	colFeSpace(NULL),
Thomas Witkowski's avatar
Thomas Witkowski committed
38 39 40
	status(0)
      {}
    
41
    void setFeSpace(const FiniteElemSpace *row, const FiniteElemSpace *col = NULL) 
Thomas Witkowski's avatar
Thomas Witkowski committed
42
    {
43 44
      rowFeSpace = row;
      colFeSpace = col;
Thomas Witkowski's avatar
Thomas Witkowski committed
45 46
    }
    
47
    void setAuxFeSpaces(std::set<const FiniteElemSpace*> feSpaces) 
Thomas Witkowski's avatar
Thomas Witkowski committed
48
    {
49
      auxFeSpaces = feSpaces;
Thomas Witkowski's avatar
Thomas Witkowski committed
50 51
    }

52
    void addAuxFeSpace(const FiniteElemSpace *fe) 
Thomas Witkowski's avatar
Thomas Witkowski committed
53
    {
54
      auxFeSpaces.insert(fe);
Thomas Witkowski's avatar
Thomas Witkowski committed
55 56
    }
    
57
    bool hasFeSpace() 
Thomas Witkowski's avatar
Thomas Witkowski committed
58
    {
59
      return rowFeSpace != NULL;
Thomas Witkowski's avatar
Thomas Witkowski committed
60 61 62 63
    }

    void updateStatus();
    
64
    int getNumAuxFeSpaces() 
Thomas Witkowski's avatar
Thomas Witkowski committed
65
    {
66
      return auxFeSpaces.size();
Thomas Witkowski's avatar
Thomas Witkowski committed
67 68
    }
    
69
    const FiniteElemSpace *getRowFeSpace() 
Thomas Witkowski's avatar
Thomas Witkowski committed
70
    {
71
      return rowFeSpace;
Thomas Witkowski's avatar
Thomas Witkowski committed
72 73
    }
    
74
    const FiniteElemSpace *getColFeSpace() 
Thomas Witkowski's avatar
Thomas Witkowski committed
75
    {
76
      return colFeSpace;
Thomas Witkowski's avatar
Thomas Witkowski committed
77 78
    }
    
79
    const FiniteElemSpace *getAuxFeSpace() 
Thomas Witkowski's avatar
Thomas Witkowski committed
80
    {
81
      FUNCNAME("SingleComponentInfo::getAuxFeSpace()");
82

83 84 85 86 87 88
      TEST_EXIT_DBG(auxFeSpaces.size() <= 1)("More than one aux FE space!\n");

      if (auxFeSpaces.size() == 1)
	return (*(auxFeSpaces.begin()));

      return NULL;
Thomas Witkowski's avatar
Thomas Witkowski committed
89 90
    }

91
    inline int getStatus() const
Thomas Witkowski's avatar
Thomas Witkowski committed
92
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
93 94 95 96
      return status;
    }
    
  protected:      
97
    const FiniteElemSpace *rowFeSpace;
Thomas Witkowski's avatar
Thomas Witkowski committed
98
    
99
    const FiniteElemSpace *colFeSpace;
Thomas Witkowski's avatar
Thomas Witkowski committed
100
    
101
    std::set<const FiniteElemSpace*> auxFeSpaces;
Thomas Witkowski's avatar
Thomas Witkowski committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138

    /// Status of the component, see the possible status flags below.
    int status;

  public:
    /// Single component status flag: empty component, no fe spaces
    static const int EMPTY;

    /// Single component status flag: row = col, no aux
    static const int EQ_SPACES_NO_AUX;

    /// Single component status flag: row = col = aux
    static const int EQ_SPACES_WITH_AUX;

    /// Single component status flag: row = col, different aux
    static const int EQ_SPACES_WITH_DIF_AUX;

    /// Single component status flag: row, col, no aux
    static const int DIF_SPACES_NO_AUX;

    /// Single component status flag: row, col, aux either equal to row or to col
    static const int DIF_SPACES_WITH_AUX;

    /// Single component status flag: row, col, aux (at least 3 different fe spaces)
    static const int DIF_SPACES_WITH_DIF_AUX;
  };

  
  class ComponentTraverseInfo
  {
  public: 
    ComponentTraverseInfo(int n) 
      : nComponents(n)
    {
      resize(n);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
139 140
    void resize(int n) 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
141 142 143 144 145
      nComponents = n;

      matrixComponents.resize(n);
      vectorComponents.resize(n);

Thomas Witkowski's avatar
Thomas Witkowski committed
146
      for (int i = 0; i < n; i++)
Thomas Witkowski's avatar
Thomas Witkowski committed
147 148 149
	matrixComponents[i].resize(n);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
150 151
    void updateStatus() 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
152
      for (int i = 0; i < nComponents; i++) {
Thomas Witkowski's avatar
Thomas Witkowski committed
153
	for (int j = 0; j < nComponents; j++)
Thomas Witkowski's avatar
Thomas Witkowski committed
154
	  matrixComponents[i][j].updateStatus();
Thomas Witkowski's avatar
Thomas Witkowski committed
155

Thomas Witkowski's avatar
Thomas Witkowski committed
156 157 158 159
	vectorComponents[i].updateStatus();
      }
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
160 161
    SingleComponentInfo &getMatrix(int row, int col) 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
162 163 164
      return matrixComponents[row][col];
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
165 166
    SingleComponentInfo &getVector(int row) 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
167 168 169
      return vectorComponents[row];
    }

170
    inline int getStatus(int row, int col) const
Thomas Witkowski's avatar
Thomas Witkowski committed
171
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
172 173 174
      return matrixComponents[row][col].getStatus();
    }

175
    inline int getStatus(int row) const
Thomas Witkowski's avatar
Thomas Witkowski committed
176
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
177 178 179
      return vectorComponents[row].getStatus();
    }

180 181 182 183 184 185 186 187 188 189 190 191 192 193
    /** \brief
     * Returns true, if for the given matrix component the row and the col FE spaces
     * are equal. Note that this is also the case, if there is another aux FE space,
     * that may be different from both, the row and the col FE spaces.
     */
    inline bool eqSpaces(int row, int col) const
    {
      int status = matrixComponents[row][col].getStatus();

      return (status == SingleComponentInfo::EQ_SPACES_NO_AUX ||
	      status == SingleComponentInfo::EQ_SPACES_WITH_AUX ||
	      status == SingleComponentInfo::EQ_SPACES_WITH_DIF_AUX);
    }

194
    const FiniteElemSpace* getAuxFeSpace(int row, int col) 
Thomas Witkowski's avatar
Thomas Witkowski committed
195
    {
196
      return matrixComponents[row][col].getAuxFeSpace();
Thomas Witkowski's avatar
Thomas Witkowski committed
197 198
    }

199
    const FiniteElemSpace* getAuxFeSpace(int row) 
Thomas Witkowski's avatar
Thomas Witkowski committed
200
    {
201
      return vectorComponents[row].getAuxFeSpace();
Thomas Witkowski's avatar
Thomas Witkowski committed
202
    }
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220

    /// Returns true if there is an aux FE that is different from row and col FE spaces.
    inline bool difAuxSpace(int row, int col) const
    {
      int status = matrixComponents[row][col].getStatus();

      return (status == SingleComponentInfo::EQ_SPACES_WITH_DIF_AUX ||
	      status == SingleComponentInfo::DIF_SPACES_WITH_DIF_AUX);
    }

    /// Returns true if there is an aux FE that is different from row and col FE spaces.
    inline bool difAuxSpace(int row) const
    {
      int status = vectorComponents[row].getStatus();

      return (status == SingleComponentInfo::EQ_SPACES_WITH_DIF_AUX ||
	      status == SingleComponentInfo::DIF_SPACES_WITH_DIF_AUX);
    }
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
    
    /** \brief
     * Returns the row FE space for a given row number, i.e., the FE space
     * of the diagonal matrix.
     *
     * \param[in]  row   Row number of the matrix line for which the FE space
     *                   should be returned.
     */    
    const FiniteElemSpace* getRowFeSpace(int row);


    /** \brief
     * Returns the non row FE space for a given row number. This is either the
     * col FE space of an off diagonal matrix or the aux fe space of another
     * matrix in the row or of the right hand side vector. If there is no non row
     * FE space, this function returns a null pointer.
     *
     * \param[in]  row   Row number of the matrix line for which the non FE space
     *                   should be returned.
     */
    const FiniteElemSpace* getNonRowFeSpace(int row);
Thomas Witkowski's avatar
Thomas Witkowski committed
242 243 244 245 246 247 248 249 250 251 252 253

  protected:
    int nComponents;

    std::vector<std::vector<SingleComponentInfo> > matrixComponents;

    std::vector<SingleComponentInfo> vectorComponents;
  };

}

#endif