OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::UnitConverter< T, DESCRIPTOR > Class Template Reference

Conversion between physical and lattice units, as well as discretization. More...

#include <unitConverter.h>

+ Inheritance diagram for olb::UnitConverter< T, DESCRIPTOR >:
+ Collaboration diagram for olb::UnitConverter< T, DESCRIPTOR >:

Public Member Functions

constexpr UnitConverter (T physDeltaX, T physDeltaT, T charPhysLength, T charPhysVelocity, T physViscosity, T physDensity, T charPhysPressure=0)
 Documentation of constructor:
 
virtual ~UnitConverter ()=default
 
constexpr int getResolution () const
 return resolution
 
constexpr T getLatticeRelaxationTime () const
 return relaxation time in lattice units
 
constexpr T getLatticeRelaxationFrequency () const
 return relaxation frequency in lattice units
 
template<typename DESCRIPTOR_ >
constexpr T getLatticeRelaxationFrequencyFromDiffusivity (const T physDiffusivity) const
 return relaxation frequency in lattice units computed from given physical diffusivity in m^2 / s
 
constexpr T getCharPhysLength () const
 return characteristic length in physical units
 
constexpr T getCharPhysVelocity () const
 return characteristic velocity in physical units
 
constexpr T getCharLatticeVelocity () const
 return characteristic velocity in lattice units
 
constexpr T getCharCFLnumber () const
 return characteristic CFL number
 
constexpr T getPhysViscosity () const
 return viscosity in physical units
 
constexpr T getPhysDensity () const
 return density in physical units
 
constexpr T getCharPhysPressure () const
 return characteristic pressure in physical units
 
constexpr T getReynoldsNumber () const
 return Reynolds number
 
constexpr T getMachNumber () const
 return Mach number
 
constexpr T getKnudsenNumber () const
 return Knudsen number
 
constexpr T getPhysLength (int latticeLength) const
 conversion from lattice to physical length
 
constexpr int getLatticeLength (T physLength) const
 conversion from physical to lattice length, returns number of voxels for given physical length
 
constexpr T getConversionFactorLength () const
 access (read-only) to private member variable
 
constexpr T getPhysDeltaX () const
 returns grid spacing (voxel length) in m
 
constexpr T getPhysTime (size_t latticeTime) const
 conversion from lattice to physical time
 
constexpr size_t getLatticeTime (T physTime) const
 conversion from physical to lattice time
 
constexpr T getConversionFactorTime () const
 access (read-only) to private member variable
 
constexpr T getPhysDeltaT () const
 returns time spacing (timestep length) in s
 
constexpr T getPhysVelocity (T latticeVelocity) const
 conversion from lattice to physical velocity
 
constexpr T getLatticeVelocity (T physVelocity) const
 conversion from physical to lattice velocity
 
template<unsigned D>
constexpr Vector< T, D > getLatticeVelocity (Vector< T, D > physU) const
 conversion from physical to lattice velocity
 
constexpr T getConversionFactorVelocity () const
 access (read-only) to private member variable
 
constexpr T getPhysDensity (T latticeDensity) const
 conversion from lattice to physical density
 
constexpr T getLatticeDensity (T physDensity) const
 conversion from physical to lattice density
 
constexpr T getLatticeDensityFromPhysPressure (T physPressure) const
 
constexpr T getConversionFactorDensity () const
 access (read-only) to private member variable
 
constexpr T getPhysMass (T latticeMass) const
 conversion from lattice to physical mass
 
constexpr T getLatticeMass (T physMass) const
 conversion from physical to lattice mass
 
constexpr T getConversionFactorMass () const
 access (read-only) to private member variable
 
constexpr T getPhysViscosity (T latticeViscosity) const
 conversion from lattice to physical viscosity
 
constexpr T getLatticeViscosity () const
 conversion from physical to lattice viscosity
 
constexpr T getConversionFactorViscosity () const
 access (read-only) to private member variable
 
constexpr T getPhysForce (T latticeForce) const
 conversion from lattice to physical force
 
template<unsigned D>
constexpr Vector< T, D > getPhysForce (Vector< T, D > latticeForce) const
 conversion from lattice to physical force vector
 
constexpr T getLatticeForce (T physForce) const
 conversion from physical to lattice force
 
constexpr T getConversionFactorForce () const
 access (read-only) to private member variable
 
constexpr T getPhysTorque (T latticeTorque) const
 conversion from lattice to physical torque
 
template<unsigned D>
constexpr Vector< T, D > getPhysTorque (Vector< T, D > latticeTorque) const
 conversion from lattice to physical force vector
 
constexpr T getLatticeTorque (T physTorque) const
 conversion from physical to lattice torque
 
constexpr T getConversionFactorTorque () const
 access (read-only) to private member variable
 
constexpr T getPhysPressure (T latticePressure) const
 conversion from lattice to physical pressure
 
constexpr T getLatticePressure (T physPressure) const
 conversion from physical to lattice pressure
 
constexpr T getConversionFactorPressure () const
 access (read-only) to private member variable
 
virtual void print () const
 nice terminal output for conversion factors, characteristical and physical data
 
void print (std::ostream &fout) const
 
void write (std::string const &fileName="unitConverter") const
 
- Public Member Functions inherited from olb::UnitConverterBase
virtual ~UnitConverterBase ()=default
 

Protected Attributes

const T _conversionLength
 
const T _conversionTime
 
const T _conversionVelocity
 
const T _conversionDensity
 
const T _conversionMass
 
const T _conversionViscosity
 
const T _conversionForce
 
const T _conversionTorque
 
const T _conversionPressure
 
const T _charPhysLength
 
const T _charPhysVelocity
 
const T _physViscosity
 
const T _physDensity
 
const T _charPhysPressure
 
const size_t _resolution
 
const T _latticeRelaxationTime
 
const T _charLatticeVelocity
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::UnitConverter< T, DESCRIPTOR >

Conversion between physical and lattice units, as well as discretization.

Be aware of the nomenclature: We distingish between physical (dimensioned) and lattice (dimensionless) values. A specific conversion factor maps the two different scopes, e.g. physLength = conversionLength * latticeLength

For pressure and temperature we first shift the physical values by a characteristic value to asure a lattice pressure and lattice temperature between 0 and 1, e.g. physPressure - charPhysPressure = conversionPressure * latticePressure

Parameters
latticeRelaxationTimerelaxation time, have to be greater than 0.5!
physViscosityphysical kinematic viscosity in m^2 / s
physDensityphysical density in kg / m^3
conversionLengthconversion factor for length m
conversionTimeconversion factor for time s
conversionMassconversion factor for mass kg
conversionVelocityconversion velocity m / s
conversionViscosityconversion kinematic viscosity m^2 / s
conversionDensityconversion density kg / m^3
conversionForceconversion force kg m / s^2
conversionPressureconversion pressure kg / m s^2
resolutionnumber of grid points per charPhysLength
charLatticeVelocity

Definition at line 141 of file unitConverter.h.

Constructor & Destructor Documentation

◆ UnitConverter()

template<typename T , typename DESCRIPTOR >
olb::UnitConverter< T, DESCRIPTOR >::UnitConverter ( T physDeltaX,
T physDeltaT,
T charPhysLength,
T charPhysVelocity,
T physViscosity,
T physDensity,
T charPhysPressure = 0 )
inlineconstexpr

Documentation of constructor:

Parameters
physDeltaXspacing between two lattice cells in m
physDeltaTtime step in s
charPhysLengthreference/characteristic length of simulation geometry in m
charPhysVelocitymaximal or highest expected velocity during simulation in m / s
physViscosityphysical kinematic viscosity in m^2 / s
physDensityphysical density in kg / m^3
charPhysPressurereference/characteristic physical pressure in Pa = kg / m s^2

Definition at line 152 of file unitConverter.h.

154 : _conversionLength(physDeltaX),
155 _conversionTime(physDeltaT),
157 _conversionDensity(physDensity),
163 _charPhysLength(charPhysLength),
164 _charPhysVelocity(charPhysVelocity),
165 _physViscosity(physViscosity),
166 _physDensity(physDensity),
167 _charPhysPressure(charPhysPressure),
171 clout(std::cout,"UnitConverter")
172 {
173 }
const size_t _resolution
const T _latticeRelaxationTime
constexpr T invCs2() any_platform
Definition functions.h:107
Expr pow(Expr base, Expr exp)
Definition expr.cpp:235

◆ ~UnitConverter()

template<typename T , typename DESCRIPTOR >
virtual olb::UnitConverter< T, DESCRIPTOR >::~UnitConverter ( )
virtualdefault

Member Function Documentation

◆ getCharCFLnumber()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getCharCFLnumber ( ) const
inlineconstexpr

return characteristic CFL number

Definition at line 214 of file unitConverter.h.

215 {
217 }

References olb::UnitConverter< T, DESCRIPTOR >::_charLatticeVelocity.

◆ getCharLatticeVelocity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getCharLatticeVelocity ( ) const
inlineconstexpr

return characteristic velocity in lattice units

Definition at line 209 of file unitConverter.h.

210 {
212 }

References olb::UnitConverter< T, DESCRIPTOR >::_charLatticeVelocity.

+ Here is the caller graph for this function:

◆ getCharPhysLength()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getCharPhysLength ( ) const
inlineconstexpr

return characteristic length in physical units

Definition at line 199 of file unitConverter.h.

200 {
201 return _charPhysLength;
202 }

References olb::UnitConverter< T, DESCRIPTOR >::_charPhysLength.

+ Here is the caller graph for this function:

◆ getCharPhysPressure()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getCharPhysPressure ( ) const
inlineconstexpr

return characteristic pressure in physical units

Definition at line 229 of file unitConverter.h.

230 {
231 return _charPhysPressure;
232 }

References olb::UnitConverter< T, DESCRIPTOR >::_charPhysPressure.

+ Here is the caller graph for this function:

◆ getCharPhysVelocity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getCharPhysVelocity ( ) const
inlineconstexpr

return characteristic velocity in physical units

Definition at line 204 of file unitConverter.h.

205 {
206 return _charPhysVelocity;
207 }

References olb::UnitConverter< T, DESCRIPTOR >::_charPhysVelocity.

+ Here is the caller graph for this function:

◆ getConversionFactorDensity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorDensity ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 331 of file unitConverter.h.

332 {
333 return _conversionDensity;
334 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionDensity.

+ Here is the caller graph for this function:

◆ getConversionFactorForce()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorForce ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 387 of file unitConverter.h.

388 {
389 return _conversionForce;
390 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionForce.

+ Here is the caller graph for this function:

◆ getConversionFactorLength()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorLength ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 261 of file unitConverter.h.

262 {
263 return _conversionLength;
264 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionLength.

+ Here is the caller graph for this function:

◆ getConversionFactorMass()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorMass ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 347 of file unitConverter.h.

348 {
349 return _conversionMass;
350 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionMass.

+ Here is the caller graph for this function:

◆ getConversionFactorPressure()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorPressure ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 427 of file unitConverter.h.

428 {
429 return _conversionPressure;
430 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionPressure.

+ Here is the caller graph for this function:

◆ getConversionFactorTime()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorTime ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 282 of file unitConverter.h.

283 {
284 return _conversionTime;
285 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionTime.

+ Here is the caller graph for this function:

◆ getConversionFactorTorque()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorTorque ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 411 of file unitConverter.h.

412 {
413 return _conversionTorque;
414 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionTorque.

◆ getConversionFactorVelocity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorVelocity ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 311 of file unitConverter.h.

312 {
313 return _conversionVelocity;
314 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionVelocity.

+ Here is the caller graph for this function:

◆ getConversionFactorViscosity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorViscosity ( ) const
inlineconstexpr

access (read-only) to private member variable

Definition at line 363 of file unitConverter.h.

364 {
366 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionViscosity.

+ Here is the caller graph for this function:

◆ getKnudsenNumber()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getKnudsenNumber ( ) const
inlineconstexpr

return Knudsen number

Definition at line 244 of file unitConverter.h.

245 {
246 // This calculates the lattice Knudsen number.
247 // See e.g. (7.22) in "The Lattice Boltzmann Method: Principles and Practice" [kruger2017lattice].
248 return getMachNumber() / getReynoldsNumber();
249 }
constexpr T getMachNumber() const
return Mach number
constexpr T getReynoldsNumber() const
return Reynolds number

References olb::UnitConverter< T, DESCRIPTOR >::getMachNumber(), and olb::UnitConverter< T, DESCRIPTOR >::getReynoldsNumber().

+ Here is the call graph for this function:

◆ getLatticeDensity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeDensity ( T physDensity) const
inlineconstexpr

conversion from physical to lattice density

Definition at line 322 of file unitConverter.h.

323 {
324 return physDensity / _conversionDensity;
325 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionDensity.

+ Here is the caller graph for this function:

◆ getLatticeDensityFromPhysPressure()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeDensityFromPhysPressure ( T physPressure) const
inlineconstexpr

Definition at line 326 of file unitConverter.h.

327 {
329 }
constexpr T getLatticePressure(T physPressure) const
conversion from physical to lattice pressure
any_platform T densityFromPressure(T latticePressure)
compute lattice density from lattice pressure
Definition util.h:386

References olb::util::densityFromPressure(), and olb::UnitConverter< T, DESCRIPTOR >::getLatticePressure().

+ Here is the call graph for this function:

◆ getLatticeForce()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeForce ( T physForce) const
inlineconstexpr

conversion from physical to lattice force

Definition at line 382 of file unitConverter.h.

383 {
384 return physForce / _conversionForce;
385 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionForce.

◆ getLatticeLength()

template<typename T , typename DESCRIPTOR >
int olb::UnitConverter< T, DESCRIPTOR >::getLatticeLength ( T physLength) const
inlineconstexpr

conversion from physical to lattice length, returns number of voxels for given physical length

Definition at line 256 of file unitConverter.h.

257 {
258 return int( physLength / _conversionLength + 0.5 );
259 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionLength.

◆ getLatticeMass()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeMass ( T physMass) const
inlineconstexpr

conversion from physical to lattice mass

Definition at line 342 of file unitConverter.h.

343 {
344 return physMass / _conversionMass;
345 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionMass.

◆ getLatticePressure()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticePressure ( T physPressure) const
inlineconstexpr

conversion from physical to lattice pressure

Definition at line 422 of file unitConverter.h.

423 {
424 return ( physPressure - _charPhysPressure ) / _conversionPressure;
425 }

References olb::UnitConverter< T, DESCRIPTOR >::_charPhysPressure, and olb::UnitConverter< T, DESCRIPTOR >::_conversionPressure.

+ Here is the caller graph for this function:

◆ getLatticeRelaxationFrequency()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeRelaxationFrequency ( ) const
inlineconstexpr

return relaxation frequency in lattice units

Definition at line 188 of file unitConverter.h.

189 {
190 return 1./_latticeRelaxationTime;
191 }

References olb::UnitConverter< T, DESCRIPTOR >::_latticeRelaxationTime.

+ Here is the caller graph for this function:

◆ getLatticeRelaxationFrequencyFromDiffusivity()

template<typename T , typename DESCRIPTOR >
template<typename DESCRIPTOR_ >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeRelaxationFrequencyFromDiffusivity ( const T physDiffusivity) const
inlineconstexpr

return relaxation frequency in lattice units computed from given physical diffusivity in m^2 / s

Definition at line 194 of file unitConverter.h.

195 {
196 return 1.0 / ( physDiffusivity / _conversionViscosity * descriptors::invCs2<T,DESCRIPTOR_>() + 0.5 );
197 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionViscosity, and olb::descriptors::invCs2().

+ Here is the call graph for this function:

◆ getLatticeRelaxationTime()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeRelaxationTime ( ) const
inlineconstexpr

return relaxation time in lattice units

Definition at line 183 of file unitConverter.h.

184 {
186 }

References olb::UnitConverter< T, DESCRIPTOR >::_latticeRelaxationTime.

+ Here is the caller graph for this function:

◆ getLatticeTime()

template<typename T , typename DESCRIPTOR >
size_t olb::UnitConverter< T, DESCRIPTOR >::getLatticeTime ( T physTime) const
inlineconstexpr

conversion from physical to lattice time

Definition at line 277 of file unitConverter.h.

278 {
279 return size_t(physTime / _conversionTime + 0.5);
280 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionTime.

+ Here is the caller graph for this function:

◆ getLatticeTorque()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeTorque ( T physTorque) const
inlineconstexpr

conversion from physical to lattice torque

Definition at line 406 of file unitConverter.h.

407 {
408 return physTorque / _conversionTorque;
409 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionTorque.

◆ getLatticeVelocity() [1/2]

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeVelocity ( T physVelocity) const
inlineconstexpr

conversion from physical to lattice velocity

Definition at line 298 of file unitConverter.h.

299 {
300 return physVelocity / _conversionVelocity;
301 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionVelocity.

+ Here is the caller graph for this function:

◆ getLatticeVelocity() [2/2]

template<typename T , typename DESCRIPTOR >
template<unsigned D>
Vector< T, D > olb::UnitConverter< T, DESCRIPTOR >::getLatticeVelocity ( Vector< T, D > physU) const
inlineconstexpr

conversion from physical to lattice velocity

Definition at line 304 of file unitConverter.h.

305 {
306 return Vector<T,D>([&](std::size_t iD) -> T {
307 return this->getLatticeVelocity(physU[iD]);
308 });
309 }
constexpr T getLatticeVelocity(T physVelocity) const
conversion from physical to lattice velocity

References olb::UnitConverter< T, DESCRIPTOR >::getLatticeVelocity().

+ Here is the call graph for this function:

◆ getLatticeViscosity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getLatticeViscosity ( ) const
inlineconstexpr

conversion from physical to lattice viscosity

Definition at line 358 of file unitConverter.h.

359 {
361 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionViscosity, and olb::UnitConverter< T, DESCRIPTOR >::_physViscosity.

+ Here is the caller graph for this function:

◆ getMachNumber()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getMachNumber ( ) const
inlineconstexpr

return Mach number

Definition at line 239 of file unitConverter.h.

240 {
242 }
constexpr T getCharLatticeVelocity() const
return characteristic velocity in lattice units
Expr sqrt(Expr x)
Definition expr.cpp:225

References olb::UnitConverter< T, DESCRIPTOR >::getCharLatticeVelocity(), olb::descriptors::invCs2(), and olb::util::sqrt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPhysDeltaT()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysDeltaT ( ) const
inlineconstexpr

returns time spacing (timestep length) in s

Definition at line 287 of file unitConverter.h.

288 {
289 return _conversionTime;
290 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionTime.

+ Here is the caller graph for this function:

◆ getPhysDeltaX()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysDeltaX ( ) const
inlineconstexpr

returns grid spacing (voxel length) in m

Definition at line 266 of file unitConverter.h.

267 {
268 return _conversionLength;
269 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionLength.

+ Here is the caller graph for this function:

◆ getPhysDensity() [1/2]

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysDensity ( ) const
inlineconstexpr

return density in physical units

Definition at line 224 of file unitConverter.h.

225 {
226 return _physDensity;
227 }

References olb::UnitConverter< T, DESCRIPTOR >::_physDensity.

+ Here is the caller graph for this function:

◆ getPhysDensity() [2/2]

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysDensity ( T latticeDensity) const
inlineconstexpr

conversion from lattice to physical density

Definition at line 317 of file unitConverter.h.

318 {
319 return _conversionDensity * latticeDensity;
320 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionDensity.

◆ getPhysForce() [1/2]

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysForce ( T latticeForce) const
inlineconstexpr

conversion from lattice to physical force

Definition at line 369 of file unitConverter.h.

370 {
371 return _conversionForce * latticeForce;
372 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionForce.

+ Here is the caller graph for this function:

◆ getPhysForce() [2/2]

template<typename T , typename DESCRIPTOR >
template<unsigned D>
Vector< T, D > olb::UnitConverter< T, DESCRIPTOR >::getPhysForce ( Vector< T, D > latticeForce) const
inlineconstexpr

conversion from lattice to physical force vector

Definition at line 375 of file unitConverter.h.

376 {
377 return Vector<T,D>([&](std::size_t iD) -> T {
378 return this->getPhysForce(latticeForce[iD]);
379 });
380 }
constexpr T getPhysForce(T latticeForce) const
conversion from lattice to physical force

References olb::UnitConverter< T, DESCRIPTOR >::getPhysForce().

+ Here is the call graph for this function:

◆ getPhysLength()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysLength ( int latticeLength) const
inlineconstexpr

conversion from lattice to physical length

Definition at line 251 of file unitConverter.h.

252 {
253 return _conversionLength * latticeLength;
254 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionLength.

◆ getPhysMass()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysMass ( T latticeMass) const
inlineconstexpr

conversion from lattice to physical mass

Definition at line 337 of file unitConverter.h.

338 {
339 return _conversionMass * latticeMass;
340 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionMass.

◆ getPhysPressure()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysPressure ( T latticePressure) const
inlineconstexpr

conversion from lattice to physical pressure

Definition at line 417 of file unitConverter.h.

418 {
419 return _conversionPressure * latticePressure + _charPhysPressure;
420 }

References olb::UnitConverter< T, DESCRIPTOR >::_charPhysPressure, and olb::UnitConverter< T, DESCRIPTOR >::_conversionPressure.

◆ getPhysTime()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysTime ( size_t latticeTime) const
inlineconstexpr

conversion from lattice to physical time

Definition at line 272 of file unitConverter.h.

273 {
274 return _conversionTime * latticeTime;
275 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionTime.

+ Here is the caller graph for this function:

◆ getPhysTorque() [1/2]

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysTorque ( T latticeTorque) const
inlineconstexpr

conversion from lattice to physical torque

Definition at line 393 of file unitConverter.h.

394 {
395 return _conversionTorque * latticeTorque;
396 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionTorque.

+ Here is the caller graph for this function:

◆ getPhysTorque() [2/2]

template<typename T , typename DESCRIPTOR >
template<unsigned D>
Vector< T, D > olb::UnitConverter< T, DESCRIPTOR >::getPhysTorque ( Vector< T, D > latticeTorque) const
inlineconstexpr

conversion from lattice to physical force vector

Definition at line 399 of file unitConverter.h.

400 {
401 return Vector<T,D>([&](std::size_t iD) -> T {
402 return this->getPhysTorque(latticeTorque[iD]);
403 });
404 }
constexpr T getPhysTorque(T latticeTorque) const
conversion from lattice to physical torque

References olb::UnitConverter< T, DESCRIPTOR >::getPhysTorque().

+ Here is the call graph for this function:

◆ getPhysVelocity()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysVelocity ( T latticeVelocity) const
inlineconstexpr

conversion from lattice to physical velocity

Definition at line 293 of file unitConverter.h.

294 {
295 return _conversionVelocity * latticeVelocity;
296 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionVelocity.

+ Here is the caller graph for this function:

◆ getPhysViscosity() [1/2]

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysViscosity ( ) const
inlineconstexpr

return viscosity in physical units

Definition at line 219 of file unitConverter.h.

220 {
221 return _physViscosity;
222 }

References olb::UnitConverter< T, DESCRIPTOR >::_physViscosity.

+ Here is the caller graph for this function:

◆ getPhysViscosity() [2/2]

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getPhysViscosity ( T latticeViscosity) const
inlineconstexpr

conversion from lattice to physical viscosity

Definition at line 353 of file unitConverter.h.

354 {
355 return _conversionViscosity * latticeViscosity;
356 }

References olb::UnitConverter< T, DESCRIPTOR >::_conversionViscosity.

◆ getResolution()

template<typename T , typename DESCRIPTOR >
int olb::UnitConverter< T, DESCRIPTOR >::getResolution ( ) const
inlineconstexpr

return resolution

Definition at line 178 of file unitConverter.h.

179 {
180 return _resolution;
181 }

References olb::UnitConverter< T, DESCRIPTOR >::_resolution.

+ Here is the caller graph for this function:

◆ getReynoldsNumber()

template<typename T , typename DESCRIPTOR >
T olb::UnitConverter< T, DESCRIPTOR >::getReynoldsNumber ( ) const
inlineconstexpr

return Reynolds number

Definition at line 234 of file unitConverter.h.

235 {
237 }

References olb::UnitConverter< T, DESCRIPTOR >::_charPhysLength, olb::UnitConverter< T, DESCRIPTOR >::_charPhysVelocity, and olb::UnitConverter< T, DESCRIPTOR >::_physViscosity.

+ Here is the caller graph for this function:

◆ print() [1/2]

template<typename T , class DESCRIPTOR >
void olb::UnitConverter< T, DESCRIPTOR >::print ( ) const
virtual

nice terminal output for conversion factors, characteristical and physical data

Implements olb::UnitConverterBase.

Reimplemented in olb::AdeUnitConverter< T, DESCRIPTOR >, olb::AdsorptionConverter< T, DESCRIPTOR >, olb::MultiPhaseUnitConverter< T, DESCRIPTOR >, olb::MultiPhaseUnitConverterFromRelaxationTime< T, DESCRIPTOR >, olb::RadiativeUnitConverter< T, DESCRIPTOR >, olb::ThermalUnitConverter< T, DESCRIPTOR, ThermalLattice >, and olb::ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR >.

Definition at line 99 of file unitConverter.hh.

100{
101 print(clout);
102}
virtual void print() const
nice terminal output for conversion factors, characteristical and physical data

◆ print() [2/2]

template<typename T , typename DESCRIPTOR >
void olb::UnitConverter< T, DESCRIPTOR >::print ( std::ostream & fout) const
virtual

Implements olb::UnitConverterBase.

Definition at line 39 of file unitConverter.hh.

40{
41 clout << "----------------- UnitConverter information -----------------" << std::endl;
42 clout << "-- Parameters:" << std::endl;
43 clout << "Resolution: N= " << getResolution() << std::endl;
44 clout << "Lattice velocity: latticeU= " << getCharLatticeVelocity() << std::endl;
45 clout << "Lattice relaxation frequency: omega= " << getLatticeRelaxationFrequency( ) << std::endl;
46 clout << "Lattice relaxation time: tau= " << getLatticeRelaxationTime() << std::endl;
47 clout << "Characteristical length(m): charL= " << getCharPhysLength() << std::endl;
48 clout << "Characteristical speed(m/s): charU= " << getCharPhysVelocity() << std::endl;
49 clout << "Phys. kinematic viscosity(m^2/s): charNu= " << getPhysViscosity() << std::endl;
50 clout << "Phys. density(kg/m^d): charRho= " << getPhysDensity() << std::endl;
51 clout << "Characteristical pressure(N/m^2): charPressure= " << getCharPhysPressure() << std::endl;
52 clout << "Mach number: machNumber= " << getMachNumber() << std::endl;
53 clout << "Reynolds number: reynoldsNumber= " << getReynoldsNumber() << std::endl;
54 clout << "Knudsen number: knudsenNumber= " << getKnudsenNumber() << std::endl;
55 clout << "Characteristical CFL number: charCFLnumber= " << getCharCFLnumber() << std::endl;
56
57 clout << std::endl;
58 clout << "-- Conversion factors:" << std::endl;
59 clout << "Voxel length(m): physDeltaX= " << getConversionFactorLength() << std::endl;
60 clout << "Time step(s): physDeltaT= " << getConversionFactorTime() << std::endl;
61 clout << "Velocity factor(m/s): physVelocity= " << getConversionFactorVelocity() << std::endl;
62 clout << "Density factor(kg/m^3): physDensity= " << getConversionFactorDensity() << std::endl;
63 clout << "Mass factor(kg): physMass= " << getConversionFactorMass() << std::endl;
64 clout << "Viscosity factor(m^2/s): physViscosity= " << getConversionFactorViscosity() << std::endl;
65 clout << "Force factor(N): physForce= " << getConversionFactorForce() << std::endl;
66 clout << "Pressure factor(N/m^2): physPressure= " << getConversionFactorPressure() << std::endl;
67
68 clout << "-------------------------------------------------------------" << std::endl;
69
70 if ( getLatticeRelaxationTime() < T(0.55) && getCharLatticeVelocity() > (T(8)*(getLatticeRelaxationTime() - T(0.5)) + T(1.e-8)) ) {
71 T tauStable = getCharLatticeVelocity() / T(8) + T(0.5);
73 if (getCharLatticeVelocity() >= T(0.3)) {
74 tauStable = T(0.15) / T(8) + T(0.5);
75 timeToCell = T(0.15) / getCharPhysVelocity();
76 }
77 T dxNew = timeToCell * getPhysViscosity() * descriptors::invCs2<T,DESCRIPTOR>() / (tauStable - T(0.5));
78 T dtNew = dxNew * timeToCell;
79 clout << "WARNING:" << std::endl;
80 clout << "Potentially UNSTABLE combination of relaxation time (tau=" << getLatticeRelaxationTime() << ")" << std::endl;
81 clout << "and characteristical CFL number (lattice velocity) charCFLnumber=" << getCharCFLnumber() << "!" << std::endl;
82 clout << "Potentially maximum characteristical CFL number (maxCharCFLnumber=" << T(8)*(getLatticeRelaxationTime() - T(0.5)) << ")" << std::endl;
83 clout << "Actual characteristical CFL number (charCFLnumber=" << getCharCFLnumber() << ") > " << T(8)*(getLatticeRelaxationTime() - T(0.5)) << std::endl;
84 if (getCharLatticeVelocity() >= T(0.3)) {
85 clout << "Please make the CFL number smaller than 0.3!" << std::endl;
86 }
87 clout << "Please reduce the the cell size or the time step size!" << std::endl;
88 if (getCharLatticeVelocity() >= T(0.3)) {
89 clout << "We recommend to use the cell size of " << dxNew << " m and the time step size of " << dtNew << " s (CFL = 0.15)." << std::endl;
90 } else {
91 clout << "We recommend to use the cell size of " << dxNew << " m and the time step size of " << dtNew << " s." << std::endl;
92 }
93 clout << "-------------------------------------------------------------" << std::endl;
94 }
95
96}
constexpr T getConversionFactorViscosity() const
access (read-only) to private member variable
constexpr T getCharPhysLength() const
return characteristic length in physical units
constexpr int getResolution() const
return resolution
constexpr T getConversionFactorDensity() const
access (read-only) to private member variable
constexpr T getPhysDensity() const
return density in physical units
constexpr T getLatticeRelaxationFrequency() const
return relaxation frequency in lattice units
constexpr T getConversionFactorLength() const
access (read-only) to private member variable
constexpr T getConversionFactorVelocity() const
access (read-only) to private member variable
constexpr T getConversionFactorMass() const
access (read-only) to private member variable
constexpr T getPhysViscosity() const
return viscosity in physical units
constexpr T getConversionFactorForce() const
access (read-only) to private member variable
constexpr T getConversionFactorPressure() const
access (read-only) to private member variable
constexpr T getKnudsenNumber() const
return Knudsen number
constexpr T getCharPhysVelocity() const
return characteristic velocity in physical units
constexpr T getConversionFactorTime() const
access (read-only) to private member variable
constexpr T getCharPhysPressure() const
return characteristic pressure in physical units
constexpr T getCharCFLnumber() const
return characteristic CFL number
constexpr T getLatticeRelaxationTime() const
return relaxation time in lattice units

References olb::descriptors::invCs2().

+ Here is the call graph for this function:

◆ write()

template<typename T , typename DESCRIPTOR >
void olb::UnitConverter< T, DESCRIPTOR >::write ( std::string const & fileName = "unitConverter") const
virtual

Implements olb::UnitConverterBase.

Definition at line 105 of file unitConverter.hh.

106{
107 std::string dataFile = singleton::directories().getLogOutDir() + fileName + ".dat";
108
109 if (singleton::mpi().isMainProcessor()) {
110 std::ofstream fout(dataFile.c_str(), std::ios::trunc);
111 if (!fout) {
112 clout << "error write() function: can not open std::ofstream" << std::endl;
113 }
114 else {
115 print( fout );
116 fout.close();
117 }
118 }
119}
std::string getLogOutDir() const
Definition singleton.h:95
MpiManager & mpi()
Directories & directories()
Definition singleton.h:162

References olb::singleton::directories(), olb::singleton::Directories::getLogOutDir(), and olb::singleton::mpi().

+ Here is the call graph for this function:

Member Data Documentation

◆ _charLatticeVelocity

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_charLatticeVelocity
protected

Definition at line 459 of file unitConverter.h.

◆ _charPhysLength

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_charPhysLength
protected

Definition at line 450 of file unitConverter.h.

◆ _charPhysPressure

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_charPhysPressure
protected

Definition at line 454 of file unitConverter.h.

◆ _charPhysVelocity

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_charPhysVelocity
protected

Definition at line 451 of file unitConverter.h.

◆ _conversionDensity

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionDensity
protected

Definition at line 442 of file unitConverter.h.

◆ _conversionForce

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionForce
protected

Definition at line 445 of file unitConverter.h.

◆ _conversionLength

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionLength
protected

Definition at line 439 of file unitConverter.h.

◆ _conversionMass

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionMass
protected

Definition at line 443 of file unitConverter.h.

◆ _conversionPressure

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionPressure
protected

Definition at line 447 of file unitConverter.h.

◆ _conversionTime

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionTime
protected

Definition at line 440 of file unitConverter.h.

◆ _conversionTorque

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionTorque
protected

Definition at line 446 of file unitConverter.h.

◆ _conversionVelocity

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionVelocity
protected

Definition at line 441 of file unitConverter.h.

◆ _conversionViscosity

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_conversionViscosity
protected

Definition at line 444 of file unitConverter.h.

◆ _latticeRelaxationTime

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_latticeRelaxationTime
protected

Definition at line 458 of file unitConverter.h.

◆ _physDensity

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_physDensity
protected

Definition at line 453 of file unitConverter.h.

◆ _physViscosity

template<typename T , typename DESCRIPTOR >
const T olb::UnitConverter< T, DESCRIPTOR >::_physViscosity
protected

Definition at line 452 of file unitConverter.h.

◆ _resolution

template<typename T , typename DESCRIPTOR >
const size_t olb::UnitConverter< T, DESCRIPTOR >::_resolution
protected

Definition at line 457 of file unitConverter.h.


The documentation for this class was generated from the following files: