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

multiScale.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 /* Main author: Daniel Lagrava
00026  **/
00027 
00031 #ifndef MULTI_SCALE_H
00032 #define MULTI_SCALE_H
00033 
00034 #include "core/globalDefs.h"
00035 #include "core/array.h"
00036 #include "core/util.h"
00037 
00038 namespace plb {
00039 
00040 template<typename T>
00041 T from_reference(T value, int dimDx, int dimDt, int dxScale, int dtScale) {
00042     int exponent = dxScale*dimDx + dtScale*dimDt;
00043     return value * util::twoToThePower(exponent);
00044 }
00045 
00046 template<typename T>
00047 T to_reference(T value, int dimDx, int dimDt, int dxScale, int dtScale) {
00048     int exponent = - dxScale*dimDx - dtScale*dimDt;
00049     return value * util::twoToThePower(exponent);
00050 }
00051 
00052 class MultiBlockManagement2D;
00053 struct Box2D;
00054 
00055 class MultiBlockManagement3D;
00056 struct Box3D;
00057 
00058 
00059 struct MultiScaleManager {
00060     virtual ~MultiScaleManager() { }
00061     virtual MultiScaleManager* clone() const =0;
00062 
00063     virtual Box2D scaleBox(Box2D box, plint nLevel) const =0;
00064     virtual Box3D scaleBox(Box3D box, plint nLevel) const =0;
00065 
00066     virtual MultiBlockManagement2D scaleMultiBlockManagement (
00067             MultiBlockManagement2D const& multiBlockManagement, plint nLevel ) const =0;
00068     virtual MultiBlockManagement3D scaleMultiBlockManagement (
00069             MultiBlockManagement3D const& multiBlockManagement, plint nLevel ) const =0;
00070 
00071     virtual void scaleVelocity(Array<double,2>& u, plint nLevel) const =0;
00072     virtual void scaleVelocity(Array<double,3>& u, plint nLevel) const =0;
00073 
00074     virtual double scaleDeltaX(plint nLevel) const =0;
00075     virtual double scaleDeltaT(plint nLevel) const =0;
00076 };
00077 
00078 class PowerTwoMultiScaleManager : public MultiScaleManager {
00079 public:
00080     virtual Box2D scaleBox(Box2D box, plint nLevel) const;
00081     virtual Box3D scaleBox(Box3D box, plint nLevel) const;
00082 
00083     virtual MultiBlockManagement2D scaleMultiBlockManagement (
00084             MultiBlockManagement2D const& multiBlockManagement, plint nLevel ) const;
00085     virtual MultiBlockManagement3D scaleMultiBlockManagement (
00086             MultiBlockManagement3D const& multiBlockManagement, plint nLevel ) const;
00087 public:
00088     static plint twoToTheLevel(plint nLevel);
00089 };
00090 
00091 class ConvectiveMultiScaleManager : public PowerTwoMultiScaleManager {
00092 public:
00093     virtual ConvectiveMultiScaleManager* clone() const;
00094     virtual void scaleVelocity(Array<double,2>& u, plint nLevel) const;
00095     virtual void scaleVelocity(Array<double,3>& u, plint nLevel) const;
00096     virtual double scaleDeltaX(plint nLevel) const;
00097     virtual double scaleDeltaT(plint nLevel) const;
00098 };
00099                                                    
00100 namespace global {
00101 
00102     class DefaultMultiScaleManager {
00103     private:
00104         DefaultMultiScaleManager();
00105         ~DefaultMultiScaleManager();
00106         void set(MultiScaleManager* newManager);
00107         MultiScaleManager const& get() const;
00108     private:
00109         MultiScaleManager* defaultManager;
00110 
00111     friend DefaultMultiScaleManager& accessDefaultMultiScaleManager();
00112     friend MultiScaleManager const& getDefaultMultiScaleManager();
00113     friend void setDefaultMultiScaleManager(MultiScaleManager* newMultiScaleManager);
00114 
00115     };
00116 
00117     DefaultMultiScaleManager& accessDefaultMultiScaleManager();
00118 
00119     MultiScaleManager const& getDefaultMultiScaleManager();
00120 
00121     void setDefaultMultiScaleManager(MultiScaleManager* newMultiScaleManager);
00122 
00123 }  // namespace global
00124 
00125 }  // namespace plb
00126 
00127 #endif // MULTI_SCALE_H