OpenLB 1.7
Loading...
Searching...
No Matches
thermalUnitConverter.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2017 Max Gaedtke, Albert Mink
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24
25#ifndef THERMALUNITCONVERTER_HH
26#define THERMALUNITCONVERTER_HH
27
28#include <fstream>
29#include <iostream>
30#include <unistd.h>
31#include "core/singleton.h"
32#include "io/fileName.h"
33
34// All OpenLB code is contained in this namespace.
35namespace olb {
36
37template <typename T, typename DESCRIPTOR, typename ThermalLattice>
39{
40 clout << "----------------- UnitConverter information -----------------" << std::endl;
41 clout << "-- Parameters:" << std::endl;
42 clout << "Resolution: N= " << this->getResolution() << std::endl;
43 clout << "Lattice velocity: latticeU= " << this->getCharLatticeVelocity() << std::endl;
44 clout << "Lattice relaxation frequency: omega= " << this->getLatticeRelaxationFrequency() << std::endl;
45 clout << "Lattice relaxation time: tau= " << this->getLatticeRelaxationTime() << std::endl;
46 clout << "Thermal Lattice relaxation frequency: omega_AD= " << this->getLatticeThermalRelaxationFrequency() << std::endl;
47 clout << "Thermal Lattice relaxation time: tau_AD= " << this->getLatticeThermalRelaxationTime() << std::endl;
48 clout << "Characteristical length(m): charL= " << this->getCharPhysLength() << std::endl;
49 clout << "Characteristical speed(m/s): charU= " << this->getCharPhysVelocity() << std::endl;
50 clout << "Phys. kinematic viscosity(m^2/s): charNu= " << this->getPhysViscosity() << std::endl;
51 clout << "Phys. density(kg/m^d): charRho= " << this->getPhysDensity() << std::endl;
52 clout << "Characteristical pressure(N/m^2): charPressure= " << this->getCharPhysPressure() << std::endl;
53 clout << "Reynolds number: reynoldsNumber= " << this->getReynoldsNumber() << std::endl;
54
55 clout << "-------------------------------------------------------------" << std::endl;
56
57 clout << "----------------- ThermalUnitConverter information -----------------" << std::endl;
58 clout << "-- Parameters:" << std::endl;
59 clout << "Phys. Delta X(m): physDeltaX= " << this->getPhysDeltaX() << std::endl;
60 clout << "Phys. Delta T(s): physDeltaT= " << this->getPhysDeltaT() << std::endl;
61 clout << "Characteristical pressure(N/m^2): charPressure= " << this->getCharPhysPressure() << std::endl;
62 clout << "Phys. Thermal Conductivity(W/m/K): physThermalCondcticity= " << getThermalConductivity() << std::endl;
63 clout << "Phys. specific Heat Capacity(J/kg/K): physSpecificHeatCapacity= " << getPhysSpecificHeatCapacity() << std::endl;
64 clout << "Phys. Thermal Expasion Coefficent(K^-1): physThermalExpansionCoefficent= " << getPhysThermalExpansionCoefficient() << std::endl;
65 clout << "Characteristical Phys. low Temperature(K): charPhysLowTemperature= " << getCharPhysLowTemperature() << std::endl;
66 clout << "Characteristical Phys. high Temperature(K): charPhysHighTemperature= " << getCharPhysHighTemperature() << std::endl;
67 clout << "Prandtl number: prandtlNumber= " << getPrandtlNumber() << std::endl;
68 clout << "Rayleigh number: rayleighNumber= " << getRayleighNumber() << std::endl;
69
70
71 clout << "-------------------------------------------------------------" << std::endl;
72
73 clout << "----------------- Conversion factors:-----------------" << std::endl;
74 clout << "Voxel length(m): physDeltaX= " << this->getConversionFactorLength() << std::endl;
75 clout << "Time step(s): physDeltaT= " << this->getConversionFactorTime() << std::endl;
76 clout << "Velocity factor(m/s): physVelocity= " << this->getConversionFactorVelocity() << std::endl;
77 clout << "Density factor(kg/m^3): physDensity= " << this->getConversionFactorDensity() << std::endl;
78 clout << "Mass factor(kg): physMass= " << this->getConversionFactorMass() << std::endl;
79 clout << "Viscosity factor(m^2/s): physViscosity= " << this->getConversionFactorViscosity() << std::endl;
80 clout << "Force factor(N): physForce= " << this->getConversionFactorForce() << std::endl;
81 clout << "Pressure factor(N/m^2): physPressure= " << this->getConversionFactorPressure() << std::endl;
82
83 clout << "-------------------------------------------------------------" << std::endl;
84
85 clout << "----------------- ThermalConversion factors:-----------------" << std::endl;
86 clout << "Temperature(K): temperature= " << getConversionFactorTemperature() << std::endl;
87 clout << "Thermal Diffusity(m^2/s): physThermalDiffusity= " << getConversionFactorThermalDiffusivity() << std::endl;
88 clout << "specific Heat Capacity(J/kg): physSpecificHeatCapacity= " << getConversionFactorSpecificHeatCapacity() << std::endl;
89 clout << "Thermal Coductivity(W/m/K): physThermalCondcticity= " << getConversionFactorThermalConductivity() << std::endl;
90 clout << "HeatFlux(W): physHeatFlux= " << getConversionFactorHeatFlux() << std::endl;
91
92 clout << "-------------------------------------------------------------" << std::endl;
93
94}
95/*
96template <typename T, typename DESCRIPTOR, typename ThermalLattice>
97void ThermalUnitConverter<T, DESCRIPTOR, ThermalLattice>::writeDatFile(std::string const& title) const
98{
99 std::string dataFile = singleton::directories().getLogOutDir() + title + ".dat";
100
101 if (singleton::mpi().isMainProcessor())
102 {
103 std::ofstream fout;
104 fout.open(dataFile.c_str(), std::ios::trunc);
105
106 fout << "----------------- ThermalUnitConverter information -----------------" << std::endl;
107 fout << "-- Parameters:" << std::endl;
108 fout << "Phys. Delta X: physDeltaX= " << getPhysDeltaX() << std::endl;
109 fout << "Phys. Delta T: physDeltaT= " << getPhysDeltaT() << std::endl;
110 fout << "Characteristical pressure(N/m^2): charPressure= " << getCharPhysPressure() << std::endl;
111 fout << "Phys. Thermal Conductivity: physThermalCondcticity= " << getPhysThermalCondcticity() << std::endl;
112 fout << "Phys. specific Heat Capacity: physSpecificHeatCapacity= " << getPhysSpecificHeatCapacity() << std::endl;
113 fout << "Phys. Thermal Expasion Coefficent physThermalExpansionCoefficent= " << getPhysThermalExpasionCoefficent << std::endl;
114 fout << "Characteristical Phys. low Temperature charPhysLowTemperature= " << getCharPhysLowTemperature << std::endl;
115 fout << "Characteristical Phys. high Temperature charPhysHighTemperature= " << getCharPhysHighTemperature << std::endl;
116 fout << std::endl;
117
118 fout << "-- Conversion factors:" << std::endl;
119 fout << "Temperature: temperature= " << getConversionFactorTemperature() << std::endl;
120 fout << "Thermal Duffusity: physThermalDiffusity= " << getConversionFactorThermalDiffusivity() << std::endl;
121 fout << "specific Heat Capacity: physSpecificHeatCapacity= " << getConversionFactorSpecificHeatCapacity() << std::endl;
122 fout << "Thermal Coductivity: physThermalCondcticity= " << getConversionFactorThermalConductivity() << std::endl;
123 fout << "HeatFlux: physHeatFlux= " << getConversionFactorHeatFlux() << std::endl;
124
125 fout << "-------------------------------------------------------------" << std::endl;
126
127 fout.close();
128 }
129}
130*/
131/*
132template<typename T, typename DESCRIPTOR>
133ThermalUnitConverter<T, DESCRIPTOR>* createThermalUnitConverter(XMLreader const& params)
134{
135 OstreamManager clout(std::cout,"createThermalUnitConverter");
136 params.setWarningsOn(false);
137
138 T physDeltaX;
139 T physDeltaT;
140
141 T charPhysHighTemperature;
142 T charPhysLowTemperature;
143 T physThermalCondcticity;
144 T physDensity;
145 T charPhysPressure = 0;
146
147 int resolution;
148 T latticeRelaxationTime;
149 T charLatticeVelocity;
150
151 // params[parameter].read(value) sets the value or returns false if the parameter can not be found
152 params["Application"]["ThermalPhysParameters"]["CharPhysLowTemperature"].read(charPhysLowTemperature);
153 params["Application"]["ThermalPhysParameters"]["charPhysHighTemperature"].read(charPhysHighTemperature);
154 params["Application"]["ThermalPhysParameters"]["PhysThermalCondcticity"].read(physThermalCondcticity);
155 params["Application"]["ThermalPhysParameters"]["PhysDensity"].read(physDensity);
156 params["Application"]["ThermalPhysParameters"]["CharPhysPressure"].read(charPhysPressure);
157
158 if (!params["Application"]["Discretization"]["PhysDeltaX"].read(physDeltaX,false)) {
159 if (!params["Application"]["Discretization"]["Resolution"].read<int>(resolution,false)) {
160 if (!params["Application"]["Discretization"]["CharLatticeVelocity"].read(charLatticeVelocity,false)) {
161 // NOT found physDeltaX, resolution or charLatticeVelocity
162 clout << "Error: Have not found PhysDeltaX, Resolution or CharLatticeVelocity in XML file."
163 << std::endl;
164 exit (1);
165 }
166 else {
167 // found charLatticeVelocity
168 if (params["Application"]["Discretization"]["PhysDeltaT"].read(physDeltaT,false)) {
169 physDeltaX = charPhysVelocity / charLatticeVelocity * physDeltaT;
170 }
171 else if (params["Application"]["Discretization"]["LatticeRelaxationTime"].read(latticeRelaxationTime,false)) {
172 physDeltaX = physViscosity * charLatticeVelocity / charPhysVelocity * descriptors::invCs2<T,DESCRIPTOR>() / (latticeRelaxationTime - 0.5);
173 }
174 }
175 }
176 else {
177 // found resolution
178 physDeltaX = charPhysLength / resolution;
179 }
180 }
181 // found physDeltaX
182 if (!params["Application"]["Discretization"]["PhysDeltaT"].read(physDeltaT,false)) {
183 if (!params["Application"]["Discretization"]["LatticeRelaxationTime"].read(latticeRelaxationTime,false)) {
184 if (!params["Application"]["Discretization"]["CharLatticeVelocity"].read(charLatticeVelocity,false)) {
185 // NOT found physDeltaT, latticeRelaxationTime and charLatticeVelocity
186 clout << "Error: Have not found PhysDeltaT, LatticeRelaxationTime or CharLatticeVelocity in XML file."
187 << std::endl;
188 exit (1);
189 }
190 else {
191 // found charLatticeVelocity
192 physDeltaT = charLatticeVelocity / charPhysVelocity * physDeltaX;
193 }
194 }
195 else {
196 // found latticeRelaxationTime
197 physDeltaT = (latticeRelaxationTime - 0.5) / descriptors::invCs2<T,DESCRIPTOR>() * physDeltaX * physDeltaX / physViscosity;
198 }
199 }
200
201 return new ThermalUnitConverter<T, DESCRIPTOR, ThermalLattice>(physDeltaX, physDeltaT, charPhysLength, charPhysVelocity, physViscosity, physDensity,T physThermalConductivity,T physSpecificHeatCapacity,T physThermalExpansionCoefficient,T charPhysLowTemperature,T charPhysHighTemperature, charPhysPressure);
202}*/
203
204} // namespace olb
205
206#endif
void print() const override
nice terminal output for conversion factors, characteristical and physical data
These functions help you to create file names.
Top level namespace for all of OpenLB.
Definition of singletons: global, publicly available information.