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

ElementObjectData.h 6.04 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
// ============================================================================
// ==                                                                        ==
// == 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 ElementObjectData.h */

#ifndef AMDIS_ELEMENTOBJECTDATA_H
#define AMDIS_ELEMENTOBJECTDATA_H

#include <map>
#include <vector>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>

#include "Global.h"
#include "Boundary.h"

namespace AMDiS {

  struct ElementObjectData {
    ElementObjectData(int a = -1, int b = 0, BoundaryType c = INTERIOR)
      : elIndex(a),
	ithObject(b),
	boundaryType(c)
    {}
    
    int elIndex;
    
    int ithObject;
    
    BoundaryType boundaryType;
  };



  class ElementObjects {
  public:
    ElementObjects(std::map<int, int> vec) 
      : elementInRank(vec),
	iterGeoPos(CENTER)
    {}

    void addVertex(DegreeOfFreedom vertex, 
		   int elIndex, int ith, BoundaryType bound = INTERIOR)
    {
      vertexElements[vertex].push_back(ElementObjectData(elIndex, ith, bound));
      vertexOwner[vertex] = std::max(vertexOwner[vertex], elementInRank[elIndex]);
    }

    void addEdge(DofEdge edge, 
		 int elIndex, int ith, BoundaryType bound = INTERIOR)
    {
      edgeElements[edge].push_back(ElementObjectData(elIndex, ith, bound));
      edgeOwner[edge] = std::max(edgeOwner[edge], elementInRank[elIndex]);
    }

    void addFace(DofFace face, 
		 int elIndex, int ith, BoundaryType bound = INTERIOR)
    {
      faceElements[face].push_back(ElementObjectData(elIndex, ith, bound));
      faceOwner[face] = std::max(faceOwner[face], elementInRank[elIndex]);
    }

    void createRankData();

    bool iterate(GeoIndex pos)
    {
      if (iterGeoPos == CENTER) {
	iterGeoPos = pos;
	switch (iterGeoPos) {
	case VERTEX:
	  vertexIter = vertexInRank.begin();
	  break;
	case EDGE:
	  edgeIter = edgeInRank.begin();
	  break;
	case FACE:
	  faceIter = faceInRank.begin();
	  break;
	default:
	  ERROR_EXIT("Not GeoIndex %d!\n", iterGeoPos);
	}
      } else {
	switch (iterGeoPos) {
	case VERTEX:
	  ++vertexIter;
	  break;
	case EDGE:
	  ++edgeIter;
	  break;
	case FACE:
	  ++faceIter;
	  break;
	default:
	  ERROR_EXIT("Not GeoIndex %d!\n", iterGeoPos);
	}
      }

      switch (iterGeoPos) {
      case VERTEX:
	if (vertexIter == vertexInRank.end()) {
	  iterGeoPos = CENTER;
	  return false;
	}
	break;
      case EDGE:
	if (edgeIter == edgeInRank.end()) {
	  iterGeoPos = CENTER;
	  return false;
	}
	break;
      case FACE:
	if (faceIter == faceInRank.end()) {
	  iterGeoPos = CENTER;
	  return false;
	}
	break;
      default:
	ERROR_EXIT("Should not happen!\n");	
      }

      return true;
    }


    std::map<int, ElementObjectData>& getIterateData()
    {
      switch (iterGeoPos) {
      case VERTEX:
	return vertexIter->second;
	break;
      case EDGE:
	return edgeIter->second;
	break;
      case FACE:
	return faceIter->second;
	break;
      default:
	ERROR_EXIT("Should not happen!\n");

	// Will never be reached, just to avoid compiler warnings.
	return faceIter->second;
      }
    }


    int getIterateOwner()
    {
      switch (iterGeoPos) {
      case VERTEX:
	return vertexOwner[vertexIter->first];
	break;
      case EDGE:
	return edgeOwner[edgeIter->first];
	break;
      case FACE:
	return faceOwner[faceIter->first];
	break;
      default:
	ERROR_EXIT("Should not happen!\n");

	// Will never be reached, just to avoid compiler warnings.
	return -1;
      }
    }

    int getOwner(DegreeOfFreedom vertex)
    {
      return vertexOwner[vertex];
    }

    int getOwner(DofEdge edge)
    {
      return edgeOwner[edge];
    }

    int getOwner(DofFace face)
    {
      return faceOwner[face];
    }

    std::vector<ElementObjectData>& getElements(DegreeOfFreedom vertex)
    {
      return vertexElements[vertex];
    }

    std::vector<ElementObjectData>& getElements(DofEdge edge)
    {
      return edgeElements[edge];
    }

    std::vector<ElementObjectData>& getElements(DofFace face)
    {
      return faceElements[face];
    }

  private:
    std::map<int, int> elementInRank;

    std::map<DegreeOfFreedom, std::vector<ElementObjectData> > vertexElements;
    std::map<DofEdge, std::vector<ElementObjectData> > edgeElements;
    std::map<DofFace, std::vector<ElementObjectData> > faceElements;

    std::map<DegreeOfFreedom, int> vertexOwner;
    std::map<DofEdge, int> edgeOwner;
    std::map<DofFace, int> faceOwner;

    std::map<DegreeOfFreedom, std::map<int, ElementObjectData> > vertexInRank;
    std::map<DofEdge, std::map<int, ElementObjectData> > edgeInRank;
    std::map<DofFace, std::map<int, ElementObjectData> > faceInRank;

    std::map<DegreeOfFreedom, std::map<int, ElementObjectData> >::iterator vertexIter;
    std::map<DofEdge, std::map<int, ElementObjectData> >::iterator edgeIter;
    std::map<DofFace, std::map<int, ElementObjectData> >::iterator faceIter;

    GeoIndex iterGeoPos;
  };

}

#endif