$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 #ifndef FINITE_DIFFERENCE_BOUNDARY_PROCESSOR_2D_HH 00026 #define FINITE_DIFFERENCE_BOUNDARY_PROCESSOR_2D_HH 00027 00028 #include "boundaryCondition/finiteDifferenceBoundaryProcessor2D.h" 00029 #include "finiteDifference/finiteDifference2D.h" 00030 #include "atomicBlock/blockLattice2D.h" 00031 #include "latticeBoltzmann/offEquilibriumTemplates.h" 00032 #include "latticeBoltzmann/geometricOperationTemplates.h" 00033 #include "core/processorIdentifiers2D.h" 00034 #include <typeinfo> 00035 00036 namespace plb { 00037 00039 00040 template<typename T, template<typename U> class Descriptor, int direction, int orientation> 00041 const int StraightFdBoundaryFunctional2D<T,Descriptor,direction,orientation>::staticId = 00042 meta::registerProcessor2D < StraightFdBoundaryFunctional2D<T, Descriptor, direction, orientation>, 00043 T, Descriptor, direction, orientation> (std::string("StraightFdBoundary2D")); 00044 00045 template<typename T, template<typename U> class Descriptor, int direction, int orientation> 00046 void StraightFdBoundaryFunctional2D<T,Descriptor,direction,orientation>::processCell ( 00047 plint iX, plint iY, BlockLattice2D<T,Descriptor>& lattice ) 00048 { 00049 typedef SymmetricTensorImpl<T,Descriptor<T>::d> S; 00050 Array<T,Descriptor<T>::d> dx_u, dy_u; 00051 Cell<T,Descriptor>& cell = lattice.get(iX,iY); 00052 Dynamics<T,Descriptor>& dynamics = cell.getDynamics(); 00053 00054 T rho = cell.computeDensity(); 00055 Array<T,Descriptor<T>::d> vel; 00056 cell.computeVelocity(vel); 00057 interpolateGradients<0>(lattice, dx_u, iX, iY); 00058 interpolateGradients<1>(lattice, dy_u, iX, iY); 00059 T dx_ux = dx_u[0]; 00060 T dy_ux = dy_u[0]; 00061 T dx_uy = dx_u[1]; 00062 T dy_uy = dy_u[1]; 00063 T omega = cell.getDynamics().getOmega(); 00064 T sToPi = - rho / Descriptor<T>::invCs2 / omega; 00065 Array<T,SymmetricTensor<T,Descriptor>::n> pi; 00066 pi[S::xx] = (T)2 * dx_ux * sToPi; 00067 pi[S::yy] = (T)2 * dy_uy * sToPi; 00068 pi[S::xy] = (dx_uy + dy_ux) * sToPi; 00069 00070 Array<T,Descriptor<T>::d> j; 00071 if (cell.getDynamics().velIsJ()) { 00072 j = vel; 00073 } 00074 else { 00075 j = rho*vel; 00076 } 00077 // Computation of the particle distribution functions 00078 // according to the regularized formula 00079 T jSqr = VectorTemplate<T,Descriptor>::normSqr(j); 00080 for (plint iPop = 0; iPop < Descriptor<T>::q; ++iPop) { 00081 cell[iPop] = dynamics.computeEquilibrium(iPop,Descriptor<T>::rhoBar(rho),j,jSqr) + 00082 offEquilibriumTemplates<T,Descriptor>::fromPiToFneq(iPop, pi); 00083 } 00084 } 00085 00086 template<typename T, template<typename U> class Descriptor, int direction, int orientation> 00087 void StraightFdBoundaryFunctional2D<T,Descriptor,direction,orientation>::process ( 00088 Box2D domain, BlockLattice2D<T,Descriptor>& lattice ) 00089 { 00090 PLB_PRECONDITION(domain.x0==domain.x1 || domain.y0==domain.y1); 00091 for (plint iX=domain.x0; iX<=domain.x1; ++iX) { 00092 for (plint iY=domain.y0; iY<=domain.y1; ++iY) { 00093 processCell(iX,iY, lattice); 00094 } 00095 } 00096 } 00097 00098 template<typename T, template<typename U> class Descriptor, int direction, int orientation> 00099 StraightFdBoundaryFunctional2D<T,Descriptor,direction,orientation>* 00100 StraightFdBoundaryFunctional2D<T,Descriptor,direction,orientation>::clone() const 00101 { 00102 return new StraightFdBoundaryFunctional2D<T,Descriptor,direction,orientation>(*this); 00103 } 00104 00105 template<typename T, template<typename U> class Descriptor, int direction, int orientation> 00106 template<int deriveDirection> 00107 void StraightFdBoundaryFunctional2D<T,Descriptor,direction,orientation>:: 00108 interpolateGradients(BlockLattice2D<T,Descriptor> const& lattice, 00109 Array<T,Descriptor<T>::d>& velDeriv, plint iX, plint iY) 00110 { 00111 fd::DirectedGradients2D<T,Descriptor,direction,orientation,direction==deriveDirection>:: 00112 o1_velocityDerivative(velDeriv, lattice, iX, iY); 00113 } 00114 00116 00117 template<typename T, template<typename U> class Descriptor, int xNormal, int yNormal> 00118 const int OuterVelocityCornerFunctional2D<T,Descriptor,xNormal,yNormal>::staticId = 00119 meta::registerProcessor2D < OuterVelocityCornerFunctional2D<T, Descriptor, xNormal,yNormal>, 00120 T, Descriptor, xNormal,yNormal> (std::string("OuterVelocityCorner2D")); 00121 00122 template<typename T, template<typename U> class Descriptor, int xNormal, int yNormal> 00123 void OuterVelocityCornerFunctional2D<T, Descriptor, xNormal, yNormal>::processCell ( 00124 plint iX, plint iY, BlockLattice2D<T,Descriptor>& lattice ) 00125 { 00126 typedef SymmetricTensorImpl<T,Descriptor<T>::d> S; 00127 00128 T rho10 = lattice.get(iX-1*xNormal, iY-0*yNormal).computeDensity(); 00129 T rho01 = lattice.get(iX-0*xNormal, iY-1*yNormal).computeDensity(); 00130 00131 T rho = (T)1/(T)2*(rho01+rho10); 00132 00133 Array<T,Descriptor<T>::d> dx_u, dy_u; 00134 fd::DirectedGradients2D<T, Descriptor, 0, xNormal, true>::o1_velocityDerivative(dx_u, lattice, iX,iY); 00135 fd::DirectedGradients2D<T, Descriptor, 1, yNormal, true>::o1_velocityDerivative(dy_u, lattice, iX,iY); 00136 T dx_ux = dx_u[0]; 00137 T dy_ux = dy_u[0]; 00138 T dx_uy = dx_u[1]; 00139 T dy_uy = dy_u[1]; 00140 00141 Cell<T,Descriptor>& cell = lattice.get(iX,iY); 00142 Dynamics<T,Descriptor>& dynamics = cell.getDynamics(); 00143 T omega = dynamics.getOmega(); 00144 00145 T sToPi = - rho / Descriptor<T>::invCs2 / omega; 00146 Array<T,SymmetricTensor<T,Descriptor>::n> pi; 00147 pi[S::xx] = (T)2 * dx_ux * sToPi; 00148 pi[S::yy] = (T)2 * dy_uy * sToPi; 00149 pi[S::xy] = (dx_uy + dy_ux) * sToPi; 00150 00151 // Computation of the particle distribution functions 00152 // according to the regularized formula 00153 Array<T,Descriptor<T>::d> vel, j; 00154 lattice.get(iX,iY).computeVelocity(vel); 00155 if (cell.getDynamics().velIsJ()) { 00156 j = vel; 00157 } 00158 else { 00159 for (plint iD = 0; iD < Descriptor<T>::d; ++iD) { 00160 j[iD] = rho*vel[iD]; 00161 } 00162 } 00163 T jSqr = VectorTemplate<T,Descriptor>::normSqr(j); 00164 00165 for (plint iPop = 0; iPop < Descriptor<T>::q; ++iPop) { 00166 cell[iPop] = 00167 dynamics.computeEquilibrium(iPop,Descriptor<T>::rhoBar(rho),j,jSqr) + 00168 offEquilibriumTemplates<T,Descriptor>::fromPiToFneq(iPop, pi); 00169 } 00170 } 00171 00172 template<typename T, template<typename U> class Descriptor, int xNormal, int yNormal> 00173 void OuterVelocityCornerFunctional2D<T, Descriptor, xNormal, yNormal>::process ( 00174 Box2D domain, BlockLattice2D<T,Descriptor>& lattice ) 00175 { 00176 plint x = domain.x0; 00177 plint y = domain.y0; 00178 PLB_ASSERT( x==domain.x1 && y==domain.y1 ); 00179 00180 processCell(x,y, lattice); 00181 } 00182 00183 template<typename T, template<typename U> class Descriptor, int xNormal, int yNormal> 00184 OuterVelocityCornerFunctional2D<T, Descriptor, xNormal, yNormal>* 00185 OuterVelocityCornerFunctional2D<T, Descriptor, xNormal, yNormal>::clone() const 00186 { 00187 return new OuterVelocityCornerFunctional2D<T, Descriptor, xNormal, yNormal>(*this); 00188 } 00189 00190 } // namespace plb 00191 00192 #endif // FINITE_DIFFERENCE_BOUNDARY_PROCESSOR_2D_HH
1.6.3
1.6.3