Skip to content
Snippets Groups Projects
Commit 27f78045 authored by Matti Pellika's avatar Matti Pellika
Browse files

No commit message

No commit message
parent f15af79d
Branches
Tags
No related merge requests found
...@@ -36,8 +36,8 @@ Cell::Cell(MElement* image) : ...@@ -36,8 +36,8 @@ Cell::Cell(MElement* image) :
{ {
_dim = image->getDim(); _dim = image->getDim();
_image = image; _image = image;
for(int i = 0; i < image->getNumVertices(); i++) for(int i = 0; i < getNumVertices(); i++)
_vs.push_back(image->getVertex(i)->getNum()); _vs.push_back(getVertex(i)->getNum());
std::sort(_vs.begin(), _vs.end()); std::sort(_vs.begin(), _vs.end());
} }
...@@ -167,65 +167,58 @@ void Cell::restoreCell(){ ...@@ -167,65 +167,58 @@ void Cell::restoreCell(){
_immune = false; _immune = false;
} }
bool Cell::addBoundaryCell(int orientation, Cell* cell, void Cell::addBoundaryCell(int orientation, Cell* cell,
bool orig, bool other) bool orig, bool other)
{ {
if(orig) _obd.insert( std::make_pair(cell, orientation ) ); if(orig) _obd.insert( std::make_pair(cell, orientation ) );
if(other) cell->addCoboundaryCell(orientation, this);
biter it = _bd.find(cell); biter it = _bd.find(cell);
if(it != _bd.end()){ if(it != _bd.end()){
(*it).second = (*it).second + orientation; int newOrientation = (*it).second + orientation;
if((*it).second == 0) { if(newOrientation != 0) (*it).second = newOrientation;
else {
_bd.erase(it); _bd.erase(it);
(*it).first->removeCoboundaryCell(this,false); (*it).first->removeCoboundaryCell(this,false);
return false; return;
} }
return true;
} }
_bd.insert( std::make_pair(cell, orientation ) ); else _bd.insert( std::make_pair(cell, orientation ) );
return true; if(other) cell->addCoboundaryCell(orientation, this, orig, false);
} }
bool Cell::addCoboundaryCell(int orientation, Cell* cell, void Cell::addCoboundaryCell(int orientation, Cell* cell,
bool orig, bool other) bool orig, bool other)
{ {
if(orig) _ocbd.insert( std::make_pair(cell, orientation ) ); if(orig) _ocbd.insert( std::make_pair(cell, orientation ) );
if(other) cell->addBoundaryCell(orientation, this);
biter it = _cbd.find(cell); biter it = _cbd.find(cell);
if(it != _cbd.end()){ if(it != _cbd.end()){
(*it).second = (*it).second + orientation; int newOrientation = (*it).second + orientation;
if((*it).second == 0) { if(newOrientation != 0) (*it).second = newOrientation;
else {
_cbd.erase(it); _cbd.erase(it);
(*it).first->removeBoundaryCell(this,false); (*it).first->removeBoundaryCell(this,false);
return false; return;
} }
return true;
} }
_cbd.insert( std::make_pair(cell, orientation ) ); else _cbd.insert( std::make_pair(cell, orientation ) );
return true; if(other) cell->addBoundaryCell(orientation, this, orig, false);
} }
int Cell::removeBoundaryCell(Cell* cell, bool other) void Cell::removeBoundaryCell(Cell* cell, bool other)
{ {
biter it = _bd.find(cell); biter it = _bd.find(cell);
if(it != _bd.end()){ if(it != _bd.end()){
_bd.erase(it); _bd.erase(it);
if(other) (*it).first->removeCoboundaryCell(this, false); if(other) (*it).first->removeCoboundaryCell(this, false);
return (*it).second;
} }
return 0;
} }
int Cell::removeCoboundaryCell(Cell* cell, bool other) void Cell::removeCoboundaryCell(Cell* cell, bool other)
{ {
biter it = _cbd.find(cell); biter it = _cbd.find(cell);
if(it != _cbd.end()){ if(it != _cbd.end()){
_cbd.erase(it); _cbd.erase(it);
if(other) (*it).first->removeBoundaryCell(this, false); if(other) (*it).first->removeBoundaryCell(this, false);
return (*it).second;
} }
return 0;
} }
bool Cell::hasBoundary(Cell* cell, bool orig) bool Cell::hasBoundary(Cell* cell, bool orig)
...@@ -329,7 +322,7 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() ...@@ -329,7 +322,7 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell()
Cell* cell = (*it).first; Cell* cell = (*it).first;
int ori = (*it).second; int ori = (*it).second;
cell->removeCoboundaryCell(c1); cell->removeCoboundaryCell(c1);
if(this->addBoundaryCell(ori, cell)) cell->addCoboundaryCell(ori, this); this->addBoundaryCell(ori, cell, false, true);
} }
for(biter it = c2Boundary.begin(); it != c2Boundary.end(); it++){ for(biter it = c2Boundary.begin(); it != c2Boundary.end(); it++){
Cell* cell = (*it).first; Cell* cell = (*it).first;
...@@ -338,13 +331,11 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() ...@@ -338,13 +331,11 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell()
cell->removeCoboundaryCell(c2); cell->removeCoboundaryCell(c2);
if(co){ if(co){
biter it2 = c1Boundary.find(cell); biter it2 = c1Boundary.find(cell);
if(it2 == c1Boundary.end() && this->addBoundaryCell(ori, cell)) { if(it2 == c1Boundary.end()){
cell->addCoboundaryCell(ori, this); this->addBoundaryCell(ori, cell, false, true);
} }
} }
else{ else this->addBoundaryCell(ori, cell, false, true);
if(this->addBoundaryCell(ori, cell)) cell->addCoboundaryCell(ori, this);
}
} }
// coboundary cells // coboundary cells
...@@ -357,7 +348,7 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() ...@@ -357,7 +348,7 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell()
Cell* cell = (*it).first; Cell* cell = (*it).first;
int ori = (*it).second; int ori = (*it).second;
cell->removeBoundaryCell(c1); cell->removeBoundaryCell(c1);
if(this->addCoboundaryCell(ori, cell)) cell->addBoundaryCell(ori, this); this->addCoboundaryCell(ori, cell, false, true);
} }
for(biter it = c2Coboundary.begin(); it != c2Coboundary.end(); it++){ for(biter it = c2Coboundary.begin(); it != c2Coboundary.end(); it++){
Cell* cell = (*it).first; Cell* cell = (*it).first;
...@@ -366,13 +357,11 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell() ...@@ -366,13 +357,11 @@ CombinedCell::CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co) : Cell()
cell->removeBoundaryCell(c2); cell->removeBoundaryCell(c2);
if(!co){ if(!co){
biter it2 = c1Coboundary.find(cell); biter it2 = c1Coboundary.find(cell);
if(it2 == c1Coboundary.end() && this->addCoboundaryCell(ori, cell)){ if(it2 == c1Coboundary.end()){
cell->addBoundaryCell(ori, this); this->addCoboundaryCell(ori, cell, false, true);
} }
} }
else { else this->addCoboundaryCell(ori, cell, false, true);
if(this->addCoboundaryCell(ori, cell)) cell->addBoundaryCell(ori, this);
}
} }
} }
......
...@@ -75,7 +75,7 @@ class Cell ...@@ -75,7 +75,7 @@ class Cell
// get the number of vertices this cell has // get the number of vertices this cell has
int getNumVertices() const { int getNumVertices() const {
if(_image == NULL) printf("ERROR: No image mesh element for cell. \n"); if(_image == NULL) printf("ERROR: No image mesh element for cell. \n");
return _image->getNumVertices(); } return _image->getNumPrimaryVertices(); }
// get the number of facets of this cell // get the number of facets of this cell
int getNumFacets() const; int getNumFacets() const;
// get the vertices on a facet of this cell // get the vertices on a facet of this cell
...@@ -143,14 +143,14 @@ class Cell ...@@ -143,14 +143,14 @@ class Cell
orig ? coboundary = _ocbd : coboundary = _cbd; } orig ? coboundary = _ocbd : coboundary = _cbd; }
// add (co)boundary cell // add (co)boundary cell
virtual bool addBoundaryCell(int orientation, Cell* cell, virtual void addBoundaryCell(int orientation, Cell* cell,
bool orig=false, bool other=false); bool orig=false, bool other=true);
virtual bool addCoboundaryCell(int orientation, Cell* cell, virtual void addCoboundaryCell(int orientation, Cell* cell,
bool orig=false, bool other=false); bool orig=false, bool other=true);
// remove (co)boundary cell // remove (co)boundary cell
virtual int removeBoundaryCell(Cell* cell, bool other=true); virtual void removeBoundaryCell(Cell* cell, bool other=true);
virtual int removeCoboundaryCell(Cell* cell, bool other=true); virtual void removeCoboundaryCell(Cell* cell, bool other=true);
// true if has given cell on (original) (co)boundary // true if has given cell on (original) (co)boundary
virtual bool hasBoundary(Cell* cell, bool orig=false); virtual bool hasBoundary(Cell* cell, bool orig=false);
......
...@@ -81,8 +81,7 @@ bool CellComplex::insert_cells(std::vector<MElement*>& elements, ...@@ -81,8 +81,7 @@ bool CellComplex::insert_cells(std::vector<MElement*>& elements,
} }
if(!subdomain) { if(!subdomain) {
int ori = cell->getFacetOri(newCell); int ori = cell->getFacetOri(newCell);
cell->addBoundaryCell( ori, newCell, true); cell->addBoundaryCell( ori, newCell, true, true);
newCell->addCoboundaryCell( ori, cell, true);
} }
} }
} }
...@@ -267,9 +266,6 @@ int CellComplex::reduceComplex(bool omit) ...@@ -267,9 +266,6 @@ int CellComplex::reduceComplex(bool omit)
int count = 0; int count = 0;
for(int i = 3; i > 0; i--) count = count + reduction(i); for(int i = 3; i > 0; i--) count = count + reduction(i);
printf(" %d volumes, %d faces, %d edges and %d vertices. \n",
getSize(3), getSize(2), getSize(1), getSize(0));
if(omit){ if(omit){
int omitted = 0; int omitted = 0;
_store.clear(); _store.clear();
...@@ -290,12 +286,15 @@ int CellComplex::reduceComplex(bool omit) ...@@ -290,12 +286,15 @@ int CellComplex::reduceComplex(bool omit)
} }
} }
printf(" %d volumes, %d faces, %d edges and %d vertices. \n",
getSize(3), getSize(2), getSize(1), getSize(0));
combine(3); combine(3);
reduction(2); reduction(2);
combine(2); combine(2);
reduction(1); reduction(1);
combine(1); combine(1);
printf(" %d volumes, %d faces, %d edges and %d vertices. \n", printf(" %d volumes, %d faces, %d edges and %d vertices. \n",
getSize(3), getSize(2), getSize(1), getSize(0)); getSize(3), getSize(2), getSize(1), getSize(0));
...@@ -332,10 +331,6 @@ int CellComplex::coreduceComplex(bool omit) ...@@ -332,10 +331,6 @@ int CellComplex::coreduceComplex(bool omit)
} }
} }
printf(" %d volumes, %d faces, %d edges and %d vertices. \n",
getSize(3), getSize(2), getSize(1), getSize(0));
int omitted = 0; int omitted = 0;
if(omit){ if(omit){
_store.clear(); _store.clear();
...@@ -352,6 +347,9 @@ int CellComplex::coreduceComplex(bool omit) ...@@ -352,6 +347,9 @@ int CellComplex::coreduceComplex(bool omit)
coreduction(cell, omitted); coreduction(cell, omitted);
} }
} }
printf(" %d volumes, %d faces, %d edges and %d vertices. \n",
getSize(3), getSize(2), getSize(1), getSize(0));
cocombine(0); cocombine(0);
coreduction(1); coreduction(1);
...@@ -508,7 +506,7 @@ bool CellComplex::coherent() ...@@ -508,7 +506,7 @@ bool CellComplex::coherent()
} }
if(!bdCell->hasCoboundary(cell)){ if(!bdCell->hasCoboundary(cell)){
printf("Warning! Incoherent boundary/coboundary pair! Fixed. \n"); printf("Warning! Incoherent boundary/coboundary pair! Fixed. \n");
bdCell->addCoboundaryCell(ori, cell); bdCell->addCoboundaryCell(ori, cell, false, false);
coherent = false; coherent = false;
} }
...@@ -527,7 +525,7 @@ bool CellComplex::coherent() ...@@ -527,7 +525,7 @@ bool CellComplex::coherent()
} }
if(!cbdCell->hasBoundary(cell)){ if(!cbdCell->hasBoundary(cell)){
printf("Warning! Incoherent coboundary/boundary pair! Fixed. \n"); printf("Warning! Incoherent coboundary/boundary pair! Fixed. \n");
cbdCell->addBoundaryCell(ori, cell); cbdCell->addBoundaryCell(ori, cell, false, false);
coherent = false; coherent = false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment