OpenLB 1.7
Loading...
Searching...
No Matches
fractionalUnitConverter.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 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 FRACTIONAL_UNITCONVERTER_H
29#define FRACTIONAL_UNITCONVERTER_H
30
31#include "unitConverter.h"
32
33namespace olb {
34
35template <typename T, typename DESCRIPTOR, typename DESCRIPTOR_AD>
37 const UnitConverter<T,DESCRIPTOR>& converter,
38 int fraction, T targetLatticeRelaxationTime )
39{
40 if (fraction <= 0) {
41 throw std::out_of_range("fracton must be positive.");
42 }
43
44 T conversionViscosityOrDiffusivity = converter.getPhysDeltaX() * converter.getPhysDeltaX() / (converter.getPhysDeltaT() * fraction);
45 T physViscosiyOrDiffusivity = (targetLatticeRelaxationTime - 0.5) * conversionViscosityOrDiffusivity / descriptors::invCs2<T,DESCRIPTOR_AD>();
46
48 converter.getPhysDeltaX() / fraction,
49 converter.getPhysDeltaT() / fraction,
50 converter.getCharPhysLength(),
51 converter.getCharPhysVelocity(),
52 physViscosiyOrDiffusivity,
53 converter.getPhysDensity(),
54 converter.getCharPhysPressure()
55 );
56}
57
58template <typename T, typename DESCRIPTOR>
60 const UnitConverter<T,DESCRIPTOR>& converter,
61 int fraction, T targetLatticeRelaxationTime )
62{
63 return createADfractionalUnitConverter<T,DESCRIPTOR,DESCRIPTOR> (
64 converter, fraction, targetLatticeRelaxationTime );
65}
66
67template <typename T, typename DESCRIPTOR>
68T residualPhysDiffusivity ( const UnitConverter<T,DESCRIPTOR>& converterFractional, T physDiffusivity )
69{
70 return physDiffusivity - converterFractional.getPhysViscosity();
71}
72
73} // olb
74
75#endif
Conversion between physical and lattice units, as well as discretization.
constexpr T getCharPhysLength() const
return characteristic length in physical units
constexpr T getPhysDensity() const
return density in physical units
constexpr T getPhysViscosity() const
return viscosity in physical units
constexpr T getCharPhysVelocity() const
return characteristic velocity in physical units
constexpr T getPhysDeltaT() const
returns time spacing (timestep length) in s
constexpr T getCharPhysPressure() const
return characteristic pressure in physical units
constexpr T getPhysDeltaX() const
returns grid spacing (voxel length) in m
Top level namespace for all of OpenLB.
UnitConverter< T, DESCRIPTOR > createFractionalUnitConverter(const UnitConverter< T, DESCRIPTOR > &converter, int fraction, T targetLatticeRelaxationTime)
T residualPhysDiffusivity(const UnitConverter< T, DESCRIPTOR > &converterFractional, T physDiffusivity)
UnitConverter< T, DESCRIPTOR > createADfractionalUnitConverter(const UnitConverter< T, DESCRIPTOR > &converter, int fraction, T targetLatticeRelaxationTime)
Unit conversion handling – header file.