RCNeighbourList.h 6.71 KB
 Peter Gottschling committed Feb 15, 2008 1 2 3 4 // ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == ==  Thomas Witkowski committed Dec 16, 2010 5 // == http://www.amdis-fem.org ==  Peter Gottschling committed Feb 15, 2008 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.  Peter Gottschling committed Feb 15, 2008 20 21 22 23 24 25 26 27  /** \file RCNeighbourList.h */ #ifndef AMDIS_RCNEIGHBOURLIST_H #define AMDIS_RCNEIGHBOURLIST_H #include #include  Thomas Witkowski committed May 12, 2009 28 #include "AMDiS_fwd.h"  Peter Gottschling committed Feb 15, 2008 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 #include "Global.h" namespace AMDiS { /** \ingroup Adaption * \brief * Stores information about coarsening and refinement patches. For refining * and coarsening we need information of the elements at the refinement and * coarsening edge. Thus, we have to collect all elements at this edge. In 2d * we have at most the current element and its neighbour across this edge, if * the edge is not part of the boundary. In 3d we have to loop around this * edge to collect all the elements. Every element at the edge has at most two * neighbours sharing the same edge. Defining an orientation for this edge, * we can define the right and left neighbour. * For every element at the refinement/coarsening edge we have an entry in a * vector. The elements of this vector build the refinement/coarsening patch. * In 2d the vector has length 2 and in 3d length mesh->getMaxEdgeNeigh() * since this is the maximal number of elements sharing the same edge in the * Mesh. */ class RCNeighbourList { public:  Thomas Witkowski committed May 20, 2009 52  /// Constructs a RCNeighbourList of size maxEdgeNeigh  Peter Gottschling committed Feb 15, 2008 53 54  RCNeighbourList(int maxEdgeNeigh);  Thomas Witkowski committed Nov 06, 2008 55  RCNeighbourList() {}  Peter Gottschling committed Feb 15, 2008 56   Thomas Witkowski committed May 20, 2009 57  /// Destructor  Peter Gottschling committed Feb 15, 2008 58 59  virtual ~RCNeighbourList();  Thomas Witkowski committed May 20, 2009 60  /// Sets flag of \ref rclist[i] = true  Thomas Witkowski committed Jul 03, 2009 61 62  inline void setCoarsePatch(int i) {  Thomas Witkowski committed May 20, 2009 63 64  rclist[i]->flag = true; }  Peter Gottschling committed Feb 15, 2008 65   Thomas Witkowski committed May 20, 2009 66  /// Sets flag of \ref rclist[i] = f  Thomas Witkowski committed Jul 03, 2009 67 68  inline void setCoarsePatch(int i, bool f) {  Thomas Witkowski committed May 20, 2009 69 70  rclist[i]->flag = f; }  Peter Gottschling committed Feb 15, 2008 71   Thomas Witkowski committed May 20, 2009 72  /// Returns \ref rclist[i].flag  Thomas Witkowski committed Jul 03, 2009 73 74  inline const bool isPatchCoarse(int i) const {  Thomas Witkowski committed May 20, 2009 75 76  return rclist[i]->flag; }  Peter Gottschling committed Feb 15, 2008 77 78 79  /** \brief * If \ref rclist[i].neigh[j] is not a NULL pointer  Thomas Witkowski committed Feb 09, 2011 80  * \ref rclist[i].neigh[j]->ith will be returned. Otherwise the return value is -1  Peter Gottschling committed Feb 15, 2008 81  */  Thomas Witkowski committed Jul 03, 2009 82 83  inline int getNeighbourNr(int i, int j) const {  Thomas Witkowski committed Feb 09, 2011 84  return rclist[i]->neigh[j] ? rclist[i]->neigh[j]->ith : -1;  Thomas Witkowski committed Nov 06, 2008 85  }  Peter Gottschling committed Feb 15, 2008 86 87 88 89 90 91  /** \brief * If \ref rclist[i].neigh[j] is not a NULL pointer * \ref rclist[i].neigh[j]->el will be returned. Otherwise the return value * is NULL */  Thomas Witkowski committed Jul 03, 2009 92 93  inline Element* getNeighbourElement(int i, int j) const {  Thomas Witkowski committed Feb 09, 2011 94  return rclist[i]->neigh[j] ? rclist[i]->neigh[j]->el : NULL;  Thomas Witkowski committed Nov 06, 2008 95  }  Peter Gottschling committed Feb 15, 2008 96   Thomas Witkowski committed May 20, 2009 97  /// Returns \ref rclist[i].el  Thomas Witkowski committed Jul 03, 2009 98 99  inline Element* getElement(int i) const {  Thomas Witkowski committed Nov 06, 2008 100 101  if (static_cast(rclist.size()) <= i) return NULL;  Thomas Witkowski committed Feb 09, 2011 102   Peter Gottschling committed Feb 15, 2008 103  return rclist[i]->el;  Thomas Witkowski committed Nov 06, 2008 104  }  Peter Gottschling committed Feb 15, 2008 105   Thomas Witkowski committed May 20, 2009 106  /// Sets \ref rclist[i].el to el and \ref rclist[i].flag to cp.  Thomas Witkowski committed Jul 03, 2009 107 108  inline const Element* setElement(int i, const Element* el, bool cp = false) {  Thomas Witkowski committed Nov 06, 2008 109 110  rclist[i]->el = const_cast(el); rclist[i]->flag = cp;  Thomas Witkowski committed Feb 09, 2011 111   Peter Gottschling committed Feb 15, 2008 112  return el;  Thomas Witkowski committed Nov 06, 2008 113  }  Peter Gottschling committed Feb 15, 2008 114   Thomas Witkowski committed May 20, 2009 115  /// Returns \ref rclist[i].elType  Thomas Witkowski committed Jul 03, 2009 116 117  inline int getType(int i) const {  Thomas Witkowski committed Nov 06, 2008 118 119  return rclist[i]->elType; }  Peter Gottschling committed Feb 15, 2008 120   Thomas Witkowski committed Jul 03, 2009 121 122  inline void setType(int i, int type) const {  Peter Gottschling committed Feb 15, 2008 123  rclist[i]->elType = type;  Thomas Witkowski committed Nov 06, 2008 124  }  Peter Gottschling committed Feb 15, 2008 125   Thomas Witkowski committed May 20, 2009 126  /// If patch can be coarsend return true, else false and reset the element marks.  Peter Gottschling committed Feb 15, 2008 127 128  virtual bool doCoarsePatch(int n_neigh);  Thomas Witkowski committed May 20, 2009 129  /// Sets \ref rclist[i].oppVertex[j] = k  Thomas Witkowski committed Feb 09, 2011 130  inline void setOppVertex(int i, int j, int k)  Thomas Witkowski committed Jul 03, 2009 131  {  Thomas Witkowski committed May 20, 2009 132 133  rclist[i]->oppVertex[j] = k; }  Peter Gottschling committed Feb 15, 2008 134   Thomas Witkowski committed May 20, 2009 135  /// Returns \ref rclist[i].oppVertex[j]  Thomas Witkowski committed Jul 03, 2009 136 137  inline int getOppVertex(int i, int j) {  Thomas Witkowski committed May 20, 2009 138 139  return rclist[i]->oppVertex[j]; }  Peter Gottschling committed Feb 15, 2008 140   Thomas Witkowski committed May 20, 2009 141  /// Sets \ref rclist[i].elType = t  Thomas Witkowski committed Feb 09, 2011 142  inline void setElType(int i, unsigned char t)  Thomas Witkowski committed Jul 03, 2009 143  {  Thomas Witkowski committed May 20, 2009 144 145  rclist[i]->elType = t; }  Peter Gottschling committed Feb 15, 2008 146   Thomas Witkowski committed May 20, 2009 147  /// Sets \ref coarseningManager = cm  Thomas Witkowski committed Jul 03, 2009 148 149  inline void setCoarseningManager(CoarseningManager *cm) {  Peter Gottschling committed Feb 15, 2008 150  coarseningManager = cm;  Thomas Witkowski committed May 20, 2009 151  }  Peter Gottschling committed Feb 15, 2008 152 153  /** \brief  Thomas Witkowski committed Feb 09, 2011 154  * Fills \ref rclist[i].neigh and \ref rclist[i].oppVertex infos (0 <= i  Peter Gottschling committed Feb 15, 2008 155 156  * < n_neigh) */  Thomas Witkowski committed Feb 09, 2011 157  void fillNeighbourRelations(int n_neigh, int bound);  Peter Gottschling committed Feb 15, 2008 158 159 160 161 162 163 164 165 166 167 168 169 170  /** \brief * Adds those dof's on the parent that are handed on by the * children and adds the dof in the midpoint of the coarsening edge (3d) */ void addDOFParent(int elIndex, DegreeOfFreedom* dof); /** \brief * If DOFs for higher order are been removed on parents during refinement * they are now added again (2d) */ void addDOFParents(int n_neigh);  Thomas Witkowski committed May 20, 2009 171  /// Removes DOFs during refinement (3d)  Peter Gottschling committed Feb 15, 2008 172 173  void removeDOFParent(int index);  Thomas Witkowski committed May 20, 2009 174  /// Removes DOFs during refinement (2d)  Peter Gottschling committed Feb 15, 2008 175 176  void removeDOFParents(int n_neigh);  Thomas Witkowski committed Feb 09, 2011 177 178 179 180 181 182 183  void periodicSplit(DegreeOfFreedom *edge[2], DegreeOfFreedom *nextEdge[2], int *n_neigh, int *n_neigh_periodic, RCNeighbourList &periodicList); void clearList();  Peter Gottschling committed Feb 15, 2008 184 185  protected:  Thomas Witkowski committed May 20, 2009 186  /// Information about one Element of the patch  Peter Gottschling committed Feb 15, 2008 187 188 189  class RCListElement { public:  Thomas Witkowski committed May 20, 2009 190  /// Pointer to the Element  Peter Gottschling committed Feb 15, 2008 191 192  Element* el;  Thomas Witkowski committed Feb 09, 2011 193 194  /// This is the i-th entry in the RCNeighbourList int ith;  Peter Gottschling committed Feb 15, 2008 195 196 197 198 199 200 201 202 203 204 205 206 207 208  /** \brief * Only used in the coarsening module: flag is true if the coarsening * edge of the Element is the coarsening edge of the patch, otherwise * flag is false; */ bool flag; /** \brief * neigh[0/1] neighbour of element to the right/left in the orientation * of the edge, or a NULL pointer in the case of a boundary face (only 3d) */ RCListElement* neigh[2];  Thomas Witkowski committed May 20, 2009 209  /// opp vertex[0/1] the opposite vertex of neigh[0/1] (only 3d)  Peter Gottschling committed Feb 15, 2008 210 211 212 213 214 215 216 217 218 219 220 221  int oppVertex[2]; /** \brief * The element type; is set during looping around the * refinement/coarsening edge; if neighbour information is produced by the * traversal routines, information about the type of an element can not be * accessed via el->getType() and thus has to be stored in the * RCListElement vector (only 3d) */ unsigned char elType; };  Thomas Witkowski committed May 20, 2009 222  /// Refinement/coarsening patch  Thomas Witkowski committed Aug 29, 2008 223  std::vector rclist;  Peter Gottschling committed Feb 15, 2008 224   Thomas Witkowski committed May 20, 2009 225  /// Pointer to the CoarseningManager  Peter Gottschling committed Feb 15, 2008 226 227 228 229 230 231  CoarseningManager *coarseningManager; }; } #endif // AMDIS_RCNEIGHBOURLIST_H