VirtualFluids
0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
MacroscopicQuantitiesTests.cpp
Go to the documentation of this file.
1
//=======================================================================================
2
// ____ ____ __ ______ __________ __ __ __ __
3
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4
// \ \ | | | | | |_) | | | | | | | / \ | |
5
// \ \ | | | | | _ / | | | | | | / /\ \ | |
6
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8
// \ \ | | ________________________________________________________________
9
// \ \ | | | ______________________________________________________________|
10
// \ \| | | | __ __ __ __ ______ _______
11
// \ | | |_____ | | | | | | | | | _ \ / _____)
12
// \ | | _____| | | | | | | | | | | \ \ \_______
13
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15
//
16
// This file is part of VirtualFluids. VirtualFluids is free software: you can
17
// redistribute it and/or modify it under the terms of the GNU General Public
18
// License as published by the Free Software Foundation, either version 3 of
19
// the License, or (at your option) any later version.
20
//
21
// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24
// for more details.
25
//
26
// SPDX-License-Identifier: GPL-3.0-or-later
27
// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28
//
32
//=======================================================================================
33
#include <gmock/gmock.h>
34
35
#include <array>
36
37
#include <
lbm/MacroscopicQuantities.h
>
38
#include <
lbm/constants/D3Q27.h
>
39
40
#include <
basics/tests/testUtilities.h
>
41
42
43
/*
44
* given distributions, which are all one.
45
*/
46
// real f[27] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
47
48
class
MacroscopicQuantitiesTest
:
public
testing::Test {
49
50
void
SetUp()
override
{
51
f
= {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
52
}
53
54
public
:
55
std::array<real, 27>
f
;
56
};
57
58
using namespace
vf::lbm
;
59
60
61
TEST_F
(
MacroscopicQuantitiesTest
,
check_density
)
62
{
63
const
double
density =
getDensity
(f.data());
64
65
const
double
expected_density
= 27.;
66
ASSERT_THAT
(density, testing::DoubleEq(
expected_density
));
67
}
68
69
TEST_F
(
MacroscopicQuantitiesTest
,
whenFsAreEqual_velocityInEachDirectionShouldBeZero
)
70
{
71
const
double
velocityX1
=
getIncompressibleVelocityX1
(f.data());
72
const
double
velocityX2
=
getIncompressibleVelocityX2
(f.data());
73
const
double
velocityX3
=
getIncompressibleVelocityX3
(f.data());
74
75
const
double
expected_velocity
= 0.;
76
EXPECT_THAT
(
velocityX1
, testing::DoubleEq(
expected_velocity
));
77
EXPECT_THAT
(
velocityX2
, testing::DoubleEq(
expected_velocity
));
78
EXPECT_THAT
(
velocityX3
, testing::DoubleEq(
expected_velocity
));
79
}
80
81
TEST_F
(
MacroscopicQuantitiesTest
,
givenAllFsAreOne_when_Eis2_velocityInX1ShouldBeOne
)
82
{
83
f[dir::dP00] = 2.;
84
85
const
double
velocityX1
=
getIncompressibleVelocityX1
(f.data());
86
const
double
velocityX2
=
getIncompressibleVelocityX2
(f.data());
87
const
double
velocityX3
=
getIncompressibleVelocityX3
(f.data());
88
89
const
double
expected_velocity_x1
= 1.;
90
const
double
expected_velocity_x2
= 0.;
91
const
double
expected_velocity_x3
= 0.;
92
93
EXPECT_THAT
(
velocityX1
, testing::DoubleEq(
expected_velocity_x1
));
94
EXPECT_THAT
(
velocityX2
, testing::DoubleEq(
expected_velocity_x2
));
95
EXPECT_THAT
(
velocityX3
, testing::DoubleEq(
expected_velocity_x3
));
96
}
97
98
TEST_F
(
MacroscopicQuantitiesTest
,
givenAllFsAreOne_when_Nis2_velocityInX2ShouldBeOne
)
99
{
100
f[dir::d0P0] = 2.;
101
102
const
double
velocity =
getIncompressibleVelocityX2
(f.data());
103
104
const
double
expected_velocity
= 1.;
105
ASSERT_THAT
(velocity, testing::DoubleEq(
expected_velocity
));
106
}
107
108
109
TEST_F
(
MacroscopicQuantitiesTest
,
givenAllFsAreOne_when_Tis2_velocityInX3ShouldBeOne
)
110
{
111
f[dir::d00P] = 2.;
112
113
const
double
velocity =
getIncompressibleVelocityX3
(f.data());
114
115
const
double
expected_velocity
= 1.;
116
ASSERT_THAT
(velocity, testing::DoubleEq(
expected_velocity
));
117
}
118
119
TEST_F
(
MacroscopicQuantitiesTest
,
givenAllFsAreOne_checkCompressibleValues
)
120
{
121
f[dir::dP00] = 2.;
122
123
real
rho{0},
vx1
{0},
vx2
{0},
vx3
{0};
124
getCompressibleMacroscopicValues
(f.data(), rho,
vx1
,
vx2
,
vx3
);
125
126
std::cout <<
getIncompressibleVelocityX1
(f.data()) << std::endl;
127
128
const
real
expected_rho
= 28.;
129
const
real
expected_velocity
= (1. / (1 +
expected_rho
));
130
131
EXPECT_THAT
(rho,
RealEq
(
expected_rho
));
132
EXPECT_THAT
(
vx1
,
RealEq
(
expected_velocity
));
133
EXPECT_THAT
(
vx2
,
RealEq
(0.));
134
EXPECT_THAT
(
vx3
,
RealEq
(0.));
135
}
136
MacroscopicQuantities.h
MacroscopicQuantitiesTest
Definition
MacroscopicQuantitiesTests.cpp:48
MacroscopicQuantitiesTest::f
std::array< real, 27 > f
Definition
MacroscopicQuantitiesTests.cpp:55
SPtr
std::shared_ptr< T > SPtr
Definition
PointerDefinitions.h:39
real
float real
Definition
DataTypes.h:42
TEST_F
TEST_F(MacroscopicQuantitiesTest, check_density)
Definition
MacroscopicQuantitiesTests.cpp:61
RealEq
auto RealEq
Definition
testUtilities.h:40
D3Q27.h
vf::lbm
Definition
BoundaryConditions.h:41
vf::lbm::getIncompressibleVelocityX3
constexpr real getIncompressibleVelocityX3(const real *const &f)
Definition
MacroscopicQuantities.h:72
vf::lbm::getIncompressibleVelocityX2
constexpr real getIncompressibleVelocityX2(const real *const &f)
Definition
MacroscopicQuantities.h:66
vf::lbm::getDensity
constexpr real getDensity(const real *const &f)
Definition
MacroscopicQuantities.h:48
vf::lbm::getCompressibleMacroscopicValues
constexpr void getCompressibleMacroscopicValues(const real *const &f, real &drho, real &oneOverRho, real &vx1, real &vx2, real &vx3)
Definition
MacroscopicQuantities.h:106
vf::lbm::getIncompressibleVelocityX1
constexpr real getIncompressibleVelocityX1(const real *const &f)
Definition
MacroscopicQuantities.h:60
testUtilities.h
tests
unit-tests
lbm
MacroscopicQuantitiesTests.cpp
Generated on Sun Nov 8 2026 00:03:31 for VirtualFluids by
1.9.8