$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

serialMultiDataField2D.hh

Go to the documentation of this file.
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 SERIAL_MULTI_DATA_FIELD_2D_HH
00029 #define SERIAL_MULTI_DATA_FIELD_2D_HH
00030 
00031 #include "serialMultiDataField2D.h"
00032 
00033 /* *************** Class SerialScalarAccess2D ************************ */
00034 
00035 namespace plb {
00036 template<typename T>
00037 SerialScalarAccess2D<T>::SerialScalarAccess2D()
00038     : locatedBlock(0)
00039 { }
00040 
00041 template<typename T>
00042 T& SerialScalarAccess2D<T>::getDistributedScalar (
00043             plint iX, plint iY,
00044             MultiBlockManagement2D const& multiBlockManagement,
00045             std::map<plint,ScalarField2D<T>*>& fields )
00046 {
00047     plint localX, localY;
00048 #ifdef PLB_DEBUG
00049     bool ok =
00050 #endif
00051         multiBlockManagement.findInLocalBulk (
00052             iX,iY, locatedBlock, localX, localY );
00053     PLB_PRECONDITION( ok );
00054     return fields[locatedBlock] -> get(localX,localY);
00055 }
00056 
00057 template<typename T>
00058 T const& SerialScalarAccess2D<T>::getDistributedScalar (
00059             plint iX, plint iY,
00060             MultiBlockManagement2D const& multiBlockManagement,
00061             std::map<plint,ScalarField2D<T>*> const& fields ) const
00062 {
00063     plint localX, localY;
00064 #ifdef PLB_DEBUG
00065     bool ok =
00066 #endif
00067         multiBlockManagement.findInLocalBulk
00068             (iX,iY, locatedBlock, localX, localY);
00069     PLB_PRECONDITION( ok );
00070     return fields.find(locatedBlock)->second -> get(localX,localY);
00071 }
00072 
00073 
00074 template<typename T>
00075 SerialScalarAccess2D<T>* SerialScalarAccess2D<T>::clone() const {
00076     return new SerialScalarAccess2D(*this);
00077 }
00078 
00079 
00080 /* *************** Class SerialTensorAccess2D ************************ */
00081 
00082 template<typename T, int nDim>
00083 SerialTensorAccess2D<T,nDim>::SerialTensorAccess2D()
00084     : locatedBlock(0)
00085 { }
00086 
00087 template<typename T, int nDim>
00088 Array<T,nDim>& SerialTensorAccess2D<T,nDim>::getDistributedTensor (
00089             plint iX, plint iY,
00090             MultiBlockManagement2D const& multiBlockManagement,
00091             std::map<plint,TensorField2D<T,nDim>*>& fields )
00092 {
00093     plint localX, localY;
00094 #ifdef PLB_DEBUG
00095     bool ok =
00096 #endif
00097         multiBlockManagement.findInLocalBulk
00098             (iX,iY, locatedBlock, localX, localY);
00099     PLB_PRECONDITION( ok );
00100     return fields[locatedBlock] -> get(localX,localY);
00101 }
00102 
00103 template<typename T, int nDim>
00104 Array<T,nDim> const& SerialTensorAccess2D<T,nDim>::getDistributedTensor (
00105             plint iX, plint iY,
00106             MultiBlockManagement2D const& multiBlockManagement,
00107             std::map<plint,TensorField2D<T,nDim>*> const& fields ) const
00108 {
00109     plint localX, localY;
00110 #ifdef PLB_DEBUG
00111     bool ok =
00112 #endif
00113         multiBlockManagement.findInLocalBulk
00114             (iX,iY, locatedBlock, localX, localY);
00115     PLB_PRECONDITION( ok );
00116     return fields.find(locatedBlock)->second -> get(localX,localY);
00117 }
00118 
00119 
00120 template<typename T, int nDim>
00121 SerialTensorAccess2D<T,nDim>* SerialTensorAccess2D<T,nDim>::clone() const {
00122     return new SerialTensorAccess2D(*this);
00123 }
00124 
00125 
00126 
00127 /* *************** Class SerialNTensorAccess2D ************************ */
00128 
00129 template<typename T>
00130 SerialNTensorAccess2D<T>::SerialNTensorAccess2D()
00131     : locatedBlock(0)
00132 { }
00133 
00134 template<typename T>
00135 T* SerialNTensorAccess2D<T>::getDistributedNTensor (
00136             plint iX, plint iY,
00137             MultiBlockManagement2D const& multiBlockManagement,
00138             std::map<plint,NTensorField2D<T>*>& fields )
00139 {
00140     plint localX, localY;
00141 #ifdef PLB_DEBUG
00142     bool ok =
00143 #endif
00144         multiBlockManagement.findInLocalBulk
00145             (iX,iY, locatedBlock, localX, localY);
00146     PLB_PRECONDITION( ok );
00147     typename std::map<plint,NTensorField2D<T>*>::const_iterator it = fields.find(locatedBlock);
00148     PLB_ASSERT( it != fields.end() );
00149     return it->second -> get(localX,localY);
00150 }
00151 
00152 template<typename T>
00153 T const* SerialNTensorAccess2D<T>::getDistributedNTensor (
00154             plint iX, plint iY,
00155             MultiBlockManagement2D const& multiBlockManagement,
00156             std::map<plint,NTensorField2D<T>*> const& fields ) const
00157 {
00158     plint localX, localY;
00159 #ifdef PLB_DEBUG
00160     bool ok =
00161 #endif
00162         multiBlockManagement.findInLocalBulk
00163             (iX,iY, locatedBlock, localX, localY);
00164     PLB_PRECONDITION( ok );
00165     typename std::map<plint,NTensorField2D<T>*>::const_iterator it = fields.find(locatedBlock);
00166     PLB_ASSERT( it != fields.end() );
00167     return it->second -> get(localX,localY);
00168 }
00169 
00170 
00171 template<typename T>
00172 SerialNTensorAccess2D<T>* SerialNTensorAccess2D<T>::clone() const {
00173     return new SerialNTensorAccess2D(*this);
00174 }
00175 
00176 }  // namespace plb
00177 
00178 #endif  // SERIAL_MULTI_DATA_FIELD_2D_HH