// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == crystal growth group == // == == // == Stiftung caesar == // == Ludwig-Erhard-Allee 2 == // == 53175 Bonn == // == germany == // == == // ============================================================================ // == == // == http://www.caesar.de/cg/AMDiS == // == == // ============================================================================ /** \file MeshStructure.h */ #ifndef AMDIS_MESHSTRUCTURE_H #define AMDIS_MESHSTRUCTURE_H #include #include "MemoryManager.h" namespace AMDiS { class RefinementManager; class TraverseStack; class ElInfo; class MeshStructure { public: MEMORY_MANAGED(MeshStructure); MeshStructure() : currentIndex_(0), currentCode_(0), pos_(0), currentElement_(0), numElements_(0) {}; void clear(); void init(Mesh *mesh); void init(const std::vector& code, int numElements) { code_ = code; numElements_ = numElements; reset(); }; void reset(); void insertElement(bool isLeaf); inline void commit() { if(pos_ > 0) { code_.push_back(currentCode_); } reset(); }; bool skipBranch(MeshStructure *insert = NULL); ElInfo *skipBranch(ElInfo *elInfo, TraverseStack *stack); bool nextElement(MeshStructure *insert = NULL); inline bool isLeafElement() { return (currentCode_ & 1) == 0; }; void merge(MeshStructure *structure) { MeshStructure temp(*this); merge(&temp, structure, this); }; static void merge(MeshStructure *structure1, MeshStructure *structure2, MeshStructure *result); void fitMeshToStructure(Mesh *mesh, RefinementManager *manager, bool checkPartition = false); void print() { FUNCNAME("MeshStructure::print()"); reset(); bool cont = true; while(cont) { if(isLeafElement()) { MSG("0"); } else { MSG("1"); } cont = nextElement(); } MSG("\n"); }; inline const std::vector& getCode() { return code_; }; inline int getNumElements() { return numElements_; }; inline int getCurrentElement() { return currentElement_; }; protected: std::vector code_; int currentIndex_; unsigned long int currentCode_; int pos_; int currentElement_; int numElements_; static const int unsignedLongSize_; }; } #endif