|
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 00025 00026 #ifndef ATOMIC_BLOCK_3D_H 00027 #define ATOMIC_BLOCK_3D_H 00028 00029 #include "core/globalDefs.h" 00030 #include "core/blockIdentifiers.h" 00031 #include "core/block3D.h" 00032 #include "core/blockStatistics.h" 00033 #include "core/geometry3D.h" 00034 #include "atomicBlock/dataProcessorWrapper3D.h" 00035 #include "atomicBlock/reductiveDataProcessorWrapper3D.h" 00036 #include <algorithm> 00037 #include <string> 00038 #include <map> 00039 00040 namespace plb { 00041 00042 // Forward declarations 00043 class AtomicBlock3D; 00044 00046 class StatSubscriber3D : public StatSubscriber { 00047 public: 00048 StatSubscriber3D(AtomicBlock3D& block_); 00050 virtual plint subscribeAverage(); 00052 virtual plint subscribeSum(); 00054 virtual plint subscribeMax(); 00056 virtual plint subscribeIntSum(); 00057 private: 00058 AtomicBlock3D& block; 00059 }; 00060 00061 struct BlockDataTransfer3D { 00062 virtual ~BlockDataTransfer3D() { } 00063 virtual plint staticCellSize() const =0; 00065 00071 virtual void send(Box3D domain, std::vector<char>& buffer, modif::ModifT kind) const =0; 00073 virtual void receive(Box3D domain, std::vector<char> const& buffer, modif::ModifT kind) =0; 00075 virtual void receive( Box3D domain, std::vector<char> const& buffer, 00076 modif::ModifT kind, std::map<int,std::string> const& foreignIds ) =0; 00078 virtual void attribute(Box3D toDomain, plint deltaX, plint deltaY, plint deltaZ, 00079 AtomicBlock3D const& from, modif::ModifT kind) =0; 00080 }; 00081 00082 class AtomicBlock3D : public Block3D { 00083 public: 00084 AtomicBlock3D(plint nx_, plint ny_, plint nz_); 00085 AtomicBlock3D(AtomicBlock3D const& rhs); 00086 virtual ~AtomicBlock3D(); 00087 void swap(AtomicBlock3D& rhs); 00089 void initialize(); 00090 public: 00092 virtual Box3D getBoundingBox() const; 00094 plint getNx() const { return nx; } 00096 plint getNy() const { return ny; } 00098 plint getNz() const { return nz; } 00100 void executeInternalProcessors(); 00102 void executeInternalProcessors(plint level); 00104 void integrateDataProcessor(DataProcessor3D* processor, plint level); 00106 void clearDataProcessors(); 00108 void removeDataProcessors(int staticId); 00110 virtual BlockDataTransfer3D& getDataTransfer() =0; 00112 virtual BlockDataTransfer3D const& getDataTransfer() const =0; 00114 virtual DataSerializer* getBlockSerializer ( 00115 Box3D const& domain, IndexOrdering::OrderingT ordering ) const; 00117 virtual DataUnSerializer* getBlockUnSerializer ( 00118 Box3D const& domain, IndexOrdering::OrderingT ordering ); 00119 public: 00121 StatSubscriber& internalStatSubscription(); 00123 void evaluateStatistics(); 00126 BlockStatistics& getInternalStatistics(); 00128 BlockStatistics const& getInternalStatistics() const; 00129 public: 00132 void setLocation(Dot3D const& location_); 00135 Dot3D getLocation() const; 00137 void setFlag(bool value); 00139 bool getFlag() const; 00140 private: 00141 typedef std::vector<std::vector<DataProcessor3D*> > DataProcessorVector; 00142 private: 00144 void integrateDataProcessor ( 00145 DataProcessor3D* processor, plint level, DataProcessorVector& processors ); 00147 void executeInternalProcessors(plint level, DataProcessorVector& processors); 00149 void copyDataProcessors(DataProcessorVector const& from, DataProcessorVector& to); 00151 void clearDataProcessors(DataProcessorVector& processors); 00152 private: 00153 plint nx, ny, nz; 00154 Dot3D location; 00155 bool flag; 00156 BlockStatistics internalStatistics; 00157 StatSubscriber3D statisticsSubscriber; 00158 DataProcessorVector explicitInternalProcessors; 00159 DataProcessorVector automaticInternalProcessors; 00160 }; 00161 00162 Dot3D computeRelativeDisplacement(AtomicBlock3D const& block1, AtomicBlock3D const& block2); 00163 00164 } // namespace plb 00165 00166 #endif // ATOMIC_BLOCK_3D