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 {
DOFMatrix::DOFMatrix(const FiniteElemSpace* rowFESpace_,
const FiniteElemSpace* colFESpace_,
::std::string name_)
std::string name_)
: rowFESpace(rowFESpace_),
colFESpace(colFESpace_),
name(name_),
......@@ -368,16 +368,16 @@ namespace AMDiS {
matrix[row].push_back(entry);
}
void DOFMatrix::addRow(::std::vector<MatEntry> row)
void DOFMatrix::addRow(std::vector<MatEntry> row)
{
matrix.push_back(row);
}
void DOFMatrix::compressDOFIndexed(int first, int last,
::std::vector<DegreeOfFreedom> &newDOF)
std::vector<DegreeOfFreedom> &newDOF)
{
int i, j, k, col;
::std::vector<MatEntry> *row;
std::vector<MatEntry> *row;
for(i = first; i <= last; i++) {
if((k = newDOF[i]) >= 0) {
......@@ -387,7 +387,7 @@ namespace AMDiS {
}
int usedSize = rowFESpace->getAdmin()->getUsedSize();
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());
for (j=0; j < rowSize; j++) {
col = (*row)[j].col;
......@@ -445,8 +445,8 @@ namespace AMDiS {
if (op) {
op->getElementMatrix(elInfo, elementMatrix);
} else {
::std::vector<Operator*>::iterator it;
::std::vector<double*>::iterator factorIt;
std::vector<Operator*>::iterator it;
std::vector<double*>::iterator factorIt;
for (it = operators.begin(), factorIt = operatorFactor.begin();
it != operators.end();
++it, ++factorIt) {
......@@ -462,7 +462,7 @@ namespace AMDiS {
Flag DOFMatrix::getAssembleFlag()
{
Flag fillFlag(0);
::std::vector<Operator*>::iterator op;
std::vector<Operator*>::iterator op;
for(op = operators.begin(); op != operators.end(); ++op) {
fillFlag |= (*op)->getFillFlag();
}
......@@ -519,8 +519,8 @@ namespace AMDiS {
!aIterator.end();
++aIterator, ++bIterator)
{
::std::vector<MatEntry>::const_iterator aRowIt;
::std::vector<MatEntry>::const_iterator bRowIt;
std::vector<MatEntry>::const_iterator aRowIt;
std::vector<MatEntry>::const_iterator bRowIt;
for(aRowIt = aIterator->begin(); aRowIt != aIterator->end(); ++aRowIt) {
int aCol = aRowIt->col;
if(aCol == UNUSED_ENTRY) continue;
......@@ -604,9 +604,9 @@ namespace AMDiS {
clear();
DOFMatrix::Iterator rhsIterator(const_cast<DOFMatrix*>(&rhs), USED_DOFS);
DOFMatrix::Iterator thisIterator(this, USED_DOFS);
::std::vector<MatEntry>::const_iterator colIt;
::std::vector<MatEntry>::const_iterator colBegin;
::std::vector<MatEntry>::const_iterator colEnd;
std::vector<MatEntry>::const_iterator colIt;
std::vector<MatEntry>::const_iterator colBegin;
std::vector<MatEntry>::const_iterator colEnd;
for(rhsIterator.reset(), thisIterator.reset();
!rhsIterator.end();
++rhsIterator, ++thisIterator)
......@@ -686,7 +686,7 @@ namespace AMDiS {
int DOFMatrix::memsize()
{
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++) {
sizeMatrix += sizeof(MatrixRow) + matrix[i].size() * sizeof(MatEntry);
}
......@@ -695,10 +695,10 @@ namespace AMDiS {
}
double norm(::std::vector<MatEntry> *row)
double norm(std::vector<MatEntry> *row)
{
double result = 0.0;
::std::vector<MatEntry>::iterator it;
std::vector<MatEntry>::iterator it;
for (it = row->begin(); it < row->end(); ++it) {
result += (*it).entry * (*it).entry;
}
......@@ -706,14 +706,14 @@ namespace AMDiS {
return(sqrt(result));
}
double min(::std::vector<MatEntry> *row)
double min(std::vector<MatEntry> *row)
{
double result = 0.0;
if (row->size() > 0) {
result = (*row)[0].entry;
}
::std::vector<MatEntry>::iterator it;
std::vector<MatEntry>::iterator it;
for (it = row->begin(); it < row->end(); ++it) {
if ((*it).entry < result) {
result = (*it).entry;
......@@ -723,14 +723,14 @@ namespace AMDiS {
return(result);
}
double max(::std::vector<MatEntry> *row)
double max(std::vector<MatEntry> *row)
{
double result = 0.0;
if (row->size() > 0) {
result = (*row)[0].entry;
}
::std::vector<MatEntry>::iterator it;
std::vector<MatEntry>::iterator it;
for (it = row->begin(); it < row->end(); ++it) {
if ((*it).entry > result) {
result = (*it).entry;
......
......@@ -81,7 +81,7 @@ namespace AMDiS {
* Is used to search for all entries of a matrix which column index is
* smaller than a given value.
*/
class MatEntryValueLess : public ::std::unary_function<MatEntry, bool> {
class MatEntryValueLess : public std::unary_function<MatEntry, bool> {
private:
const double value_;
public:
......@@ -99,7 +99,7 @@ namespace AMDiS {
* Is used to search for all entries of a matrix which value is smaller
* than a given value.
*/
class MatEntryColLess : public ::std::unary_function<MatEntry, bool> {
class MatEntryColLess : public std::unary_function<MatEntry, bool> {
private:
const int col_;
public:
......@@ -117,7 +117,7 @@ namespace AMDiS {
* This function is required if two MatEntries are compared by their col
* 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 {
return m1.col < m2.col;
};
......@@ -128,7 +128,7 @@ namespace AMDiS {
* This function compares two matrix entries by their values. It returns true,
* 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 {
return m1.entry < m2.entry;
};
......@@ -139,7 +139,7 @@ namespace AMDiS {
* This function compares two matrix entries by their values. It returns true,
* 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 {
return fabs(m1.entry) < fabs(m2.entry);
};
......@@ -149,7 +149,7 @@ namespace AMDiS {
* This function compares two matrix entries by their values. It returns true,
* 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 {
return fabs(m1.entry) > fabs(m2.entry);
};
......@@ -166,7 +166,7 @@ namespace AMDiS {
* objects. Each entry consists of a column DOF index and the corresponding
* 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:
......@@ -174,14 +174,14 @@ namespace AMDiS {
/** \ingroup DOFAdministration
* \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
*/
class Iterator : public DOFIterator< ::std::vector<MatEntry> > {
class Iterator : public DOFIterator< std::vector<MatEntry> > {
public:
Iterator(DOFIndexed< ::std::vector<MatEntry> > *c,
Iterator(DOFIndexed< std::vector<MatEntry> > *c,
DOFIteratorType type)
: DOFIterator< ::std::vector<MatEntry> >(c, type)
: DOFIterator< std::vector<MatEntry> >(c, type)
{};
};
......@@ -189,7 +189,7 @@ namespace AMDiS {
* A MatrixRow represents one row of the sparse matrix. It is realized by
* a STL vector of MatEntry<T> objects
*/
typedef ::std::vector<MatEntry> MatrixRow;
typedef std::vector<MatEntry> MatrixRow;
/** \brief
* Symbolic constant for an unused matrix entry
......@@ -211,7 +211,7 @@ namespace AMDiS {
*/
DOFMatrix(const FiniteElemSpace* rowFESpace,
const FiniteElemSpace* colFESpace,
::std::string n="");
std::string n="");
/** \brief
* Copy-Constructor
......@@ -234,14 +234,14 @@ namespace AMDiS {
/** \brief
* 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();
};
/** \brief
* 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();
};
......@@ -249,7 +249,7 @@ namespace AMDiS {
* Used by DOFAdmin to compress the DOFMatrix
*/
virtual void compressDOFIndexed(int first, int last,
::std::vector<DegreeOfFreedom> &newDOF);
std::vector<DegreeOfFreedom> &newDOF);
/** \brief
* Implements DOFIndexedBase::freeDOFContent()
......@@ -307,27 +307,27 @@ namespace AMDiS {
operatorEstFactor.push_back(estFactor);
};
inline ::std::vector<double*>::iterator getOperatorFactorBegin() {
inline std::vector<double*>::iterator getOperatorFactorBegin() {
return operatorFactor.begin();
};
inline ::std::vector<double*>::iterator getOperatorFactorEnd() {
inline std::vector<double*>::iterator getOperatorFactorEnd() {
return operatorFactor.end();
};
inline ::std::vector<double*>::iterator getOperatorEstFactorBegin() {
inline std::vector<double*>::iterator getOperatorEstFactorBegin() {
return operatorEstFactor.begin();
};
inline ::std::vector<double*>::iterator getOperatorEstFactorEnd() {
inline std::vector<double*>::iterator getOperatorEstFactorEnd() {
return operatorEstFactor.end();
};
inline ::std::vector<Operator*>::iterator getOperatorsBegin() {
inline std::vector<Operator*>::iterator getOperatorsBegin() {
return operators.begin();
};
inline ::std::vector<Operator*>::iterator getOperatorsEnd() {
inline std::vector<Operator*>::iterator getOperatorsEnd() {
return operators.end();
};
......@@ -371,25 +371,25 @@ namespace AMDiS {
/** \brief
* Returns \ref matrix
*/
::std::vector< ::std::vector<MatEntry> >& getMatrix() {
std::vector< std::vector<MatEntry> >& getMatrix() {
return matrix;
};
void setMatrix(::std::vector< ::std::vector<MatEntry> > m) {
void setMatrix(std::vector< std::vector<MatEntry> > m) {
matrix = m;
};
/** \brief
* Returns \ref matrix[n]
*/
const ::std::vector<MatEntry>& getRow(int n) const {
const std::vector<MatEntry>& getRow(int n) const {
return matrix[n];
};
/** \brief
* Returns \ref matrix[n]
*/
::std::vector<MatEntry>& getRow(int n) {
std::vector<MatEntry>& getRow(int n) {
return matrix[n];
};
......@@ -437,10 +437,29 @@ namespace AMDiS {
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
* Returns \ref name
*/
inline const ::std::string& getName() const {
inline const std::string& getName() const {
return name;
};
......@@ -455,7 +474,7 @@ namespace AMDiS {
/** \brief
* 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()))))
("Illegal matrix index %d.\n",i);
return matrix[i];
......@@ -464,7 +483,7 @@ namespace AMDiS {
/** \brief
* 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()))))
("Illegal vector index %d.\n", i);
return matrix[i];
......@@ -528,8 +547,8 @@ namespace AMDiS {
bool add = true);
inline double *hasSparseDOFEntry(int irow, int jcol) {
::std::vector<MatEntry>::iterator it;
::std::vector<MatEntry>::iterator end = matrix[irow].end();
std::vector<MatEntry>::iterator it;
std::vector<MatEntry>::iterator end = matrix[irow].end();
for (it = matrix[irow].begin(); it != end; ++it) {
if (it->col == NO_MORE_ENTRIES)
return NULL;
......@@ -543,7 +562,7 @@ namespace AMDiS {
void addMatEntry(int row, int DegreeOfFreedom, double value);
void addRow(::std::vector<MatEntry> row);
void addRow(std::vector<MatEntry> row);
/** \brief
* Prints \ref matrix to stdout
......@@ -567,15 +586,15 @@ namespace AMDiS {
bool symmetric();
inline ::std::vector<Operator*> getOperators() {
inline std::vector<Operator*> getOperators() {
return operators;
};
inline ::std::vector<double*> getOperatorFactor() {
inline std::vector<double*> getOperatorFactor() {
return operatorFactor;
};
inline ::std::vector<double*> getOperatorEstFactor() {
inline std::vector<double*> getOperatorEstFactor() {
return operatorEstFactor;
};
......@@ -591,7 +610,7 @@ namespace AMDiS {
// ===== Serializable implementation =====
void serialize(::std::ostream &out)
void serialize(std::ostream &out)
{
unsigned int matrixSize = matrix.size();
unsigned int vecSize = 0;
......@@ -604,7 +623,7 @@ namespace AMDiS {
}
};
void deserialize(::std::istream &in) {
void deserialize(std::istream &in) {
unsigned int matrixSize, vecSize;
in.read(reinterpret_cast<char*>(&matrixSize), sizeof(unsigned int));
......@@ -640,12 +659,12 @@ namespace AMDiS {
/** \brief
* Name of the DOFMatrix
*/
::std::string name;
std::string name;
/** \brief
* Sparse matrix stored in an STL vector of MatrixRow objects
*/
::std::vector<MatrixRow> matrix;
std::vector<MatrixRow> matrix;
/** \brief
* Used while mesh traversal
......@@ -656,18 +675,18 @@ namespace AMDiS {
* Pointers to all operators of the equation systems. Are used in the
* assembling process.
*/
::std::vector<Operator*> operators;
std::vector<Operator*> operators;
/** \brief
* Defines for each operator a factor which is used to scal the element
* matrix after the assembling process of the operator.
*/
::std::vector<double*> operatorFactor;
std::vector<double*> operatorFactor;
/** \brief
*
*/
::std::vector<double*> operatorEstFactor;
std::vector<double*> operatorEstFactor;
/** \brief
*
......@@ -697,11 +716,11 @@ namespace AMDiS {
return m->logToPhysIndex(a, b);
}
double norm(::std::vector<MatEntry> *row);
double norm(std::vector<MatEntry> *row);
double min(::std::vector<MatEntry> *row);
double min(std::vector<MatEntry> *row);
double max(::std::vector<MatEntry> *row);
double max(std::vector<MatEntry> *row);
}
......
......@@ -72,7 +72,11 @@ namespace AMDiS {
ElInfo *elInfo = NULL;
elInfo = stack.traverseFirst(mesh, -1, Mesh::CALL_LEAF_EL);
while (elInfo) {
if ((maxRefineLevel > -1) &&
(static_cast<int>(elInfo->getLevel()) < maxRefineLevel)) {
markElement(adaptInfo, elInfo);
}
elInfo = stack.traverseNext(elInfo);
}
......
......@@ -59,10 +59,12 @@ namespace AMDiS {
row(row_),
maximumMarking(false),
p(2),
info(10)
info(10),
maxRefineLevel(-1)
{
GET_PARAMETER(0, name + "->p", "%f", &p);
GET_PARAMETER(0, name + "->info", "%d", &info);
GET_PARAMETER(0, name + "->max refinement level", "%d", &maxRefineLevel);
};
/** \brief
......@@ -196,6 +198,10 @@ namespace AMDiS {
*/
int elMarkCoarsen;
/** \brief
* Maximal depth for element refinement.
*/
int maxRefineLevel;
};
// ===========================================================================
......
......@@ -111,7 +111,7 @@ namespace AMDiS {
createMarker();
}
if (adoptProblem && adoptFlag.isSet(INIT_MARKER)) {
marker_ = adoptProblem->getMarker();
marker = adoptProblem->getMarker();
}
......@@ -436,11 +436,11 @@ namespace AMDiS {
for (int i = 0; i < nComponents; i++) {
sprintf(number, "[%d]", i);
numberedName = name_ + "->marker" + std::string(number);
marker_[i] = Marker::createMarker(numberedName, i);
if (marker_[i]) {
marker[i] = Marker::createMarker(numberedName, i);
if (marker[i]) {
numMarkersCreated++;
if (numMarkersCreated > 1)
marker_[i]->setMaximumMarking(true);
marker[i]->setMaximumMarking(true);
}
}
}
......@@ -584,8 +584,8 @@ namespace AMDiS {
Flag markFlag = 0;
for (int i = 0; i < nComponents; i++) {
if (marker_[i]) {
markFlag |= marker_[i]->markMesh(adaptInfo, componentMeshes_[i]);
if (marker[i]) {
markFlag |= marker[i]->markMesh(adaptInfo, componentMeshes_[i]);
} else {
WARNING("no marker for component %d\n", i);
}
......@@ -598,9 +598,9 @@ namespace AMDiS {
{
FUNCNAME("ProblemVec::refineMesh()");
int numMeshes = static_cast<int>(meshes_.size());
int nMeshes = static_cast<int>(meshes_.size());
Flag refineFlag = 0;
for (int i = 0; i < numMeshes; i++) {
for (int i = 0; i < nMeshes; i++) {
refineFlag |= refinementManager_->refineMesh(meshes_[i]);
}
return refineFlag;
......@@ -610,10 +610,10 @@ namespace AMDiS {
{
FUNCNAME("ProblemVec::coarsenMesh()");
int i, numMeshes = static_cast<int>(meshes_.size());
int nMeshes = static_cast<int>(meshes_.size());
Flag coarsenFlag = 0;
for(i = 0; i < numMeshes; i++) {
if(adaptInfo->isCoarseningAllowed(i)) {
for (int i = 0; i < nMeshes; i++) {
if (adaptInfo->isCoarseningAllowed(i)) {
coarsenFlag |= coarseningManager_->coarsenMesh(meshes_[i]);
WARNING("coarsening for component %d no allowed\n", i);
......@@ -724,10 +724,6 @@ namespace AMDiS {
if (assembleMatrix && matrix->getBoundaryManager())
matrix->getBoundaryManager()->initMatrix(matrix);
if (componentMeshes_[i] != componentMeshes_[j]) {
ERROR_EXIT("not yet\n");
} else {
BoundaryType *bound = NULL;
if (useGetBound_) {
bound = GET_MEMORY(BoundaryType, basisFcts->getNumber());
......@@ -764,7 +760,6 @@ namespace AMDiS {
if (useGetBound_) {
FREE_MEMORY(bound, BoundaryType, basisFcts->getNumber());
}
}
assembledMatrix_[i][j] = true;
}
......
......@@ -77,7 +77,7 @@ namespace AMDiS {
TEST_EXIT(nComponents > 0)("components not set!\n");
estimator_.resize(nComponents, NULL);
marker_.resize(nComponents, NULL);
marker.resize(nComponents, NULL);
assembleMatrixOnlyOnce_.resize(nComponents);
assembledMatrix_.resize(nComponents);
......@@ -391,17 +391,17 @@ namespace AMDiS {
};
/** \brief
* Returns \ref marker_.
* Returns \ref marker.
*/
inline Marker *getMarker(int comp) {
return marker_[comp];
return marker[comp];
};
/** \brief
* Returns \ref marker_.
* Returns \ref marker.
*/
inline std::vector<Marker*> getMarker() {
return marker_;
return marker;
};
/** \brief
......@@ -458,8 +458,8 @@ namespace AMDiS {
estimator_[comp] = est;
};
inline void setMarker(Marker* marker, int comp) {
marker_[comp] = marker;