Select Git revision
statisticsWindow.cpp
-
Christophe Geuzaine authoredChristophe Geuzaine authored
ChainComplex.cpp 18.98 KiB
// Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
//
// Contributed by Matti Pellikka <matti.pellikka@gmail.com>.
#include "GmshConfig.h"
#if defined(HAVE_KBIPACK)
#include "ChainComplex.h"
ChainComplex::ChainComplex(CellComplex* cellComplex, int domain)
{
_dim = cellComplex->getDim();
_cellComplex = cellComplex;
for(int i = 0; i < 5; i++){
_HMatrix[i] = NULL;
_kerH[i] = NULL;
_codH[i] = NULL;
_JMatrix[i] = NULL;
_QMatrix[i] = NULL;
_Hbasis[i] = NULL;
}
int lastCols = 0;
for(int dim = 0; dim < 4; dim++){
unsigned int cols = cellComplex->getSize(dim);
unsigned int rows = 0;
int index = 1;
// ignore cells depending on domain
for(CellComplex::citer cit = cellComplex->firstCell(dim);
cit != cellComplex->lastCell(dim); cit++){
Cell* cell = *cit;
cols--;
if((domain == 0 && !cell->inSubdomain()) || domain == 1
|| (domain == 2 && cell->inSubdomain()) ){
cols++;
_cellIndices[dim][cell] = index;
index++;
}
else _cellIndices[dim][cell] = 0;
}
if(dim > 0) rows = lastCols;
lastCols = cols;
if(cols == 0){ // no dim-cells, no map
_HMatrix[dim] = NULL;
}
else if(rows == 0){ // no dim-1-cells, maps everything to zero
_HMatrix[dim] = create_gmp_matrix_zero(1, cols);
}
else{
mpz_t elem;
mpz_init(elem);
_HMatrix[dim] = create_gmp_matrix_zero(rows, cols);
for( std::set<Cell*, Less_Cell>::iterator cit =
cellComplex->firstCell(dim);
cit != cellComplex->lastCell(dim); cit++){
Cell* cell = *cit;
if( (domain == 0 && !cell->inSubdomain()) || domain == 1
|| (domain == 2 && cell->inSubdomain()) ){
for(Cell::biter it = cell->firstBoundary();
it != cell->lastBoundary(); it++){
Cell* bdCell = it->first;
if(it->second.get() == 0) continue;
if((domain == 0 && !bdCell->inSubdomain()) || domain == 1