VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
ChimeraTests.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
36
37#ifdef VF_DOUBLE_ACCURACY
38#define REAL_EQ(a) testing::DoubleEq(a)
39#else
40#define REAL_EQ(a) testing::FloatEq(a)
41#endif
42
43/*
44* InverseChimeraWithK
45*/
46TEST(ChimeraTest, forwardChimeraWithInverseK)
47{
48 real mfa = 1;
49 real mfb = 1;
50 real mfc = 1;
51
52 const real vv = 1.;
53 const real v2 = 1.;
54
55 const real K = 1.;
56 const real inverseK = 1 / K;
57
59
60 EXPECT_THAT(mfa, REAL_EQ(3.)); // mfa + mfb + mfc
61 EXPECT_THAT(mfb, REAL_EQ(-4.)); // -(mfa + mfb + mfc + 1)
62 EXPECT_THAT(mfc, REAL_EQ(6.)); // (mfa + mfc) + (mfa + mfb + mfc + 1)
63}
64
65
66TEST(ChimeraTest, backwardChimeraWithInverseK)
67{
68 // starting with the result values from the test above.
69 real mfa = 3.;
70 real mfb = -4.;
71 real mfc = 6.;
72
73 const real vv = 1.;
74 const real v2 = 1.;
75
76 const real K = 1.;
77 const real inverseK = 1 / K;
78
80
81 // resulting in the start values from the test above.
85}
86
87/*
88* Chimera
89*/
90TEST(ChimeraTest, forwardChimera)
91{
92 real mfa = 1;
93 real mfb = 1;
94 real mfc = 1;
95
96 const real vv = 1.;
97 const real v2 = 1.;
98
100
101 EXPECT_THAT(mfa, REAL_EQ(3.)); // mfa + mfb + mfc
102 EXPECT_THAT(mfb, REAL_EQ(-3.)); // -(mfa + mfb + mfc)
103 EXPECT_THAT(mfc, REAL_EQ(5.)); // (mfa + mfc) + (mfa + mfb + mfc)
104}
105
106
107TEST(ChimeraTest, backwardChimera)
108{
109 // starting with the result values from the test above.
110 real mfa = 3.;
111 real mfb = -3.;
112 real mfc = 5.;
113
114 const real vv = 1.;
115 const real v2 = 1.;
116
118
119 // resulting in the start values from the test above.
120 EXPECT_THAT(mfa, REAL_EQ(1.));
121 EXPECT_THAT(mfb, REAL_EQ(1.));
122 EXPECT_THAT(mfc, REAL_EQ(1.));
123}
124
125/*
126* ChimeraWithK
127*/
128TEST(ChimeraTest, forwardChimeraWithK)
129{
130 real mfa = 1;
131 real mfb = 1;
132 real mfc = 1;
133
134 const real vv = 1.;
135 const real v2 = 1.;
136
137 const real K = 1.;
138
140
141 EXPECT_THAT(mfa, REAL_EQ(3.)); // mfa + mfb + mfc
142 EXPECT_THAT(mfb, REAL_EQ(-4.)); // -(mfa + mfb + mfc)
143 EXPECT_THAT(mfc, REAL_EQ(6.)); // (mfa + mfc) + (mfa + mfb + mfc)
144}
145
146
147TEST(ChimeraTest, backwardChimeraWithK)
148{
149 // starting with the result values from the test above.
150 real mfa = 3.;
151 real mfb = -4.;
152 real mfc = 6.;
153
154 const real vv = 1.;
155 const real v2 = 1.;
156
157 const real K = 1.;
158
160
161 // resulting in the start values from the test above.
162 EXPECT_THAT(mfa, REAL_EQ(1.));
163 EXPECT_THAT(mfb, REAL_EQ(1.));
164 EXPECT_THAT(mfc, REAL_EQ(1.));
165}
166
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
TEST(ChimeraTest, forwardChimeraWithInverseK)
#define REAL_EQ(a)
constexpr void backwardChimera(real &mfa, real &mfb, real &mfc, real vv, real v2)
backward chimera transformation backwardChimera Transformation from central moments to distributions ...
constexpr void forwardChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real K)
constexpr void backwardChimeraWithK(real &mfa, real &mfb, real &mfc, real vv, real v2, real K)
constexpr void forwardChimeraWithInverseK(real &mfa, real &mfb, real &mfc, real vv, real v2, real inverseK, real K)
forward chimera transformation forwardChimeraWithInverseK Transformation from distributions to centra...
constexpr void forwardChimera(real &mfa, real &mfb, real &mfc, real vv, real v2)
forward chimera transformation forwardChimera Transformation from distributions to central moments ac...
constexpr void backwardChimeraWithInverseK(real &mfa, real &mfb, real &mfc, real vv, real v2, real inverseK, real K)
backward chimera transformation backwardChimeraWithInverseK Transformation from central moments to di...