$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 UNITS_H 00026 #define UNITS_H 00027 00028 #include "core/globalDefs.h" 00029 #include "core/globalDefs.h" 00030 #include "parallelism/mpiManager.h" 00031 #include "io/parallelIO.h" 00032 #include <string> 00033 #include <fstream> 00034 00035 namespace plb { 00036 00038 template<typename T> 00039 class IncomprFlowParam { 00040 public: 00042 00049 IncomprFlowParam(T physicalU_, T latticeU_, T Re_, T physicalLength_, plint resolution_, T lx_, T ly_, T lz_=T() ) 00050 : latticeU(latticeU_), physicalU(physicalU_), Re(Re_), physicalLength(physicalLength_), 00051 resolution(resolution_), lx(lx_), ly(ly_), lz(lz_) 00052 { } 00053 00054 IncomprFlowParam(T latticeU_, T Re_, plint resolution_, T lx_, T ly_, T lz_=T() ) 00055 : latticeU(latticeU_), Re(Re_), resolution(resolution_), lx(lx_), ly(ly_), lz(lz_) 00056 { 00057 physicalU = (T)1; 00058 physicalLength = (T)1; 00059 } 00061 T getLatticeU() const { return latticeU; } 00063 T getPhysicalU() const { return physicalU; } 00065 T getRe() const { return Re; } 00067 T getPhysicalLength() const { return physicalLength; } 00069 plint getResolution() const { return resolution; } 00071 T getLx() const { return getPhysicalLength()*lx; } 00073 T getLy() const { return getPhysicalLength()*ly; } 00075 T getLz() const { return getPhysicalLength()*lz; } 00077 T getDeltaX() const { return (T)getPhysicalLength()/(T)getResolution(); } 00079 T getDeltaT() const { return getDeltaX()*getLatticeU()/getPhysicalU(); } 00081 plint nCell(T l) const { return (int)(l/getDeltaX()+(T)0.5); } 00083 plint nStep(T t) const { return (int)(t/getDeltaT()+(T)0.5); } 00085 plint getNx(bool offLattice=false) const { return nCell(getLx())+1+(int)offLattice; } 00087 plint getNy(bool offLattice=false) const { return nCell(getLy())+1+(int)offLattice; } 00089 plint getNz(bool offLattice=false) const { return nCell(getLz())+1+(int)offLattice; } 00091 T getLatticeNu() const { return getLatticeU()*(T)getResolution()/Re; } 00093 T getTau() const { return (T)3*getLatticeNu()+(T)0.5; } 00095 T getOmega() const { return (T)1 / getTau(); } 00096 private: 00097 T physicalU, latticeU, physicalLength, Re; 00098 plint resolution; 00099 T lx, ly, lz; 00100 }; 00101 00102 template<typename T> 00103 void writeLogFile(IncomprFlowParam<T> const& parameters, 00104 std::string const& title) 00105 { 00106 std::string fullName = global::directories().getLogOutDir() + "plbLog.dat"; 00107 plb_ofstream ofile(fullName.c_str()); 00108 ofile << title << "\n\n"; 00109 ofile << "Velocity in lattice units: u=" << parameters.getLatticeU() << "\n"; 00110 ofile << "Reynolds number: Re=" << parameters.getRe() << "\n"; 00111 ofile << "Lattice resolution: N=" << parameters.getResolution() << "\n"; 00112 ofile << "Relaxation frequency: omega=" << parameters.getOmega() << "\n"; 00113 ofile << "Extent of the system: lx=" << parameters.getLx() << "\n"; 00114 ofile << "Extent of the system: ly=" << parameters.getLy() << "\n"; 00115 ofile << "Extent of the system: lz=" << parameters.getLz() << "\n"; 00116 ofile << "Grid spacing deltaX: dx=" << parameters.getDeltaX() << "\n"; 00117 ofile << "Time step deltaT: dt=" << parameters.getDeltaT() << "\n"; 00118 } 00119 00121 template<typename T> 00122 class ComprFlowParam { 00123 public: 00125 00133 ComprFlowParam(T latticeU_, T latticeRho_, T latticeTemp_, T physU_, T physRho_, T physTemp_, 00134 T Re_, T Pe_, plint resolution_, T lx_, T ly_, T lz_=T() ) 00135 : latticeU(latticeU_), latticeRho(latticeRho_), latticeTemp(latticeTemp_), 00136 physRho(physRho_), physU(physU_), physTemp(physTemp_), 00137 Re(Re_), Pe(Pe_), resolution(resolution_), lx(lx_), ly(ly_), lz(lz_) 00138 { } 00140 T getLatticeU() const { return latticeU; } 00142 T getLatticeRho() const { return latticeRho; } 00144 T getLatticeTemp() const { return latticeTemp; } 00146 T getPhysicalU() const { return physU; } 00148 T getPhysicalRho() const { return physRho; } 00150 T getPhysicalTemp() const { return physTemp; } 00152 T getRe() const { return Re; } 00154 T getPe() const { return Pe; } 00156 plint getResolution() const { return resolution; } 00158 T getLx() const { return lx; } 00160 T getLy() const { return ly; } 00162 T getLz() const { return lz; } 00164 T getDeltaX() const { return (T)1/(T)getResolution(); } 00166 T getDeltaT() const { return getDeltaX() * getLatticeU() / getPhysicalU(); } 00168 T getDeltaRho() const { return getPhysicalRho() / getLatticeRho(); } 00170 T getDeltaTemp() const { return getPhysicalTemp() / getLatticeTemp(); } 00172 plint nCell(T l) const { return (int)(l/getDeltaX()+(T)0.5); } 00174 plint nStep(T t) const { return (int)(t/getDeltaT()+(T)0.5); } 00176 plint getNx(bool offLattice=false) const { return nCell(lx)+1+(int)offLattice; } 00178 plint getNy(bool offLattice=false) const { return nCell(ly)+1+(int)offLattice; } 00180 plint getNz(bool offLattice=false) const { return nCell(lz)+1+(int)offLattice; } 00182 T getLatticeMu() const { return getLatticeU()*getResolution()*getLatticeRho() / Re; } 00184 T getLatticeKappa() const { return getLatticeU()*getResolution()*getLatticeRho() / Pe; } 00186 T getTau() const { return getLatticeMu() / getLatticeRho() / getLatticeTemp()+(T)0.5; } 00187 // TODO for the moment only Pr = 1 (Pe = Re) fluids are simulable.... 00189 T getOmega() const { return (T)1 / getTau(); } 00190 private: 00191 T latticeU, latticeRho, latticeTemp, physRho, physU, physTemp, Re, Pe; 00192 plint resolution; 00193 T lx, ly, lz; 00194 }; 00195 00196 template<typename T> 00197 void writeLogFile(ComprFlowParam<T> const& parameters, 00198 std::string const& title) 00199 { 00200 std::string fullName = global::directories().getLogOutDir() + "plbLog.dat"; 00201 plb_ofstream ofile(fullName.c_str()); 00202 ofile << title << "\n\n"; 00203 ofile << "Velocity in lattice units: u=" << parameters.getLatticeU() << "\n"; 00204 ofile << "Density in lattice units: rho=" << parameters.getLatticeRho() << "\n"; 00205 ofile << "Temperature in lattice units: T=" << parameters.getLatticeTemp() << "\n"; 00206 ofile << "Reynolds number: Re=" << parameters.getRe() << "\n"; 00207 ofile << "Peclet number: Pe=" << parameters.getPe() << "\n"; 00208 ofile << "Lattice resolution: N=" << parameters.getResolution() << "\n"; 00209 ofile << "Extent of the system: lx=" << parameters.getLx() << "\n"; 00210 ofile << "Extent of the system: ly=" << parameters.getLy() << "\n"; 00211 ofile << "Extent of the system: lz=" << parameters.getLz() << "\n"; 00212 ofile << "Grid spacing deltaX: dx=" << parameters.getDeltaX() << "\n"; 00213 ofile << "Time step deltaT: dt=" << parameters.getDeltaT() << "\n"; 00214 ofile << "Density deltaRho: dRho=" << parameters.getDeltaRho() << "\n"; 00215 ofile << "Temp deltaTemp: dTemp=" << parameters.getDeltaTemp() << "\n"; 00216 ofile << "Relaxation time: Tau=" << parameters.getTau() << "\n"; 00217 } 00218 00219 } // namespace plb 00220 00221 #endif 00222
1.6.3
1.6.3