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

mrtDynamics.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 contributed this code.
00026  */
00027 
00032 #ifndef MRT_DYNAMICS_H
00033 #define MRT_DYNAMICS_H
00034 
00035 #include "core/globalDefs.h"
00036 #include "basicDynamics/isoThermalDynamics.h"
00037 
00038 namespace plb {
00039 
00040 template<typename T, template<typename U> class Descriptor>
00041 class MRTparam {
00042 public:
00043     typedef T MatT[Descriptor<T>::q][Descriptor<T>::q];
00044 public:
00045     MRTparam();
00046     virtual ~MRTparam() { }
00047     MRTparam(T omega_);
00048     MRTparam(T omega_, T lambda_);
00049     MRTparam(std::vector<T> s_);
00050     MRTparam(HierarchicUnserializer& unserializer);
00051     void serialize(HierarchicSerializer& serializer) const;
00052     void unserialize(HierarchicUnserializer& unserializer);
00053     MRTparam<T,Descriptor>* clone() const;
00055     virtual void setParameter(plint whichParameter, T value);
00057     virtual T getParameter(plint whichParameter) const;
00059     virtual T getOmega() const;
00061     virtual void setOmega(T omega_);
00063     T getLambda() const;
00065     void setLambda(T lambda_);
00067     T getOmegaQ() const;
00069     void setOmegaQ(T q_);
00071     T getOmegaEpsilon() const;
00073     void setOmegaEpsilon(T epsilon_);
00075     std::vector<T> const& getS() const;
00077     MatT& getInvM();
00078 private:
00080     void iniRelaxationVector();
00082     void precompute_invM_S();
00083 private:
00084     T invM_S[Descriptor<T>::q][Descriptor<T>::q]; // relaxation time matrix.
00085     std::vector<T> s;
00086 };
00087 
00088 template<typename T, template<typename U> class Descriptor>
00089 class MRTparamList {
00090 public:
00091     void set(plint id, MRTparam<T,Descriptor> const& param);
00092     MRTparam<T,Descriptor>& get(plint id);
00093     MRTparam<T,Descriptor> const& get(plint id) const;
00094 private:
00095     std::vector<MRTparam<T,Descriptor> > parameters;
00096 };
00097 
00098 template<typename T, template<typename U> class Descriptor>
00099 MRTparamList<T,Descriptor>& mrtParam();
00100 
00102 template<typename T, template<typename U> class Descriptor>
00103 class MRTdynamics : public IsoThermalBulkDynamics<T,Descriptor> {
00104 public:
00105 /* *************** Construction / Destruction ************************ */
00106     MRTdynamics(plint externalParam_);
00107     MRTdynamics(MRTparam<T,Descriptor>* param_);
00108     MRTdynamics(HierarchicUnserializer& unserializer);
00109     MRTdynamics(MRTdynamics<T,Descriptor> const& rhs);
00110     MRTdynamics<T,Descriptor>& operator=(MRTdynamics<T,Descriptor> const& rhs);
00111     ~MRTdynamics<T,Descriptor>();
00112     void swap(MRTdynamics<T,Descriptor>& rhs);
00113     
00115     virtual MRTdynamics<T,Descriptor>* clone() const;
00116 
00118     virtual int getId() const;
00119 
00121     virtual void serialize(HierarchicSerializer& serializer) const;
00123     virtual void unserialize(HierarchicUnserializer& unserializer);
00124 
00125 /* *************** Collision and Equilibrium ************************* */
00126 
00128     virtual void collide(Cell<T,Descriptor>& cell,
00129                          BlockStatistics& statistics_);
00130 
00132     virtual T computeEquilibrium(plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j,
00133                                  T jSqr, T thetaBar=T()) const;
00134                                  
00135     MRTparam<T,Descriptor> const& getMrtParameter() const;
00136 private:
00137     MRTparam<T,Descriptor>* param;
00138     plint externalParam;
00139     static int id;
00140 };
00141 
00143 template<typename T, template<typename U> class Descriptor>
00144 class ExternalVelocityMRTdynamics : public IsoThermalBulkDynamics<T,Descriptor> {
00145 public:
00146 /* *************** Construction / Destruction ************************ */
00147     ExternalVelocityMRTdynamics(plint externalParam_);
00148     ExternalVelocityMRTdynamics(MRTparam<T,Descriptor>* param_);
00149     ExternalVelocityMRTdynamics(HierarchicUnserializer& unserializer);
00150     ExternalVelocityMRTdynamics(ExternalVelocityMRTdynamics<T,Descriptor> const& rhs);
00151     ExternalVelocityMRTdynamics<T,Descriptor>& operator=(ExternalVelocityMRTdynamics<T,Descriptor> const& rhs);
00152     ~ExternalVelocityMRTdynamics<T,Descriptor>();
00153     void swap(ExternalVelocityMRTdynamics<T,Descriptor>& rhs);
00154     
00156     virtual ExternalVelocityMRTdynamics<T,Descriptor>* clone() const;
00157 
00159     virtual int getId() const;
00160 
00162     virtual void serialize(HierarchicSerializer& serializer) const;
00164     virtual void unserialize(HierarchicUnserializer& unserializer);
00165 
00166 /* *************** Collision and Equilibrium ************************* */
00167 
00169     virtual void collide(Cell<T,Descriptor>& cell,
00170                          BlockStatistics& statistics_);
00171 
00173     virtual T computeEquilibrium(plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j,
00174                                  T jSqr, T thetaBar=T()) const;
00175                                  
00176 /* *************** Moments ******************************************* */
00177 
00178     // The function computeDensity() is not overridden, and the default
00179     //   implementation is kept, for two reasons. First, it is equivalent to access
00180     //   rho from the external scalar or to recompute it from the bulk (this
00181     //   is not the case for the velocity, in a Shan/Chen multicomponent model).
00182     //   Second, the Shan/Chen data-processor needs computeDensity() to be
00183     //   default implemented, because it uses this function to treat walls with
00184     //   a virtual-density mechanism.
00185 
00187     virtual void computeVelocity( Cell<T,Descriptor> const& cell,
00188                                   Array<T,Descriptor<T>::d>& u ) const;
00190 
00191     virtual T computeRhoBar(Cell<T,Descriptor> const& cell) const;
00192 
00194 
00195     virtual void computeRhoBarJ(Cell<T,Descriptor> const& cell,
00196                                 T& rhoBar, Array<T,Descriptor<T>::d>& j) const;
00197                                  
00198 public:
00199     MRTparam<T,Descriptor> const &getMrtParameter() const {
00200         return *param;
00201     }
00202 private:
00203     MRTparam<T,Descriptor>* param;
00204     plint externalParam;
00205     static int id;
00206 };
00207 
00209 
00213 template<typename T, template<typename U> class Descriptor>
00214 class IncMRTdynamics : public IsoThermalBulkDynamics<T,Descriptor> {
00215 public:
00216 /* *************** Construction / Destruction ************************ */
00217     IncMRTdynamics(plint externalParam_);
00218     IncMRTdynamics(MRTparam<T,Descriptor>* param_);
00219     IncMRTdynamics(HierarchicUnserializer& unserializer);
00220     IncMRTdynamics(IncMRTdynamics<T,Descriptor> const& rhs);
00221     IncMRTdynamics<T,Descriptor>& operator=(IncMRTdynamics<T,Descriptor> const& rhs);
00222     ~IncMRTdynamics<T,Descriptor>();
00223     void swap(IncMRTdynamics<T,Descriptor>& rhs);
00224     
00226     virtual IncMRTdynamics<T,Descriptor>* clone() const;
00227 
00229     virtual int getId() const;
00230 
00232     virtual void serialize(HierarchicSerializer& serializer) const;
00234     virtual void unserialize(HierarchicUnserializer& unserializer);
00235 
00236 /* *************** Collision and Equilibrium ************************* */
00237 
00239     virtual void collide(Cell<T,Descriptor>& cell,
00240                          BlockStatistics& statistics_);
00241 
00243     virtual T computeEquilibrium(plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j,
00244                                  T jSqr, T thetaBar=T()) const;
00245                                  
00246     virtual bool velIsJ() const;
00247 
00248 /* *************** Macroscopic variables ***************************** */
00249     
00251     virtual void computeVelocity( Cell<T,Descriptor> const& cell,
00252                                   Array<T,Descriptor<T>::d>& u ) const;
00253 public:
00254     MRTparam<T,Descriptor> const &getMrtParameter() const {
00255         return *param;
00256     }
00257 private:
00258     MRTparam<T,Descriptor>* param;
00259     plint externalParam;
00260     static int id;
00261 };
00262 
00263 
00265 
00269 template<typename T, template<typename U> class Descriptor>
00270 class ExternalVelocityIncMRTdynamics : public IsoThermalBulkDynamics<T,Descriptor> {
00271 public:
00272 /* *************** Construction / Destruction ************************ */
00273     ExternalVelocityIncMRTdynamics(plint externalParam_);
00274     ExternalVelocityIncMRTdynamics(MRTparam<T,Descriptor>* param_);
00275     ExternalVelocityIncMRTdynamics(HierarchicUnserializer& unserializer);
00276     ExternalVelocityIncMRTdynamics(ExternalVelocityIncMRTdynamics<T,Descriptor> const& rhs);
00277     ExternalVelocityIncMRTdynamics<T,Descriptor>& operator=(ExternalVelocityIncMRTdynamics<T,Descriptor> const& rhs);
00278     ~ExternalVelocityIncMRTdynamics<T,Descriptor>();
00279     void swap(ExternalVelocityIncMRTdynamics<T,Descriptor>& rhs);
00280     
00282     virtual ExternalVelocityIncMRTdynamics<T,Descriptor>* clone() const;
00283 
00285     virtual int getId() const;
00286 
00288     virtual void serialize(HierarchicSerializer& serializer) const;
00290     virtual void unserialize(HierarchicUnserializer& unserializer);
00291 
00292 /* *************** Collision and Equilibrium ************************* */
00293 
00295     virtual void collide(Cell<T,Descriptor>& cell,
00296                          BlockStatistics& statistics_);
00297 
00299     virtual T computeEquilibrium(plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j,
00300                                  T jSqr, T thetaBar=T()) const;
00301                                  
00302     virtual bool velIsJ() const;
00303     
00304 /* *************** Moments ******************************************* */
00305 
00306     // The function computeDensity() is not overridden, and the default
00307     //   implementation is kept, for two reasons. First, it is equivalent to access
00308     //   rho from the external scalar or to recompute it from the bulk (this
00309     //   is not the case for the velocity, in a Shan/Chen multicomponent model).
00310     //   Second, the Shan/Chen data-processor needs computeDensity() to be
00311     //   default implemented, because it uses this function to treat walls with
00312     //   a virtual-density mechanism.
00313 
00315     virtual void computeVelocity( Cell<T,Descriptor> const& cell,
00316                                   Array<T,Descriptor<T>::d>& u ) const;
00318 
00319     virtual T computeRhoBar(Cell<T,Descriptor> const& cell) const;
00320 
00322 
00323     virtual void computeRhoBarJ(Cell<T,Descriptor> const& cell,
00324                                 T& rhoBar, Array<T,Descriptor<T>::d>& j) const;
00325 public:
00326     MRTparam<T,Descriptor> const &getMrtParameter() const {
00327         return *param;
00328     }
00329 private:
00330     MRTparam<T,Descriptor>* param;
00331     plint externalParam;
00332     static int id;
00333 };
00334 
00335 }  // namespace plb
00336 
00337 #endif  // MRT_DYNAMICS_H
00338