$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 00031 #ifndef EXTERNAL_FORCE_TEMPLATES_2D_H 00032 #define EXTERNAL_FORCE_TEMPLATES_2D_H 00033 00034 #include "core/globalDefs.h" 00035 00036 namespace plb { 00037 00038 template<typename T> 00039 struct externalForceTemplatesImpl<T, descriptors::ForcedD2Q9Descriptor<T> > 00040 { 00041 00042 static void addNaiveForce ( 00043 Array<T,descriptors::ForcedD2Q9Descriptor<T>::q>& f, 00044 T* externalScalars, 00045 Array<T,descriptors::ForcedD2Q9Descriptor<T>::d> const& u, T omega, T amplitude ) 00046 { 00047 static const int forceBeginsAt 00048 = descriptors::ForcedD2Q9Descriptor<T>::ExternalField::forceBeginsAt; 00049 T* force = externalScalars + forceBeginsAt; 00050 T& fx = force[0]; 00051 T& fy = force[1]; 00052 00053 f[1] += (-fx + fy) * (T)(1./12.); 00054 f[2] += (-fx ) * (T)(1./3.); 00055 f[3] += (-fx - fy) * (T)(1./12.); 00056 f[4] += ( - fy) * (T)(1./3.); 00057 f[5] += ( fx - fy) * (T)(1./12.); 00058 f[6] += ( fx ) * (T)(1./3.); 00059 f[7] += ( fx + fy) * (T)(1./12.); 00060 f[8] += ( fy) * (T)(1./3.); 00061 } 00062 00063 static void addGuoForce ( 00064 Array<T,descriptors::ForcedD2Q9Descriptor<T>::q>& f, 00065 T* externalScalars, 00066 Array<T,descriptors::ForcedD2Q9Descriptor<T>::d> const& u, T omega, T amplitude ) 00067 { 00068 static const int forceBeginsAt 00069 = descriptors::ForcedD2Q9Descriptor<T>::ExternalField::forceBeginsAt; 00070 T* force = externalScalars + forceBeginsAt; 00071 T mu = amplitude*((T)1-omega/(T)2); 00072 00073 static const T oneOver3 = (T)1/(T)3; 00074 static const T oneOver12 = (T)1/(T)12; 00075 static const T fourOver3 = (T)4/(T)3; 00076 00077 const T twoUx = (T)2*u[0]; 00078 const T threeUx = (T)3*u[0]; 00079 00080 const T twoUy = (T)2*u[1]; 00081 const T threeUy = (T)3*u[1]; 00082 00083 f[0] += -fourOver3*mu*(force[0]*u[0]+force[1]*u[1]); 00084 00085 f[1] += oneOver12*mu*(force[0]*(-(T)1+twoUx-threeUy)+force[1]*((T)1+twoUy-threeUx)); 00086 00087 f[2] += oneOver3*mu*(force[0]*(-(T)1+twoUx)-force[1]*u[1]); 00088 00089 f[3] += oneOver12*mu*(force[0]*(-(T)1+twoUx+threeUy)+force[1]*(-(T)1+twoUy+threeUx)); 00090 00091 f[4] += -oneOver3*mu*(force[0]*u[0]+force[1]*((T)1-twoUy)); 00092 00093 f[5] += oneOver12*mu*(force[0]*((T)1+twoUx-threeUy)+force[1]*(-(T)1+twoUy-threeUx)); 00094 00095 f[6] += oneOver3*mu*(force[0]*((T)1+twoUx)-force[1]*u[1]); 00096 00097 f[7] += oneOver12*mu*(force[0]*((T)1+twoUx+threeUy)+force[1]*((T)1+twoUy+threeUx)); 00098 00099 f[8] += -oneOver3*mu*(force[0]*u[0]+force[1]*(-(T)1-twoUy)); 00100 } 00101 00102 static T heForcedBGKCollision ( 00103 Array<T,descriptors::ForcedD2Q9Descriptor<T>::q>& f, T* externalScalars, 00104 T rhoBar, Array<T,descriptors::ForcedD2Q9Descriptor<T>::d> const& j, T omega ) 00105 { 00106 static const int forceBeginsAt 00107 = descriptors::ForcedD2Q9Descriptor<T>::ExternalField::forceBeginsAt; 00108 T* force = externalScalars + forceBeginsAt; 00109 T invRho = descriptors::ForcedD2Q9Descriptor<T>::invRho(rhoBar); 00110 const T jSqr = VectorTemplateImpl<T,descriptors::ForcedD2Q9Descriptor<T>::d>::normSqr(j); 00111 00112 Array<T,descriptors::ForcedD2Q9Descriptor<T>::d> uLB(j[0]*invRho, j[1]*invRho); 00113 const T uSqrLB = VectorTemplateImpl<T,descriptors::ForcedD2Q9Descriptor<T>::d>::normSqr(uLB); 00114 00115 dynamicsTemplatesImpl<T,descriptors::D2Q9DescriptorBase<T> >::bgk_ma2_collision(f, rhoBar, j, omega); 00116 00117 for (plint iPop=0; iPop < descriptors::ForcedD2Q9Descriptor<T>::q; ++iPop) { 00118 T ug = (descriptors::ForcedD2Q9Descriptor<T>::c[iPop][0]-uLB[0])*force[0] + 00119 (descriptors::ForcedD2Q9Descriptor<T>::c[iPop][1]-uLB[1])*force[1]; 00120 00121 f[iPop] += descriptors::ForcedD2Q9Descriptor<T>::invCs2 * ug * dynamicsTemplatesImpl<T,descriptors::ForcedD2Q9Descriptor<T> > 00122 ::bgk_ma2_equilibrium( iPop, (T)1, (T)1, uLB, uSqrLB ); 00123 } 00124 T uSqr = util::sqr(uLB[0] + 0.5*force[0]) + 00125 util::sqr(uLB[1] + 0.5*force[1]); 00126 return uSqr; 00127 } 00128 00129 // static T heForcedBGKCollision ( 00130 // Array<T,descriptors::ForcedD2Q9Descriptor<T>::q>& f, T* externalScalars, 00131 // T rhoBar, Array<T,descriptors::ForcedD2Q9Descriptor<T>::d> const& j, T omega ) 00132 // { 00133 // static const int forceBeginsAt 00134 // = descriptors::ForcedD2Q9Descriptor<T>::ExternalField::forceBeginsAt; 00135 // T* force = externalScalars + forceBeginsAt; 00136 // T invRho = descriptors::ForcedD2Q9Descriptor<T>::invRho(rhoBar); 00137 // const T jSqr = VectorTemplateImpl<T,descriptors::ForcedD2Q9Descriptor<T>::d>::normSqr(j); 00138 // 00139 // Array<T,descriptors::ForcedD2Q9Descriptor<T>::d> uLB(j[0]*invRho, j[1]*invRho); 00140 // const T uSqrLB = VectorTemplateImpl<T,descriptors::ForcedD2Q9Descriptor<T>::d>::normSqr(uLB); 00141 // 00142 // for (plint iPop=0; iPop < descriptors::ForcedD2Q9Descriptor<T>::q; ++iPop) { 00143 // T ug = (descriptors::ForcedD2Q9Descriptor<T>::c[iPop][0]-invRho*j[0])*force[0] + 00144 // (descriptors::ForcedD2Q9Descriptor<T>::c[iPop][1]-invRho*j[1])*force[1]; 00145 // f[iPop] *= (T)1-omega; 00146 // f[iPop] += omega * dynamicsTemplatesImpl<T,descriptors::ForcedD2Q9Descriptor<T> > 00147 // ::bgk_ma2_equilibrium( iPop, rhoBar, invRho, j, jSqr ); 00148 // 00149 // f[iPop] += descriptors::ForcedD2Q9Descriptor<T>::invCs2 * ug * dynamicsTemplatesImpl<T,descriptors::ForcedD2Q9Descriptor<T> > 00150 // ::bgk_ma2_equilibrium( iPop, (T)1, (T)1, uLB, uSqrLB ); 00151 // } 00152 // T uSqr = util::sqr(uLB[0] + 0.5*force[0]) + 00153 // util::sqr(uLB[1] + 0.5*force[1]); 00154 // return uSqr; 00155 // } 00156 00157 }; 00158 00159 } // namespace plb 00160 00161 #endif
1.6.3
1.6.3