$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 00037 #ifndef OFF_EQUILIBRIUM_TEMPLATES_H 00038 #define OFF_EQUILIBRIUM_TEMPLATES_H 00039 00040 #include "core/globalDefs.h" 00041 #include "core/cell.h" 00042 #include "core/util.h" 00043 #include "hermitePolynomialsTemplates.h" 00044 #include "geometricOperationTemplates.h" 00045 00046 namespace plb { 00047 00048 template<typename T, class Descriptor> struct offEquilibriumTemplatesImpl; 00049 00051 template<typename T, template<typename U> class Descriptor> 00052 struct offEquilibriumTemplates { 00053 00055 00062 static T fromPiToFneq(plint iPop, Array<T,SymmetricTensor<T,Descriptor>::n> const& pi) { 00063 return offEquilibriumTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00064 ::fromPiToFneq(iPop, pi); 00065 } 00066 00067 static T fromPiAndQtoFneq(plint iPop, Array<T,SymmetricTensor<T,Descriptor>::n> const& pi, 00068 Array<T,SymmetricRankThreeTensor<T,Descriptor>::n> const& q) { 00069 return offEquilibriumTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00070 ::fromPiAndQtoFneq(iPop, pi, q); 00071 } 00072 00074 00081 static T fromStrainToFneq(plint iPop, Array<T,SymmetricTensor<T,Descriptor>::n> const& S, T density, T omega) { 00082 return offEquilibriumTemplatesImpl<T,typename Descriptor<T>::BaseDescriptor> 00083 ::fromStrainToFneq(iPop, S, density, omega); 00084 } 00085 00086 }; // struct offEquilibriumTemplates 00087 00088 template<typename T, class Descriptor> 00089 struct offEquilibriumTemplatesImpl { 00090 00091 static T fromPiToFneq ( 00092 plint iPop, Array<T,SymmetricTensorImpl<T,Descriptor::d>::n> const& PiNeq ) 00093 { 00094 typedef Descriptor L; 00095 T fNeq = T(); 00096 plint iPi = 0; 00097 // Iterate only over superior triangle + diagonal, and add 00098 // the elements under the diagonal by symmetry 00099 for (int iAlpha=0; iAlpha<L::d; ++iAlpha) { 00100 // Treat diagonal term first 00101 fNeq += PiNeq[iPi] * (L::c[iPop][iAlpha]*L::c[iPop][iAlpha] 00102 - L::cs2); 00103 ++iPi; 00104 // Then, treat off-diagonal terms 00105 for (int iBeta=iAlpha+1; iBeta<L::d; ++iBeta) { 00106 // Multiply off-diagonal elements by 2 because 00107 // the Q tensor is symmetric 00108 fNeq += PiNeq[iPi] 00109 * (T)2 * L::c[iPop][iAlpha]*L::c[iPop][iBeta]; 00110 ++iPi; 00111 } 00112 } 00113 fNeq *= L::t[iPop] * L::invCs2 * L::invCs2 / (T)2; 00114 return fNeq; 00115 } 00116 00117 static T fromPiAndQtoFneq ( 00118 plint iPop, Array<T,SymmetricTensorImpl<T,Descriptor::d>::n> const& PiNeq, 00119 Array<T,SymmetricRankThreeTensorImpl<T,Descriptor::d>::n> const& Q) 00120 { 00121 typedef Descriptor L; 00122 00123 Array<T,SymmetricTensorImpl<T,Descriptor::d>::n> H2 = 00124 HermiteTemplateImpl<T,Descriptor,Descriptor::d>::order2(iPop); 00125 Array<T,SymmetricRankThreeTensorImpl<T,Descriptor::d>::n> H3 = 00126 HermiteTemplateImpl<T,Descriptor,Descriptor::d>::order3(iPop); 00127 00128 T factor = L::t[iPop] * L::invCs2 * L::invCs2 / (T)2; 00129 00130 T fNeqPi = factor * SymmetricTensorImpl<T,Descriptor::d>::contractIndexes(H2,PiNeq); 00131 T fNeqQ = factor * L::invCs2 / (T)3 * 00132 SymmetricRankThreeTensorImpl<T,Descriptor::d>::contractIndexes(H3,Q); 00133 00134 return fNeqPi + fNeqQ; 00135 } 00136 00138 00145 static T fromStrainToFneq ( 00146 plint iPop, Array<T,SymmetricTensorImpl<T,Descriptor::d>::n> const& S, T density, T omega) 00147 { 00148 typedef Descriptor L; 00149 T fNeq = fromPiToFneq(iPop,S) * (-(T)2 * density * L::cs2 / omega); 00150 return fNeq; 00151 } 00152 00153 }; // struct offEquilibriumTemplates 00154 00155 } // namespace plb 00156 00157 #include "latticeBoltzmann/offEquilibriumTemplates2D.h" 00158 #include "latticeBoltzmann/offEquilibriumTemplates3D.h" 00159 00160 #endif
1.6.3
1.6.3