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

multiBlockLattice3D.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_LATTICE_3D_H
00029 #define MULTI_BLOCK_LATTICE_3D_H
00030 
00031 #include "core/globalDefs.h"
00032 #include "multiBlock/multiBlock3D.h"
00033 #include "core/blockLatticeBase3D.h"
00034 #include "atomicBlock/blockLattice3D.h"
00035 #include "core/blockStatistics.h"
00036 #include "core/cell.h"
00037 #include "core/dynamics.h"
00038 #include <vector>
00039 
00040 namespace plb {
00041 
00042 template<typename T, template<typename U> class Descriptor> class BlockLattice3D;
00043 
00044 
00045 template<typename T, template<typename U> class Descriptor>
00046 struct MultiCellAccess3D {
00047     virtual ~MultiCellAccess3D() { }
00048     virtual Cell<T,Descriptor>& getDistributedCell (
00049             plint iX, plint iY, plint iZ,
00050             MultiBlockManagement3D const& multiBlockManagement,
00051             std::map<plint,BlockLattice3D<T,Descriptor>*>& lattices ) =0;
00052     virtual Cell<T,Descriptor> const& getDistributedCell (
00053             plint iX, plint iY, plint iZ,
00054             MultiBlockManagement3D const& multiBlockManagement,
00055             std::map<plint,BlockLattice3D<T,Descriptor>*> const& lattices ) const =0;
00056     virtual void broadCastCell(Cell<T,Descriptor>& cell, plint fromBlock,
00057                                MultiBlockManagement3D const& multiBlockManagement) const=0;
00058     virtual MultiCellAccess3D<T,Descriptor>* clone() const =0;
00059 };
00060 
00062 
00071 template<typename T, template<typename U> class Descriptor>
00072 class MultiBlockLattice3D : public BlockLatticeBase3D<T,Descriptor>, public MultiBlock3D {
00073 public:
00074     typedef std::map<plint,BlockLattice3D<T,Descriptor>*> BlockMap;
00075 public:
00076     MultiBlockLattice3D(MultiBlockManagement3D const& multiBlockManagement,
00077                         BlockCommunicator3D* blockCommunicator_,
00078                         CombinedStatistics* combinedStatistics_,
00079                         MultiCellAccess3D<T,Descriptor>* multiCellAccess_,
00080                         Dynamics<T,Descriptor>* backgroundDynamics_);
00081     MultiBlockLattice3D(plint nx, plint ny, plint nz, Dynamics<T,Descriptor>* backgroundDynamics_);
00082     ~MultiBlockLattice3D();
00083     MultiBlockLattice3D(MultiBlockLattice3D<T,Descriptor> const& rhs);
00084     MultiBlockLattice3D(MultiBlock3D const& rhs);
00085     MultiBlockLattice3D<T,Descriptor>* clone() const;
00086     MultiBlockLattice3D<T,Descriptor>* clone(MultiBlockManagement3D const& newManagement) const;
00090     MultiBlockLattice3D(MultiBlock3D const& rhs, Box3D subDomain, bool crop=true);
00093     void swap(MultiBlockLattice3D& rhs);
00096     MultiBlockLattice3D<T,Descriptor>& operator=(MultiBlockLattice3D<T,Descriptor> const& rhs);
00097 
00098     Dynamics<T,Descriptor> const& getBackgroundDynamics() const;
00099     virtual Cell<T,Descriptor>& get(plint iX, plint iY, plint iZ);
00100     virtual Cell<T,Descriptor> const& get(plint iX, plint iY, plint iZ) const;
00101     virtual void specifyStatisticsStatus(Box3D domain, bool status);
00102     virtual void collide(Box3D domain);
00103     virtual void collide();
00104     virtual void stream(Box3D domain);
00105     virtual void stream();
00106     virtual void collideAndStream(Box3D domain);
00107     virtual void collideAndStream();
00108     virtual void incrementTime();
00109     virtual void resetTime(pluint value);
00110     virtual BlockLattice3D<T,Descriptor>& getComponent(plint blockId);
00111     virtual BlockLattice3D<T,Descriptor> const& getComponent(plint blockId) const;
00112     virtual plint sizeOfCell() const;
00113     virtual plint getCellDim() const;
00114     virtual int getStaticId() const;
00115     virtual void copyReceive (
00116                 MultiBlock3D const& fromBlock, Box3D const& fromDomain,
00117                 Box3D const& toDomain, modif::ModifT whichData=modif::dataStructure );
00118 public:
00119     BlockMap& getBlockLattices();
00120     BlockMap const& getBlockLattices() const;
00121     virtual void getDynamicsDict(Box3D domain, std::map<std::string,int>& dict);
00122     std::string getBlockName() const;
00123     std::vector<std::string> getTypeInfo() const;
00124     static std::string blockName();
00125     static std::string basicType();
00126     static std::string descriptorType();
00127 private:
00128     void allocateAndInitialize();
00129     void eliminateStatisticsInEnvelope();
00130     Box3D extendPeriodic(Box3D const& box, plint envelopeWidth) const;
00131 private:
00132     Dynamics<T,Descriptor>* backgroundDynamics;
00133     MultiCellAccess3D<T,Descriptor>* multiCellAccess;
00134     BlockMap blockLattices;
00135     static const int staticId;
00136 };
00137 
00138 template<typename T, template<typename U> class Descriptor>
00139 double getStoredAverageDensity(MultiBlockLattice3D<T,Descriptor> const& blockLattice);
00140 
00141 template<typename T, template<typename U> class Descriptor>
00142 double getStoredAverageEnergy(MultiBlockLattice3D<T,Descriptor> const& blockLattice);
00143 
00144 template<typename T, template<typename U> class Descriptor>
00145 double getStoredMaxVelocity(MultiBlockLattice3D<T,Descriptor> const& blockLattice);
00146 
00147 }  // namespace plb
00148 
00149 #endif  // MULTI_BLOCK_LATTICE_3D_H