$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 00025 #ifndef CO_PROCESSOR_INSTANTIATION_3D_HH 00026 #define CO_PROCESSOR_INSTANTIATION_3D_HH 00027 00028 #include "core/globalDefs.h" 00029 #include "coProcessors/coProcessorInstantiation3D.h" 00030 00031 namespace plb { 00032 00033 template<typename T, template<typename U> class Descriptor> 00034 std::map<plint,PureDynamics<T> > identifyBlocksWithPureDynamics ( 00035 MultiBlockLattice3D<T,Descriptor>& lattice, plint dynamicsId ) 00036 { 00037 MultiContainerBlock3D container(lattice); 00038 std::vector<MultiBlock3D*> latticeAndContainer; 00039 latticeAndContainer.push_back(&lattice); 00040 latticeAndContainer.push_back(&container); 00041 00042 applyProcessingFunctional( new IdentifyPureDynamics3D<T,Descriptor>(dynamicsId), 00043 lattice.getBoundingBox(), latticeAndContainer ); 00044 00045 MultiBlockManagement3D const& management = container.getMultiBlockManagement(); 00046 SparseBlockStructure3D const& sparseBlock = management.getSparseBlockStructure(); 00047 ThreadAttribution const& threadAttribution = management.getThreadAttribution(); 00048 std::map<plint,Box3D> const& domains = sparseBlock.getBulks(); 00049 00050 std::vector<plint> domainIds(domains.size()); 00051 std::vector<int> isPure(domains.size()); 00052 std::vector<T> omega(domains.size()); 00053 00054 std::map<plint,Box3D>::const_iterator it = domains.begin(); 00055 plint pos = 0; 00056 for (; it != domains.end(); ++it) { 00057 plint id = it->first; 00058 domainIds[pos] = id; 00059 if (threadAttribution.isLocal(id)) { 00060 AtomicContainerBlock3D const& component = container.getComponent(id); 00061 PureDynamics<T> const* data = 00062 dynamic_cast<PureDynamics<T> const*>(component.getData()); 00063 PLB_ASSERT( data ); 00064 isPure[pos] = data->isPure ? 1:0; 00065 omega[pos] = data->omega; 00066 } 00067 else { 00068 isPure[pos] = 0; 00069 omega[pos] = T(); 00070 } 00071 ++pos; 00072 } 00073 00074 #ifdef PLB_MPI_PARALLEL 00075 std::vector<int> isPureTmp(isPure.size()); 00076 global::mpi().reduceVect(isPure, isPureTmp, MPI_SUM); 00077 global::mpi().bCast(&isPureTmp[0], isPureTmp.size()); 00078 isPureTmp.swap(isPure); 00079 00080 std::vector<T> omegaTmp(omega.size()); 00081 global::mpi().reduceVect(omega, omegaTmp, MPI_SUM); 00082 global::mpi().bCast(&omegaTmp[0], omegaTmp.size()); 00083 omegaTmp.swap(omega); 00084 #endif 00085 00086 std::map<plint,PureDynamics<T> > pureDynamicsMap; 00087 for (pluint i=0; i<isPure.size(); ++i) { 00088 pureDynamicsMap.insert(std::pair<plint,PureDynamics<T> > ( 00089 domainIds[i], PureDynamics<T>(isPure[i], omega[i] ) ) ); 00090 } 00091 00092 return pureDynamicsMap; 00093 } 00094 00095 } // namespace plb 00096 00097 #endif // CO_PROCESSOR_INSTANTIATION_3D_HH
1.6.3
1.6.3