$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 PARALLEL_MULTI_DATA_FIELD_2D_HH 00029 #define PARALLEL_MULTI_DATA_FIELD_2D_HH 00030 00031 #include "parallelMultiDataField2D.h" 00032 00033 #ifdef PLB_MPI_PARALLEL 00034 00035 namespace plb { 00036 00037 /* *************** Class ParallelScalarAccess2D ************************ */ 00038 00039 template<typename T> 00040 ParallelScalarAccess2D<T>::ParallelScalarAccess2D() 00041 : locatedBlock(0) 00042 { } 00043 00044 template<typename T> 00045 T& ParallelScalarAccess2D<T>::getDistributedScalar ( 00046 plint iX, plint iY, 00047 MultiBlockManagement2D const& multiBlockManagement, 00048 std::map<plint,ScalarField2D<T>*>& fields ) 00049 { 00050 std::vector<plint> foundId; 00051 std::vector<plint> foundX, foundY; 00052 bool hasBulkCell = multiBlockManagement.findAllLocalRepresentations(iX,iY, foundId, foundX, foundY); 00053 if (hasBulkCell) { 00054 distributedScalar = fields[foundId[0]] -> get(foundX[0], foundY[0]); 00055 } 00056 global::mpi().bCastThroughMaster(&distributedScalar, 1, hasBulkCell); 00057 return distributedScalar; 00058 } 00059 00060 template<typename T> 00061 T const& ParallelScalarAccess2D<T>::getDistributedScalar ( 00062 plint iX, plint iY, 00063 MultiBlockManagement2D const& multiBlockManagement, 00064 std::map<plint,ScalarField2D<T>*> const& fields ) const 00065 { 00066 std::vector<plint> foundId; 00067 std::vector<plint> foundX, foundY; 00068 bool hasBulkCell = multiBlockManagement.findAllLocalRepresentations(iX,iY, foundId, foundX, foundY); 00069 if (hasBulkCell) { 00070 typename std::map<plint,ScalarField2D<T>*>::const_iterator it = fields.find(foundId[0]); 00071 distributedScalar = it->second -> get(foundX[0], foundY[0]); 00072 } 00073 global::mpi().bCastThroughMaster(&distributedScalar, 1, hasBulkCell); 00074 return distributedScalar; 00075 } 00076 00077 00078 template<typename T> 00079 ParallelScalarAccess2D<T>* ParallelScalarAccess2D<T>::clone() const { 00080 return new ParallelScalarAccess2D(*this); 00081 } 00082 00083 00084 /* *************** Class ParallelTensorAccess2D ************************ */ 00085 00086 template<typename T, int nDim> 00087 ParallelTensorAccess2D<T,nDim>::ParallelTensorAccess2D() 00088 : locatedBlock(0) 00089 { } 00090 00091 template<typename T, int nDim> 00092 Array<T,nDim>& ParallelTensorAccess2D<T,nDim>::getDistributedTensor ( 00093 plint iX, plint iY, 00094 MultiBlockManagement2D const& multiBlockManagement, 00095 std::map<plint,TensorField2D<T,nDim>*>& fields ) 00096 { 00097 std::vector<plint> foundId; 00098 std::vector<plint> foundX, foundY; 00099 bool hasBulkCell = multiBlockManagement.findAllLocalRepresentations(iX,iY, foundId, foundX, foundY); 00100 if (hasBulkCell) { 00101 Array<T,nDim> const& foundTensor = fields[foundId[0]] -> get(foundX[0], foundY[0]); 00102 for (int iD=0; iD<nDim; ++iD) { 00103 distributedTensor[iD] = foundTensor[iD]; 00104 } 00105 } 00106 global::mpi().bCastThroughMaster(&distributedTensor[0], nDim, hasBulkCell); 00107 return distributedTensor; 00108 } 00109 00110 template<typename T, int nDim> 00111 Array<T,nDim> const& ParallelTensorAccess2D<T,nDim>::getDistributedTensor ( 00112 plint iX, plint iY, 00113 MultiBlockManagement2D const& multiBlockManagement, 00114 std::map<plint,TensorField2D<T,nDim>*> const& fields ) const 00115 { 00116 std::vector<plint> foundId; 00117 std::vector<plint> foundX, foundY; 00118 bool hasBulkCell = multiBlockManagement.findAllLocalRepresentations(iX,iY, foundId, foundX, foundY); 00119 if (hasBulkCell) { 00120 typename std::map<plint,TensorField2D<T,nDim>*>::const_iterator it = fields.find(foundId[0]); 00121 Array<T,nDim> const& foundTensor = it->second -> get(foundX[0], foundY[0]); 00122 for (int iD=0; iD<nDim; ++iD) { 00123 distributedTensor[iD] = foundTensor[iD]; 00124 } 00125 } 00126 global::mpi().bCastThroughMaster(&distributedTensor[0], nDim, hasBulkCell); 00127 return distributedTensor; 00128 00129 } 00130 00131 template<typename T, int nDim> 00132 ParallelTensorAccess2D<T,nDim>* ParallelTensorAccess2D<T,nDim>::clone() const { 00133 return new ParallelTensorAccess2D(*this); 00134 } 00135 00136 00137 00138 /* *************** Class ParallelNTensorAccess2D ************************ */ 00139 00140 template<typename T> 00141 ParallelNTensorAccess2D<T>::ParallelNTensorAccess2D() 00142 : distributedNTensor(0), 00143 locatedBlock(0) 00144 { } 00145 00146 template<typename T> 00147 ParallelNTensorAccess2D<T>::~ParallelNTensorAccess2D() 00148 { 00149 delete [] distributedNTensor; 00150 } 00151 00152 template<typename T> 00153 ParallelNTensorAccess2D<T>::ParallelNTensorAccess2D(ParallelNTensorAccess2D<T> const& rhs) 00154 : distributedNTensor(0), 00155 locatedBlock(rhs.locatedBlock) 00156 { } 00157 00158 template<typename T> 00159 T* ParallelNTensorAccess2D<T>::getDistributedNTensor ( 00160 plint iX, plint iY, 00161 MultiBlockManagement2D const& multiBlockManagement, 00162 std::map<plint,NTensorField2D<T>*>& fields ) 00163 { 00164 std::vector<plint> foundId; 00165 std::vector<plint> foundX, foundY; 00166 bool hasBulkCell = multiBlockManagement.findAllLocalRepresentations(iX,iY, foundId, foundX, foundY); 00167 typename std::map<plint,NTensorField2D<T>*>::const_iterator it = fields.find(foundId[0]); 00168 PLB_ASSERT( it != fields.end() ); 00169 int ndim = (int)it->second->getNdim(); 00170 delete [] distributedNTensor; 00171 distributedNTensor = new T[ndim]; 00172 if (hasBulkCell) { 00173 T const* foundNTensor = fields[foundId[0]] -> get(foundX[0], foundY[0]); 00174 for (int iD=0; iD<ndim; ++iD) { 00175 distributedNTensor[iD] = foundNTensor[iD]; 00176 } 00177 } 00178 global::mpi().bCastThroughMaster(&distributedNTensor[0], ndim, hasBulkCell); 00179 return distributedNTensor; 00180 } 00181 00182 template<typename T> 00183 T const* ParallelNTensorAccess2D<T>::getDistributedNTensor ( 00184 plint iX, plint iY, 00185 MultiBlockManagement2D const& multiBlockManagement, 00186 std::map<plint,NTensorField2D<T>*> const& fields ) const 00187 { 00188 std::vector<plint> foundId; 00189 std::vector<plint> foundX, foundY; 00190 bool hasBulkCell = multiBlockManagement.findAllLocalRepresentations(iX,iY, foundId, foundX, foundY); 00191 typename std::map<plint,NTensorField2D<T>*>::const_iterator it = fields.find(foundId[0]); 00192 PLB_ASSERT( it != fields.end() ); 00193 int ndim = (int)it->second->getNdim(); 00194 delete [] distributedNTensor; 00195 distributedNTensor = new T[ndim]; 00196 if (hasBulkCell) { 00197 T const* foundNTensor = it->second -> get(foundX[0], foundY[0]); 00198 for (int iD=0; iD<ndim; ++iD) { 00199 distributedNTensor[iD] = foundNTensor[iD]; 00200 } 00201 } 00202 global::mpi().bCastThroughMaster(&distributedNTensor[0], ndim, hasBulkCell); 00203 return distributedNTensor; 00204 } 00205 00206 template<typename T> 00207 ParallelNTensorAccess2D<T>* ParallelNTensorAccess2D<T>::clone() const { 00208 return new ParallelNTensorAccess2D(*this); 00209 } 00210 00211 } // namespace plb 00212 00213 #endif // PLB_MPI_PARALLEL 00214 00215 #endif // PARALLEL_MULTI_DATA_FIELD_2D_HH
1.6.3
1.6.3