$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00029 #ifndef SPARSE_BLOCK_STRUCTURE_3D_H 00030 #define SPARSE_BLOCK_STRUCTURE_3D_H 00031 00032 #include "core/globalDefs.h" 00033 #include "core/geometry3D.h" 00034 #include "multiBlock/threadAttribution.h" 00035 #include <vector> 00036 #include <map> 00037 00038 00039 namespace plb { 00040 00041 class SparseBlockStructure3D { 00042 public: 00043 typedef std::map<Dot3D, std::vector<plint> > GridT; 00044 public: 00046 SparseBlockStructure3D(plint nx, plint ny, plint nz); 00048 SparseBlockStructure3D(Box3D boundingBox_); 00050 SparseBlockStructure3D(Box3D boundingBox_, 00051 plint gridNx_, plint gridNy_, plint gridNz_); 00053 SparseBlockStructure3D(SparseBlockStructure3D const& rhs, Box3D boundingBox_); 00055 void addBlock(Box3D const& bulk, Box3D const& uniqueBulk, plint blockId); 00057 void addBlock(Box3D const& bulk, plint blockId); 00059 void removeBlock(plint blockId); 00061 bool exists(plint blockId); 00063 plint nextIncrementalId() const; 00065 Box3D getBoundingBox() const; 00067 bool getBulk(plint blockId, Box3D& bulk) const; 00069 bool getUniqueBulk(plint blockId, Box3D& uniqueBulk) const; 00071 plint getNumBlocks() const; 00073 plint getNumBulkCells() const; 00075 std::map<plint,Box3D> const& getBulks() const; 00077 std::vector<plint> getLocalBlocks(ThreadAttribution const& attribution) const; 00079 plint locate(plint iX, plint iY, plint iZ) const; 00081 void intersect( Box3D const& bulk, std::vector<plint>& ids, 00082 std::vector<Box3D>& intersections ) const; 00085 void computeOverlaps( Box3D const& bulk, plint dx, plint dy, plint dz, 00086 std::vector<plint>& ids, 00087 std::vector<Box3D>& overlapsOnBulk, 00088 std::vector<Box3D>& overlapsOnNeighbors ) const; 00090 void computeOverlaps( plint blockId, plint envelopeWidth, 00091 std::vector<plint>& ids, 00092 std::vector<Box3D>& overlapsOnBulk, 00093 std::vector<Box3D>& overlapsOnNeighbors ) const; 00096 void findNeighbors( Box3D const& block, plint neighborhoodWidth, 00097 std::vector<plint>& neighbors, 00098 plint excludeId=-1 ) const; 00100 void findNeighbors( plint blockId, plint neighborhoodWidth, 00101 std::vector<plint>& neighbors ) const; 00102 void swap(SparseBlockStructure3D& rhs); 00103 private: 00105 void defaultGridN(); 00107 void iniGridParameters(); 00109 plint gridPosX(plint realX) const; 00111 plint gridPosY(plint realY) const; 00113 plint gridPosZ(plint realZ) const; 00115 Box3D getGridBox(Box3D const& realBlock) const; 00118 void computeEnvelopeTerm ( 00119 plint block0, plint block1, 00120 plint& env0, plint& env1, plint delta ) const; 00122 void integrateBlock(plint blockId, Box3D bulk); 00124 void extractBlock(plint blockId); 00125 private: 00126 Box3D boundingBox; 00127 plint gridLx, gridLy, gridLz; 00128 plint gridNx, gridNy, gridNz; 00129 GridT grid; 00130 // Attention: If replacing the map by a hashed_map, remember that 00131 // nextIncrementalId() uses the fact that elements are ordered inside 00132 // the map. Therefore, nextIncrementalId() must then be rewritten. 00133 std::map<plint,Box3D> bulks; 00136 std::map<plint,Box3D> uniqueBulks; 00137 }; 00138 00139 SparseBlockStructure3D scale(SparseBlockStructure3D const& sparseBlock, plint relativeLevel); 00140 00144 SparseBlockStructure3D intersect( SparseBlockStructure3D const& sparseBlock, 00145 Box3D domain, bool crop ); 00146 00148 SparseBlockStructure3D intersect( SparseBlockStructure3D const& sparseBlock, 00149 Box3D domain, Box3D newBoundingBox ); 00150 00153 SparseBlockStructure3D intersect( SparseBlockStructure3D const& sparseBlock1, 00154 SparseBlockStructure3D const& sparseBlock2, bool crop ); 00155 00160 SparseBlockStructure3D extend( SparseBlockStructure3D const& sparseBlock, 00161 Box3D addedBulk, Box3D addedUniqueBulk, 00162 std::vector<plint>& newIds ); 00163 00165 SparseBlockStructure3D except( SparseBlockStructure3D const& sparseBlock, 00166 Box3D exceptedBlock, 00167 std::map<plint,std::vector<plint> >& remappedIds ); 00168 00170 SparseBlockStructure3D block_union( SparseBlockStructure3D const& sparseBlock1, 00171 SparseBlockStructure3D const& sparseBlock2, 00172 std::map<plint,std::vector<plint> >& remappedIds ); 00173 00181 SparseBlockStructure3D alignDistribution3D ( 00182 SparseBlockStructure3D const& originalStructure, 00183 SparseBlockStructure3D const& partnerStructure, 00184 std::vector<plint>& newIds, 00185 std::map<plint,std::vector<plint> >& remappedFromPartner ); 00186 00187 00189 class EuclideanIterator3D { 00190 public: 00191 EuclideanIterator3D(SparseBlockStructure3D const& sparseBlock_); 00195 bool getNextChunkX(plint iX, plint iY, plint iZ, 00196 plint& blockId, plint& chunkSize) const; 00200 bool getNextChunkY(plint iX, plint iY, plint iZ, 00201 plint& blockId, plint& chunkSize) const; 00205 bool getNextChunkZ(plint iX, plint iY, plint iZ, 00206 plint& blockId, plint& chunkSize) const; 00207 private: 00208 SparseBlockStructure3D const& sparseBlock; 00209 }; 00210 00211 } // namespace plb 00212 00213 #endif // SPARSE_BLOCK_STRUCTURE_3D_H
1.6.3
1.6.3