diff --git a/istl/paamg/construction.hh b/istl/paamg/construction.hh index 92a3ab0634d73821c72998f356b5360c3e28dc40..2211a8ebb58f295e1b6fd38a5c029479d85ece80 100644 --- a/istl/paamg/construction.hh +++ b/istl/paamg/construction.hh @@ -163,23 +163,6 @@ namespace Dune #if HAVE_MPI - template<typename T> - class ConstructionTraits<ParallelInformation<T> > - { - public: - typedef const MPI_Comm Arguments; - - static inline ParallelInformation<T>* construct(Arguments& args) - { - return new ParallelInformation<T>(args); - } - - static inline void deconstruct(ParallelInformation<T>* pi) - { - delete pi; - } - }; - template<class T1, class T2> class ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> > diff --git a/istl/paamg/globalaggregates.hh b/istl/paamg/globalaggregates.hh index 0c078589a93b8bdfa435223c3d8f380eb69dc63c..177c8ab53ea17f068571ab5b10d40c4b4f39d35d 100644 --- a/istl/paamg/globalaggregates.hh +++ b/istl/paamg/globalaggregates.hh @@ -118,27 +118,6 @@ namespace Dune {}; #if HAVE_MPI - template<typename T, typename O, typename T1> - struct AggregatesPublisher<T,O,ParallelInformation<T1> > - { - typedef T Vertex; - typedef O OverlapFlags; - typedef Dune::Amg::ParallelInformation<T1> ParallelInformation; - typedef typename ParallelInformation::ParallelIndexSet IndexSet; - - static void publish(AggregatesMap<Vertex>& aggregates, - ParallelInformation& pinfo, - const GlobalLookupIndexSet<IndexSet>& globalLookup) - { - typedef Dune::Amg::GlobalAggregatesMap<Vertex,IndexSet> GlobalMap; - GlobalMap gmap(aggregates, globalLookup); - pinfo.template buildInterface<OverlapFlags>(); - pinfo.template buildCommunicator<GlobalMap>(gmap, gmap); - pinfo.template communicateForward<AggregatesGatherScatter<Vertex,IndexSet> >(gmap, gmap); - pinfo.freeCommunicator(); - } - - }; #endif diff --git a/istl/paamg/indicescoarsener.hh b/istl/paamg/indicescoarsener.hh index 6307c250ee429c0c870a024635296e58374c3a8e..a931c52127efd06d4659fc247ae7284ee0aa57e8 100644 --- a/istl/paamg/indicescoarsener.hh +++ b/istl/paamg/indicescoarsener.hh @@ -189,16 +189,14 @@ namespace Dune }; + /** + * @brief Coarsen Indices in the parallel case. + */ template<typename G, typename L, typename E> class IndicesCoarsener<OwnerOverlapCopyCommunication<G,L>,E> : public ParallelIndicesCoarsener<OwnerOverlapCopyCommunication<G,L>,E> {}; - template<typename T,typename E> - class IndicesCoarsener<ParallelInformation<T>,E> - : public ParallelIndicesCoarsener<ParallelInformation<T>,E> - {}; - #endif diff --git a/istl/paamg/pinfo.hh b/istl/paamg/pinfo.hh index 808485b0e762f0126f3a6838b73bcea0f8d106b1..cbe6480b29857ee98ddc7ea1c6cbf6cf41495f88 100644 --- a/istl/paamg/pinfo.hh +++ b/istl/paamg/pinfo.hh @@ -23,75 +23,6 @@ namespace Dune namespace Amg { -#if HAVE_MPI - - template<class T> - class ParallelInformation - { - public: - typedef T ParallelIndexSet; - typedef Dune::RemoteIndices<ParallelIndexSet> RemoteIndices; - typedef Dune::Interface<ParallelIndexSet> Interface; - typedef Dune::BufferedCommunicator<ParallelIndexSet>Communicator; - typedef Dune::GlobalLookupIndexSet<ParallelIndexSet> GlobalLookupIndexSet; - typedef Dune::CollectiveCommunication<MPI_Comm> MPICommunicator; - - enum { - category = SolverCategory::overlapping - }; - - ParallelInformation(const MPI_Comm& comm); - - ~ParallelInformation(); - - const MPICommunicator& communicator() const; - - template<bool ignorePublic> - void rebuildRemoteIndices(); - - template<typename OverlapFlags> - void buildInterface(); - - template<typename Data> - void buildCommunicator(const Data& source, const Data& dest); - - void freeCommunicator(); - - template<class GatherScatter, class Data> - void communicateForward(const Data& source, Data& dest); - - template<class GatherScatter, class Data> - void communicateBackward(Data& source, const Data& dest); - - ParallelIndexSet& indexSet(); - - const ParallelIndexSet& indexSet() const; - - RemoteIndices& remoteIndices(); - - const RemoteIndices& remoteIndices() const; - - Interface& interface(); - - const Interface& interface() const; - - void buildGlobalLookup(std::size_t); - - void freeGlobalLookup(); - - const GlobalLookupIndexSet& globalLookup() const; - - private: - ParallelIndexSet* indexSet_; - RemoteIndices* remoteIndices_; - Interface* interface_; - Communicator* communicator_; - MPICommunicator mpiCommunicator_; - GlobalLookupIndexSet* globalLookup_; - }; - -#endif - class SequentialInformation { public: @@ -150,128 +81,6 @@ namespace Dune GlobalLookupIndexSet gli; }; -#if HAVE_MPI - template<class T> - ParallelInformation<T>::ParallelInformation(const MPI_Comm& comm) - : indexSet_(new ParallelIndexSet()), - remoteIndices_(new RemoteIndices(*indexSet_, *indexSet_, comm)), - interface_(new Interface()), communicator_(new Communicator()), - mpiCommunicator_(comm), globalLookup_(0) - {} - - template<class T> - ParallelInformation<T>::~ParallelInformation() - { - delete communicator_; - delete interface_; - delete remoteIndices_; - delete indexSet_; - } - - template<class T> - inline const typename ParallelInformation<T>::MPICommunicator& - ParallelInformation<T>::communicator() const - { - return mpiCommunicator_; - } - - template<class T> - template<bool ignorePublic> - inline void ParallelInformation<T>::rebuildRemoteIndices() - { - remoteIndices_->template rebuild<ignorePublic>(); - } - - template<class T> - template<typename OverlapFlags> - inline void ParallelInformation<T>::buildInterface() - { - interface_->build(*remoteIndices_, NegateSet<OverlapFlags>(), - OverlapFlags()); - } - - - template<class T> - template<typename Data> - inline void ParallelInformation<T>::buildCommunicator(const Data& source, - const Data& dest) - { - communicator_->build(source, dest, *interface_); - } - - - template<class T> - inline void ParallelInformation<T>::freeCommunicator() - { - communicator_->free(); - } - - template<class T> - template<class GatherScatter, class Data> - inline void ParallelInformation<T>::communicateForward(const Data& source, Data& dest) - { - communicator_->template forward<GatherScatter>(source, dest); - } - - template<class T> - template<class GatherScatter, class Data> - inline void ParallelInformation<T>::communicateBackward(Data& source, const Data& dest) - { - communicator_->template backward<GatherScatter>(source, dest); - } - - template<class T> - typename ParallelInformation<T>::ParallelIndexSet& ParallelInformation<T>::indexSet(){ - return *indexSet_; - } - - template<class T> - const typename ParallelInformation<T>::ParallelIndexSet& ParallelInformation<T>::indexSet() const { - return *indexSet_; - } - - template<class T> - typename ParallelInformation<T>::RemoteIndices& ParallelInformation<T>::remoteIndices(){ - return *remoteIndices_; - } - - template<class T> - const typename ParallelInformation<T>::RemoteIndices& ParallelInformation<T>::remoteIndices() const { - return *remoteIndices_; - } - - template<class T> - typename ParallelInformation<T>::Interface& ParallelInformation<T>::interface(){ - return *interface_; - } - - template<class T> - const typename ParallelInformation<T>::Interface& ParallelInformation<T>::interface() const { - return *interface_; - } - - template<class T> - void ParallelInformation<T>::buildGlobalLookup(std::size_t size) - { - globalLookup_ = new GlobalLookupIndexSet(*indexSet_, size); - } - - template<class T> - void ParallelInformation<T>::freeGlobalLookup() - { - delete globalLookup_; - globalLookup_=0; - } - - template<class T> - const typename ParallelInformation<T>::GlobalLookupIndexSet& - ParallelInformation<T>::globalLookup() const - { - assert(globalLookup_ != 0); - return *globalLookup_; - } - -#endif } // namespace Amg } //namespace Dune diff --git a/istl/paamg/pmatrix.hh b/istl/paamg/pmatrix.hh deleted file mode 100644 index 36c4a515f658121e6ed8cf0a559f92c5906ac29e..0000000000000000000000000000000000000000 --- a/istl/paamg/pmatrix.hh +++ /dev/null @@ -1,110 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -#ifndef DUNE_AMG_PMATRIX_HH -#define DUNE_AMG_PMATRIX_HH - -#include <dune/common/helpertemplates.hh> -#include <dune/common/typetraits.hh> -#include <dune/istl/solvercategory.hh> -#include <dune/istl/operators.hh> -#include "pinfo.hh" - -#if HAVE_MPI - -namespace Dune -{ - namespace Amg - { - - /** - * @brief Matrix together with information about the distribution - * between the processes. - * - */ - template<class M, class IS, class X, class Y> - class ParallelMatrix : public AssembledLinearOperator<M,X,Y> - { - public: - /** @brief The type of the matrix. */ - typedef M Matrix; - /** - * @brief The type of the matrix. - * - * For use as an ISTL Operator. - */ - typedef M matrix_type; - /** @brief The type of the index set. */ - typedef Dune::Amg::ParallelInformation<IS> ParallelInformation; - - enum { - category = SolverCategory::overlapping - }; - - ParallelMatrix(const Matrix& matrix, const ParallelInformation& info) - : matrix_(&matrix), info_(&info) - {} - - - /** - * @brief Get the locally stored matrix. - * @return The locally stored matrix. - */ - const Matrix& getmat() const - { - return *matrix_; - } - /** - * @brief Get the index set that maps global indices to matrix rows. - * @return The index set. - */ - const ParallelInformation& info() const - { - return *info_; - } - - void apply(const X& x, Y&) const - { - DUNE_THROW(NotImplemented, "Markus was too lazy to implement this."); - } - - void applyscaleadd(typename X::field_type a, const X& x, Y&) const - { - DUNE_THROW(NotImplemented, "Markus was too lazy to implement this."); - } - private: - /** @brief The local part of the matrix. */ - const Matrix* matrix_; - /** @brief The index set. */ - const ParallelInformation* info_; - }; - - template<class M, class IS> - struct ParallelMatrixArgs - { - M& matrix; - ParallelInformation<IS>& info; - - ParallelMatrixArgs(M& m, ParallelInformation<IS>& i) - : matrix(m), info(i) - {} - }; - - template<class T> - class ConstructionTraits; - - template<class M, class IS, class X, class Y> - class ConstructionTraits<ParallelMatrix<M,IS,X,Y> > - { - public: - typedef const ParallelMatrixArgs<M,IS> Arguments; - - static inline ParallelMatrix<M,IS,X,Y>* construct(Arguments& args) - { - return new ParallelMatrix<M,IS,X,Y>(args.matrix, args.info); - } - }; - } // end namespace Amg - -} //end namespace Dune -#endif -#endif diff --git a/istl/paamg/test/galerkintest.cc b/istl/paamg/test/galerkintest.cc index e3a7e7e33e158cba68076397ce8dcf02f7d8f857..6383104797e22fbf3b3d8c9627d8c504075cfaca 100644 --- a/istl/paamg/test/galerkintest.cc +++ b/istl/paamg/test/galerkintest.cc @@ -15,6 +15,7 @@ #include <dune/common/fmatrix.hh> #include <dune/istl/paamg/indicescoarsener.hh> #include <dune/istl/paamg/galerkin.hh> +#include <dune/istl/owneroverlapcopy.hh> #include <dune/common/propertymap.hh> #include "anisotropic.hh" //#include<dune/istl/paamg/aggregates.hh> @@ -27,9 +28,10 @@ void testCoarsenIndices(int N) MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &procs); - typedef Dune::ParallelIndexSet<int,LocalIndex,512> ParallelIndexSet; - typedef Dune::RemoteIndices<ParallelIndexSet> RemoteIndices; - typedef Dune::Amg::ParallelInformation<ParallelIndexSet> ParallelInformation; + + typedef Dune::OwnerOverlapCopyCommunication<int> ParallelInformation; + typedef typename ParallelInformation::ParallelIndexSet ParallelIndexSet; + typedef typename ParallelInformation::RemoteIndices RemoteIndices; typedef Dune::FieldMatrix<double,BS,BS> Block; typedef Dune::BCRSMatrix<Block> BCRSMat; int n; @@ -43,7 +45,7 @@ void testCoarsenIndices(int N) BCRSMat mat = setupAnisotropic2d<BS>(N, indices, cc, &n); - pinfo.rebuildRemoteIndices<false>(); + pinfo.remoteIndices().rebuild<false>(); typedef Dune::Amg::MatrixGraph<BCRSMat> MatrixGraph; typedef Dune::Amg::SubGraph<Dune::Amg::MatrixGraph<BCRSMat>,std::vector<bool> > SubGraph; @@ -128,15 +130,15 @@ void testCoarsenIndices(int N) assert(mat.N()==mg.maxVertex()); - bool* visitedIterator = new bool[N*N]; + bool* visitedIterator = new bool[mat.N()]; - for(Vertex i=0; i < mg.maxVertex(); ++i) + for(Vertex i=0; i < mat.N(); ++i) visitedIterator[i]=false; VisitedMap2 visitedMap2(visitedIterator, Dune::IdentityMap()); BCRSMat* coarseMat = productBuilder.build(mat, mg, visitedMap2, pinfo, - aggregatesMap, coarseIndices.size(), + aggregatesMap, noCoarseVertices, Dune::EnumItem<GridFlag,GridAttributes::copy>()); delete[] visitedIterator; diff --git a/istl/paamg/transfer.hh b/istl/paamg/transfer.hh index 54682275d8c7e0232a949bf8c4185b8f41305a42..32075f3e8f18955d89ed8b4a5f5add53cee29dc1 100644 --- a/istl/paamg/transfer.hh +++ b/istl/paamg/transfer.hh @@ -58,20 +58,6 @@ namespace Dune #if HAVE_MPI - template<class V,class V1, class T> - class Transfer<V,V1,ParallelInformation<T> > - { - public: - typedef V Vertex; - typedef V1 Vector; - template<typename T1> - static void prolongate(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine, - T1 damp); - - static void restrict (const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector & fine, - ParallelInformation<T>& comm); - }; - template<class V,class V1, class T1, class T2> class Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> > { @@ -133,26 +119,6 @@ namespace Dune } #if HAVE_MPI - template<class V, class V1, class T> - template<typename T1> - inline void Transfer<V,V1,ParallelInformation<T> >::prolongate(const AggregatesMap<Vertex>& aggregates, - Vector& coarse, Vector& fine, - T1 damp) - { - Transfer<V,V1,SequentialInformation>::prolongate(aggregates, coarse, fine, damp); - } - - template<class V, class V1, class T> - inline void Transfer<V,V1,ParallelInformation<T> >::restrict (const AggregatesMap<Vertex>& aggregates, - Vector& coarse, const Vector & fine, - ParallelInformation<T>& comm) - { - Transfer<V,V1,SequentialInformation>::restrict (aggregates, coarse, fine, SequentialInformation()); - // We need this here to avoid it in the smoothers on the coarse level. - // There (in the preconditioner d is const. - comm.project(coarse); - } - template<class V, class V1, class T1, class T2> template<typename T3> inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::prolongate(const AggregatesMap<Vertex>& aggregates,