parallel/pico/DomainCoupler.hpp

00001 // -*- C++ -*-
00002 //
00003 //  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 //                                   Fehmi Cirak
00006 //                        California Institute of Technology
00007 //                           (C) 2004 All Rights Reserved
00008 //
00009 //  <LicenseText>
00010 //
00011 //  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00012 //
00013 // EDITED BY MATT GALLOWAY FOR USE WITH DAPTA
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 { // Define namespace DAPTA
00026 
00027 namespace pico { // Define namespace pico
00028 
00029 template <typename V>
00030 class DomainCoupler {
00031    //
00032    // Each rank of the MPI communicator _pComm owns upto two types subdomains (0/1).
00033    //
00034    // Communication between subdomains of type 0 and 1 is called inter communication. 
00035    // Communication between subdomains of only  type 0 or only type 1 is called  
00036    // intra communication. 
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       // registration
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       // communication
00055       void prepareCommunicationsIntra(const SolvType& type);
00056       void exchangeSubdomainDataIntra(const SolvType& type);    
00057       void prepareCommunicationsInter();
00058       
00059       // register buffers
00060       template <typename T>
00061       void registerSendBuffer(const SolvType& type, T* const start, int size);
00062       
00063       // accessors for receive buffer
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       // helper - for debugging purposes
00070       template <typename Iterator> 
00071       void relevantSubDomainNumbers(Iterator domainNumbers, int t, char *tch);
00072    
00073    private:
00074       // copy and equality constructor
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       // std::map<processor number, subdomain pointer>
00089       _SubDomainCont                            _subDomains[2];
00090       
00091       _SubDomainCont                            _relevSubDomainsInter[2];
00092       _SubDomainCont                            _relevSubDomainsIntra[2];
00093       
00094       MPI_Comm                                  _pComm;
00095 }; 
00096 
00097 } // namespace pico
00098 
00099 } // namespace DAPTA
00100 
00101 #include "DomainCoupler.cpp"
00102 
00103 #endif

Generated on Tue May 29 17:13:49 2007 for DAPTA by  doxygen 1.5.1