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