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 __RCB_HPP__ 00016 #define __RCB_HPP__ 00017 00018 #include "parallel/DomainDecomposer.hpp" 00019 #include "tools/Tools.hpp" 00020 00021 #include <vector> 00022 #include <algorithm> 00023 00024 namespace DAPTA { // Define namespace DAPTA 00025 00027 00029 template <typename V> 00030 class RCBDecomposer : public DomainDecomposer<V> { 00031 public: 00032 typedef V* VertexHandle; 00033 00034 RCBDecomposer(std::vector<VertexHandle> _vertices) : DomainDecomposer<V>(_vertices) {;} 00035 RCBDecomposer() {;} 00036 ~RCBDecomposer() {;} 00037 00038 std::vector<int> decompose(unsigned numberOfPartitions, unsigned myNumber); 00039 private: 00040 typedef typename std::vector<VertexHandle> PointCont; 00041 typedef typename PointCont::iterator PointIt; 00042 00044 struct RCBTree { 00045 RCBTree(PointIt dataBegin, PointIt dataEnd, int level) : 00046 _dataBegin(dataBegin), _dataEnd(dataEnd), _level(level) { 00047 _childL=NULL; 00048 _childR=NULL; 00049 } 00050 00051 ~RCBTree() { 00052 if (_childL) delete _childL; 00053 if (_childR) delete _childR; 00054 } 00055 00056 // data stored at the nodes 00057 PointIt _dataBegin; 00058 PointIt _dataEnd; 00059 00060 // internal rcb data 00061 int _level; 00062 struct RCBTree *_childL; 00063 struct RCBTree *_childR; 00064 }; 00065 00066 int maxBoxInDimension (PointIt begin, PointIt end); 00067 void buildRCBTree (RCBTree *tree, const int& maxLevel); 00068 bool leaf (RCBTree *tree) { return (!tree->_childL); } 00069 void collectLeafNodeData (RCBTree *tree, std::vector<PointIt>& begins, std::vector<PointIt>& ends); 00070 }; 00071 00072 } // namespace DAPTA 00073 00074 #include "RCB.cpp" 00075 00076 #endif
1.5.1