let3d_mpi.hpp

Go to the documentation of this file.
00001 /* Kernel Independent Fast Multipole Method
00002    Copyright (C) 2004 Lexing Ying, New York University
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2, or (at your option)
00007 any later version.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00012 for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; see the file COPYING.  If not, write to the Free
00016 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017 02111-1307, USA.  */
00018 #ifndef _LET3D_HPP_
00019 #define _LET3D_HPP_
00020 
00021 #include "common/vec3t.hpp"
00022 #include "common/nummat.hpp"
00023 #include "comobject_mpi.hpp"
00024 
00025 using std::vector;
00026 
00027 enum {
00029   LET_CBTRNODE = 1,
00031   LET_USERNODE = 2,
00033   LET_EVTRNODE = 4,
00035   LET_OWNRNODE = 8,
00037   LET_SRCENODE = 16 
00038 };
00039 
00040 //---------------------------------------------------------------------------
00042 
00051 class Let3d_MPI: public ComObject_MPI
00052 {
00053   //---------------------------------------
00054 public:
00056   class NodeExt {
00057   public:
00060          vector<int> _Unodes;
00063          vector<int> _Vnodes;
00067          vector<int> _Wnodes;
00069          vector<int> _Xnodes;
00070 
00072          int _ctbSrcNodeIdx;
00074          int _ctbSrcExaBeg;
00076          int _ctbSrcExaNum;
00078          vector<int> _ctbSrcOwnVecIdxs;
00079 
00081          int _usrSrcNodeIdx;
00083          int _usrSrcExaBeg;
00085          int _usrSrcExaNum;
00086 
00088          int _evaTrgNodeIdx;
00090          int _evaTrgExaBeg;
00092          int _evaTrgExaNum;
00094          vector<int> _evaTrgOwnVecIdxs;
00095   public:
00097          NodeExt(): 
00098                 _ctbSrcNodeIdx(0), _ctbSrcExaBeg(0), _ctbSrcExaNum(0),
00099                 _usrSrcNodeIdx(0), _usrSrcExaBeg(0), _usrSrcExaNum(0),
00100                 _evaTrgNodeIdx(0), _evaTrgExaBeg(0), _evaTrgExaNum(0)
00101          {;}
00102   };
00104 
00107   class Node {
00108   protected:
00110          int _par;
00112          int _chd;
00117          Index3 _path2Node;
00119          int _depth;
00121          int _glbSrcNodeIdx;
00123          int _glbSrcExaBeg;
00125          int _glbSrcExaNum;
00127          int _tag;
00129          NodeExt* _ptr;
00130   public:
00132          Node(int p, int c, Index3 t, int d):
00133                 _par(p), _chd(c), _path2Node(t), _depth(d),
00134                 _tag(false), _ptr(NULL) {;}
00135          ~Node() {
00136                 if(_ptr!=NULL)            delete _ptr;
00137          }
00138          //access
00140          int& par() { return _par; }
00142          int& chd() { return _chd; }
00144          Index3& path2Node() { return _path2Node; }
00146          int& depth() { return _depth; }
00148          int& tag() { return _tag; }
00150          int& glbSrcNodeIdx() { return _glbSrcNodeIdx; }
00152          int& glbSrcExaBeg() { return _glbSrcExaBeg; }
00154          int& glbSrcExaNum() { return _glbSrcExaNum; }
00155 
00157          NodeExt* ptr() {               if(_ptr==NULL) _ptr = new NodeExt();            return _ptr;     }
00158 
00160          vector<int>& Unodes() { return ptr()->_Unodes; }
00162          vector<int>& Vnodes() { return ptr()->_Vnodes; }
00164          vector<int>& Wnodes() { return ptr()->_Wnodes; }
00166          vector<int>& Xnodes() { return ptr()->_Xnodes; }
00167 
00169          int& ctbSrcNodeIdx() { return ptr()->_ctbSrcNodeIdx; }
00171          int& ctbSrcExaBeg() { return ptr()->_ctbSrcExaBeg; }
00173          int& ctbSrcExaNum() { return ptr()->_ctbSrcExaNum; }
00175          vector<int>& ctbSrcOwnVecIdxs() { return ptr()->_ctbSrcOwnVecIdxs; }
00176 
00178          int& usrSrcNodeIdx() { return ptr()->_usrSrcNodeIdx; }
00180          int& usrSrcExaBeg() { return ptr()->_usrSrcExaBeg; }
00182          int& usrSrcExaNum() { return ptr()->_usrSrcExaNum; }
00183 
00185          int& evaTrgNodeIdx() { return ptr()->_evaTrgNodeIdx; }
00187          int& evaTrgExaBeg() { return ptr()->_evaTrgExaBeg; }
00189          int& evaTrgExaNum() { return ptr()->_evaTrgExaNum; }
00191          vector<int>& evaTrgOwnVecIdxs() { return ptr()->_evaTrgOwnVecIdxs; }
00192   };
00193   
00194   //---------------------------------------
00195 protected:
00196   //PARAMS
00198   Vec _srcPos;
00200   Vec _trgPos;
00202   Point3 _ctr;
00204   int _rootLevel;
00205 
00207   int _ptsMax;
00209   int _maxLevel;
00210 
00212   vector<Node> _nodeVec;
00213 
00215   int _glbGlbSrcNodeCnt;
00217   int _glbGlbSrcExaCnt;
00219   int _lclGlbSrcNodeCnt;
00221   int _lclGlbSrcExaCnt;
00222 
00224   int _ctbSrcNodeCnt;
00226   int _ctbSrcExaCnt;
00228   vector<int> _ctb2GlbSrcNodeMap;
00230   vector<int> _ctb2GlbSrcExaMap;
00231 
00233   int _evaTrgNodeCnt;
00235   int _evaTrgExaCnt;
00236 
00238   int _usrSrcNodeCnt;
00240   int _usrSrcExaCnt;
00242   vector<int> _usr2GlbSrcNodeMap;
00244   vector<int> _usr2GlbSrcExaMap;
00245   
00246   //---------------------------------------
00247 public:
00249   Let3d_MPI(const string& p);
00250   ~Let3d_MPI();
00251   //MEMBER ACCESS
00253   Vec& srcPos() { return _srcPos; }
00255   Vec& trgPos() { return _trgPos; }
00257   Point3& ctr() { return _ctr; }
00259   int& rootLevel() { return _rootLevel; }
00261   double radius() { return pow(2.0, -_rootLevel); }
00263   int& ptsMax() { return _ptsMax; }
00265   int& maxLevel() { return _maxLevel; }
00266   //SETUP AND USE
00268   int setup();
00273   int print();
00274   //construction
00277   int srcData();
00280   int trgData();
00281   //---------------------------------------------
00282   //LOCAL
00284   int calGlbNodeLists(int gNodeIdx);
00286   int dwnOrderCollect(vector<int>&);
00288   int upwOrderCollect(vector<int>&); 
00289 
00291   vector<Node>& nodeVec() { return _nodeVec; }
00293   Node& node(int gNodeIdx) { return _nodeVec[gNodeIdx]; }
00295   bool    root(int gNodeIdx)     { return node(gNodeIdx).par()==-1; }
00297   bool    terminal(int gNodeIdx) { return node(gNodeIdx).chd()==-1; }
00299   int     parent(int gNodeIdx)   { assert(node(gNodeIdx).par()!=-1); return node(gNodeIdx).par(); }
00305   int     child( int gNodeIdx, const Index3& Idx);
00310   Index3  path2Node(int gNodeIdx)     { return node(gNodeIdx).path2Node(); }
00312   int     depth(int gNodeIdx)    { return node(gNodeIdx).depth(); }
00314   Point3  center(int gNodeIdx);
00320   double  radius(int gNodeIdx);
00321 
00323   int& glbGlbSrcNodeCnt() { return _glbGlbSrcNodeCnt; }
00325   int& glbGlbSrcExaCnt() { return _glbGlbSrcExaCnt; }
00327   int& lclGlbSrcNodeCnt() { return _lclGlbSrcNodeCnt; }
00329   int& lclGlbSrcExaCnt() { return _lclGlbSrcExaCnt; }
00330 
00332   int& ctbSrcNodeCnt() { return _ctbSrcNodeCnt; }
00334   int& ctbSrcExaCnt() { return _ctbSrcExaCnt; }
00336   vector<int>& ctb2GlbSrcNodeMap() { return _ctb2GlbSrcNodeMap; }
00338   vector<int>& ctb2GlbSrcExaMap() { return _ctb2GlbSrcExaMap; }
00339 
00341   int& evaTrgNodeCnt() { return _evaTrgNodeCnt; }
00343   int& evaTrgExaCnt() { return _evaTrgExaCnt; }
00344 
00346   int& usrSrcNodeCnt() { return _usrSrcNodeCnt; }
00348   int& usrSrcExaCnt() { return _usrSrcExaCnt; }
00350   vector<int>& usr2GlbSrcNodeMap() { return _usr2GlbSrcNodeMap; }
00352   vector<int>& usr2GlbSrcExaMap() { return _usr2GlbSrcExaMap; }
00353 
00359   int findGlbNode(int depth, const Index3& path2Node);
00361   bool adjacent(int me , int you);
00362 
00364   int dim() const { return 3; }
00365   
00368   int  procLclNum(Vec pos) { int tmp; VecGetLocalSize(pos, &tmp); return tmp/dim(); }
00370   int  procGlbNum(Vec pos) { int tmp; VecGetSize(     pos, &tmp); return tmp/dim(); }
00373   void procLclRan(Vec pos, int& beg, int& end) { VecGetOwnershipRange(pos, &beg, &end); beg=beg/dim(); end=end/dim(); }
00374 };
00375 
00376 #endif

Generated on Sun Dec 4 21:12:40 2005 for fmm3d_mpi by  doxygen 1.4.5