$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
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 META_STUFF_FUNCTIONAL_3D_HH 00029 #define META_STUFF_FUNCTIONAL_3D_HH 00030 00031 #include "dataProcessors/metaStuffFunctional3D.h" 00032 #include "dataProcessors/metaStuffHelper.h" 00033 #include "core/plbDebug.h" 00034 #include "core/util.h" 00035 #include "core/dynamicsIdentifiers.h" 00036 #include "core/blockStatistics.h" 00037 #include "atomicBlock/atomicBlock3D.h" 00038 #include "atomicBlock/blockLattice3D.h" 00039 #include "atomicBlock/dataField3D.h" 00040 #include <cmath> 00041 00042 namespace plb { 00043 00044 00045 /* ******** StoreDynamicsFunctional3D ************************************ */ 00046 00047 template<typename T, template<typename U> class Descriptor> 00048 StoreDynamicsFunctional3D<T,Descriptor>::StoreDynamicsFunctional3D() 00049 : maxChainLengthId(this->getStatistics().subscribeMax()) 00050 { } 00051 00052 template<typename T, template<typename U> class Descriptor> 00053 void StoreDynamicsFunctional3D<T,Descriptor>::processGenericBlocks ( 00054 Box3D domain, std::vector<AtomicBlock3D*> blocks ) 00055 { 00056 PLB_PRECONDITION( blocks.size()==2 ); 00057 BlockLattice3D<T,Descriptor>& lattice = *dynamic_cast<BlockLattice3D<T,Descriptor>*>(blocks[0]); 00058 AtomicContainerBlock3D& container = *dynamic_cast<AtomicContainerBlock3D*>(blocks[1]); 00059 StoreDynamicsID* storeID = new StoreDynamicsID; 00060 for (plint iX=domain.x0; iX<=domain.x1; ++iX) { 00061 for (plint iY=domain.y0; iY<=domain.y1; ++iY) { 00062 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) { 00063 std::vector<int> chain; 00064 constructIdChain(lattice.get(iX,iY,iZ).getDynamics(), chain); 00065 storeID->addIdChain(chain); 00066 this->getStatistics().gatherMax(maxChainLengthId, (double)chain.size()); 00067 } 00068 } 00069 } 00070 storeID->startIterations(); 00071 container.setData(storeID); 00072 } 00073 00074 template<typename T, template<typename U> class Descriptor> 00075 StoreDynamicsFunctional3D<T,Descriptor>* StoreDynamicsFunctional3D<T,Descriptor>::clone() const { 00076 return new StoreDynamicsFunctional3D<T,Descriptor>(*this); 00077 } 00078 00079 template<typename T, template<typename U> class Descriptor> 00080 void StoreDynamicsFunctional3D<T,Descriptor>::getTypeOfModification(std::vector<modif::ModifT>& modified) const { 00081 modified[0] = modif::nothing; 00082 modified[1] = modif::staticVariables; 00083 } 00084 00085 template<typename T, template<typename U> class Descriptor> 00086 BlockDomain::DomainT StoreDynamicsFunctional3D<T,Descriptor>::appliesTo() const { 00087 return BlockDomain::bulk; 00088 } 00089 00090 template<typename T, template<typename U> class Descriptor> 00091 pluint StoreDynamicsFunctional3D<T,Descriptor>::getMaxChainLength() const { 00092 double maximum=this->getStatistics().getMax(maxChainLengthId); 00093 return (pluint)(.5+maximum); 00094 } 00095 00096 00097 /* ******** ExtractDynamicsChainFunctional3D ************************************ */ 00098 00099 template<typename T, template<typename U> class Descriptor> 00100 ExtractDynamicsChainFunctional3D<T,Descriptor>::ExtractDynamicsChainFunctional3D ( 00101 ExtractDynamicsChainFunctional3D<T,Descriptor>::DMap const& dynamicsMap_, 00102 pluint maxChainSize_ ) 00103 : dynamicsMap(dynamicsMap_), 00104 maxChainSize(maxChainSize_) 00105 { } 00106 00107 template<typename T, template<typename U> class Descriptor> 00108 void ExtractDynamicsChainFunctional3D<T,Descriptor>::process ( 00109 Box3D domain, BlockLattice3D<T,Descriptor>& lattice, 00110 ScalarField3D<int>& mask ) 00111 { 00112 Dot3D offset = computeRelativeDisplacement(lattice, mask); 00113 for (plint iX=domain.x0; iX<=domain.x1; ++iX) { 00114 for (plint iY=domain.y0; iY<=domain.y1; ++iY) { 00115 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) { 00116 std::vector<int> chain; 00117 constructIdChain(lattice.get(iX,iY,iZ).getDynamics(), chain); 00118 util::extendVectorSize(chain, maxChainSize); 00119 mask.get(iX+offset.x,iY+offset.y,iZ+offset.z) = dynamicsMap[chain]; 00120 } 00121 } 00122 } 00123 } 00124 00125 template<typename T, template<typename U> class Descriptor> 00126 ExtractDynamicsChainFunctional3D<T,Descriptor>* ExtractDynamicsChainFunctional3D<T,Descriptor>::clone() const { 00127 return new ExtractDynamicsChainFunctional3D<T,Descriptor>(*this); 00128 } 00129 00130 template<typename T, template<typename U> class Descriptor> 00131 void ExtractDynamicsChainFunctional3D<T,Descriptor>::getTypeOfModification(std::vector<modif::ModifT>& modified) const { 00132 modified[0] = modif::nothing; 00133 modified[1] = modif::staticVariables; 00134 } 00135 00136 template<typename T, template<typename U> class Descriptor> 00137 BlockDomain::DomainT ExtractDynamicsChainFunctional3D<T,Descriptor>::appliesTo() const { 00138 return BlockDomain::bulk; 00139 } 00140 00141 00142 /* ******** ExtractTopMostDynamicsFunctional3D ************************************ */ 00143 00144 template<typename T, template<typename U> class Descriptor> 00145 void ExtractTopMostDynamicsFunctional3D<T,Descriptor>::process ( 00146 Box3D domain, BlockLattice3D<T,Descriptor>& lattice, 00147 ScalarField3D<int>& mask ) 00148 { 00149 for (plint iX=domain.x0; iX<=domain.x1; ++iX) { 00150 for (plint iY=domain.y0; iY<=domain.y1; ++iY) { 00151 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) { 00152 mask.get(iX,iY,iZ) = lattice.get(iX,iY,iZ).getDynamics().getId(); 00153 } 00154 } 00155 } 00156 } 00157 00158 template<typename T, template<typename U> class Descriptor> 00159 ExtractTopMostDynamicsFunctional3D<T,Descriptor>* 00160 ExtractTopMostDynamicsFunctional3D<T,Descriptor>::clone() const 00161 { 00162 return new ExtractTopMostDynamicsFunctional3D<T,Descriptor>(*this); 00163 } 00164 00165 template<typename T, template<typename U> class Descriptor> 00166 void ExtractTopMostDynamicsFunctional3D<T,Descriptor>:: 00167 getTypeOfModification(std::vector<modif::ModifT>& modified) const 00168 { 00169 modified[0] = modif::nothing; 00170 modified[1] = modif::staticVariables; 00171 } 00172 00173 template<typename T, template<typename U> class Descriptor> 00174 BlockDomain::DomainT ExtractTopMostDynamicsFunctional3D<T,Descriptor>::appliesTo() const { 00175 return BlockDomain::bulk; 00176 } 00177 00178 00179 /* ******** ExtractBottomMostDynamicsFunctional3D ************************************ */ 00180 00181 template<typename T, template<typename U> class Descriptor> 00182 void ExtractBottomMostDynamicsFunctional3D<T,Descriptor>::process ( 00183 Box3D domain, BlockLattice3D<T,Descriptor>& lattice, 00184 ScalarField3D<int>& mask ) 00185 { 00186 for (plint iX=domain.x0; iX<=domain.x1; ++iX) { 00187 for (plint iY=domain.y0; iY<=domain.y1; ++iY) { 00188 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) { 00189 mask.get(iX,iY,iZ) = getBottomMostDynamics(lattice.get(iX,iY,iZ).getDynamics()).getId(); 00190 } 00191 } 00192 } 00193 } 00194 00195 template<typename T, template<typename U> class Descriptor> 00196 ExtractBottomMostDynamicsFunctional3D<T,Descriptor>* 00197 ExtractBottomMostDynamicsFunctional3D<T,Descriptor>::clone() const 00198 { 00199 return new ExtractBottomMostDynamicsFunctional3D<T,Descriptor>(*this); 00200 } 00201 00202 template<typename T, template<typename U> class Descriptor> 00203 void ExtractBottomMostDynamicsFunctional3D<T,Descriptor>:: 00204 getTypeOfModification(std::vector<modif::ModifT>& modified) const 00205 { 00206 modified[0] = modif::nothing; 00207 modified[1] = modif::staticVariables; 00208 } 00209 00210 template<typename T, template<typename U> class Descriptor> 00211 BlockDomain::DomainT ExtractBottomMostDynamicsFunctional3D<T,Descriptor>::appliesTo() const { 00212 return BlockDomain::bulk; 00213 } 00214 00215 00216 /* ******** AssignEntireCellFunctional3D ************************************ */ 00217 00218 template<typename T, template<typename U> class Descriptor> 00219 void AssignEntireCellFunctional3D<T,Descriptor>::process ( 00220 Box3D domain, BlockLattice3D<T,Descriptor>& sourceLattice, 00221 BlockLattice3D<T,Descriptor>& destinationLattice ) 00222 { 00223 std::vector<char> data; 00224 Dot3D offset = computeRelativeDisplacement(sourceLattice, destinationLattice); 00225 for (plint iX=domain.x0; iX<=domain.x1; ++iX) { 00226 for (plint iY=domain.y0; iY<=domain.y1; ++iY) { 00227 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) { 00228 Cell<T,Descriptor> const& cell = sourceLattice.get(iX,iY,iZ); 00229 00230 pluint pos = data.size(); 00231 data.resize(pos+CellInfo<T,Descriptor>::n*sizeof(T)); 00232 cell.serialize(&data[pos]); 00233 00234 HierarchicSerializer serializer(data, cell.getDynamics().getId()); 00235 cell.getDynamics().serialize(serializer); 00236 } 00237 } 00238 } 00239 00240 pluint pos=0; 00241 for (plint iX=domain.x0; iX<=domain.x1; ++iX) { 00242 for (plint iY=domain.y0; iY<=domain.y1; ++iY) { 00243 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) { 00244 plint iX_ = iX+offset.x; 00245 plint iY_ = iY+offset.y; 00246 plint iZ_ = iZ+offset.z; 00247 Cell<T,Descriptor>& cell = destinationLattice.get(iX_,iY_,iZ_); 00248 00249 cell.unSerialize(&data[pos]); 00250 pos += CellInfo<T,Descriptor>::n*sizeof(T); 00251 00252 HierarchicUnserializer unserializer(data, pos); 00253 destinationLattice.attributeDynamics ( 00254 iX_,iY_,iZ_, meta::dynamicsRegistration<T,Descriptor>(). 00255 generate(unserializer) ); 00256 pos = unserializer.getCurrentPos(); 00257 } 00258 } 00259 } 00260 } 00261 00262 template<typename T, template<typename U> class Descriptor> 00263 AssignEntireCellFunctional3D<T,Descriptor>* 00264 AssignEntireCellFunctional3D<T,Descriptor>::clone() const 00265 { 00266 return new AssignEntireCellFunctional3D<T,Descriptor>(*this); 00267 } 00268 00269 template<typename T, template<typename U> class Descriptor> 00270 void AssignEntireCellFunctional3D<T,Descriptor>:: 00271 getTypeOfModification(std::vector<modif::ModifT>& modified) const 00272 { 00273 modified[0] = modif::nothing; 00274 modified[1] = modif::staticVariables; 00275 } 00276 00277 template<typename T, template<typename U> class Descriptor> 00278 BlockDomain::DomainT AssignEntireCellFunctional3D<T,Descriptor>::appliesTo() const { 00279 return BlockDomain::bulkAndEnvelope; 00280 } 00281 00282 } // namespace plb 00283 00284 #endif // META_STUFF_FUNCTIONAL_3D_HH
1.6.3
1.6.3