$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 00029 #ifndef UTIL_ADVECTION_DIFFUSION_H 00030 #define UTIL_ADVECTION_DIFFUSION_H 00031 00032 #include "core/globalDefs.h" 00033 00034 namespace plb { 00035 00036 namespace utilAdvDiff { 00037 00039 template <typename Descriptor, int direction, int orientation> 00040 class SubIndexOutgoing{ 00041 private: 00042 SubIndexOutgoing() 00043 { 00044 int normalX,normalY,normalZ; 00045 typedef Descriptor L; 00046 00047 switch(direction) 00048 { 00049 case 0: 00050 { 00051 if(orientation==1) 00052 normalX= 1; 00053 else 00054 normalX=-1; 00055 normalY=0; 00056 normalZ=0; 00057 break; 00058 } 00059 case 1: 00060 { 00061 if(orientation==1) 00062 normalY= 1; 00063 else 00064 normalY=-1; 00065 normalX=0; 00066 normalZ=0; 00067 break; 00068 } 00069 case 2: 00070 { 00071 if(orientation==1) 00072 normalZ= 1; 00073 else 00074 normalZ=-1; 00075 normalX=0; 00076 normalY=0; 00077 break; 00078 } 00079 } 00080 00081 // I define the dimension of Normal Vec=3 to make this routine usable for 2D and 3D flat walls 00082 std::vector<plint> NormalVec (3,0); 00083 NormalVec[0]=normalX; 00084 NormalVec[1]=normalY; 00085 NormalVec[2]=normalZ; 00086 // add zero velocity 00087 //knownIndexes.push_back(0); 00088 // compute scalar product with boundary normal for all other velocities 00089 for (plint iPop=1; iPop<L::q; ++iPop) { 00090 plint sum=0; 00091 for(int id=0; id<L::d; ++id){ 00092 sum += L::c[iPop][id]*NormalVec[id]; 00093 } 00094 if (sum<0){ 00095 indices.push_back(iPop); 00096 } 00097 } 00098 00099 } 00100 std::vector<plint> indices; 00101 00102 template <typename Descriptor_, int direction_, int orientation_> 00103 friend std::vector<plint> const& subIndexOutgoing(); 00104 }; 00105 00106 template <typename Descriptor, int direction, int orientation> 00107 std::vector<plint> const& subIndexOutgoing() { 00108 static SubIndexOutgoing<Descriptor, direction, orientation> subIndexOutgoingSingleton; 00109 return subIndexOutgoingSingleton.indices; 00110 } 00111 00112 00113 00114 // For Egdges 00115 template <typename Descriptor, int plane, int normal1, int normal2> 00116 class SubIndexOutgoing3DonEdges{ 00117 private: 00118 SubIndexOutgoing3DonEdges() 00119 { 00120 int normalX,normalY,normalZ; 00121 typedef Descriptor L; 00122 00123 switch(plane) 00124 { 00125 case 0: 00126 { 00127 normalX=0; 00128 if(normal1==1) 00129 normalY= 1; 00130 else 00131 normalY=-1; 00132 if(normal2==1) 00133 normalZ= 1; 00134 else 00135 normalZ=-1; 00136 break; 00137 } 00138 case 1: 00139 { 00140 normalY=0; 00141 if(normal1==1) 00142 normalX= 1; 00143 else 00144 normalX=-1; 00145 if(normal2==1) 00146 normalZ= 1; 00147 else 00148 normalZ=-1; 00149 break; 00150 } 00151 case 2: 00152 { 00153 normalZ=0; 00154 if(normal1==1) 00155 normalX= 1; 00156 else 00157 normalX=-1; 00158 if(normal2==1) 00159 normalY= 1; 00160 else 00161 normalY=-1; 00162 break; 00163 } 00164 } 00165 00166 // add zero velocity 00167 //knownIndexes.push_back(0); 00168 // compute scalar product with boundary normal for all other velocities 00169 for (plint iP=1; iP<L::q; ++iP) 00170 { 00171 if ((L::c[iP][0]*normalX + L::c[iP][1]*normalY + L::c[iP][2]*normalZ) < 0) 00172 { 00173 indices.push_back(iP); 00174 } 00175 } 00176 } 00177 std::vector<plint> indices; 00178 00179 template <typename Descriptor_, int plane_, int normal1_, int normal2_> 00180 friend std::vector<plint> const& subIndexOutgoing3DonEdges(); 00181 }; 00182 00183 template <typename Descriptor, int plane, int normal1, int normal2> 00184 std::vector<plint> const& subIndexOutgoing3DonEdges() { 00185 static SubIndexOutgoing3DonEdges<Descriptor, plane, normal1, normal2> subIndexOutgoing3DonEdgesSingleton; 00186 return subIndexOutgoing3DonEdgesSingleton.indices; 00187 } 00188 00189 00190 // For 3D Corners 00191 template <typename Descriptor, int normalX, int normalY, int normalZ> 00192 class SubIndexOutgoing3DonCorners{ 00193 private: 00194 SubIndexOutgoing3DonCorners() 00195 { 00196 typedef Descriptor L; 00197 00198 // add zero velocity 00199 //knownIndexes.push_back(0); 00200 // compute scalar product with boundary normal for all other velocities 00201 for (plint iP=1; iP<L::q; ++iP) { 00202 if (L::c[iP][0]*normalX + L::c[iP][1]*normalY + L::c[iP][2]*normalZ<0) { 00203 indices.push_back(iP); 00204 } 00205 } 00206 } 00207 00208 std::vector<plint> indices; 00209 00210 template <typename Descriptor_, int normalX_, int normalY_, int normalZ_> 00211 friend std::vector<plint> const& subIndexOutgoing3DonCorners(); 00212 }; 00213 00214 template <typename Descriptor, int normalX, int normalY, int normalZ> 00215 std::vector<plint> const& subIndexOutgoing3DonCorners() { 00216 static SubIndexOutgoing3DonCorners<Descriptor, normalX, normalY, normalZ> subIndexOutgoing3DonCornersSingleton; 00217 return subIndexOutgoing3DonCornersSingleton.indices; 00218 } 00219 00220 00221 // For 2D Corners 00222 00223 template <typename Descriptor, int normalX, int normalY> 00224 class SubIndexOutgoing2DonCorners{ 00225 private: 00226 SubIndexOutgoing2DonCorners() 00227 { 00228 typedef Descriptor L; 00229 00230 // add zero velocity 00231 //knownIndexes.push_back(0); 00232 // compute scalar product with boundary normal for all other velocities 00233 for (plint iPop=1; iPop<L::q; ++iPop) { 00234 if (L::c[iPop][0]*normalX + L::c[iPop][1]*normalY<0) { 00235 indices.push_back(iPop); 00236 } 00237 } 00238 } 00239 00240 std::vector<plint> indices; 00241 00242 template <typename Descriptor_, int normalX_, int normalY_> 00243 friend std::vector<plint> const& subIndexOutgoing2DonCorners(); 00244 }; 00245 00246 template <typename Descriptor, int normalX, int normalY> 00247 std::vector<plint> const& subIndexOutgoing2DonCorners() { 00248 static SubIndexOutgoing2DonCorners<Descriptor, normalX, normalY> subIndexOutgoing2DonCornersSingleton; 00249 return subIndexOutgoing2DonCornersSingleton.indices; 00250 } 00251 00252 } // utilAdvDiff 00253 00254 } //olb 00255 00256 #endif 00257
1.6.3
1.6.3