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

coProcessorFunctional3D.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 
00025 #ifndef CO_PROCESSOR_FUNCTIONAL_3D_HH
00026 #define CO_PROCESSOR_FUNCTIONAL_3D_HH
00027 
00028 #include "coProcessors/coProcessorFunctional3D.h"
00029 #include "core/plbDebug.h"
00030 #include "core/util.h"
00031 #include "atomicBlock/atomicBlock3D.h"
00032 #include "atomicBlock/blockLattice3D.h"
00033 
00034 namespace plb {
00035 
00036 /* ********  IdentifyPureDynamics3D ************************************ */
00037 
00038 template<typename T, template<typename U> class Descriptor>
00039  IdentifyPureDynamics3D<T,Descriptor>::IdentifyPureDynamics3D(plint dynamicsId_)
00040     : dynamicsId(dynamicsId_)
00041 { }
00042 
00043 template<typename T, template<typename U> class Descriptor>
00044 void  IdentifyPureDynamics3D<T,Descriptor>::processGenericBlocks (
00045         Box3D domain, std::vector<AtomicBlock3D*> blocks )
00046 {
00047     T eps = 1.e-6;
00048     PLB_PRECONDITION( blocks.size()==2 );
00049     BlockLattice3D<T,Descriptor>& lattice = *dynamic_cast<BlockLattice3D<T,Descriptor>*>(blocks[0]);
00050     AtomicContainerBlock3D& container = *dynamic_cast<AtomicContainerBlock3D*>(blocks[1]);
00051     PureDynamics<T>* pureDynamics = new PureDynamics<T>;
00052     bool firstElement = true;
00053     for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
00054         for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
00055             for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) {
00056                 Dynamics<T,Descriptor>& dynamics = lattice.get(iX,iY,iZ).getDynamics();
00057                 pureDynamics->isPure = dynamics.getId() == dynamicsId;
00058                 if (firstElement) {
00059                     pureDynamics->omega = dynamics.getOmega();
00060                 }
00061                 else {
00062                     if ( fabs(pureDynamics->omega-dynamics.getOmega())>eps ) {
00063                         pureDynamics->isPure = false;
00064                     }
00065                 }
00066                 if (!pureDynamics->isPure) break;
00067                 firstElement = false;
00068             }
00069             if (!pureDynamics->isPure) break;
00070         }
00071         if (!pureDynamics->isPure) break;
00072     }
00073     if (!pureDynamics->isPure) {
00074         pureDynamics->omega = T();
00075     }
00076     container.setData(pureDynamics);
00077 }
00078 
00079 template<typename T, template<typename U> class Descriptor>
00080  IdentifyPureDynamics3D<T,Descriptor>*  IdentifyPureDynamics3D<T,Descriptor>::clone() const {
00081     return new  IdentifyPureDynamics3D<T,Descriptor>(*this);
00082 }
00083 
00084 template<typename T, template<typename U> class Descriptor>
00085 void  IdentifyPureDynamics3D<T,Descriptor>::getTypeOfModification(std::vector<modif::ModifT>& modified) const {
00086     modified[0] = modif::nothing;
00087     modified[1] = modif::staticVariables;
00088 }
00089 
00090 template<typename T, template<typename U> class Descriptor>
00091 BlockDomain::DomainT  IdentifyPureDynamics3D<T,Descriptor>::appliesTo() const {
00092     return BlockDomain::bulk;
00093 }
00094 
00095 }  // namespace plb
00096 
00097 #endif  // CO_PROCESSOR_FUNCTIONAL_3D_HH