$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
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: Orestis Malaspinas 00026 */ 00027 00032 #ifndef ADVECTION_DIFFUSION_DYNAMICS_HH 00033 #define ADVECTION_DIFFUSION_DYNAMICS_HH 00034 00035 #include "core/latticeStatistics.h" 00036 #include "complexDynamics/advectionDiffusionDynamics.h" 00037 #include "latticeBoltzmann/advectionDiffusionMomentTemplates.h" 00038 #include "latticeBoltzmann/advectionDiffusionDynamicsTemplates.h" 00039 #include "latticeBoltzmann/offEquilibriumAdvectionDiffusionTemplates.h" 00040 00041 00042 namespace plb { 00043 00044 template<typename T, template<typename U> class Descriptor> 00045 struct AD_SmagoOperations { 00046 static T computePrefactor(T omega0, T cSmago) { 00047 return (T)0.5 * util::sqr(cSmago*omega0*Descriptor<T>::invCs2); 00048 } 00049 static T computeOmega(T omega0, T alpha, Array<T,Descriptor<T>::d> const& j1) 00050 { 00051 T j1Norm = norm(j1); 00052 T linearTerm = alpha*j1Norm; 00053 T squareTerm = (T)2*alpha*alpha*j1Norm; 00054 // In the following formula, the square-root appearing in the explicit form of 00055 // omega is developed to second-order. 00056 return omega0*(1-linearTerm+squareTerm); 00057 } 00058 }; 00059 00060 00061 /* *************** Class AdvectionDiffusionDynamics ************************************ */ 00062 00063 template<typename T, template<typename U> class Descriptor> 00064 AdvectionDiffusionDynamics<T,Descriptor>::AdvectionDiffusionDynamics(T omega_) 00065 : BasicBulkDynamics<T,Descriptor>(omega_) 00066 { } 00067 00068 template<typename T, template<typename U> class Descriptor> 00069 void AdvectionDiffusionDynamics<T,Descriptor>::regularize ( 00070 Cell<T,Descriptor>& cell, T rhoBar, Array<T,Descriptor<T>::d> const& j, 00071 T jSqr, Array<T,SymmetricTensor<T,Descriptor>::n> const& PiNeq, T thetaBar ) const 00072 { 00073 // jAdvDiff is the first order moment of 00074 typedef Descriptor<T> D; 00075 Array<T,Descriptor<T>::d> jEq; 00076 00077 advectionDiffusionMomentTemplates<T,Descriptor>::get_jEq(cell, rhoBar, jEq); 00078 00079 advectionDiffusionDynamicsTemplates<T,Descriptor>::regularize(cell,rhoBar,j,jEq); 00080 } 00081 00082 template<typename T, template<typename U> class Descriptor> 00083 T AdvectionDiffusionDynamics<T,Descriptor>::computeEbar(Cell<T,Descriptor> const& cell) const 00084 { 00085 return T(); 00086 } 00087 00088 00089 /* *************** Class SmagorinskyAdvectionDiffusionRLBdynamics *************** */ 00090 00091 template<typename T, template<typename U> class Descriptor> 00092 int SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>::id = 00093 meta::registerTwoParamDynamics<T,Descriptor,SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor> >("SmagoAdvectionDiffusion_RLB"); 00094 00097 template<typename T, template<typename U> class Descriptor> 00098 SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>::SmagorinskyAdvectionDiffusionRLBdynamics (T omega_, T cSmago_ ) 00099 : AdvectionDiffusionDynamics<T,Descriptor>(omega_), 00100 cSmago(cSmago_) 00101 { } 00102 00103 template<typename T, template<typename U> class Descriptor> 00104 SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>* SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>::clone() const { 00105 return new SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>(*this); 00106 } 00107 00108 template<typename T, template<typename U> class Descriptor> 00109 int SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>::getId() const { 00110 return id; 00111 } 00112 00113 template<typename T, template<typename U> class Descriptor> 00114 void SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>::collide ( 00115 Cell<T,Descriptor>& cell, BlockStatistics& statistics ) 00116 { 00117 T rhoBar; 00118 Array<T,Descriptor<T>::d> jEq, jNeq; 00119 advectionDiffusionMomentTemplates<T,Descriptor>::get_rhoBar_jEq_jNeq(cell, rhoBar, jEq, jNeq); 00120 00121 T omega0 = this->getOmega(); 00122 T alpha = AD_SmagoOperations<T,Descriptor>::computePrefactor(omega0, cSmago); 00123 T omega = AD_SmagoOperations<T,Descriptor>::computeOmega(omega0, alpha, jNeq); 00124 00125 T uSqr = advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00126 no_corr_rlb_collision(cell, rhoBar, jEq, jNeq, omega ); 00127 00128 if (cell.takesStatistics()) { 00129 gatherStatistics(statistics, rhoBar, uSqr); 00130 } 00131 } 00132 00135 template<typename T, template<typename U> class Descriptor> 00136 T SmagorinskyAdvectionDiffusionRLBdynamics<T,Descriptor>::computeEquilibrium ( 00137 plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j, T jSqr, T thetaBar ) const 00138 { 00139 return advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00140 bgk_ma1_equilibrium(iPop, rhoBar, j); 00141 } 00142 00143 00144 /* *************** Class AdvectionDiffusionRLBdynamics *************** */ 00145 00146 template<typename T, template<typename U> class Descriptor> 00147 int AdvectionDiffusionRLBdynamics<T,Descriptor>::id = 00148 meta::registerOneParamDynamics<T,Descriptor,AdvectionDiffusionRLBdynamics<T,Descriptor> >("AdvectionDiffusion_RLB"); 00149 00152 template<typename T, template<typename U> class Descriptor> 00153 AdvectionDiffusionRLBdynamics<T,Descriptor>::AdvectionDiffusionRLBdynamics (T omega_ ) 00154 : AdvectionDiffusionDynamics<T,Descriptor>(omega_) 00155 { } 00156 00157 template<typename T, template<typename U> class Descriptor> 00158 AdvectionDiffusionRLBdynamics<T,Descriptor>* AdvectionDiffusionRLBdynamics<T,Descriptor>::clone() const { 00159 return new AdvectionDiffusionRLBdynamics<T,Descriptor>(*this); 00160 } 00161 00162 template<typename T, template<typename U> class Descriptor> 00163 int AdvectionDiffusionRLBdynamics<T,Descriptor>::getId() const { 00164 return id; 00165 } 00166 00167 template<typename T, template<typename U> class Descriptor> 00168 void AdvectionDiffusionRLBdynamics<T,Descriptor>::collide ( 00169 Cell<T,Descriptor>& cell, BlockStatistics& statistics ) 00170 { 00171 T rhoBar; 00172 Array<T,Descriptor<T>::d> jEq, jNeq; 00173 advectionDiffusionMomentTemplates<T,Descriptor>::get_rhoBar_jEq_jNeq(cell, rhoBar, jEq, jNeq); 00174 00175 T uSqr = advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00176 no_corr_rlb_collision(cell, rhoBar, jEq, jNeq, this->getOmega() ); 00177 00178 if (cell.takesStatistics()) { 00179 gatherStatistics(statistics, rhoBar, uSqr); 00180 } 00181 } 00182 00185 template<typename T, template<typename U> class Descriptor> 00186 T AdvectionDiffusionRLBdynamics<T,Descriptor>::computeEquilibrium ( 00187 plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j, T jSqr, T thetaBar ) const 00188 { 00189 return advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00190 bgk_ma1_equilibrium(iPop, rhoBar, j); 00191 } 00192 00193 00194 /* *************** Class AdvectionDiffusionWithSourceRLBdynamics *************** */ 00195 00196 template<typename T, template<typename U> class Descriptor> 00197 int AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>::id = 00198 meta::registerOneParamDynamics<T,Descriptor,AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor> >("AdvectionDiffusionWithSource_RLB"); 00199 00202 template<typename T, template<typename U> class Descriptor> 00203 AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>::AdvectionDiffusionWithSourceRLBdynamics (T omega_ ) 00204 : AdvectionDiffusionDynamics<T,Descriptor>(omega_) 00205 { } 00206 00207 template<typename T, template<typename U> class Descriptor> 00208 AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>* AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>::clone() const { 00209 return new AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>(*this); 00210 } 00211 00212 template<typename T, template<typename U> class Descriptor> 00213 int AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>::getId() const { 00214 return id; 00215 } 00216 00217 template<typename T, template<typename U> class Descriptor> 00218 void AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>::collide ( 00219 Cell<T,Descriptor>& cell, BlockStatistics& statistics ) 00220 { 00221 T rhoBar; 00222 Array<T,Descriptor<T>::d> jEq, jNeq; 00223 advectionDiffusionMomentTemplates<T,Descriptor>::get_rhoBar_jEq_jNeq(cell, rhoBar, jEq, jNeq); 00224 00225 T sourceTerm = *cell.getExternal(Descriptor<T>::ExternalField::scalarBeginsAt); 00226 rhoBar += sourceTerm; 00227 00228 T uSqr = advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00229 no_corr_rlb_collision(cell, rhoBar, jEq, jNeq, this->getOmega() ); 00230 00231 if (cell.takesStatistics()) { 00232 gatherStatistics(statistics, rhoBar, uSqr); 00233 } 00234 } 00235 00238 template<typename T, template<typename U> class Descriptor> 00239 T AdvectionDiffusionWithSourceRLBdynamics<T,Descriptor>::computeEquilibrium ( 00240 plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j, T jSqr, T thetaBar ) const 00241 { 00242 return advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00243 bgk_ma1_equilibrium(iPop, rhoBar, j); 00244 } 00245 00246 00247 /* *************** Class AdvectionDiffusionBGKdynamics *************** */ 00248 00249 template<typename T, template<typename U> class Descriptor> 00250 int AdvectionDiffusionBGKdynamics<T,Descriptor>::id = 00251 meta::registerOneParamDynamics<T,Descriptor,AdvectionDiffusionBGKdynamics<T,Descriptor> >("AdvectionDiffusion_BGK"); 00252 00255 template<typename T, template<typename U> class Descriptor> 00256 AdvectionDiffusionBGKdynamics<T,Descriptor>::AdvectionDiffusionBGKdynamics ( 00257 T omega_ ) 00258 : AdvectionDiffusionDynamics<T,Descriptor>(omega_) 00259 { } 00260 00261 template<typename T, template<typename U> class Descriptor> 00262 AdvectionDiffusionBGKdynamics<T,Descriptor>* AdvectionDiffusionBGKdynamics<T,Descriptor>::clone() const { 00263 return new AdvectionDiffusionBGKdynamics<T,Descriptor>(*this); 00264 } 00265 00266 template<typename T, template<typename U> class Descriptor> 00267 int AdvectionDiffusionBGKdynamics<T,Descriptor>::getId() const { 00268 return id; 00269 } 00270 00271 template<typename T, template<typename U> class Descriptor> 00272 void AdvectionDiffusionBGKdynamics<T,Descriptor>::collide ( 00273 Cell<T,Descriptor>& cell, BlockStatistics& statistics ) 00274 { 00275 T rhoBar; 00276 Array<T,Descriptor<T>::d> jEq; 00277 advectionDiffusionMomentTemplates<T,Descriptor>::get_rhoBar_jEq(cell, rhoBar, jEq); 00278 00279 T uSqr = advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00280 no_corr_bgk_collision(cell, rhoBar, jEq, this->getOmega()); 00281 00282 if (cell.takesStatistics()) { 00283 gatherStatistics(statistics, rhoBar, uSqr); 00284 } 00285 } 00286 00289 template<typename T, template<typename U> class Descriptor> 00290 T AdvectionDiffusionBGKdynamics<T,Descriptor>::computeEquilibrium ( 00291 plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j, T jSqr, T thetaBar ) const 00292 { 00293 return advectionDiffusionDynamicsTemplates<T,Descriptor>:: 00294 bgk_ma1_equilibrium(iPop, rhoBar, j); 00295 00296 } 00297 00298 00299 } // namespace plb 00300 00301 #endif // ADVECTION_DIFFUSION_DYNAMICS_HH
1.6.3
1.6.3