00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __DOMAINCOUPLER_HPP__
00016 #define __DOMAINCOUPLER_HPP__
00017
00018 #include "PicoNames.hpp"
00019 #include "SubDomain.hpp"
00020
00021 #include <map>
00022 #include <cassert>
00023 #include <mpi.h>
00024
00025 namespace DAPTA {
00026
00027 namespace pico {
00028
00029 template <typename V>
00030 class DomainCoupler {
00031
00032
00033
00034
00035
00036
00037
00038
00039 public:
00040 typedef V VertexType;
00041 typedef V* VertexHandle;
00042 typedef typename VertexType::CoordType CoordType;
00043 typedef typename VertexType::CoordArrayType CoordArrayType;
00044
00045 DomainCoupler(MPI_Comm pComm) : _pComm(pComm) { assert(_pComm != MPI_COMM_NULL); }
00046 ~DomainCoupler() {;}
00047
00048
00049 void registerSubDomain(const SolvType& type, const CoordArrayType lo,
00050 const CoordArrayType up, const double& maxElemSize);
00051 void registerSubDomain(const SolvType& type, const CoordType * const coor,
00052 const int& nodes, const double& maxElemSize);
00053
00054
00055 void prepareCommunicationsIntra(const SolvType& type);
00056 void exchangeSubdomainDataIntra(const SolvType& type);
00057 void prepareCommunicationsInter();
00058
00059
00060 template <typename T>
00061 void registerSendBuffer(const SolvType& type, T* const start, int size);
00062
00063
00064 template <typename RT>
00065 RT* recvBuffer(const SolvType& type, const RT& notUsed);
00066 template <typename T>
00067 int recvBufferSize(const SolvType& type);
00068
00069
00070 template <typename Iterator>
00071 void relevantSubDomainNumbers(Iterator domainNumbers, int t, char *tch);
00072
00073 private:
00074
00075 DomainCoupler(const DomainCoupler<V> &);
00076 const DomainCoupler<V> & operator=(const DomainCoupler<V> &);
00077
00078 private:
00079 void gatherSubDomains();
00080 void relevantSubDomainsInter();
00081 void relevantSubDomainsIntra(const SolvType& type);
00082 void exchangeBufferSizesIntra(const SolvType& type);
00083
00084 private:
00085 typedef std::map<int, SubDomain<V>*> _SubDomainCont;
00086 typedef typename _SubDomainCont::iterator _SubDomainIt;
00087
00088
00089 _SubDomainCont _subDomains[2];
00090
00091 _SubDomainCont _relevSubDomainsInter[2];
00092 _SubDomainCont _relevSubDomainsIntra[2];
00093
00094 MPI_Comm _pComm;
00095 };
00096
00097 }
00098
00099 }
00100
00101 #include "DomainCoupler.cpp"
00102
00103 #endif