|
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_2D_H 00027 #define ATOMIC_BLOCK_2D_H 00028 00029 #include "core/globalDefs.h" 00030 #include "core/blockIdentifiers.h" 00031 #include "core/block2D.h" 00032 #include "core/blockStatistics.h" 00033 #include "core/geometry2D.h" 00034 #include "atomicBlock/dataProcessorWrapper2D.h" 00035 #include "atomicBlock/reductiveDataProcessorWrapper2D.h" 00036 #include <algorithm> 00037 #include <map> 00038 00039 namespace plb { 00040 00041 // Forward declarations 00042 class AtomicBlock2D; 00043 00045 class StatSubscriber2D : public StatSubscriber { 00046 public: 00047 StatSubscriber2D(AtomicBlock2D& block_); 00049 virtual plint subscribeAverage(); 00051 virtual plint subscribeSum(); 00053 virtual plint subscribeMax(); 00055 virtual plint subscribeIntSum(); 00056 private: 00057 AtomicBlock2D& block; 00058 }; 00059 00060 struct BlockDataTransfer2D { 00061 virtual ~BlockDataTransfer2D() { } 00062 virtual plint staticCellSize() const =0; 00063 virtual void send(Box2D domain, std::vector<char>& buffer, modif::ModifT kind) const =0; 00064 virtual void receive(Box2D domain, std::vector<char> const& buffer, modif::ModifT kind) =0; 00066 virtual void receive( Box2D domain, std::vector<char> const& buffer, 00067 modif::ModifT kind, std::map<int,std::string> const& foreignIds ) =0; 00068 virtual void attribute(Box2D toDomain, plint deltaX, plint deltaY, 00069 AtomicBlock2D const& from, modif::ModifT kind) =0; 00070 }; 00071 00072 class AtomicBlock2D : public Block2D { 00073 public: 00074 AtomicBlock2D(plint nx_, plint ny_); 00075 AtomicBlock2D(AtomicBlock2D const& rhs); 00076 virtual ~AtomicBlock2D(); 00077 void swap(AtomicBlock2D& rhs); 00079 void initialize(); 00080 public: 00082 virtual Box2D getBoundingBox() const; 00084 plint getNx() const { return nx; } 00086 plint getNy() const { return ny; } 00088 void executeInternalProcessors(); 00090 void executeInternalProcessors(plint level); 00092 void integrateDataProcessor(DataProcessor2D* processor, plint level); 00094 void clearDataProcessors(); 00096 void removeDataProcessors(int staticId); 00098 virtual BlockDataTransfer2D& getDataTransfer() =0; 00100 virtual BlockDataTransfer2D const& getDataTransfer() const =0; 00102 virtual DataSerializer* getBlockSerializer ( 00103 Box2D const& domain, IndexOrdering::OrderingT ordering ) const; 00105 virtual DataUnSerializer* getBlockUnSerializer ( 00106 Box2D const& domain, IndexOrdering::OrderingT ordering ); 00107 public: 00109 StatSubscriber& internalStatSubscription(); 00111 void evaluateStatistics(); 00114 BlockStatistics& getInternalStatistics(); 00116 BlockStatistics const& getInternalStatistics() const; 00117 public: 00120 void setLocation(Dot2D const& location_); 00123 Dot2D getLocation() const; 00125 void setFlag(bool value); 00127 bool getFlag() const; 00128 private: 00129 typedef std::vector<std::vector<DataProcessor2D*> > DataProcessorVector; 00130 private: 00132 void integrateDataProcessor ( 00133 DataProcessor2D* processor, plint level, DataProcessorVector& processors ); 00135 void executeInternalProcessors(plint level, DataProcessorVector& processors); 00137 void copyDataProcessors(DataProcessorVector const& from, DataProcessorVector& to); 00139 void clearDataProcessors(DataProcessorVector& processors); 00140 private: 00141 plint nx, ny; 00142 Dot2D location; 00143 bool flag; 00144 BlockStatistics internalStatistics; 00145 StatSubscriber2D statisticsSubscriber; 00146 DataProcessorVector explicitInternalProcessors; 00147 DataProcessorVector automaticInternalProcessors; 00148 }; 00149 00150 Dot2D computeRelativeDisplacement(AtomicBlock2D const& block1, AtomicBlock2D const& block2); 00151 00152 } // namespace plb 00153 00154 #endif // ATOMIC_BLOCK_2D