InteriorBoundary.h 6.07 KB
 1 2 3 4 // ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == ==  Thomas Witkowski committed Dec 16, 2010 5 // == http://www.amdis-fem.org ==  6 7 // == == // ============================================================================  Thomas Witkowski committed Dec 16, 2010 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.  20 21 22 23 24 25 26  /** \file InteriorBoundary.h */ #ifndef AMDIS_INTERIORBOUNDARY_H #define AMDIS_INTERIORBOUNDARY_H #include  Thomas Witkowski committed Apr 27, 2009 27 #include  28   Thomas Witkowski committed Sep 28, 2009 29 #include "AMDiS_fwd.h"  Thomas Witkowski committed Jan 22, 2010 30 31 #include "MacroElement.h" #include "Element.h"  Thomas Witkowski committed Jul 08, 2010 32 #include "Boundary.h"  33 34 35  namespace AMDiS {  Thomas Witkowski committed Jan 29, 2010 36 37  typedef std::vector > ExcludeList;  38 39  /// Defines the geometrical objects that forms the boundary; struct BoundaryObject {  Thomas Witkowski committed Jan 22, 2010 40   Thomas Witkowski committed Mar 31, 2011 41 42 43 44 45 46 47  BoundaryObject(); BoundaryObject(Element *e, int eType, GeoIndex sObj, int iObj, bool rMode = false);  48   Thomas Witkowski committed Jan 24, 2011 49 50  static bool computeReverseMode(BoundaryObject &obj0, BoundaryObject &obj1,  51  const FiniteElemSpace *feSpace,  Thomas Witkowski committed Jan 24, 2011 52 53  BoundaryType boundary);  Thomas Witkowski committed Jan 22, 2010 54 55 56 57  bool operator==(const BoundaryObject& other) const; bool operator!=(const BoundaryObject& other) const;  58  /// The macro element to which the boundary element corresponds to.  Thomas Witkowski committed Apr 27, 2009 59  Element* el;  60   Thomas Witkowski committed Jul 16, 2009 61 62 63  /// Index of the macro element. int elIndex;  Thomas Witkowski committed Dec 07, 2009 64 65 66  /// Element type index, only used in 3d. int elType;  67 68 69 70  /** \brief * Defines the geometrical object at the boundary. It must be "a part" of the * macro element \ref el, i.e., either 1 (a vertex), 2 (an edge) or 3 (a face). */  71  GeoIndex subObj;  72 73  /** \brief  Thomas Witkowski committed Jan 12, 2012 74  * Defines which of vertex, edge or face of the macro element is part of the  75 76  * boundary. *  77 78 79  * Example: If the macro element is a triangle, than \ref subObj may be either * 1 (vertex) or 2 (edge). Assume its the last one. So this variable defines * which of the three possible edges of the triangle is at the interior  80 81  * boundary. */  82  int ithObj;  Thomas Witkowski committed Jan 19, 2010 83 84 85  bool reverseMode;  Thomas Witkowski committed Jan 29, 2010 86  /** \brief  Thomas Witkowski committed Jan 12, 2012 87 88 89 90 91 92 93  * In many situations it may be necessary to exclude some parts of the * element to be part of the boundary. In 3d, when a face is part of the * boundary, an edge or an vertex may be exludeded. In 2d only vertices may * be exluded to be part of an edge boundary. This list contains pairs of * exludeded structures. The first component of every pair denotes if it is * a vertex or an edge, and the second component denotes the local index of * the structure.  Thomas Witkowski committed Jan 29, 2010 94 95  */ ExcludeList excludedSubstructures;  96 97 98 99 100 101 102  }; /** \brief * Defines one atomic part of the boundary, i.e., two boundary objects where the * boundary goes through. */ struct AtomicBoundary {  103 104 105 106 107 108  AtomicBoundary() : type(INTERIOR) {} bool operator==(const AtomicBoundary& other) const;  109  /// The rank's part of the boundary.  110  BoundaryObject rankObj;  111 112  /// The object on the other side of the boundary.  113  BoundaryObject neighObj;  Thomas Witkowski committed Jul 08, 2010 114 115 116 117 118  /// Integer flag that is used to distinguish between different types of /// boundaries. Till now it is used only for periodic boundaries, which are also /// handles as interior boundaries. BoundaryType type;  119 120 121 122 123 124 125  }; /** \brief * Defines the interior boundary, i.e. a bound within the domain. It is used for * the classical domain decomposition parallelization. */ class InteriorBoundary {  Thomas Witkowski committed Jul 01, 2009 126 127 128  public: typedef std::map > RankToBoundMap;  Thomas Witkowski committed Feb 05, 2010 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  /// Iterator for the interior boundary object. class iterator { public: iterator(InteriorBoundary &b) : bound(b) { reset(); } /// Set the iterator to the first position. void reset() { mapIt = bound.boundary.begin(); nextNonempty(); if (mapIt != bound.boundary.end()) vecIt = mapIt->second.begin(); } /// Test if iterator is at the final position. bool end() const { return (mapIt == bound.boundary.end()); } /// Move iterator to the next position. void operator++() { ++vecIt; if (vecIt == mapIt->second.end()) { ++mapIt; nextNonempty(); if (mapIt != bound.boundary.end()) vecIt = mapIt->second.begin(); } }  Thomas Witkowski committed Feb 10, 2010 167 168 169 170 171 172 173 174 175 176  inline AtomicBoundary& operator*() { return *vecIt; } inline AtomicBoundary* operator->() { return &(*vecIt); }  Thomas Witkowski committed Feb 05, 2010 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194  void nextRank() { ++mapIt; nextNonempty(); if (mapIt != bound.boundary.end()) vecIt = mapIt->second.begin(); } int getRank() { return mapIt->first; } protected: inline void nextNonempty() {  Thomas Witkowski committed Feb 08, 2010 195 196 197  if (mapIt == bound.boundary.end()) return;  Thomas Witkowski committed Feb 05, 2010 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212  while (mapIt->second.size() == 0) { ++mapIt; if (mapIt == bound.boundary.end()) return; } } protected: RankToBoundMap::iterator mapIt; std::vector::iterator vecIt; InteriorBoundary &bound; };  213  public:  Thomas Witkowski committed Apr 27, 2009 214 215  InteriorBoundary() {}  Thomas Witkowski committed Nov 29, 2010 216 217 218 219 220  void clear() { boundary.clear(); }  Thomas Witkowski committed Oct 14, 2009 221  AtomicBoundary& getNewAtomic(int rank);  Thomas Witkowski committed Apr 27, 2009 222   Thomas Witkowski committed Sep 28, 2009 223  /// Writes this object to a file.  Thomas Witkowski committed Sep 25, 2009 224 225  void serialize(std::ostream &out);  Thomas Witkowski committed Sep 28, 2009 226 227  /// Reads the state of an interior boundary from a file. void deserialize(std::istream &in, std::map &elIndexMap);  Thomas Witkowski committed Sep 25, 2009 228   229 230 231 232  /// Compares this interior boundaries with some other. The order of the /// boundary elements within the object does not play a role. bool operator==(const InteriorBoundary& other) const;  Thomas Witkowski committed Jan 29, 2010 233 234 235 236 237  protected: void serializeExcludeList(std::ostream &out, ExcludeList &list); void deserializeExcludeList(std::istream &in, ExcludeList &list);  Thomas Witkowski committed Apr 27, 2009 238  public:  Thomas Witkowski committed Jul 01, 2009 239  RankToBoundMap boundary;  240 241 242 243  }; } #endif // AMDIS_INTERIORBOUNDARY_H