Commit 99d00627 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Added parameter for marker: max refinement level

parent c89c0012
...@@ -27,7 +27,7 @@ namespace AMDiS { ...@@ -27,7 +27,7 @@ namespace AMDiS {
DOFMatrix::DOFMatrix(const FiniteElemSpace* rowFESpace_, DOFMatrix::DOFMatrix(const FiniteElemSpace* rowFESpace_,
const FiniteElemSpace* colFESpace_, const FiniteElemSpace* colFESpace_,
::std::string name_) std::string name_)
: rowFESpace(rowFESpace_), : rowFESpace(rowFESpace_),
colFESpace(colFESpace_), colFESpace(colFESpace_),
name(name_), name(name_),
...@@ -368,16 +368,16 @@ namespace AMDiS { ...@@ -368,16 +368,16 @@ namespace AMDiS {
matrix[row].push_back(entry); matrix[row].push_back(entry);
} }
void DOFMatrix::addRow(::std::vector<MatEntry> row) void DOFMatrix::addRow(std::vector<MatEntry> row)
{ {
matrix.push_back(row); matrix.push_back(row);
} }
void DOFMatrix::compressDOFIndexed(int first, int last, void DOFMatrix::compressDOFIndexed(int first, int last,
::std::vector<DegreeOfFreedom> &newDOF) std::vector<DegreeOfFreedom> &newDOF)
{ {
int i, j, k, col; int i, j, k, col;
::std::vector<MatEntry> *row; std::vector<MatEntry> *row;
for(i = first; i <= last; i++) { for(i = first; i <= last; i++) {
if((k = newDOF[i]) >= 0) { if((k = newDOF[i]) >= 0) {
...@@ -387,7 +387,7 @@ namespace AMDiS { ...@@ -387,7 +387,7 @@ namespace AMDiS {
} }
int usedSize = rowFESpace->getAdmin()->getUsedSize(); int usedSize = rowFESpace->getAdmin()->getUsedSize();
for(i=0; i < usedSize; i++) { for(i=0; i < usedSize; i++) {
row = reinterpret_cast< ::std::vector<MatEntry>*>(&(matrix[i])); row = reinterpret_cast< std::vector<MatEntry>*>(&(matrix[i]));
int rowSize = static_cast<int>(row->size()); int rowSize = static_cast<int>(row->size());
for (j=0; j < rowSize; j++) { for (j=0; j < rowSize; j++) {
col = (*row)[j].col; col = (*row)[j].col;
...@@ -445,8 +445,8 @@ namespace AMDiS { ...@@ -445,8 +445,8 @@ namespace AMDiS {
if (op) { if (op) {
op->getElementMatrix(elInfo, elementMatrix); op->getElementMatrix(elInfo, elementMatrix);
} else { } else {
::std::vector<Operator*>::iterator it; std::vector<Operator*>::iterator it;
::std::vector<double*>::iterator factorIt; std::vector<double*>::iterator factorIt;
for (it = operators.begin(), factorIt = operatorFactor.begin(); for (it = operators.begin(), factorIt = operatorFactor.begin();
it != operators.end(); it != operators.end();
++it, ++factorIt) { ++it, ++factorIt) {
...@@ -462,7 +462,7 @@ namespace AMDiS { ...@@ -462,7 +462,7 @@ namespace AMDiS {
Flag DOFMatrix::getAssembleFlag() Flag DOFMatrix::getAssembleFlag()
{ {
Flag fillFlag(0); Flag fillFlag(0);
::std::vector<Operator*>::iterator op; std::vector<Operator*>::iterator op;
for(op = operators.begin(); op != operators.end(); ++op) { for(op = operators.begin(); op != operators.end(); ++op) {
fillFlag |= (*op)->getFillFlag(); fillFlag |= (*op)->getFillFlag();
} }
...@@ -519,8 +519,8 @@ namespace AMDiS { ...@@ -519,8 +519,8 @@ namespace AMDiS {
!aIterator.end(); !aIterator.end();
++aIterator, ++bIterator) ++aIterator, ++bIterator)
{ {
::std::vector<MatEntry>::const_iterator aRowIt; std::vector<MatEntry>::const_iterator aRowIt;
::std::vector<MatEntry>::const_iterator bRowIt; std::vector<MatEntry>::const_iterator bRowIt;
for(aRowIt = aIterator->begin(); aRowIt != aIterator->end(); ++aRowIt) { for(aRowIt = aIterator->begin(); aRowIt != aIterator->end(); ++aRowIt) {
int aCol = aRowIt->col; int aCol = aRowIt->col;
if(aCol == UNUSED_ENTRY) continue; if(aCol == UNUSED_ENTRY) continue;
...@@ -604,9 +604,9 @@ namespace AMDiS { ...@@ -604,9 +604,9 @@ namespace AMDiS {
clear(); clear();
DOFMatrix::Iterator rhsIterator(const_cast<DOFMatrix*>(&rhs), USED_DOFS); DOFMatrix::Iterator rhsIterator(const_cast<DOFMatrix*>(&rhs), USED_DOFS);
DOFMatrix::Iterator thisIterator(this, USED_DOFS); DOFMatrix::Iterator thisIterator(this, USED_DOFS);
::std::vector<MatEntry>::const_iterator colIt; std::vector<MatEntry>::const_iterator colIt;
::std::vector<MatEntry>::const_iterator colBegin; std::vector<MatEntry>::const_iterator colBegin;
::std::vector<MatEntry>::const_iterator colEnd; std::vector<MatEntry>::const_iterator colEnd;
for(rhsIterator.reset(), thisIterator.reset(); for(rhsIterator.reset(), thisIterator.reset();
!rhsIterator.end(); !rhsIterator.end();
++rhsIterator, ++thisIterator) ++rhsIterator, ++thisIterator)
...@@ -686,7 +686,7 @@ namespace AMDiS { ...@@ -686,7 +686,7 @@ namespace AMDiS {
int DOFMatrix::memsize() int DOFMatrix::memsize()
{ {
int sizeDOFMatrix = sizeof(DOFMatrix); int sizeDOFMatrix = sizeof(DOFMatrix);
int sizeMatrix = sizeof(::std::vector<MatrixRow>); int sizeMatrix = sizeof(std::vector<MatrixRow>);
for (int i = 0; i < static_cast<int>(matrix.size()); i++) { for (int i = 0; i < static_cast<int>(matrix.size()); i++) {
sizeMatrix += sizeof(MatrixRow) + matrix[i].size() * sizeof(MatEntry); sizeMatrix += sizeof(MatrixRow) + matrix[i].size() * sizeof(MatEntry);
} }
...@@ -695,10 +695,10 @@ namespace AMDiS { ...@@ -695,10 +695,10 @@ namespace AMDiS {
} }
double norm(::std::vector<MatEntry> *row) double norm(std::vector<MatEntry> *row)
{ {
double result = 0.0; double result = 0.0;
::std::vector<MatEntry>::iterator it; std::vector<MatEntry>::iterator it;
for (it = row->begin(); it < row->end(); ++it) { for (it = row->begin(); it < row->end(); ++it) {
result += (*it).entry * (*it).entry; result += (*it).entry * (*it).entry;
} }
...@@ -706,14 +706,14 @@ namespace AMDiS { ...@@ -706,14 +706,14 @@ namespace AMDiS {
return(sqrt(result)); return(sqrt(result));
} }
double min(::std::vector<MatEntry> *row) double min(std::vector<MatEntry> *row)
{ {
double result = 0.0; double result = 0.0;
if (row->size() > 0) { if (row->size() > 0) {
result = (*row)[0].entry; result = (*row)[0].entry;
} }
::std::vector<MatEntry>::iterator it; std::vector<MatEntry>::iterator it;
for (it = row->begin(); it < row->end(); ++it) { for (it = row->begin(); it < row->end(); ++it) {
if ((*it).entry < result) { if ((*it).entry < result) {
result = (*it).entry; result = (*it).entry;
...@@ -723,14 +723,14 @@ namespace AMDiS { ...@@ -723,14 +723,14 @@ namespace AMDiS {
return(result); return(result);
} }
double max(::std::vector<MatEntry> *row) double max(std::vector<MatEntry> *row)
{ {
double result = 0.0; double result = 0.0;
if (row->size() > 0) { if (row->size() > 0) {
result = (*row)[0].entry; result = (*row)[0].entry;
} }
::std::vector<MatEntry>::iterator it; std::vector<MatEntry>::iterator it;
for (it = row->begin(); it < row->end(); ++it) { for (it = row->begin(); it < row->end(); ++it) {
if ((*it).entry > result) { if ((*it).entry > result) {
result = (*it).entry; result = (*it).entry;
......
...@@ -81,7 +81,7 @@ namespace AMDiS { ...@@ -81,7 +81,7 @@ namespace AMDiS {
* Is used to search for all entries of a matrix which column index is * Is used to search for all entries of a matrix which column index is
* smaller than a given value. * smaller than a given value.
*/ */
class MatEntryValueLess : public ::std::unary_function<MatEntry, bool> { class MatEntryValueLess : public std::unary_function<MatEntry, bool> {
private: private:
const double value_; const double value_;
public: public:
...@@ -99,7 +99,7 @@ namespace AMDiS { ...@@ -99,7 +99,7 @@ namespace AMDiS {
* Is used to search for all entries of a matrix which value is smaller * Is used to search for all entries of a matrix which value is smaller
* than a given value. * than a given value.
*/ */
class MatEntryColLess : public ::std::unary_function<MatEntry, bool> { class MatEntryColLess : public std::unary_function<MatEntry, bool> {
private: private:
const int col_; const int col_;
public: public:
...@@ -117,7 +117,7 @@ namespace AMDiS { ...@@ -117,7 +117,7 @@ namespace AMDiS {
* This function is required if two MatEntries are compared by their col * This function is required if two MatEntries are compared by their col
* entry (for example when sorting a vector of MatEntries). * entry (for example when sorting a vector of MatEntries).
*/ */
struct CmpMatEntryCol : public ::std::binary_function<MatEntry, MatEntry, bool> { struct CmpMatEntryCol : public std::binary_function<MatEntry, MatEntry, bool> {
bool operator()(const MatEntry& m1, const MatEntry m2) const { bool operator()(const MatEntry& m1, const MatEntry m2) const {
return m1.col < m2.col; return m1.col < m2.col;
}; };
...@@ -128,7 +128,7 @@ namespace AMDiS { ...@@ -128,7 +128,7 @@ namespace AMDiS {
* This function compares two matrix entries by their values. It returns true, * This function compares two matrix entries by their values. It returns true,
* if the value of m2 is greater than the value of m1. * if the value of m2 is greater than the value of m1.
*/ */
struct CmpMatEntryValue : public ::std::binary_function<MatEntry, MatEntry, bool> { struct CmpMatEntryValue : public std::binary_function<MatEntry, MatEntry, bool> {
bool operator()(const MatEntry& m1, const MatEntry m2) const { bool operator()(const MatEntry& m1, const MatEntry m2) const {
return m1.entry < m2.entry; return m1.entry < m2.entry;
}; };
...@@ -139,7 +139,7 @@ namespace AMDiS { ...@@ -139,7 +139,7 @@ namespace AMDiS {
* This function compares two matrix entries by their values. It returns true, * This function compares two matrix entries by their values. It returns true,
* if the value of m2 is greater than the value of m1. * if the value of m2 is greater than the value of m1.
*/ */
struct CmpMatEntryAbsValueLess : public ::std::binary_function<MatEntry, MatEntry, bool> { struct CmpMatEntryAbsValueLess : public std::binary_function<MatEntry, MatEntry, bool> {
bool operator()(const MatEntry& m1, const MatEntry m2) const { bool operator()(const MatEntry& m1, const MatEntry m2) const {
return fabs(m1.entry) < fabs(m2.entry); return fabs(m1.entry) < fabs(m2.entry);
}; };
...@@ -149,7 +149,7 @@ namespace AMDiS { ...@@ -149,7 +149,7 @@ namespace AMDiS {
* This function compares two matrix entries by their values. It returns true, * This function compares two matrix entries by their values. It returns true,
* if the value of m1 is greater than the value of m2. * if the value of m1 is greater than the value of m2.
*/ */
struct CmpMatEntryAbsValueGreater : public ::std::binary_function<MatEntry, MatEntry, bool> { struct CmpMatEntryAbsValueGreater : public std::binary_function<MatEntry, MatEntry, bool> {
bool operator()(const MatEntry& m1, const MatEntry m2) const { bool operator()(const MatEntry& m1, const MatEntry m2) const {
return fabs(m1.entry) > fabs(m2.entry); return fabs(m1.entry) > fabs(m2.entry);
}; };
...@@ -166,7 +166,7 @@ namespace AMDiS { ...@@ -166,7 +166,7 @@ namespace AMDiS {
* objects. Each entry consists of a column DOF index and the corresponding * objects. Each entry consists of a column DOF index and the corresponding
* double matrix entry. Unused entries are marked with a negative column index. * double matrix entry. Unused entries are marked with a negative column index.
*/ */
class DOFMatrix : public DOFIndexed< ::std::vector<MatEntry> >, class DOFMatrix : public DOFIndexed< std::vector<MatEntry> >,
public Serializable public Serializable
{ {
public: public:
...@@ -174,14 +174,14 @@ namespace AMDiS { ...@@ -174,14 +174,14 @@ namespace AMDiS {
/** \ingroup DOFAdministration /** \ingroup DOFAdministration
* \brief * \brief
* Alias for DOFIterator< ::std::vector<MatEntry<T> > >. So one can access an * Alias for DOFIterator< std::vector<MatEntry<T> > >. So one can access an
* iterator working on a DOFMatrix via DOFMatrix::Iterator * iterator working on a DOFMatrix via DOFMatrix::Iterator
*/ */
class Iterator : public DOFIterator< ::std::vector<MatEntry> > { class Iterator : public DOFIterator< std::vector<MatEntry> > {
public: public:
Iterator(DOFIndexed< ::std::vector<MatEntry> > *c, Iterator(DOFIndexed< std::vector<MatEntry> > *c,
DOFIteratorType type) DOFIteratorType type)
: DOFIterator< ::std::vector<MatEntry> >(c, type) : DOFIterator< std::vector<MatEntry> >(c, type)
{}; {};
}; };
...@@ -189,7 +189,7 @@ namespace AMDiS { ...@@ -189,7 +189,7 @@ namespace AMDiS {
* A MatrixRow represents one row of the sparse matrix. It is realized by * A MatrixRow represents one row of the sparse matrix. It is realized by
* a STL vector of MatEntry<T> objects * a STL vector of MatEntry<T> objects
*/ */
typedef ::std::vector<MatEntry> MatrixRow; typedef std::vector<MatEntry> MatrixRow;
/** \brief /** \brief
* Symbolic constant for an unused matrix entry * Symbolic constant for an unused matrix entry
...@@ -211,7 +211,7 @@ namespace AMDiS { ...@@ -211,7 +211,7 @@ namespace AMDiS {
*/ */
DOFMatrix(const FiniteElemSpace* rowFESpace, DOFMatrix(const FiniteElemSpace* rowFESpace,
const FiniteElemSpace* colFESpace, const FiniteElemSpace* colFESpace,
::std::string n=""); std::string n="");
/** \brief /** \brief
* Copy-Constructor * Copy-Constructor
...@@ -234,14 +234,14 @@ namespace AMDiS { ...@@ -234,14 +234,14 @@ namespace AMDiS {
/** \brief /** \brief
* Returns an iterator to the begin of matrix rows (\ref matrix.begin()) * Returns an iterator to the begin of matrix rows (\ref matrix.begin())
*/ */
::std::vector< ::std::vector<MatEntry> >::iterator begin() { std::vector< std::vector<MatEntry> >::iterator begin() {
return matrix.begin(); return matrix.begin();
}; };
/** \brief /** \brief
* Returns an iterator to the end of matrix rows (\ref matrix.end()) * Returns an iterator to the end of matrix rows (\ref matrix.end())
*/ */
::std::vector< ::std::vector<MatEntry> >::iterator end() { std::vector< std::vector<MatEntry> >::iterator end() {
return matrix.end(); return matrix.end();
}; };
...@@ -249,7 +249,7 @@ namespace AMDiS { ...@@ -249,7 +249,7 @@ namespace AMDiS {
* Used by DOFAdmin to compress the DOFMatrix * Used by DOFAdmin to compress the DOFMatrix
*/ */
virtual void compressDOFIndexed(int first, int last, virtual void compressDOFIndexed(int first, int last,
::std::vector<DegreeOfFreedom> &newDOF); std::vector<DegreeOfFreedom> &newDOF);
/** \brief /** \brief
* Implements DOFIndexedBase::freeDOFContent() * Implements DOFIndexedBase::freeDOFContent()
...@@ -307,27 +307,27 @@ namespace AMDiS { ...@@ -307,27 +307,27 @@ namespace AMDiS {
operatorEstFactor.push_back(estFactor); operatorEstFactor.push_back(estFactor);
}; };
inline ::std::vector<double*>::iterator getOperatorFactorBegin() { inline std::vector<double*>::iterator getOperatorFactorBegin() {
return operatorFactor.begin(); return operatorFactor.begin();
}; };
inline ::std::vector<double*>::iterator getOperatorFactorEnd() { inline std::vector<double*>::iterator getOperatorFactorEnd() {
return operatorFactor.end(); return operatorFactor.end();
}; };
inline ::std::vector<double*>::iterator getOperatorEstFactorBegin() { inline std::vector<double*>::iterator getOperatorEstFactorBegin() {
return operatorEstFactor.begin(); return operatorEstFactor.begin();
}; };
inline ::std::vector<double*>::iterator getOperatorEstFactorEnd() { inline std::vector<double*>::iterator getOperatorEstFactorEnd() {
return operatorEstFactor.end(); return operatorEstFactor.end();
}; };
inline ::std::vector<Operator*>::iterator getOperatorsBegin() { inline std::vector<Operator*>::iterator getOperatorsBegin() {
return operators.begin(); return operators.begin();
}; };
inline ::std::vector<Operator*>::iterator getOperatorsEnd() { inline std::vector<Operator*>::iterator getOperatorsEnd() {
return operators.end(); return operators.end();
}; };
...@@ -371,25 +371,25 @@ namespace AMDiS { ...@@ -371,25 +371,25 @@ namespace AMDiS {
/** \brief /** \brief
* Returns \ref matrix * Returns \ref matrix
*/ */
::std::vector< ::std::vector<MatEntry> >& getMatrix() { std::vector< std::vector<MatEntry> >& getMatrix() {
return matrix; return matrix;
}; };
void setMatrix(::std::vector< ::std::vector<MatEntry> > m) { void setMatrix(std::vector< std::vector<MatEntry> > m) {
matrix = m; matrix = m;
}; };
/** \brief /** \brief
* Returns \ref matrix[n] * Returns \ref matrix[n]
*/ */
const ::std::vector<MatEntry>& getRow(int n) const { const std::vector<MatEntry>& getRow(int n) const {
return matrix[n]; return matrix[n];
}; };
/** \brief /** \brief
* Returns \ref matrix[n] * Returns \ref matrix[n]
*/ */
::std::vector<MatEntry>& getRow(int n) { std::vector<MatEntry>& getRow(int n) {
return matrix[n]; return matrix[n];
}; };
...@@ -437,10 +437,29 @@ namespace AMDiS { ...@@ -437,10 +437,29 @@ namespace AMDiS {
return matrix.size(); return matrix.size();
}; };
/** \brief
* Returns number of cols. For that, the function iteratos over all
* rows and searchs for the entry with the highest col number.
*/
int getNumCols() const {
int max = 0;
int rowSize = static_cast<int>(matrix.size());
for (int i = 0; i < rowSize; i++) {
int colSize = static_cast<int>(matrix[i].size());
for (int j = 0; j < colSize; j++) {
if (matrix[i][j].col > max) {
max = matrix[i][j].col;
}
}
}
return max;
};
/** \brief /** \brief
* Returns \ref name * Returns \ref name
*/ */
inline const ::std::string& getName() const { inline const std::string& getName() const {
return name; return name;
}; };
...@@ -455,7 +474,7 @@ namespace AMDiS { ...@@ -455,7 +474,7 @@ namespace AMDiS {
/** \brief /** \brief
* Returns \ref matrix[i] which is the i-th row * Returns \ref matrix[i] which is the i-th row
*/ */
inline const ::std::vector<MatEntry>& operator[](int i) const { inline const std::vector<MatEntry>& operator[](int i) const {
TEST_EXIT_DBG((i >= 0) && (i < (static_cast<int>(matrix.size())))) TEST_EXIT_DBG((i >= 0) && (i < (static_cast<int>(matrix.size()))))
("Illegal matrix index %d.\n",i); ("Illegal matrix index %d.\n",i);
return matrix[i]; return matrix[i];
...@@ -464,7 +483,7 @@ namespace AMDiS { ...@@ -464,7 +483,7 @@ namespace AMDiS {
/** \brief /** \brief
* Returns \ref matrix[i] which is the i-th row * Returns \ref matrix[i] which is the i-th row
*/ */
inline ::std::vector<MatEntry>& operator[](int i) { inline std::vector<MatEntry>& operator[](int i) {
TEST_EXIT_DBG((i >= 0) && (i < (static_cast<int>(matrix.size())))) TEST_EXIT_DBG((i >= 0) && (i < (static_cast<int>(matrix.size()))))
("Illegal vector index %d.\n", i); ("Illegal vector index %d.\n", i);
return matrix[i]; return matrix[i];
...@@ -528,8 +547,8 @@ namespace AMDiS { ...@@ -528,8 +547,8 @@ namespace AMDiS {
bool add = true); bool add = true);
inline double *hasSparseDOFEntry(int irow, int jcol) { inline double *hasSparseDOFEntry(int irow, int jcol) {
::std::vector<MatEntry>::iterator it; std::vector<MatEntry>::iterator it;
::std::vector<MatEntry>::iterator end = matrix[irow].end(); std::vector<MatEntry>::iterator end = matrix[irow].end();
for (it = matrix[irow].begin(); it != end; ++it) { for (it = matrix[irow].begin(); it != end; ++it) {
if (it->col == NO_MORE_ENTRIES) if (it->col == NO_MORE_ENTRIES)
return NULL; return NULL;
...@@ -543,7 +562,7 @@ namespace AMDiS { ...@@ -543,7 +562,7 @@ namespace AMDiS {
void addMatEntry(int row, int DegreeOfFreedom, double value); void addMatEntry(int row, int DegreeOfFreedom, double value);
void addRow(::std::vector<MatEntry> row); void addRow(std::vector<MatEntry> row);
/** \brief /** \brief
* Prints \ref matrix to stdout * Prints \ref matrix to stdout
...@@ -567,15 +586,15 @@ namespace AMDiS { ...@@ -567,15 +586,15 @@ namespace AMDiS {
bool symmetric(); bool symmetric();
inline ::std::vector<Operator*> getOperators() { inline std::vector<Operator*> getOperators() {
return operators; return operators;
}; };
inline ::std::vector<double*> getOperatorFactor() { inline std::vector<double*> getOperatorFactor() {
return operatorFactor; return operatorFactor;
}; };
inline ::std::vector<double*> getOperatorEstFactor() { inline std::vector<double*> getOperatorEstFactor() {
return operatorEstFactor; return operatorEstFactor;
}; };
...@@ -591,7 +610,7 @@ namespace AMDiS { ...@@ -591,7 +610,7 @@ namespace AMDiS {
// ===== Serializable implementation ===== // ===== Serializable implementation =====
void serialize(::std::ostream &out) void serialize(std::ostream &out)
{ {
unsigned int matrixSize = matrix.size(); unsigned int matrixSize = matrix.size();
unsigned int vecSize = 0; unsigned int vecSize = 0;
...@@ -604,7 +623,7 @@ namespace AMDiS { ...@@ -604,7 +623,7 @@ namespace AMDiS {
} }
}; };