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

multiBlockSerializer3D.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 
00028 #ifndef MULTI_BLOCK_SERIALIZER_3D_H
00029 #define MULTI_BLOCK_SERIALIZER_3D_H
00030 
00031 #include "core/globalDefs.h"
00032 #include "multiBlock/multiBlock3D.h"
00033 #include "core/serializer.h"
00034 #include "core/util.h"
00035 
00036 namespace plb {
00037 
00038 class MultiBlockSerializer3D : public DataSerializer {
00039 public:
00040     MultiBlockSerializer3D(MultiBlock3D const& multiBlock_,
00041                            IndexOrdering::OrderingT ordering_);
00042     MultiBlockSerializer3D(MultiBlock3D const& multiBlock_,
00043                            Box3D domain_,
00044                            IndexOrdering::OrderingT ordering_);
00045     virtual MultiBlockSerializer3D* clone() const;
00046     virtual pluint getSize() const;
00047     virtual const char* getNextDataBuffer(pluint& bufferSize) const;
00048     virtual bool isEmpty() const;
00049 private:
00050     SparseBlockStructure3D const& getSparseBlockStructure() const;
00051     bool isLocal(plint blockId) const;
00052     void computeBufferAlongX(plint nextBlockId, plint nextChunkSize) const;
00053     void computeBufferAlongY(plint nextBlockId, plint nextChunkSize) const;
00054     void computeBufferAlongZ(plint nextBlockId, plint nextChunkSize) const;
00055     void communicateBuffer(plint bufferSize, plint fromBlockId, bool isAllocated) const;
00056     void fillBufferWithZeros(plint nextChunkSize) const;
00057 private:
00058     MultiBlock3D const& multiBlock;
00059     IndexOrdering::OrderingT ordering;
00060     Box3D domain;
00061     mutable plint iX, iY, iZ;
00062     mutable std::vector<char> buffer;
00063 };
00064 
00065 class MultiBlockUnSerializer3D : public DataUnSerializer {
00066 public:
00067     MultiBlockUnSerializer3D(MultiBlock3D& multiBlock_,
00068                              IndexOrdering::OrderingT ordering_);
00069     MultiBlockUnSerializer3D(MultiBlock3D& multiBlock_,
00070                              Box3D domain_,
00071                              IndexOrdering::OrderingT ordering_);
00072     virtual MultiBlockUnSerializer3D* clone() const;
00073     virtual pluint getSize() const;
00074     virtual char* getNextDataBuffer(pluint& bufferSize);
00075     virtual void commitData();
00076     virtual bool isFull() const;
00077 private:
00078     SparseBlockStructure3D const& getSparseBlockStructure() const;
00079     bool isLocal(plint blockId) const;
00080     void fillBufferAlongX(plint nextBlockId, plint nextChunkSize);
00081     void fillBufferAlongY(plint nextBlockId, plint nextChunkSize);
00082     void fillBufferAlongZ(plint nextBlockId, plint nextChunkSize);
00083     void communicateBuffer(plint bufferSize, plint toBlockId, bool isAllocated) const;
00084 private:
00085     MultiBlock3D& multiBlock;
00086     IndexOrdering::OrderingT ordering;
00087     Box3D domain;
00088     mutable plint iX, iY, iZ;
00089     mutable std::vector<char> buffer;
00090 };
00091 
00092 class MultiBlockFastSerializer3D : public DataSerializer {
00093 public:
00094     MultiBlockFastSerializer3D(MultiBlock3D const& multiBlock_,
00095                                IndexOrdering::OrderingT ordering_);
00096     MultiBlockFastSerializer3D(MultiBlock3D const& multiBlock_,
00097                                Box3D domain_,
00098                                IndexOrdering::OrderingT ordering_);
00099     virtual MultiBlockFastSerializer3D* clone() const;
00100     virtual pluint getSize() const;
00101     virtual const char* getNextDataBuffer(pluint& bufferSize) const;
00102     virtual bool isEmpty() const;
00103 private:
00104     pluint computeSlice() const;
00105 private:
00106     MultiBlock3D const& multiBlock;
00107     IndexOrdering::OrderingT ordering;
00108     Box3D domain;
00109     mutable plint pos;
00110     mutable std::vector<char> buffer;
00111 };
00112 
00113 class MultiBlockFastUnSerializer3D : public DataUnSerializer {
00114 public:
00115     MultiBlockFastUnSerializer3D(MultiBlock3D& multiBlock_,
00116                                  IndexOrdering::OrderingT ordering_);
00117     MultiBlockFastUnSerializer3D(MultiBlock3D& multiBlock_,
00118                                  Box3D domain_,
00119                                  IndexOrdering::OrderingT ordering_);
00120     virtual MultiBlockFastUnSerializer3D* clone() const;
00121     virtual pluint getSize() const;
00122     virtual char* getNextDataBuffer(pluint& bufferSize);
00123     virtual void commitData();
00124     virtual bool isFull() const;
00125 private:
00126     MultiBlock3D& multiBlock;
00127     IndexOrdering::OrderingT ordering;
00128     Box3D domain;
00129     mutable plint pos;
00130     mutable std::vector<char> buffer;
00131 };
00132 
00133 
00134 }  //  namespace plb
00135 
00136 #endif  // MULTI_BLOCK_SERIALIZER_3D_H