Commit 86d20202 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Bug fix

parent acf241d9
...@@ -1544,10 +1544,7 @@ namespace AMDiS { ...@@ -1544,10 +1544,7 @@ namespace AMDiS {
elMat->set(0.0); elMat->set(0.0);
Element *element = elInfo->getElement(); rowFESpace->getBasisFcts()->getLocalIndicesVec(elInfo->getElement(),
rowFESpace->getBasisFcts()->getLocalIndicesVec(element,
rowFESpace->getAdmin(), rowFESpace->getAdmin(),
&(elMat->rowIndices)); &(elMat->rowIndices));
...@@ -1555,7 +1552,7 @@ namespace AMDiS { ...@@ -1555,7 +1552,7 @@ namespace AMDiS {
if (rowFESpace == colFESpace) { if (rowFESpace == colFESpace) {
elMat->colIndices = elMat->rowIndices; elMat->colIndices = elMat->rowIndices;
} else { } else {
colFESpace->getBasisFcts()->getLocalIndicesVec(element, colFESpace->getBasisFcts()->getLocalIndicesVec(elInfo->getElement(),
colFESpace->getAdmin(), colFESpace->getAdmin(),
&(elMat->colIndices)); &(elMat->colIndices));
} }
......
...@@ -43,10 +43,12 @@ namespace AMDiS { ...@@ -43,10 +43,12 @@ namespace AMDiS {
(const_cast<DOFAdmin*>( rowFESpace->getAdmin()))->addDOFIndexed(this); (const_cast<DOFAdmin*>( rowFESpace->getAdmin()))->addDOFIndexed(this);
boundaryManager = NEW BoundaryManager; boundaryManager = NEW BoundaryManager;
elementMatrix = NEW ElementMatrix(rowFESpace->getBasisFcts()->getNumber(),
colFESpace->getBasisFcts()->getNumber());
} }
DOFMatrix::DOFMatrix(const DOFMatrix& rhs) DOFMatrix::DOFMatrix(const DOFMatrix& rhs)
: name(rhs.name+"copy") : name(rhs.name + "copy")
{ {
*this = rhs; *this = rhs;
if (rowFESpace && rowFESpace->getAdmin()) if (rowFESpace && rowFESpace->getAdmin())
...@@ -60,13 +62,14 @@ namespace AMDiS { ...@@ -60,13 +62,14 @@ namespace AMDiS {
if (rowFESpace && rowFESpace->getAdmin()) { if (rowFESpace && rowFESpace->getAdmin()) {
(const_cast<DOFAdmin*>(rowFESpace->getAdmin()))->removeDOFIndexed(this); (const_cast<DOFAdmin*>(rowFESpace->getAdmin()))->removeDOFIndexed(this);
} }
if (elementMatrix)
DELETE elementMatrix;
} }
void DOFMatrix::print() const void DOFMatrix::print() const
{ {
FUNCNAME("DOFMatrix::print()"); FUNCNAME("DOFMatrix::print()");
int i, j, jcol;
DOFMatrix::MatrixRow row;
int sizeUsed = rowFESpace->getAdmin()->getUsedSize(); int sizeUsed = rowFESpace->getAdmin()->getUsedSize();
...@@ -75,19 +78,18 @@ namespace AMDiS { ...@@ -75,19 +78,18 @@ namespace AMDiS {
return; return;
} }
for (i = 0; i < sizeUsed; i++) { for (int i = 0; i < sizeUsed; i++) {
row = matrix[i]; DOFMatrix::MatrixRow row = matrix[i];
MSG("row %3d:",i); MSG("row %3d:",i);
int rowSize = static_cast<int>( row.size()); int rowSize = static_cast<int>( row.size());
for (j = 0; j < rowSize; j++) { for (int j = 0; j < rowSize; j++) {
jcol = row[j].col; int jcol = row[j].col;
if (entryUsed(i,j)) { if (entryUsed(i, j)) {
Msg::print(" (%3d,%20.17lf)", jcol, row[j].entry); Msg::print(" (%3d,%20.17lf)", jcol, row[j].entry);
} }
} }
Msg::print("\n"); Msg::print("\n");
} }
return;
} }
void DOFMatrix::printRow(int i) const void DOFMatrix::printRow(int i) const
...@@ -216,7 +218,13 @@ namespace AMDiS { ...@@ -216,7 +218,13 @@ namespace AMDiS {
if (rhs.boundaryManager) { if (rhs.boundaryManager) {
boundaryManager = new BoundaryManager(*rhs.boundaryManager); boundaryManager = new BoundaryManager(*rhs.boundaryManager);
} else { } else {
boundaryManager=NULL; boundaryManager = NULL;
}
if (rhs.elementMatrix) {
elementMatrix = NEW ElementMatrix(rowFESpace->getBasisFcts()->getNumber(),
colFESpace->getBasisFcts()->getNumber());
} else {
elementMatrix = NULL;
} }
return *this; return *this;
...@@ -230,13 +238,12 @@ namespace AMDiS { ...@@ -230,13 +238,12 @@ namespace AMDiS {
{ {
FUNCNAME("DOFMatrix::addElementMatrix"); FUNCNAME("DOFMatrix::addElementMatrix");
DegreeOfFreedom row, col; DegreeOfFreedom row;
double entry;
int n_row = elMat.rowIndices.getSize(); int nRow = elMat.rowIndices.getSize();
int n_col = elMat.colIndices.getSize(); int nCol = elMat.colIndices.getSize();
for (int i = 0; i < n_row; i++) { // for all rows of element matrix for (int i = 0; i < nRow; i++) { // for all rows of element matrix
row = elMat.rowIndices[i]; row = elMat.rowIndices[i];
BoundaryCondition *condition = BoundaryCondition *condition =
...@@ -252,10 +259,9 @@ namespace AMDiS { ...@@ -252,10 +259,9 @@ namespace AMDiS {
((*matrixRow)[0]).entry = 1.0; ((*matrixRow)[0]).entry = 1.0;
} }
} else { } else {
for (int j = 0; j < n_col; j++) { // for all columns for (int j = 0; j < nCol; j++) { // for all columns
col = elMat.colIndices[j]; addSparseDOFEntry(sign, row, elMat.colIndices[j],
entry = elMat[i][j]; elMat[i][j], add);
addSparseDOFEntry(sign, row, col, entry, add);
} }
} }
} }
...@@ -310,15 +316,14 @@ namespace AMDiS { ...@@ -310,15 +316,14 @@ namespace AMDiS {
return; return;
int freeCol = -1; int freeCol = -1;
int rowSize = static_cast<int>( row->size()); int rowSize = static_cast<int>(row->size());
TEST_EXIT_DBG(jcol >= 0 && TEST_EXIT_DBG(jcol >= 0 &&
jcol < colFESpace->getAdmin()->getUsedSize()) jcol < colFESpace->getAdmin()->getUsedSize())
("Column index %d out of range 0-%d\n", jcol, colFESpace->getAdmin()->getUsedSize() - 1); ("Column index %d out of range 0-%d\n", jcol, colFESpace->getAdmin()->getUsedSize() - 1);
// first entry is diagonal entry // first entry is diagonal entry
if (rowFESpace == colFESpace) if ((rowSize == 0) && (rowFESpace == colFESpace)) {
if (rowSize == 0) {
MatEntry newEntry = {irow, 0.0}; MatEntry newEntry = {irow, 0.0};
row->push_back(newEntry); row->push_back(newEntry);
rowSize = 1; rowSize = 1;
...@@ -339,7 +344,7 @@ namespace AMDiS { ...@@ -339,7 +344,7 @@ namespace AMDiS {
if ((*row)[i].col == NO_MORE_ENTRIES) { if ((*row)[i].col == NO_MORE_ENTRIES) {
freeCol = i; freeCol = i;
if (rowSize > i+1) { if (rowSize > i+1) {
(*row)[i+1].entry = NO_MORE_ENTRIES; (*row)[i + 1].entry = NO_MORE_ENTRIES;
} }
break; break;
} }
...@@ -347,8 +352,10 @@ namespace AMDiS { ...@@ -347,8 +352,10 @@ namespace AMDiS {
// jcol found? // jcol found?
if (i < rowSize) { if (i < rowSize) {
if (!add) if (!add) {
(*row)[i].entry = 0.0; (*row)[i].entry = 0.0;
}
(*row)[i].entry += sign * entry; (*row)[i].entry += sign * entry;
} else { } else {
if (freeCol == -1) { if (freeCol == -1) {
...@@ -449,9 +456,9 @@ namespace AMDiS { ...@@ -449,9 +456,9 @@ namespace AMDiS {
Operator *operat = op ? op : operators[0]; Operator *operat = op ? op : operators[0];
// Do no combine the next two lines into one! // !!! Do no combine the next two lines into one !!!
ElementMatrix *elementMatrix = NULL; // ElementMatrix *elementMatrix = NULL;
elementMatrix = operat->getAssembler(omp_get_thread_num())->initElementMatrix(elementMatrix, elInfo); operat->getAssembler(omp_get_thread_num())->initElementMatrix(elementMatrix, elInfo);
if (op) { if (op) {
op->getElementMatrix(elInfo, elementMatrix); op->getElementMatrix(elInfo, elementMatrix);
...@@ -470,8 +477,7 @@ namespace AMDiS { ...@@ -470,8 +477,7 @@ namespace AMDiS {
} }
addElementMatrix(factor, *elementMatrix, bound); addElementMatrix(factor, *elementMatrix, bound);
// DELETE elementMatrix;
DELETE elementMatrix;
} }
Flag DOFMatrix::getAssembleFlag() Flag DOFMatrix::getAssembleFlag()
......
...@@ -671,6 +671,11 @@ namespace AMDiS { ...@@ -671,6 +671,11 @@ namespace AMDiS {
*/ */
bool coupleMatrix; bool coupleMatrix;
/** \brief
* Temporary variable used in assemble()
*/
ElementMatrix *elementMatrix;
friend class DOFAdmin; friend class DOFAdmin;
friend class DOFVector<double>; friend class DOFVector<double>;
friend class DOFVector<unsigned char>; friend class DOFVector<unsigned char>;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment