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

smagorinskyGenerics2D.h

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 /* Orestis Malaspinas designed some of the classes and concepts contained
00026  * in this file. */
00027 
00028 #ifndef SMAGORINSKY_GENERICS_2D_H
00029 #define SMAGORINSKY_GENERICS_2D_H
00030 
00031 namespace plb {
00032 
00033 template<typename T, template<typename U> class Descriptor, class SmagoFunction>
00034 class StaticSmagorinskyFunctional2D : public BoxProcessingFunctional2D_L<T,Descriptor> {
00035 public:
00036     StaticSmagorinskyFunctional2D(SmagoFunction smagoFunction_, T cSmago0_)
00037         : smagoFunction(smagoFunction_),
00038           cSmago0(cSmago0_)
00039     { }
00040     virtual void process(Box2D domain, BlockLattice2D<T,Descriptor>& lattice) {
00041         Dot2D relativeOffset = lattice.getLocation();
00042         for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
00043             for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
00044                 T cSmago = smagoFunction (
00045                         iX+relativeOffset.x,
00046                         iY+relativeOffset.y,
00047                         cSmago0 );
00048                 T omega0 = lattice.get(iX,iY).getOmega();
00049                 lattice.attributeDynamics ( iX,iY,
00050                         cloneAndInsertAtTopDynamics (
00051                             lattice.get(iX,iY).getDynamics(),
00052                             new SmagorinskyDynamics<T,Descriptor> (
00053                                 new NoDynamics<T,Descriptor>, omega0, cSmago ) ) );
00054             }
00055         }
00056     }
00057     virtual BlockDomain::DomainT appliesTo() const {
00058         // Composite dynamics needs to be instantiated everywhere, including envelope.
00059         return BlockDomain::bulkAndEnvelope;
00060     }
00061     virtual void getTypeOfModification(std::vector<modif::ModifT>& modified) const {
00062         modified[0] = modif::staticVariables;
00063     }
00064     virtual StaticSmagorinskyFunctional2D<T,Descriptor,SmagoFunction>* clone() const 
00065     {
00066         return new StaticSmagorinskyFunctional2D<T,Descriptor,SmagoFunction>(*this);
00067     }
00068 private:
00069     SmagoFunction smagoFunction;
00070     T cSmago0;
00071 };
00072 
00073 template<typename T>
00074 T constOmegaFromOmega0(plint iX, plint iY, T omega0) {
00075     return omega0;
00076 }
00077 
00078 template<typename T, template<typename U> class Descriptor>
00079 void instantiateStaticSmagorinsky(BlockLattice2D<T,Descriptor>& lattice, Box2D domain, T cSmago) {
00080     instantiateStaticSmagorinsky(lattice, domain, constOmegaFromOmega0<T>);
00081 }
00082 
00083 template<typename T, template<typename U> class Descriptor>
00084 void instantiateStaticSmagorinsky(MultiBlockLattice2D<T,Descriptor>& lattice, Box2D domain, T cSmago) {
00085     instantiateStaticSmagorinsky(lattice, domain, constOmegaFromOmega0<T>);
00086 }
00087 
00088 template<typename T, template<typename U> class Descriptor, class SmagoFunction>
00089 void instantiateStaticSmagorinsky(BlockLattice2D<T,Descriptor>& lattice, Box2D domain, SmagoFunction smagoFunction, T cSmago0)
00090 {
00091     applyProcessingFunctional (
00092             new StaticSmagorinskyFunctional2D<T,Descriptor,SmagoFunction>(smagoFunction, cSmago0),
00093             domain, lattice );
00094 }
00095 
00096 template<typename T, template<typename U> class Descriptor, class SmagoFunction>
00097 void instantiateStaticSmagorinsky(MultiBlockLattice2D<T,Descriptor>& lattice, Box2D domain, SmagoFunction smagoFunction, T cSmago0)
00098 {
00099     applyProcessingFunctional (
00100             new StaticSmagorinskyFunctional2D<T,Descriptor,SmagoFunction>(smagoFunction, cSmago0),
00101             domain, lattice );
00102 }
00103 
00104 } // namespace plb
00105 
00106 #endif  // SMAGORINSKY_GENERICS_2D_H