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