diff --git a/common/collectivecommunication.hh b/common/collectivecommunication.hh index e79d549ae6b4197d8059e3fdcca5d75b40fd267e..841f8ee20e2dd633ef2d279fbbc4316fe1ea0ffc 100644 --- a/common/collectivecommunication.hh +++ b/common/collectivecommunication.hh @@ -11,11 +11,23 @@ namespace Dune { - /*! @brief Collective communication sequential default implementation + /*! @brief Collective communication interface and sequential default implementation - This class implements global communication functions in a sequential - environment without doing any communication. In specializations - one can implement the real thing. + A CollectiveCommunication object is returned by all grids (also + the sequential ones) in order to allow code to be written in + a transparent way for sequential and parallel grids. + + This class provides a default implementation for sequential grids. + The number of processes involved is 1, any sum, maximum, etc. returns + just its input argument and so on. + + In specializations one can implement the real thing using appropriate + communication functions, e.g. there exists an implementation using + the Message Passing %Interface (MPI), see Dune::CollectiveCommunication<MPI_Comm>. + + Moreover, the communication subsystem used by an implementation + is not visible in the interface, i.e. Dune grid implementations + are not restricted to MPI. \ingroup GICollectiveCommunication */ @@ -23,78 +35,116 @@ namespace Dune class CollectiveCommunication { public: + //! Construct default object CollectiveCommunication () {} + //! Return rank, is between 0 and size()-1 int rank () const { return 0; } + //! Number of processes in set, is greater than 0 int size () const { return 1; } + /** @brief Compute the sum of the argument over all processes and + return the result in every process. Assumes that T has an operator+ + */ template<typename T> T sum (T& in) const // MPI does not know about const :-( { return in; } + /** @brief Compute the sum over all processes for each component of an array and return the result + in every process. Assumes that T has an operator+ + */ template<typename T> int sum (T* inout, int len) const { return 0; } + /** @brief Compute the product of the argument over all processes and + return the result in every process. Assumes that T has an operator* + */ template<typename T> T prod (T& in) const // MPI does not know about const :-( { return in; } + /** @brief Compute the product over all processes + for each component of an array and return the result + in every process. Assumes that T has an operator* + */ template<typename T> int prod (T* inout, int len) const { return 0; } + /** @brief Compute the minimum of the argument over all processes and + return the result in every process. Assumes that T has an operator< + */ template<typename T> T min (T& in) const // MPI does not know about const :-( { return in; } + /** @brief Compute the minimum over all processes + for each component of an array and return the result + in every process. Assumes that T has an operator< + */ template<typename T> int min (T* inout, int len) const { return 0; } + /** @brief Compute the maximum of the argument over all processes and + return the result in every process. Assumes that T has an operator< + */ template<typename T> T max (T& in) const // MPI does not know about const :-( { return in; } + /** @brief Compute the maximum over all processes + for each component of an array and return the result + in every process. Assumes that T has an operator< + */ template<typename T> int max (T* inout, int len) const { return 0; } + /** @brief Wait until all processes have arrived at this point in the program. + */ int barrier () const { return 0; } + /** @brief Distribute an array from the process with rank root to all other processes + */ template<typename T> int broadcast (T* inout, int len, int root) const { return 0; } + /** @brief Each process sends its in array of length len to the root process + (including the root itself). In the root process these arrays are stored in rank + order in the out array which must have size len * number of processes. + */ template<typename T> int gather (T* in, T* out, int len, int root) const // note out must have same size as in { diff --git a/common/mpicollectivecommunication.hh b/common/mpicollectivecommunication.hh index ab28c84dc7ece0588420181c851b76072ffdb6c6..b2f700210f966b3772f9ccfd8452537472e7df3d 100644 --- a/common/mpicollectivecommunication.hh +++ b/common/mpicollectivecommunication.hh @@ -453,6 +453,7 @@ namespace Dune class CollectiveCommunication<MPI_Comm> { public: + //! Instantiation using a MPI communicator CollectiveCommunication (const MPI_Comm& c) : communicator(c) { @@ -460,16 +461,19 @@ namespace Dune MPI_Comm_size(communicator,&procs); } + //! @copydoc CollectiveCommunication::rank() int rank () const { return me; } + //! @copydoc CollectiveCommunication::size() int size () const { return procs; } + //! @copydoc CollectiveCommunication::sum(T&) template<typename T> T sum (T& in) const // MPI does not know about const :-( { @@ -479,6 +483,7 @@ namespace Dune return out; } + //! @copydoc CollectiveCommunication::sum(T*,int) template<typename T> int sum (T* inout, int len) const { @@ -487,6 +492,7 @@ namespace Dune GenericSum_MPI_Op<T>::get(),communicator); } + //! @copydoc CollectiveCommunication::prod(T&) template<typename T> T prod (T& in) const // MPI does not know about const :-( { @@ -496,6 +502,7 @@ namespace Dune return out; } + //! @copydoc CollectiveCommunication::prod(T*,int) template<typename T> int prod (T* inout, int len) const { @@ -504,6 +511,7 @@ namespace Dune GenericProduct_MPI_Op<T>::get(),communicator); } + //! @copydoc CollectiveCommunication::min(T&) template<typename T> T min (T& in) const // MPI does not know about const :-( { @@ -513,6 +521,7 @@ namespace Dune return out; } + //! @copydoc CollectiveCommunication::min(T*,int) template<typename T> int min (T* inout, int len) const { @@ -521,6 +530,7 @@ namespace Dune GenericMin_MPI_Op<T>::get(),communicator); } + //! @copydoc CollectiveCommunication::max(T&) template<typename T> T max (T& in) const // MPI does not know about const :-( { @@ -530,6 +540,7 @@ namespace Dune return out; } + //! @copydoc CollectiveCommunication::max(T*,int) template<typename T> int max (T* inout, int len) const { @@ -538,19 +549,21 @@ namespace Dune GenericMax_MPI_Op<T>::get(),communicator); } + //! @copydoc CollectiveCommunication::barrier() int barrier () const { return MPI_Barrier(communicator); } - //! send array from process with rank root to all others + //! @copydoc CollectiveCommunication::broadcast() template<typename T> int broadcast (T* inout, int len, int root) const { return MPI_Bcast(inout,len,Generic_MPI_Datatype<T>::get(),root,communicator); } - //! receive array of values from each processor in root + + //! @copydoc CollectiveCommunication::gather() template<typename T> int gather (T* in, T* out, int len, int root) const // note out must have space for P*len elements { diff --git a/grid/common/grid.hh b/grid/common/grid.hh index e8d7879216533909658180aa3c8dd39deb7d3934..6bcbc50c40862e6aedee7beffffb106441b95931 100644 --- a/grid/common/grid.hh +++ b/grid/common/grid.hh @@ -344,7 +344,7 @@ namespace Dune { */ /** - @addtogroup GridImplementations Implementations Overview + @addtogroup GridImplementations Implementations of the Dune grid interface @ingroup Grid @brief A List of the different Implementations of the Dune Grid Interface. */ diff --git a/grid/sgrid.hh b/grid/sgrid.hh index a6956635633aeaada9ed579836b2cd2e81b14c12..871a55f929522c22ebb69af88a2963740083853a 100644 --- a/grid/sgrid.hh +++ b/grid/sgrid.hh @@ -1169,7 +1169,7 @@ namespace Dune { /** \brief [<em> provides \ref Dune::Grid </em>] \brief A structured mesh in d dimensions consisting of "cubes". - \ingroup GImpSGrid + \ingroup GridImplementations This module describes the pilot implementation of the Dune grid interface. It implements the grid interface for simple structured meshes. diff --git a/grid/yaspgrid.hh b/grid/yaspgrid.hh index 9daff01033850e5c745cb582854e8aeb3ee43b73..23c7ad87bf40d73776ba7a77a8ff85e0b45cb6f5 100644 --- a/grid/yaspgrid.hh +++ b/grid/yaspgrid.hh @@ -2116,18 +2116,15 @@ namespace Dune { /*! \brief [<em> provides \ref Dune::Grid </em>] \brief Provides a distributed structured cube mesh. - \ingroup GImpYaspGrid + \ingroup GridImplementations YaspGrid stands for yet another structured parallel grid. - It will implement the dune grid interface for structured grids with codim 0 - and dim, with arbitrary overlap, parallel features with two overlap - models, periodic boundaries and fast a implementation allowing on-the-fly computations. + It implements the dune grid interface for structured grids with codim 0 + and dim, with arbitrary overlap (including zero), + periodic boundaries and fast implementation allowing on-the-fly computations. \par History: \li started on July 31, 2004 by PB based on abstractions developed in summer 2003 - - \note The only class intended for public use is \ref Dune::YaspGrid - itself. All other classes are of no use for an application writer. */ template<int dim, int dimworld> class YaspGrid :