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.6 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 26 27 28 29 30 31 32

/** \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"
33
#include "Serializer.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

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;
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65


    void serialize(std::ostream &out)
    {
      SerUtil::serialize(out, elIndex);
      SerUtil::serialize(out, ithObject);
      SerUtil::serialize(out, boundaryType);
    }


    void deserialize(std::istream &in)
    {
      SerUtil::deserialize(in, elIndex);
      SerUtil::deserialize(in, ithObject);
      SerUtil::deserialize(in, boundaryType);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
66 67 68 69 70 71
  };



  class ElementObjects {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
72 73
    ElementObjects()
      : iterGeoPos(CENTER)
Thomas Witkowski's avatar
Thomas Witkowski committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
    {}

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

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

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

Thomas Witkowski's avatar
Thomas Witkowski committed
94
    void createRankData(std::map<int, int>& macroElementRankMap);
Thomas Witkowski's avatar
Thomas Witkowski committed
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

    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;
      }
    }

197

Thomas Witkowski's avatar
Thomas Witkowski committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
    int getOwner(DegreeOfFreedom vertex)
    {
      return vertexOwner[vertex];
    }

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

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

213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229

    int isInRank(DegreeOfFreedom vertex, int rank)
    {
      return (vertexInRank[vertex].count(rank));
    }

    int isInRank(DofEdge edge, int rank)
    {
      return (edgeInRank[edge].count(rank));
    }

    int isInRank(DofFace face, int rank)
    {
      return (faceInRank[face].count(rank));
    }


Thomas Witkowski's avatar
Thomas Witkowski committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
    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];
    }

245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260

    std::map<int, ElementObjectData>& getElementsInRank(DegreeOfFreedom vertex)
    {
      return vertexInRank[vertex];
    }

    std::map<int, ElementObjectData>& getElementsInRank(DofEdge edge)
    {
      return edgeInRank[edge];
    }

    std::map<int, ElementObjectData>& getElementsInRank(DofFace face)
    {
      return faceInRank[face];
    }

261 262 263 264 265 266 267 268 269 270 271 272 273
    void serialize(std::ostream &out);

    void deserialize(std::istream &in);

  private:
    void serialize(std::ostream &out, std::vector<ElementObjectData>& elVec);

    void deserialize(std::istream &in, std::vector<ElementObjectData>& elVec);

    void serialize(std::ostream &out, std::map<int, ElementObjectData>& data);

    void deserialize(std::istream &in, std::map<int, ElementObjectData>& data);

Thomas Witkowski's avatar
Thomas Witkowski committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
  private:
    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