$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 00034 #ifndef ADVECTION_DIFFUSION_DYNAMICS_TEMPLATES_H 00035 #define ADVECTION_DIFFUSION_DYNAMICS_TEMPLATES_H 00036 00037 #include "core/globalDefs.h" 00038 #include "core/cell.h" 00039 #include "core/util.h" 00040 #include "latticeBoltzmann/offEquilibriumTemplates.h" 00041 #include "latticeBoltzmann/offEquilibriumAdvectionDiffusionTemplates.h" 00042 00043 namespace plb { 00044 00045 template<typename T, class Descriptor> struct advectionDiffusionDynamicsTemplatesImpl; 00046 00048 template<typename T, template<typename U> class Descriptor> 00049 struct advectionDiffusionDynamicsTemplates { 00050 00051 static T bgk_ma1_equilibrium(plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& jEq) 00052 { 00053 return advectionDiffusionDynamicsTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00054 ::bgk_ma1_equilibrium(iPop, rhoBar, jEq); 00055 } 00056 00057 static void regularize(Cell<T,Descriptor>& cell, T rhoBar, Array<T,Descriptor<T>::d> const& jAdvDiff, 00058 Array<T,Descriptor<T>::d> const& jEq) 00059 { 00060 advectionDiffusionDynamicsTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00061 ::regularize(cell.getRawPopulations(), rhoBar, jAdvDiff, jEq); 00062 } 00063 00064 static T no_corr_bgk_collision( 00065 Cell<T,Descriptor>& cell, T rhoBar, 00066 Array<T,Descriptor<T>::d> const& jEq, T omega) 00067 { 00068 return advectionDiffusionDynamicsTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00069 ::no_corr_bgk_collision(cell.getRawPopulations(), rhoBar, jEq, omega); 00070 } 00071 00072 static T no_corr_rlb_collision(Cell<T,Descriptor>& cell, T rhoBar, 00073 Array<T,Descriptor<T>::d> const& jEq, 00074 Array<T,Descriptor<T>::d> const& jNeq, 00075 T omega ) 00076 { 00077 return advectionDiffusionDynamicsTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00078 ::no_corr_rlb_collision(cell.getRawPopulations(), rhoBar, jEq, jNeq, omega); 00079 } 00080 00081 }; // struct advectionDiffusionDynamicsTemplates 00082 00083 00085 template<typename T, class Descriptor> 00086 struct advectionDiffusionDynamicsTemplatesImpl 00087 { 00088 00089 static T bgk_ma1_equilibrium(plint iPop, T rhoBar, Array<T,Descriptor::d> const& jEq) 00090 { 00091 T c_j = Descriptor::c[iPop][0]*jEq[0]; 00092 for (int iD=1; iD < Descriptor::d; ++iD) { 00093 c_j += Descriptor::c[iPop][iD]*jEq[iD]; 00094 } 00095 return Descriptor::t[iPop] * (rhoBar + Descriptor::invCs2 * c_j); 00096 } 00097 00099 static void regularize( Array<T,Descriptor::q>& f, T rhoBar, 00100 Array<T,Descriptor::d> const& jAdvDiff, 00101 Array<T,Descriptor::d> const& jEq ) 00102 { 00103 // Off-equilibrium j 00104 Array<T,Descriptor::d> jNeq; 00105 for (int iD=0; iD<Descriptor::d; ++iD) 00106 { 00107 jNeq[iD] = jAdvDiff[iD] - jEq[iD]; 00108 } 00109 00110 // Regularize each population 00111 for (plint iPop=0; iPop<Descriptor::q; ++iPop) 00112 { 00113 T fEq = bgk_ma1_equilibrium(iPop, rhoBar, jEq); 00114 T fNeq = (T)Descriptor::c[iPop][0] * jNeq[0]; 00115 for (plint iD = 1; iD < Descriptor::d; ++iD) 00116 { 00117 fNeq += (T)Descriptor::c[iPop][iD] * jNeq[iD]; 00118 } 00119 fNeq *= Descriptor::t[iPop] * Descriptor::invCs2; 00120 f[iPop] = fEq + fNeq; 00121 } 00122 } 00123 00124 static T no_corr_bgk_collision( 00125 Array<T,Descriptor::q>& f, T rhoBar, Array<T,Descriptor::d> const& jEq, 00126 T omega) 00127 { 00128 T invRho = Descriptor::invRho(rhoBar); 00129 const T jSqr = VectorTemplateImpl<T,Descriptor::d>::normSqr(jEq); 00130 for (plint iPop=0; iPop < Descriptor::q; ++iPop) { 00131 f[iPop] *= (T)1-omega; 00132 f[iPop] += omega * advectionDiffusionDynamicsTemplatesImpl<T,Descriptor>::bgk_ma1_equilibrium ( 00133 iPop, rhoBar, jEq); 00134 } 00135 return jSqr*invRho*invRho; 00136 } 00137 00138 static T no_corr_rlb_collision ( 00139 Array<T,Descriptor::q>& f, T rhoBar, Array<T,Descriptor::d> const& jEq, 00140 Array<T,Descriptor::d> const& jNeq,T omega ) 00141 { 00142 T invRho = Descriptor::invRho(rhoBar); 00143 const T jSqr = VectorTemplateImpl<T,Descriptor::d>::normSqr(jEq); 00144 00145 for (plint iPop=0; iPop < Descriptor::q; ++iPop) 00146 { 00147 f[iPop] = advectionDiffusionDynamicsTemplatesImpl<T,Descriptor>:: 00148 bgk_ma1_equilibrium(iPop, rhoBar, jEq); 00149 T fNeq = ((T)1-omega) * 00150 offEquilibriumAdvectionDiffusionTemplatesImpl<T,Descriptor>::fromJtoFneq(iPop, jNeq); 00151 f[iPop] += fNeq; 00152 } 00153 return jSqr*invRho*invRho; 00154 } 00155 00156 }; // struct advectionDiffusionDynamicsTemplatesImpl 00157 00158 } // namespace plb 00159 00160 #include "latticeBoltzmann/advectionDiffusionDynamicsTemplates2D.h" 00161 #include "latticeBoltzmann/advectionDiffusionDynamicsTemplates3D.h" 00162 00163 #endif
1.6.3
1.6.3