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

ntensorAnalysisFunctional3D.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 NTENSOR_ANALYSIS_FUNCTIONAL_3D_HH
00029 #define NTENSOR_ANALYSIS_FUNCTIONAL_3D_HH
00030 
00031 #include "dataProcessors/ntensorAnalysisFunctional3D.h"
00032 #include "core/plbDebug.h"
00033 #include "core/util.h"
00034 #include "core/blockStatistics.h"
00035 #include "latticeBoltzmann/momentTemplates.h"
00036 #include "latticeBoltzmann/geometricOperationTemplates.h"
00037 #include "finiteDifference/fdStencils1D.h"
00038 #include "atomicBlock/atomicBlock3D.h"
00039 #include "atomicBlock/blockLattice3D.h"
00040 #include "atomicBlock/dataField3D.h"
00041 #include <cmath>
00042 #include <limits>
00043 
00044 namespace plb {
00045 
00046 template<typename T1, typename T2>
00047 void CopyConvertNTensorFunctional3D<T1,T2>::process (
00048         Box3D domain, NTensorField3D<T1>& field1,
00049                       NTensorField3D<T2>& field2 )
00050 {
00051 
00052     PLB_PRECONDITION( field1.getNdim() == field2.getNdim());
00053     plint ndim = field1.getNdim();
00054     Dot3D offset = computeRelativeDisplacement(field1, field2);
00055 
00056     // Improve computational speed if the field is scalar-valued.
00057     if (ndim==1) {
00058         for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
00059             for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
00060                 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) {
00061                     for (int iDim=0; iDim<ndim; ++iDim) {
00062                         *field2.get(iX+offset.x,iY+offset.y,iZ+offset.z) =
00063                             (T2) *field1.get(iX,iY,iZ);
00064                     }
00065                 }
00066             }
00067         }
00068     }
00069     // Generic implementation for any number of dimensions.
00070     else {
00071         for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
00072             for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
00073                 for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) {
00074                     for (int iDim=0; iDim<ndim; ++iDim) {
00075                         field2.get(iX+offset.x,iY+offset.y,iZ+offset.z)[iDim] =
00076                             (T2) field1.get(iX,iY,iZ)[iDim];
00077                     }
00078                 }
00079             }
00080         }
00081     }
00082 }
00083 
00084 template<typename T1, typename T2>
00085 CopyConvertNTensorFunctional3D<T1,T2>* CopyConvertNTensorFunctional3D<T1,T2>::clone() const
00086 {
00087     return new CopyConvertNTensorFunctional3D<T1,T2>(*this);
00088 }
00089 
00090 template<typename T1, typename T2>
00091 void CopyConvertNTensorFunctional3D<T1,T2>::getTypeOfModification(std::vector<modif::ModifT>& modified) const {
00092     modified[0] = modif::nothing;
00093     modified[1] = modif::staticVariables;
00094 }
00095 
00096 template<typename T1, typename T2>
00097 BlockDomain::DomainT CopyConvertNTensorFunctional3D<T1,T2>::appliesTo() const {
00098     return BlockDomain::bulkAndEnvelope;
00099 }
00100 
00101 }  // namespace plb
00102 
00103 #endif  // NTENSOR_ANALYSIS_FUNCTIONAL_3D_HH