$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

localMultiBlockInfo3D.h

Go to the documentation of this file.
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 LOCAL_MULTI_BLOCK_INFO_3D_H
00030 #define LOCAL_MULTI_BLOCK_INFO_3D_H
00031 
00032 #include "core/globalDefs.h"
00033 #include "core/geometry3D.h"
00034 #include "multiBlock/threadAttribution.h"
00035 #include "multiBlock/sparseBlockStructure3D.h"
00036 #include <vector>
00037 
00038 
00039 namespace plb {
00040 
00043 class Overlap3D {
00044 public:
00045     Overlap3D(plint originalId_, plint overlapId_, Box3D const& intersection_)
00046         : originalId(originalId_), overlapId(overlapId_),
00047           originalRegion(intersection_),
00048           overlapRegion(intersection_)
00049     { }
00050     Overlap3D(plint originalId_, plint overlapId_,
00051               Box3D const& originalRegion_,
00052               plint shiftX, plint shiftY, plint shiftZ)
00053         : originalId(originalId_), overlapId(overlapId_),
00054           originalRegion(originalRegion_),
00055           overlapRegion(originalRegion.shift(-shiftX, -shiftY, -shiftZ))
00056     { }
00057     plint getOriginalId() const { return originalId; }
00058     plint getOverlapId()  const { return overlapId; }
00060     Box3D const& getOriginalCoordinates() const { return originalRegion; }
00062 
00066     Box3D const& getOverlapCoordinates() const  { return overlapRegion; }
00067     plint getShiftX() const { return originalRegion.x0 - overlapRegion.x0; }
00068     plint getShiftY() const { return originalRegion.y0 - overlapRegion.y0; }
00069     plint getShiftZ() const { return originalRegion.z0 - overlapRegion.z0; }
00070 private: 
00071     plint originalId, overlapId;
00072     Box3D originalRegion, overlapRegion;
00073 };
00074 
00076 
00080 inline bool operator<(Overlap3D const& overlap1, Overlap3D const& overlap2)
00081 {
00082     return
00083         (overlap1.getOriginalId() < overlap2.getOriginalId()) || (
00084             (overlap1.getOriginalId() == overlap2.getOriginalId()) && (
00085                 (overlap1.getOverlapId() < overlap2.getOverlapId()) || (
00086                     (overlap1.getOverlapId() == overlap2.getOverlapId()) &&
00087                     (overlap1.getOriginalCoordinates() < overlap2.getOriginalCoordinates()) ) ) );
00088 }
00089 
00091 
00097 struct PeriodicOverlap3D {
00098     PeriodicOverlap3D(Overlap3D const& overlap_, plint normalX_, plint normalY_, plint normalZ_);
00099     Overlap3D overlap;
00100     plint      normalX;
00101     plint      normalY;
00102     plint      normalZ;
00103 };
00104 
00105 
00107 inline bool operator<( PeriodicOverlap3D const& overlap1,
00108                        PeriodicOverlap3D const& overlap2 )
00109 {
00110     return overlap1.overlap < overlap2.overlap;
00111 }
00112 
00113 class LocalMultiBlockInfo3D {
00114 public:
00115     LocalMultiBlockInfo3D( SparseBlockStructure3D const& sparseBlock,
00116                            ThreadAttribution const& attribution,
00117                            plint envelopeWidth_ );
00119     std::vector<plint> const& getBlocks() const;
00121     std::vector<Overlap3D> const& getNormalOverlaps() const;
00124     std::vector<PeriodicOverlap3D> const& getPeriodicOverlaps() const;
00126     std::vector<PeriodicOverlap3D> const& getPeriodicOverlapWithRemoteData() const;
00127     void swap(LocalMultiBlockInfo3D& rhs);
00128 private:
00130     void computeMyBlocks(SparseBlockStructure3D const& sparseBlock,
00131                          ThreadAttribution const& attribution);
00133     void computeAllNormalOverlaps(SparseBlockStructure3D const& sparseBlock);
00135     void computeNormalOverlaps(SparseBlockStructure3D const& sparseBlock, plint blockId);
00137     void computeAllPeriodicOverlaps(SparseBlockStructure3D const& sparseBlock);
00139     void computePeriodicOverlaps(SparseBlockStructure3D const& sparseBlock, plint blockId);
00140 private:
00141     plint                          envelopeWidth;
00142     std::vector<plint>             myBlocks;
00143     std::vector<Overlap3D>         normalOverlaps;
00144     std::vector<PeriodicOverlap3D> periodicOverlaps;
00145     std::vector<PeriodicOverlap3D> periodicOverlapWithRemoteData;
00146 };
00147 
00148 } // namespace plb
00149 
00150 #endif  // LOCAL_MULTI_BLOCK_INFO_3D_H