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
38#include <lbm/constants/D3Q27.h>
39
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
48class 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
58using namespace vf::lbm;
59
60
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
80
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
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
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
120{
121 f[dir::dP00] = 2.;
122
123 real rho{0}, vx1{0}, vx2{0}, vx3{0};
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
133 EXPECT_THAT(vx2, RealEq(0.));
134 EXPECT_THAT(vx3, RealEq(0.));
135}
136
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
TEST_F(MacroscopicQuantitiesTest, check_density)
auto RealEq
constexpr real getIncompressibleVelocityX3(const real *const &f)
constexpr real getIncompressibleVelocityX2(const real *const &f)
constexpr real getDensity(const real *const &f)
constexpr void getCompressibleMacroscopicValues(const real *const &f, real &drho, real &oneOverRho, real &vx1, real &vx2, real &vx3)
constexpr real getIncompressibleVelocityX1(const real *const &f)