Commit d5d0ec5a authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Work in progress on parallel domain decomposition.

parent be06847b
...@@ -75,7 +75,8 @@ namespace AMDiS { ...@@ -75,7 +75,8 @@ namespace AMDiS {
bool operator==(const DOFAdmin&) const; bool operator==(const DOFAdmin&) const;
/// Compares two DOFAdmins by their names. /// Compares two DOFAdmins by their names.
inline bool operator!=(const DOFAdmin& ad) const { inline bool operator!=(const DOFAdmin& ad) const
{
return !(ad==*this); return !(ad==*this);
} }
...@@ -104,12 +105,14 @@ namespace AMDiS { ...@@ -104,12 +105,14 @@ namespace AMDiS {
void compress(std::vector<DegreeOfFreedom> &new_dof); void compress(std::vector<DegreeOfFreedom> &new_dof);
/// Returns an iterator to the begin of \ref dofIndexedList /// Returns an iterator to the begin of \ref dofIndexedList
std::list<DOFIndexedBase*>::iterator beginDOFIndexed() { std::list<DOFIndexedBase*>::iterator beginDOFIndexed()
{
return dofIndexedList.begin(); return dofIndexedList.begin();
} }
/// Returns an iterator to the end of \ref dofIndexedList /// Returns an iterator to the end of \ref dofIndexedList
std::list<DOFIndexedBase*>::iterator endDOFIndexed() { std::list<DOFIndexedBase*>::iterator endDOFIndexed()
{
return dofIndexedList.end(); return dofIndexedList.end();
} }
...@@ -118,47 +121,56 @@ namespace AMDiS { ...@@ -118,47 +121,56 @@ namespace AMDiS {
*/ */
/// Returns \ref sizeUsed. /// Returns \ref sizeUsed.
inline const int getUsedSize() const { inline const int getUsedSize() const
{
return sizeUsed; return sizeUsed;
} }
/// Returns \ref size /// Returns \ref size
inline const int getSize() const { inline const int getSize() const
{
return size; return size;
} }
/// Returns \ref usedCount /// Returns \ref usedCount
inline const int getUsedDOFs() const { inline const int getUsedDOFs() const
{
return usedCount; return usedCount;
} }
/// Returns \ref holeCount /// Returns \ref holeCount
inline const int getHoleCount() const { inline const int getHoleCount() const
{
return holeCount; return holeCount;
} }
/// Returns \ref name /// Returns \ref name
inline const std::string& getName() const { inline const std::string& getName() const
{
return name; return name;
} }
/// Returns \ref nrDOF[i], i.e., the number of dofs for the position i. /// Returns \ref nrDOF[i], i.e., the number of dofs for the position i.
inline const int getNumberOfDOFs(int i) const { inline const int getNumberOfDOFs(int i) const
{
return nrDOF[i]; return nrDOF[i];
} }
/// Returns \ref nrDOF /// Returns \ref nrDOF
inline const DimVec<int>& getNumberOfDOFs() const { inline const DimVec<int>& getNumberOfDOFs() const
{
return nrDOF; return nrDOF;
} }
/// Returns \ref nr0DOF[i] /// Returns \ref nr0DOF[i]
inline const int getNumberOfPreDOFs(int i) const { inline const int getNumberOfPreDOFs(int i) const
{
return nr0DOF[i]; return nr0DOF[i];
} }
/// Returns \ref nr0DOF /// Returns \ref nr0DOF
inline const DimVec<int>& getNumberOfPreDOFs() const { inline const DimVec<int>& getNumberOfPreDOFs() const
{
return nr0DOF; return nr0DOF;
} }
...@@ -168,12 +180,14 @@ namespace AMDiS { ...@@ -168,12 +180,14 @@ namespace AMDiS {
} }
/// Returns \ref dofFree, the array denoting DOFs to be either free or used. /// Returns \ref dofFree, the array denoting DOFs to be either free or used.
inline const std::vector<bool>& getDOFFree() const { inline const std::vector<bool>& getDOFFree() const
{
return dofFree; return dofFree;
} }
/// Returns if the given DOF is free. /// Returns if the given DOF is free.
inline const bool isDOFFree(int i) const { inline const bool isDOFFree(int i) const
{
return dofFree[i]; return dofFree[i];
} }
...@@ -190,12 +204,14 @@ namespace AMDiS { ...@@ -190,12 +204,14 @@ namespace AMDiS {
void setNumberOfPreDOFs(int i, int v); void setNumberOfPreDOFs(int i, int v);
/// Sets \ref name = n /// Sets \ref name = n
inline void setName(const std::string& n) { inline void setName(const std::string& n)
{
name = n; name = n;
} }
/// Sets \ref mesh = m /// Sets \ref mesh = m
inline void setMesh(Mesh* m) { inline void setMesh(Mesh* m)
{
mesh = m; mesh = m;
} }
......
...@@ -69,7 +69,8 @@ namespace AMDiS { ...@@ -69,7 +69,8 @@ namespace AMDiS {
* Sub classes must * Sub classes must
* implement goToBeginOfIteratedObject() which resets the iterator. * implement goToBeginOfIteratedObject() which resets the iterator.
*/ */
virtual void reset() { virtual void reset()
{
position = 0; position = 0;
dofFreeIterator = dofFree->begin(); dofFreeIterator = dofFree->begin();
if (dofFreeIterator == dofFree->end()) if (dofFreeIterator == dofFree->end())
...@@ -86,15 +87,16 @@ namespace AMDiS { ...@@ -86,15 +87,16 @@ namespace AMDiS {
* Sub classes must * Sub classes must
* implement goToBeginOfIteratedObject() which resets the iterator. * implement goToBeginOfIteratedObject() which resets the iterator.
*/ */
virtual void reset2() { virtual void reset2()
{
position = 0; position = 0;
dofFreeIterator = dofFree->begin(); dofFreeIterator = dofFree->begin();
if(dofFreeIterator == dofFree->end()) { if (dofFreeIterator == dofFree->end()) {
return; return;
} }
goToBeginOfIteratedObject(); goToBeginOfIteratedObject();
if(type != ALL_DOFS) { if (type != ALL_DOFS) {
if(*dofFreeIterator == (type == USED_DOFS)) if (*dofFreeIterator == (type == USED_DOFS))
operator++(); operator++();
} }
} }
...@@ -108,7 +110,8 @@ namespace AMDiS { ...@@ -108,7 +110,8 @@ namespace AMDiS {
* must implement incObjectIterator() which increments the object * must implement incObjectIterator() which increments the object
* iterator. * iterator.
*/ */
inline const DOFIteratorBase& operator++() { inline const DOFIteratorBase& operator++()
{
if (type == ALL_DOFS) { if (type == ALL_DOFS) {
incObjectIterator(); incObjectIterator();
dofFreeIterator++; dofFreeIterator++;
...@@ -136,13 +139,15 @@ namespace AMDiS { ...@@ -136,13 +139,15 @@ namespace AMDiS {
} }
/// Postfix operator++. /// Postfix operator++.
inline DOFIteratorBase operator++(int) { inline DOFIteratorBase operator++(int)
{
DOFIteratorBase clone = *this; DOFIteratorBase clone = *this;
operator++(); operator++();
return clone; return clone;
} }
inline const DOFIteratorBase& operator--() { inline const DOFIteratorBase& operator--()
{
if (type == ALL_DOFS) { if (type == ALL_DOFS) {
decObjectIterator(); decObjectIterator();
dofFreeIterator--; dofFreeIterator--;
...@@ -160,14 +165,16 @@ namespace AMDiS { ...@@ -160,14 +165,16 @@ namespace AMDiS {
return *this; return *this;
} }
inline DOFIteratorBase operator--(int) { inline DOFIteratorBase operator--(int)
{
DOFIteratorBase clone = *this; DOFIteratorBase clone = *this;
operator--(); operator--();
return clone; return clone;
} }
/// Dereferntiation of the \ref dofFreeIterator /// Dereferntiation of the \ref dofFreeIterator
virtual bool isDOFFree() { virtual bool isDOFFree()
{
return *dofFreeIterator; return *dofFreeIterator;
} }
...@@ -175,12 +182,21 @@ namespace AMDiS { ...@@ -175,12 +182,21 @@ namespace AMDiS {
* Returns whether \ref dofFreeIterator already has reached the end of * Returns whether \ref dofFreeIterator already has reached the end of
* \ref dofFree * \ref dofFree
*/ */
inline bool end() { return (dofFreeIterator == dofFree->end()); } inline bool end()
{
return (dofFreeIterator == dofFree->end());
}
inline bool begin() { return (dofFreeIterator == dofFree->begin()); } inline bool begin()
{
return (dofFreeIterator == dofFree->begin());
}
/// Returns the current position index of this iterator /// Returns the current position index of this iterator
inline int getDOFIndex() { return position; } inline int getDOFIndex()
{
return position;
}
protected: protected:
/// Override this to enable iteration through the object /// Override this to enable iteration through the object
...@@ -237,33 +253,57 @@ namespace AMDiS { ...@@ -237,33 +253,57 @@ namespace AMDiS {
{} {}
/// Dereference operator /// Dereference operator
inline T& operator*() { return *it; } inline T& operator*()
{
return *it;
}
/// Dereference operator /// Dereference operator
inline T* operator->() { return &(*it); } inline T* operator->()
{
return &(*it);
}
inline bool operator!=(const DOFIterator<T>& rhs)
{
if (this->iteratedObject != rhs.iteratedObject)
return true;
if (this->it != rhs.it)
return true;
inline bool operator!=(const DOFIterator<T>& rhs) {
if(this->iteratedObject != rhs.iteratedObject) return true;
if(this->it != rhs.it) return true;
return false; return false;
} }
inline bool operator==(const DOFIterator<T>& rhs) { inline bool operator==(const DOFIterator<T>& rhs)
{
return !(this->operator==(rhs)); return !(this->operator==(rhs));
} }
protected: protected:
/// Implementation of DOFIteratorBase::goToBeginOfIteratedObject() /// Implementation of DOFIteratorBase::goToBeginOfIteratedObject()
inline void goToBeginOfIteratedObject() { it = iteratedObject->begin(); } inline void goToBeginOfIteratedObject()
{
it = iteratedObject->begin();
}
/// Implementation of DOFIteratorBase::goToEndOfIteratedObject() /// Implementation of DOFIteratorBase::goToEndOfIteratedObject()
inline void goToEndOfIteratedObject() { it = iteratedObject->end(); } inline void goToEndOfIteratedObject()
{
it = iteratedObject->end();
}
/// Implementation of DOFIteratorBase::incObjectIterator() /// Implementation of DOFIteratorBase::incObjectIterator()
inline void incObjectIterator() { ++it; } inline void incObjectIterator()
{
++it;
}
/// Implementation of DOFIteratorBase::incObjectIterator() /// Implementation of DOFIteratorBase::incObjectIterator()
inline void decObjectIterator() { --it; } inline void decObjectIterator()
{
--it;
}
protected: protected:
/// Object that is iterated /// Object that is iterated
......
...@@ -189,9 +189,8 @@ namespace AMDiS { ...@@ -189,9 +189,8 @@ namespace AMDiS {
for (std::set<int>::iterator itRanks = partitionDofs[it->first].begin(); for (std::set<int>::iterator itRanks = partitionDofs[it->first].begin();
itRanks != partitionDofs[it->first].end(); itRanks != partitionDofs[it->first].end();
++itRanks) { ++itRanks) {
if (*itRanks != mpiRank) { if (*itRanks != mpiRank)
sendNewDofs[*itRanks][oldDofIndex] = newDofIndex; sendNewDofs[*itRanks][oldDofIndex] = newDofIndex;
}
} }
} else { } else {
recvNewDofs[it->second].push_back((it->first)[0]); recvNewDofs[it->second].push_back((it->first)[0]);
...@@ -261,9 +260,8 @@ namespace AMDiS { ...@@ -261,9 +260,8 @@ namespace AMDiS {
/// === Change dof indices for rank partition. === /// === Change dof indices for rank partition. ===
for (int i = 0; i < static_cast<int>(rankDofs.size()); i++) { for (int i = 0; i < static_cast<int>(rankDofs.size()); i++)
const_cast<DegreeOfFreedom*>(rankDofs[i])[0] = rstart + i; const_cast<DegreeOfFreedom*>(rankDofs[i])[0] = rstart + i;
}
/// === Create petsc matrix. === /// === Create petsc matrix. ===
int ierr; int ierr;
......
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