$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_MOMENTS_TEMPLATES_H 00035 #define ADVECTION_DIFFUSION_MOMENTS_TEMPLATES_H 00036 00037 #include "core/globalDefs.h" 00038 #include "core/cell.h" 00039 #include "core/util.h" 00040 #include "latticeBoltzmann/geometricOperationTemplates.h" 00041 #include "latticeBoltzmann/roundOffPolicy.h" 00042 #include "latticeBoltzmann/momentTemplates.h" 00043 00044 namespace plb { 00045 00046 template<typename T, class Descriptor> struct advectionDiffusionMomentTemplatesImpl; 00047 00048 // This structure forwards the calls to the appropriate helper class 00049 template<typename T, template<typename U> class Descriptor> 00050 struct advectionDiffusionMomentTemplates { 00051 00052 static void get_rhoBar_jEq(Cell<T,Descriptor> const& cell, T& rhoBar, 00053 Array<T,Descriptor<T>::d>& jEq) 00054 { 00055 advectionDiffusionMomentTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00056 ::get_rhoBar_jEq(cell.getRawPopulations(), rhoBar, jEq, 00057 cell.getExternal(Descriptor<T>::ExternalField::velocityBeginsAt)); 00058 } 00059 00060 static void get_jEq(Cell<T,Descriptor> const& cell, const T& rhoBar, 00061 Array<T,Descriptor<T>::d>& jEq) 00062 { 00063 advectionDiffusionMomentTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00064 ::get_jEq(rhoBar, jEq, cell.getExternal(Descriptor<T>::ExternalField::velocityBeginsAt)); 00065 } 00066 00067 static void get_rhoBar_jEq_jNeq(Cell<T,Descriptor> const& cell, T& rhoBar, 00068 Array<T,Descriptor<T>::d>& jEq, Array<T,Descriptor<T>::d>& jNeq ) 00069 { 00070 advectionDiffusionMomentTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00071 ::get_rhoBar_jEq_jNeq(cell.getRawPopulations(), rhoBar, jEq, jNeq, 00072 cell.getExternal(Descriptor<T>::ExternalField::velocityBeginsAt)); 00073 } 00074 00075 }; // struct advectionDiffusionMomentTemplates 00076 00077 00078 // This structure forwards the calls to the appropriate helper class 00079 template<typename T, class Descriptor> 00080 struct advectionDiffusionMomentTemplatesImpl 00081 { 00082 00083 static void get_rhoBar_jEq(Array<T,Descriptor::q> const& f, T& rhoBar, 00084 Array<T,Descriptor::d>& jEq, const T u[Descriptor::d] ) 00085 { 00086 rhoBar = momentTemplatesImpl<T,Descriptor>::get_rhoBar(f); 00087 T rho = Descriptor::fullRho(rhoBar); 00088 for (plint iD = 0; iD < Descriptor::d; ++iD) 00089 { 00090 jEq[iD] = rho * u[iD]; 00091 } 00092 } 00093 00094 static void get_jEq(const T& rhoBar, Array<T,Descriptor::d>& jEq, const T u[Descriptor::d] ) 00095 { 00096 T rho = Descriptor::fullRho(rhoBar); 00097 for (plint iD = 0; iD < Descriptor::d; ++iD) 00098 { 00099 jEq[iD] = rho * u[iD]; 00100 } 00101 } 00102 00103 00104 static void get_rhoBar_jEq_jNeq(Array<T,Descriptor::q> const& f, T& rhoBar, 00105 Array<T,Descriptor::d>& jEq, Array<T,Descriptor::d>& jNeq, 00106 const T u[Descriptor::d]) 00107 { 00108 rhoBar = momentTemplatesImpl<T,Descriptor>::get_rhoBar(f); 00109 T rho = Descriptor::fullRho(rhoBar); 00110 Array<T,Descriptor::d> jReal; //sum f_i*c_i 00111 for (plint iD = 0; iD < Descriptor::d; ++iD) 00112 { 00113 jReal[iD] = (T)Descriptor::c[0][iD] * f[0]; 00114 for (plint iPop = 1; iPop < Descriptor::q; ++iPop) 00115 { 00116 jReal[iD] += (T)Descriptor::c[iPop][iD] * f[iPop]; 00117 } 00118 jEq[iD] = rho * u[iD]; 00119 jNeq[iD] = jReal[iD] - jEq[iD]; 00120 } 00121 } 00122 00123 }; // struct advectionDiffusionMomentTemplatesImpl 00124 00125 } // namespace plb 00126 00127 #include "latticeBoltzmann/advectionDiffusionMomentTemplates2D.h" 00128 #include "latticeBoltzmann/advectionDiffusionMomentTemplates3D.h" 00129 00130 #endif
1.6.3
1.6.3