Skip to content
Snippets Groups Projects
Commit 4fa23fff authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

use method clone to copy Comm<>


git-svn-id: https://dune.mathematik.uni-freiburg.de/svn/alugrid/trunk@1142 0d966ed9-3843-0410-af09-ebfb50bd7c74
parent bfea379e
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ class MpAccessGlobal {
CommIF () {}
public:
virtual ~CommIF() {}
virtual CommIF* clone () const = 0;
};
inline virtual ~MpAccessGlobal () ;
......
......@@ -52,7 +52,7 @@ int MpAccessMPI :: getRank()
}
MpAccessMPI :: MpAccessMPI (const MpAccessMPI & a)
: _mpiCommPtr(new Comm<MPI_Comm> (getMPICommunicator(a._mpiCommPtr))),
: _mpiCommPtr( a._mpiCommPtr->clone() ),
_psize( getSize() ) , _myrank( getRank() )
{
}
......
......@@ -22,7 +22,11 @@ public:
Comm( MPICommunicator );
// destructor freeing mpi communicator
~Comm();
// conversion operator to MPI_Comm
operator MPICommunicator () const { return _mpiComm; }
//! return copy of this object
virtual CommIF* clone() const { return new Comm< MPICommunicator > ( _mpiComm ); }
};
protected:
......@@ -37,6 +41,8 @@ protected:
int mpi_allgather (char *, int, char *, int) const ;
int mpi_allgather (double *, int, double *, int ) const ;
public :
// constructor taking MPI_Comm
// to avoid MPI types here this is a template constructor
template <class MPICommunicator>
inline MpAccessMPI (MPICommunicator mpicomm )
: _mpiCommPtr( new Comm<MPICommunicator> ( mpicomm ) ),
......@@ -44,7 +50,9 @@ public :
{
}
// copy constructor
MpAccessMPI (const MpAccessMPI &) ;
// destructor
~MpAccessMPI () ;
protected:
int getSize () ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment