|
Palabos
Version 1.0
|
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 BLOCK_LATTICE_3D_H 00029 #define BLOCK_LATTICE_3D_H 00030 00031 #include "core/globalDefs.h" 00032 #include "core/plbDebug.h" 00033 #include "core/cell.h" 00034 #include "atomicBlock/dataField3D.h" 00035 #include "core/blockLatticeBase3D.h" 00036 #include "atomicBlock/atomicBlock3D.h" 00037 #include "core/blockIdentifiers.h" 00038 #include <vector> 00039 #include <map> 00040 00042 namespace plb { 00043 00044 template<typename T, template<typename U> class Descriptor> struct Dynamics; 00045 template<typename T, template<typename U> class Descriptor> class BlockLattice3D; 00046 00047 00048 template<typename T, template<typename U> class Descriptor> 00049 class BlockLatticeDataTransfer3D : public BlockDataTransfer3D { 00050 public: 00051 BlockLatticeDataTransfer3D(BlockLattice3D<T,Descriptor>& lattice_); 00052 virtual plint staticCellSize() const; 00054 virtual void send(Box3D domain, std::vector<char>& buffer, modif::ModifT kind) const; 00056 virtual void receive(Box3D domain, std::vector<char> const& buffer, modif::ModifT kind); 00058 virtual void receive( Box3D domain, std::vector<char> const& buffer, 00059 modif::ModifT kind, std::map<int,std::string> const& foreignIds ); 00061 virtual void attribute(Box3D toDomain, plint deltaX, plint deltaY, plint deltaZ, 00062 AtomicBlock3D const& from, modif::ModifT kind); 00063 private: 00064 void send_static(Box3D domain, std::vector<char>& buffer) const; 00065 void send_dynamic(Box3D domain, std::vector<char>& buffer) const; 00066 void send_all(Box3D domain, std::vector<char>& buffer) const; 00067 00068 void receive_static(Box3D domain, std::vector<char> const& buffer); 00069 void receive_dynamic(Box3D domain, std::vector<char> const& buffer); 00070 void receive_all(Box3D domain, std::vector<char> const& buffer); 00071 void receive_regenerate( Box3D domain, std::vector<char> const& buffer, 00072 std::map<int,int> const& idIndirect = (std::map<int,int>()) ); 00073 00074 void attribute_static ( 00075 Box3D toDomain, plint deltaX, plint deltaY, plint deltaZ, 00076 BlockLattice3D<T,Descriptor> const& from ); 00077 void attribute_dynamic ( 00078 Box3D toDomain, plint deltaX, plint deltaY, plint deltaZ, 00079 BlockLattice3D<T,Descriptor> const& from ); 00080 void attribute_all ( 00081 Box3D toDomain, plint deltaX, plint deltaY, plint deltaZ, 00082 BlockLattice3D<T,Descriptor> const& from ); 00083 void attribute_regenerate ( 00084 Box3D toDomain, plint deltaX, plint deltaY, plint deltaZ, 00085 BlockLattice3D<T,Descriptor> const& from ); 00086 private: 00087 BlockLattice3D<T,Descriptor>& lattice; 00088 template<typename T_, template<typename U_> class Descriptor_> 00089 friend class ExternalRhoJcollideAndStream2D; 00090 }; 00091 00093 00098 template<typename T, template<typename U> class Descriptor> 00099 class BlockLattice3D : public BlockLatticeBase3D<T,Descriptor>, public AtomicBlock3D 00100 { 00101 public: 00103 BlockLattice3D(plint nx_, plint ny_, plint nz_, Dynamics<T,Descriptor>* backgroundDynamics_); 00105 ~BlockLattice3D(); 00107 BlockLattice3D(BlockLattice3D<T,Descriptor> const& rhs); 00109 BlockLattice3D& operator=(BlockLattice3D<T,Descriptor> const& rhs); 00111 void swap(BlockLattice3D& rhs); 00112 public: 00114 virtual Cell<T,Descriptor>& get(plint iX, plint iY, plint iZ) { 00115 PLB_PRECONDITION(iX<this->getNx()); 00116 PLB_PRECONDITION(iY<this->getNy()); 00117 PLB_PRECONDITION(iZ<this->getNz()); 00118 return grid[iX][iY][iZ]; 00119 } 00121 virtual Cell<T,Descriptor> const& get(plint iX, plint iY, plint iZ) const { 00122 PLB_PRECONDITION(iX<this->getNx()); 00123 PLB_PRECONDITION(iY<this->getNy()); 00124 PLB_PRECONDITION(iZ<this->getNz()); 00125 return grid[iX][iY][iZ]; 00126 } 00128 virtual void specifyStatisticsStatus ( 00129 Box3D domain, bool status ); 00131 virtual void collide(Box3D domain); 00133 virtual void collide(); 00135 virtual void stream(Box3D domain); 00137 virtual void stream(); 00139 virtual void collideAndStream(Box3D domain); 00141 virtual void collideAndStream(); 00143 virtual void incrementTime(); 00145 virtual BlockLatticeDataTransfer3D<T,Descriptor>& getDataTransfer(); 00147 virtual BlockLatticeDataTransfer3D<T,Descriptor> const& getDataTransfer() const; 00148 public: 00150 void attributeDynamics(plint iX, plint iY, plint iZ, Dynamics<T,Descriptor>* dynamics); 00152 Dynamics<T,Descriptor>& getBackgroundDynamics(); 00154 Dynamics<T,Descriptor> const& getBackgroundDynamics() const; 00156 void bulkStream(Box3D domain); 00158 void boundaryStream(Box3D bound, Box3D domain); 00160 void bulkCollideAndStream(Box3D domain); 00161 private: 00163 void linearBulkCollideAndStream(Box3D domain); 00166 void blockwiseBulkCollideAndStream(Box3D domain); 00167 private: 00169 void allocateAndInitialize(); 00171 void releaseMemory(); 00172 void implementPeriodicity(); 00173 private: 00174 void periodicDomain(Box3D domain); 00175 private: 00176 Dynamics<T,Descriptor>* backgroundDynamics; 00177 Cell<T,Descriptor> *rawData; 00178 Cell<T,Descriptor> ***grid; 00179 BlockLatticeDataTransfer3D<T,Descriptor> dataTransfer; 00180 public: 00181 static CachePolicy3D& cachePolicy(); 00182 template<typename T_, template<typename U_> class Descriptor_> 00183 friend class ExternalRhoJcollideAndStream3D; 00184 }; 00185 00186 template<typename T, template<typename U> class Descriptor> 00187 double getStoredAverageDensity(BlockLattice3D<T,Descriptor> const& blockLattice); 00188 00189 template<typename T, template<typename U> class Descriptor> 00190 double getStoredAverageEnergy(BlockLattice3D<T,Descriptor> const& blockLattice); 00191 00192 template<typename T, template<typename U> class Descriptor> 00193 double getStoredAverageVelocity(BlockLattice3D<T,Descriptor> const& blockLattice); 00194 00195 } // namespace plb 00196 00197 #endif // BLOCK_LATTICE_3D_H