let3d.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.hpp"
00024 
00025 using std::vector;
00026 
00027 enum {
00028   LET_SRCNODE = 1,
00029   LET_TRGNODE = 2
00030 };
00031 
00032 //---------------------------------------------------------------------------
00033 // unique identifier: a set of points and its bounding box 
00034 class Let3d: public ComObject
00035 {
00036 public:
00037   //---------------------------------------
00038   class Node {
00039   protected:
00040          int _parent, _child;
00041          Index3 _path2Node;
00042          int _depth;
00043          int _tag; //s empty, t empty ...
00044 
00046          int _srcNodeIdx;
00048          int _srcExaBeg;
00050          int _srcExaNum;
00052          vector<int> _srcOwnVecIdxs;
00053 
00055          int _trgNodeIdx;
00057          int _trgExaBeg;
00059          int _trgExaNum;
00061          vector<int> _trgOwnVecIdxs;
00062 
00064          vector<int> _Unodes;
00066          vector<int> _Vnodes;
00068          vector<int> _Wnodes;
00070          vector<int> _Xnodes;
00071          
00072   public:
00073          Node(int p, int c, Index3 t, int d):
00074                 _parent(p), _child(c), _path2Node(t), _depth(d), _tag(false),
00075                 _srcNodeIdx(0), _srcExaBeg(0), _srcExaNum(0),
00076                 _trgNodeIdx(0), _trgExaBeg(0), _trgExaNum(0) {;}
00077 
00078          int& parent()        { return _parent; }
00079          int& child()           { return _child; }
00080          Index3& path2Node() { return _path2Node; }
00081          int& depth()         { return _depth; }
00082          int& tag()           { return _tag; }
00083          
00084          int& srcNodeIdx()            { return _srcNodeIdx; }
00085          int& srcExaBeg()           { return _srcExaBeg; }
00086          int& srcExaNum()           { return _srcExaNum; }
00087          vector<int>& srcOwnVecIdxs() { return _srcOwnVecIdxs; }
00088          
00089          int& trgNodeIdx()            { return _trgNodeIdx; }
00090          int& trgExaBeg()           { return _trgExaBeg; }
00091          int& trgExaNum()           { return _trgExaNum; }
00092          vector<int>& trgOwnVecIdxs() { return _trgOwnVecIdxs; }
00093          
00094          vector<int>& Unodes() { return _Unodes; }
00095          vector<int>& Vnodes() { return _Vnodes; }
00096          vector<int>& Wnodes() { return _Wnodes; }
00097          vector<int>& Xnodes() { return _Xnodes; }
00098   };
00099   //----------------------------------------------
00100 protected:
00101   //PARAMS(REQ)
00102   DblNumMat* _srcPos;
00103   DblNumMat* _trgPos;
00104   Point3 _center;
00105   int _rootLevel;
00106   //PARAMS(OPT)
00107   int _ptsMax;
00108   int _maxLevel; //AT MOST 16
00109   //COMPONENTS
00110   vector<Node> _nodeVec;
00111 
00113   int _level; 
00114   int _srcNodeCnt, _srcExaCnt;
00115   int _trgNodeCnt, _trgExaCnt;
00116 public:
00117   Let3d(const string& p);
00118   ~Let3d();
00119   //MEMBER ACCESS
00120   DblNumMat*& srcPos() { return _srcPos; }
00121   DblNumMat*& trgPos() { return _trgPos; }
00122   Point3& center() { return _center; }
00123   int& rootLevel() { return _rootLevel; }
00124   double radius()  { return pow(2.0, -_rootLevel); }
00125   int& ptsMax()  { return _ptsMax; }
00126   int& maxLevel()  { return _maxLevel; }
00127   //SETUP AND USE
00128   int setup(map<string,string>& opts);
00129   int print();
00130   //access
00131   vector<Node>& nodeVec() { return _nodeVec; }
00132   int srcNodeCnt()   { return _srcNodeCnt; }
00133   int srcExaCnt()  { return _srcExaCnt; }
00134   int trgNodeCnt()   { return _trgNodeCnt; }
00135   int trgExaCnt()  { return _trgExaCnt; }
00136   //construction
00137   int srcData();
00138   int trgData();
00139   //---------------------------------------------
00140   //LOCAL
00142   int calgnext(int gNodeIdx);
00144   int dwnOrderCollect(vector<int>&);
00146   int upwOrderCollect(vector<int>&); 
00148   Node& node(int gNodeIdx) { return _nodeVec[gNodeIdx]; }
00149 
00150   //tree traversal and informational retrieval
00151   bool    root(int gNodeIdx)     { return node(gNodeIdx).parent()==-1; } //no parent
00152   bool    terminal(int gNodeIdx) { return node(gNodeIdx).child()==-1; } //no child
00153   int     parent(int gNodeIdx)   { assert(node(gNodeIdx).parent()!=-1); return node(gNodeIdx).parent(); }
00154   int     child( int gNodeIdx, const Index3& idx);
00155   Index3  path2Node(int gNodeIdx) { return node(gNodeIdx).path2Node(); }
00156   int     depth(int gNodeIdx)      { return node(gNodeIdx).depth(); }
00157   int     tag(int gNodeIdx)        { return node(gNodeIdx).tag(); }
00158   
00159   Point3  center(int gNodeIdx);  
00160   double  radius(int gNodeIdx);  
00161   
00162   int findgnt(int depth, const Index3& path2Node);  
00163   bool adjacent(int, int);                
00164   
00165   int dim() const { return 3; }  
00166 };
00167   
00168 #endif

Generated on Sun Dec 4 19:24:39 2005 for fmm3d by  doxygen 1.4.5