From 4a6efb1dc59aedf05ad617eeea92aeff1bbb5224 Mon Sep 17 00:00:00 2001 From: Matti Pellika <matti.pellikka@tut.fi> Date: Mon, 23 Jan 2012 10:07:15 +0000 Subject: [PATCH] Cleanup --- Geo/Cell.cpp | 296 +++++++++++++++++++++++---------------------------- Geo/Cell.h | 72 ++++++------- 2 files changed, 162 insertions(+), 206 deletions(-) diff --git a/Geo/Cell.cpp b/Geo/Cell.cpp index 6c83d6ac2a..ea9ccbc8ae 100755 --- a/Geo/Cell.cpp +++ b/Geo/Cell.cpp @@ -7,15 +7,15 @@ #include "Cell.h" -bool Less_Cell::operator()(const Cell* c1, const Cell* c2) const -{ +bool Less_Cell::operator()(const Cell* c1, const Cell* c2) const +{ // If cell complex is done use enumeration (same as vertex order) if(c1->getNum() != 0) return (c1->getNum() < c2->getNum()); - + // Otherwise order by vertex numbering (good heuristic for reduction) if(c1->getNumSortedVertices() != c2->getNumSortedVertices()){ return (c1->getNumSortedVertices() < c2->getNumSortedVertices()); - } + } for(int i=0; i < c1->getNumSortedVertices();i++){ if(c1->getSortedVertex(i) < c2->getSortedVertex(i)) return true; else if (c1->getSortedVertex(i) > c2->getSortedVertex(i)) return false; @@ -24,9 +24,8 @@ bool Less_Cell::operator()(const Cell* c1, const Cell* c2) const } int Cell::_globalNum = 0; -Cell::Cell(int dim, std::vector<MVertex*>& v) -{ - _pnum = 0; +Cell::Cell(int dim, std::vector<MVertex*>& v) +{ _dim = dim; _domain = 0; _combined = false; @@ -34,120 +33,96 @@ Cell::Cell(int dim, std::vector<MVertex*>& v) _v = v; std::sort(_v.begin(), _v.end(), MVertexLessThanNum()); - //_num = ++_globalNum; _num = 0; _index = 0; } -/*Cell::Cell(int num, int dim, int type, std::vector<int>& v, int domain) -{ - _num = num; - _dim = dim; - _domain = domain; - _combined = false; - _immune = false; - _type = type; - _v = v; - _index = 0; - }*/ Cell::Cell(MElement* element, int domain) -{ - _pnum = element->getNum(); +{ _dim = element->getDim(); _domain = domain; _combined = false; _immune = false; - int type = element->getType(); - if(type != TYPE_PNT && type != TYPE_LIN && type != TYPE_TRI && type != TYPE_TET) _type = 2; - else _type = 1; for(int i = 0; i < element->getNumPrimaryVertices(); i++){ _v.push_back(element->getVertex(i)); } std::sort(_v.begin(), _v.end(), MVertexLessThanNum()); - //_num = ++_globalNum; _num = 0; _index = 0; - + } Cell::Cell(Cell* parent, int i) -{ - _pnum = parent->getParentNum(); +{ _dim = parent->getDim()-1; _domain = parent->getDomain(); _combined = false; _immune = false; - parent->findBdElement(i, _type, _v); + parent->findBdElement(i, _v); std::sort(_v.begin(), _v.end(), MVertexLessThanNum()); - //_num = ++_globalNum; _num = 0; _index = 0; - + } -void Cell::findBdElement(int i, int& type, std::vector<MVertex*>& vertices) const +void Cell::findBdElement(int i, std::vector<MVertex*>& vertices) const { vertices.clear(); - type = 0; - if(_type == 1){ - if(_dim == 1){ // i = 0 -> ori = -1, i = 1 -> ori = 1 - type = 1; - vertices.push_back(_v[i]); + if(_dim == 1){ // i = 0 -> ori = -1, i = 1 -> ori = 1 + vertices.push_back(_v[i]); + } + else if(_dim == 2){ + if(i == 0){ // ori = 1 + vertices.push_back(_v[0]); + vertices.push_back(_v[1]); } - else if(_dim == 2){ - type = 1; - if(i == 0){ // ori = 1 - vertices.push_back(_v[0]); - vertices.push_back(_v[1]); - } - else if(i == 1){ // ori = 1 - vertices.push_back(_v[1]); - vertices.push_back(_v[2]); - } - else if(i == 2){ // ori = 1 - vertices.push_back(_v[2]); - vertices.push_back(_v[0]); - } + else if(i == 1){ // ori = 1 + vertices.push_back(_v[1]); + vertices.push_back(_v[2]); } - else if(_dim == 3){ - type = 1; - if(i == 0){ - vertices.push_back(_v[0]); - vertices.push_back(_v[2]); - vertices.push_back(_v[1]); - } - else if(i == 1){ - vertices.push_back(_v[0]); - vertices.push_back(_v[1]); - vertices.push_back(_v[3]); - } - else if(i == 2){ - vertices.push_back(_v[0]); - vertices.push_back(_v[3]); - vertices.push_back(_v[2]); - } - else if(i == 3){ - vertices.push_back(_v[3]); - vertices.push_back(_v[1]); - vertices.push_back(_v[2]); - } + else if(i == 2){ // ori = 1 + vertices.push_back(_v[2]); + vertices.push_back(_v[0]); + } + } + else if(_dim == 3){ + if(i == 0){ + vertices.push_back(_v[0]); + vertices.push_back(_v[2]); + vertices.push_back(_v[1]); + } + else if(i == 1){ + vertices.push_back(_v[0]); + vertices.push_back(_v[1]); + vertices.push_back(_v[3]); + } + else if(i == 2){ + vertices.push_back(_v[0]); + vertices.push_back(_v[3]); + vertices.push_back(_v[2]); + } + else if(i == 3){ + vertices.push_back(_v[3]); + vertices.push_back(_v[1]); + vertices.push_back(_v[2]); } } } -int Cell::getNumBdElements() const -{ + +int Cell::getNumBdElements() const +{ if(_dim == 0) return 0; else if(_dim == 1) return 2; - else if(_dim == 2 && _type == 1) return 3; - else if(_dim == 3 && _type == 1) return 4; + else if(_dim == 2) return 3; + else if(_dim == 3) return 4; else return 0; } -int Cell::findBdCellOrientation(Cell* cell) const -{ +int Cell::findBdCellOrientation(Cell* cell) const +{ std::vector<MVertex*> v; cell->getMeshVertices(v); if(_dim == 0) return 0; @@ -155,80 +130,76 @@ int Cell::findBdCellOrientation(Cell* cell) const if(v[0]->getNum() == _v[0]->getNum()) return -1; else if(v[0]->getNum() == _v[1]->getNum()) return 1; } - else if(_type == 1){ - if(_dim == 2){ - if (v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[1]->getNum() ) return 1; - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[0]->getNum() ) return -1; - - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[2]->getNum() ) return 1; - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[1]->getNum() ) return -1; - - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[0]->getNum() ) return 1; - else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[2]->getNum() ) return -1; - } - else if(_dim == 3) { - if (v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[1]->getNum() ) return 1; - else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[2]->getNum()) return -1; - - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[0]->getNum()) return 1; - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[1]->getNum()) return -1; - - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[2]->getNum()) return 1; - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[0]->getNum()) return -1; - - - else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[3]->getNum() ) return 1; - else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[1]->getNum()) return -1; - - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[0]->getNum()) return 1; - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[3]->getNum()) return -1; - - else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[1]->getNum()) return 1; - else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[0]->getNum()) return -1; - - - else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[2]->getNum() ) return 1; - else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[3]->getNum()) return -1; - - else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[3]->getNum()) return 1; - else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[2]->getNum()) return -1; - - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[3]->getNum()) return 1; - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[0]->getNum()) return -1; - - - else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[2]->getNum() ) return 1; - else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[1]->getNum()) return -1; - - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[3]->getNum()) return 1; - else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[2]->getNum()) return -1; - - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[1]->getNum()) return 1; - else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[3]->getNum()) return -1; - } + if(_dim == 2){ + if (v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[1]->getNum() ) return 1; + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[0]->getNum() ) return -1; + + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[2]->getNum() ) return 1; + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[1]->getNum() ) return -1; + + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[0]->getNum() ) return 1; + else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[2]->getNum() ) return -1; + } + else if(_dim == 3) { + if (v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[1]->getNum() ) return 1; + else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[2]->getNum()) return -1; + + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[0]->getNum()) return 1; + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[1]->getNum()) return -1; + + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[2]->getNum()) return 1; + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[0]->getNum()) return -1; + + + else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[3]->getNum() ) return 1; + else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[1]->getNum()) return -1; + + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[0]->getNum()) return 1; + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[3]->getNum()) return -1; + + else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[1]->getNum()) return 1; + else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[0]->getNum()) return -1; + + + else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[2]->getNum() ) return 1; + else if(v[0]->getNum() == _v[0]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[3]->getNum()) return -1; + + else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[3]->getNum()) return 1; + else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[2]->getNum()) return -1; + + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[0]->getNum() && v[2]->getNum() == _v[3]->getNum()) return 1; + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[0]->getNum()) return -1; + + + else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[2]->getNum() ) return 1; + else if(v[0]->getNum() == _v[3]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[1]->getNum()) return -1; + + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[2]->getNum() && v[2]->getNum() == _v[3]->getNum()) return 1; + else if(v[0]->getNum() == _v[1]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[2]->getNum()) return -1; + + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[3]->getNum() && v[2]->getNum() == _v[1]->getNum()) return 1; + else if(v[0]->getNum() == _v[2]->getNum() && v[1]->getNum() == _v[1]->getNum() && v[2]->getNum() == _v[3]->getNum()) return -1; } return 0; } -int Cell::getTypeMSH() const +int Cell::getTypeMSH() const { - if(_type == 1){ - if(_dim == 0) return 15; - else if(_dim == 1) return 1; - else if(_dim == 2) return 2; - else if(_dim == 3) return 4; - } + if(_dim == 0) return 15; + else if(_dim == 1) return 1; + else if(_dim == 2) return 2; + else if(_dim == 3) return 4; else return 0; } -bool Cell::hasVertex(int vertex) const +bool Cell::hasVertex(int vertex) const { //_vs std::vector<int> v; for(unsigned int i = 0; i < _v.size(); i++) { v.push_back(_v[i]->getNum()); } - std::vector<int>::const_iterator it = std::find(v.begin(), v.end(), + std::vector<int>::const_iterator it = std::find(v.begin(), v.end(), vertex); if (it != v.end()) return true; else return false; @@ -243,7 +214,7 @@ bool CombinedCell::hasVertex(int vertex) const return false; } -void Cell::printCell() +void Cell::printCell() { printf("%d-cell %d: \n" , getDim(), getNum()); printf("Vertices: "); @@ -269,10 +240,10 @@ void Cell::restoreCell(){ for(unsigned int i = 0; i < toRemove.size(); i++) _bd.erase(toRemove[i]); _combined = false; _index = 0; - _immune = false; + _immune = false; } -void Cell::addBoundaryCell(int orientation, Cell* cell, bool other) +void Cell::addBoundaryCell(int orientation, Cell* cell, bool other) { biter it = _bd.find(cell); if(it != _bd.end()){ @@ -290,7 +261,7 @@ void Cell::addBoundaryCell(int orientation, Cell* cell, bool other) if(other) cell->addCoboundaryCell(orientation, this, false); } -void Cell::addCoboundaryCell(int orientation, Cell* cell, bool other) +void Cell::addCoboundaryCell(int orientation, Cell* cell, bool other) { biter it = _cbd.find(cell); if(it != _cbd.end()){ @@ -308,7 +279,7 @@ void Cell::addCoboundaryCell(int orientation, Cell* cell, bool other) if(other) cell->addBoundaryCell(orientation, this, false); } -void Cell::removeBoundaryCell(Cell* cell, bool other) +void Cell::removeBoundaryCell(Cell* cell, bool other) { biter it = _bd.find(cell); if(it != _bd.end()){ @@ -317,8 +288,8 @@ void Cell::removeBoundaryCell(Cell* cell, bool other) if(other) it->first->removeCoboundaryCell(this, false); } } - -void Cell::removeCoboundaryCell(Cell* cell, bool other) + +void Cell::removeCoboundaryCell(Cell* cell, bool other) { biter it = _cbd.find(cell); if(it != _cbd.end()){ @@ -327,7 +298,7 @@ void Cell::removeCoboundaryCell(Cell* cell, bool other) if(other) it->first->removeBoundaryCell(this, false); } } - + bool Cell::hasBoundary(Cell* cell, bool orig) { if(!orig){ @@ -353,11 +324,11 @@ bool Cell::hasCoboundary(Cell* cell, bool orig) biter it = _cbd.find(cell); if(it != _cbd.end() && it->second.geto() != 0) return true; return false; - } + } } /* -void Cell::printBoundary(bool orig) -{ +void Cell::printBoundary(bool orig) +{ for(biter it = firstBoundary(orig); it != lastBoundary(orig); it++){ printf("Boundary cell orientation: %d ", (*it).second); Cell* cell2 = (*it).first; @@ -368,7 +339,7 @@ void Cell::printBoundary(bool orig) } } -void Cell::printCoboundary(bool orig) +void Cell::printCoboundary(bool orig) { for(biter it = firstCoboundary(orig); it != lastCoboundary(orig); it++){ printf("Coboundary cell orientation: %d, ", (*it).second); @@ -380,15 +351,15 @@ void Cell::printCoboundary(bool orig) } }*/ -CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() -{ +CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() +{ // use "smaller" cell as c2 if(c1->getNumCells() < c2->getNumCells()){ Cell* temp = c1; c1 = c2; c2 = temp; } - + _num = ++_globalNum; _index = c1->getIndex(); _domain = c1->getDomain(); @@ -409,7 +380,7 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() Cell* cell = it->first; int ori = it->second.get(); if(ori == 0) continue; - cell->removeCoboundaryCell(c1, false); + cell->removeCoboundaryCell(c1, false); this->addBoundaryCell(ori, cell, true); } for(biter it = c2->firstBoundary(); it != c2->lastBoundary(); it++){ @@ -417,21 +388,19 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() if(!orMatch) it->second.set(-1*it->second.get()); int ori = it->second.get(); if(ori == 0) continue; - cell->removeCoboundaryCell(c2, false); + cell->removeCoboundaryCell(c2, false); if(co && !c1->hasBoundary(cell)){ this->addBoundaryCell(ori, cell, true); } else if(!co) this->addBoundaryCell(ori, cell, true); } - c1->clearBoundary(); - c2->clearBoundary(); // coboundary cells for(biter it = c1->firstCoboundary(); it != c1->lastCoboundary(); it++){ Cell* cell = it->first; int ori = it->second.get(); if(ori == 0) continue; - cell->removeBoundaryCell(c1, false); + cell->removeBoundaryCell(c1, false); this->addCoboundaryCell(ori, cell, true); } for(biter it = c2->firstCoboundary(); it != c2->lastCoboundary(); it++){ @@ -439,20 +408,17 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() if(!orMatch) it->second.set(-1*it->second.get()); int ori = it->second.get(); if(ori == 0) continue; - cell->removeBoundaryCell(c2, false); + cell->removeBoundaryCell(c2, false); if(!co && !c1->hasCoboundary(cell)){ this->addCoboundaryCell(ori, cell, true); } else if(co) this->addCoboundaryCell(ori, cell, true); } - c1->clearCoboundary(); - c2->clearCoboundary(); - } -CombinedCell::CombinedCell(std::vector<Cell*>& cells) : Cell() -{ +CombinedCell::CombinedCell(std::vector<Cell*>& cells) : Cell() +{ _num = ++_globalNum; _index = cells.at(0)->getIndex(); _domain = cells.at(0)->getDomain(); diff --git a/Geo/Cell.h b/Geo/Cell.h index d2df4a4ef3..7fb65e077b 100644 --- a/Geo/Cell.h +++ b/Geo/Cell.h @@ -27,11 +27,11 @@ class BdInfo { public: BdInfo(int ori) { _ori = ori; _origOri = 0; } - + int get() const { return _ori; } void reset() { _ori = _origOri; } void init() { _origOri = _ori; } - void set(int ori) { _ori = ori; } + void set(int ori) { _ori = ori; } int geto() const { return _origOri; } }; @@ -42,7 +42,7 @@ class Cell { protected: static int _globalNum; - + int _num; // mutable index for each cell (used to create boundary operator matrices) int _index; @@ -50,26 +50,24 @@ class Cell { int _domain; // whether this cell a combinded cell of elemetary cells - bool _combined; + bool _combined; // for some algorithms to omit this cell bool _immune; // list of cells on the boundary and on the coboundary of this cell std::map<Cell*, BdInfo, Less_Cell> _bd; std::map<Cell*, BdInfo, Less_Cell> _cbd; - + private: int _dim; - int _pnum; - int _type; // sorted vertices of this cell (used for ordering of the cells) std::vector<MVertex*> _v; public: - Cell(int dim, std::vector<MVertex*>& v); - Cell() : _num(0), _dim(0), _index(0), _type(0), _domain(0), _combined(false), _immune(false) {} + Cell(int dim, std::vector<MVertex*>& v); + Cell() : _num(0), _dim(0), _index(0), _domain(0), _combined(false), _immune(false) {} Cell(MElement* element, int domain); Cell(Cell* parent, int i); @@ -77,10 +75,8 @@ class Cell { int getDomain() const { return _domain; } int getNum() const { return _num; } void setNum(int num) { _num = num; }; - int getType() const { return _type; } - int getTypeMSH() const; + int getTypeMSH() const; virtual int getDim() const { return _dim; } - int getParentNum() const { return _pnum; } bool inSubdomain() const { if(_domain != 0) return true; else return false; } void getMeshVertices(std::vector<MVertex*>& v) const { v = _v; } @@ -96,7 +92,7 @@ class Cell { MVertex* getMeshVertex(int vertex) const { return _v.at(vertex); } void clearSortedVertices() { _v.clear(); } - void findBdElement(int i, int& type, std::vector<MVertex*>& vertices) const; + void findBdElement(int i, std::vector<MVertex*>& vertices) const; int getNumBdElements() const; int findBdCellOrientation(Cell* cell) const; @@ -105,44 +101,44 @@ class Cell { // restores the cell information to its original state before reduction void restoreCell(); - + // true if this cell has given vertex virtual bool hasVertex(int vertex) const; - + // (co)boundary cell iterator typedef std::map<Cell*, BdInfo, Less_Cell>::iterator biter; // iterators to (first/last (co)boundary cells of this cell // (orig: to original (co)boundary cells of this cell) - biter firstBoundary(bool orig=false){ + biter firstBoundary(bool orig=false){ biter it = _bd.begin(); if(!orig) while(it->second.get() == 0 && it != _bd.end()) it++; else while(it->second.geto() == 0 && it != _bd.end()) it++; return it; } biter lastBoundary(){ return _bd.end(); } - biter firstCoboundary(bool orig=false){ + biter firstCoboundary(bool orig=false){ biter it = _cbd.begin(); if(!orig) while(it->second.get() == 0 && it != _cbd.end()) it++; else while(it->second.geto() == 0 && it != _cbd.end()) it++; - return it; + return it; } biter lastCoboundary(){ return _cbd.end(); } - int getBoundarySize(bool orig=false) { + int getBoundarySize(bool orig=false) { int size = 0; for(biter bit = _bd.begin(); bit != _bd.end(); bit++){ if(!orig && bit->second.get() != 0) size++; else if(orig && bit->second.geto() != 0) size++; } return size; } - int getCoboundarySize(bool orig=false) { + int getCoboundarySize(bool orig=false) { int size = 0; for(biter bit = _cbd.begin(); bit != _cbd.end(); bit++){ if(!orig && bit->second.get() != 0) size++; else if(orig && bit->second.geto() != 0) size++; } return size; } - + // get the (orig: original) cell boundary void getBoundary(std::map<Cell*, short int, Less_Cell >& boundary, bool orig=false){ boundary.clear(); @@ -161,14 +157,13 @@ class Cell { } } - + // add (co)boundary cell // (other: reciprocally also add this cell from the other cell's (co)boundary) - void addBoundaryCell(int orientation, Cell* cell, bool other); + void addBoundaryCell(int orientation, Cell* cell, bool other); void addCoboundaryCell(int orientation, Cell* cell, bool other); - - //void saveOriginalBd() { _obd = _bd; _ocbd = _cbd; } - void saveOriginalBd() { + + void saveOriginalBd() { for(biter it = firstCoboundary(); it != lastCoboundary(); it++){ it->second.init(); } @@ -177,35 +172,31 @@ class Cell { } } - // remove (co)boundary cell + // remove (co)boundary cell // (other: reciprocally also revove this cell from the other cell's (co)boundary) void removeBoundaryCell(Cell* cell, bool other); void removeCoboundaryCell(Cell* cell, bool other); - + // true if has given cell on (orig: original) (co)boundary bool hasBoundary(Cell* cell, bool orig=false); bool hasCoboundary(Cell* cell, bool orig=false); - - void clearBoundary() { }//_bd.clear(); } - void clearCoboundary() {}// _cbd.clear(); } - + // print cell debug info virtual void printCell(); //virtual void printBoundary(bool orig=false); - //virtual void printCoboundary(bool orig=false); - + //virtual void printCoboundary(bool orig=false); + // tools for combined cells bool isCombined() const { return _combined; } - virtual void getCells( std::map< Cell*, int, Less_Cell >& cells) { + virtual void getCells( std::map< Cell*, int, Less_Cell >& cells) { cells.clear(); - cells[this] = 1; + cells[this] = 1; return; } virtual int getNumCells() const {return 1;} typedef std::map<Cell*, int, Less_Cell>::iterator citer; bool operator==(const Cell& c2) const { - //if(this->isCombined() != c2.isCombined()) return false; return (this->getNum() == c2.getNum()); } @@ -214,24 +205,23 @@ class Cell { // A cell that is a combination of cells of same dimension class CombinedCell : public Cell{ - + private: // list of cells this cell is a combination of std::map< Cell*, int, Less_Cell > _cells; public: - + CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co=false); CombinedCell(std::vector<Cell*>& cells); ~CombinedCell() {} int getDim() const { return _cells.begin()->first->getDim(); } void getCells(std::map< Cell*, int, Less_Cell >& cells) { cells = _cells; } - int getNumCells() const {return _cells.size();} + int getNumCells() const {return _cells.size();} bool hasVertex(int vertex) const; bool operator==(const Cell& c2) const { - //if(this->isCombined() != c2.isCombined()) return false; return (this->getNum() == c2.getNum()); } }; -- GitLab