OpenLB 1.7
Loading...
Searching...
No Matches
powerLawUnitConverter.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2017-2018 Max Gaedtke, Albert Mink, Davide Dapelo
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
28#ifndef PL_UNITCONVERTER_H
29#define PL_UNITCONVERTER_H
30
31
32#include <math.h>
33#include "io/ostreamManager.h"
34#include "core/util.h"
35#include "io/xmlReader.h"
36#include "unitConverter.h"
37
38
39// All OpenLB code is contained in this namespace.
40namespace olb {
41
42
43
76template <typename T, typename DESCRIPTOR>
77class PowerLawUnitConverter : public UnitConverter<T, DESCRIPTOR> {
78public:
89 constexpr PowerLawUnitConverter( T physDeltaX, T physDeltaT, T charPhysLength,
90 T charPhysVelocity, T physConsistencyCoeff, T powerLawIndex,
91 T physDensity, T charPhysPressure = 0 )
92 : UnitConverter<T, DESCRIPTOR>( physDeltaX, physDeltaT, charPhysLength, charPhysVelocity,
93 physConsistencyCoeff * util::pow(charPhysVelocity / (2*charPhysLength), powerLawIndex-1),
94 physDensity, charPhysPressure ),
95 _conversionConsistencyCoeff(util::pow( physDeltaT,powerLawIndex-2 ) * util::pow( physDeltaX,2 ) ),
96 _powerLawIndex(powerLawIndex),
97 _physConsistencyCoeff(physConsistencyCoeff),
98 clout(std::cout,"PowerLawUnitConverter")
99 {
100 }
101
103 constexpr T getReynoldsNumber( ) const
104 {
105 // Calculation according to Metzner and Reed (1955): 10.1002/aic.690010409
106 return util::pow(this->_charPhysVelocity, T{2} - _powerLawIndex) * util::pow(this->_charPhysLength, _powerLawIndex)
107 / _physConsistencyCoeff;
108 }
109
111 constexpr T getPhysConsistencyCoeff( ) const
112 {
113 return _physConsistencyCoeff;
114 }
116 constexpr T getPhysConsistencyCoeff( T latticeConsistencyCoeff ) const
117 {
118 return _conversionConsistencyCoeff * latticeConsistencyCoeff;
119 }
121 constexpr T getLatticeConsistencyCoeff( ) const
122 {
123 return _physConsistencyCoeff / _conversionConsistencyCoeff;
124 }
126 constexpr T getConversionFactorConsistencyCoeff() const
127 {
128 return _conversionConsistencyCoeff;
129 }
130
132 constexpr T getPowerLawIndex() const
133 {
134 return _powerLawIndex;
135 }
136
138 void print() const override;
139 void print(std::ostream& fout) const override;
140
141 void write(std::string const& fileName = "unitConverter") const override;
142
143protected:
144 // conversion factors
145 const T _conversionConsistencyCoeff; // m^2 s^(n-2)
146
147 // physical units, e.g characteristic or reference values
148 const T _powerLawIndex;
149 const T _physConsistencyCoeff; // m^2 s^(n-2)
150
151private:
152 mutable OstreamManager clout;
153};
154
156template <typename T, typename DESCRIPTOR>
157PowerLawUnitConverter<T, DESCRIPTOR>* createPowerLawUnitConverter(XMLreader const& params);
158
159template <typename T, typename DESCRIPTOR>
160class PowerLawUnitConverterFrom_Resolution_RelaxationTime_Reynolds_PLindex : public PowerLawUnitConverter<T, DESCRIPTOR> {
161public:
162 constexpr PowerLawUnitConverterFrom_Resolution_RelaxationTime_Reynolds_PLindex(
163 int resolution,
164 T latticeRelaxationTime,
165 T charPhysLength,
166 T charPhysVelocity,
167 T Re,
168 T powerLawIndex,
169 T physDensity,
170 T charPhysPressure = 0)
171 : PowerLawUnitConverter<T, DESCRIPTOR>( (charPhysLength/resolution),
172 (latticeRelaxationTime - 0.5) / descriptors::invCs2<T,DESCRIPTOR>() * util::pow((charPhysLength/resolution),2) / ( ( charPhysLength * charPhysVelocity * util::pow( charPhysVelocity / ( 2 * charPhysLength ), 1 - powerLawIndex ) / Re ) * util::pow( charPhysVelocity / (2 * charPhysLength ), powerLawIndex - 1 ) ),
173 charPhysLength, charPhysVelocity,
174 charPhysLength * charPhysVelocity * util::pow( charPhysVelocity / ( 2 * charPhysLength ), 1 - powerLawIndex ) / Re, powerLawIndex, physDensity, charPhysPressure )
175 {
176 }
177
178};
179
180} // namespace olb
181
182#endif
Pack< T > pow(Pack< T > base, Pack< T > exp)
Definition 256.h:395
constexpr T invCs2() any_platform
void write(BlockReduction3D2D< T > &blockReduction, int iT, const plotParam< T > param={}, const std::vector< T > &valueArea=std::vector< T >())
This function is used to plot heat maps as jpeg files.
void print(U data, const std::string &name="", OstreamManager clout=OstreamManager(std::cout,"print"), const char delimiter=',')
Top level namespace for all of OpenLB.
PowerLawUnitConverter< T, DESCRIPTOR > * createPowerLawUnitConverter(XMLreader const &params)
Unit conversion handling – header file.
Set of functions commonly used in LB computations – header file.
Input/Output in XML format – header file.