preCICE v3.1.2
Loading...
Searching...
No Matches
DimensionsTest.cpp
Go to the documentation of this file.
1#include <Eigen/Core>
2#include "math/constants.hpp"
4#include "testing/Testing.hpp"
6#include "utils/String.hpp"
7
8using namespace precice;
9using namespace precice::utils;
10
11BOOST_AUTO_TEST_SUITE(DimensionTests)
12BOOST_AUTO_TEST_SUITE(UtilsTests)
13
14BOOST_AUTO_TEST_CASE(LinearizeDelinearize)
15{
16 PRECICE_TEST(1_rank);
17 { // 2D
18 using Eigen::Vector2d;
19 BOOST_TEST(linearize(Vector2d(0.0, 0.0)) == 0);
20 BOOST_TEST(linearize(Vector2d(1.0, 0.0)) == 1);
21 BOOST_TEST(linearize(Vector2d(0.0, 1.0)) == 2);
22 BOOST_TEST(linearize(Vector2d(1.0, 1.0)) == 3);
23
24 Vector2d delin0 = delinearize(0, 2);
25 BOOST_TEST(delin0(0) == -1.0);
26 BOOST_TEST(delin0(1) == -1.0);
27
28 Vector2d delin1 = delinearize(1, 2);
29 BOOST_TEST(delin1(0) == 1.0);
30 BOOST_TEST(delin1(1) == -1.0);
31
32 Vector2d delin2 = delinearize(2, 2);
33 BOOST_TEST(delin2(0) == -1.0);
34 BOOST_TEST(delin2(1) == 1.0);
35
36 Vector2d delin3 = delinearize(3, 2);
37 BOOST_TEST(delin3(0) == 1.0);
38 BOOST_TEST(delin3(1) == 1.0);
39 }
40
41 { // 3D
42 using Eigen::Vector3d;
43 BOOST_TEST(linearize(Vector3d(0.0, 0.0, 0.0)) == 0);
44 BOOST_TEST(linearize(Vector3d(1.0, 0.0, 0.0)) == 1);
45 BOOST_TEST(linearize(Vector3d(0.0, 1.0, 0.0)) == 2);
46 BOOST_TEST(linearize(Vector3d(1.0, 1.0, 0.0)) == 3);
47 BOOST_TEST(linearize(Vector3d(0.0, 0.0, 1.0)) == 4);
48 BOOST_TEST(linearize(Vector3d(1.0, 0.0, 1.0)) == 5);
49 BOOST_TEST(linearize(Vector3d(0.0, 1.0, 1.0)) == 6);
50 BOOST_TEST(linearize(Vector3d(1.0, 1.0, 1.0)) == 7);
51
52 Vector3d delin0 = delinearize(0, 3);
53 BOOST_TEST(delin0(0) == -1.0);
54 BOOST_TEST(delin0(1) == -1.0);
55 BOOST_TEST(delin0(2) == -1.0);
56
57 Vector3d delin1 = delinearize(1, 3);
58 BOOST_TEST(delin1(0) == 1.0);
59 BOOST_TEST(delin1(1) == -1.0);
60 BOOST_TEST(delin1(2) == -1.0);
61
62 Vector3d delin2 = delinearize(2, 3);
63 BOOST_TEST(delin2(0) == -1.0);
64 BOOST_TEST(delin2(1) == 1.0);
65 BOOST_TEST(delin2(2) == -1.0);
66
67 Vector3d delin3 = delinearize(3, 3);
68 BOOST_TEST(delin3(0) == 1.0);
69 BOOST_TEST(delin3(1) == 1.0);
70 BOOST_TEST(delin3(2) == -1.0);
71
72 Vector3d delin4 = delinearize(4, 3);
73 BOOST_TEST(delin4(0) == -1.0);
74 BOOST_TEST(delin4(1) == -1.0);
75 BOOST_TEST(delin4(2) == 1.0);
76
77 Vector3d delin5 = delinearize(5, 3);
78 BOOST_TEST(delin5(0) == 1.0);
79 BOOST_TEST(delin5(1) == -1.0);
80 BOOST_TEST(delin5(2) == 1.0);
81
82 Vector3d delin6 = delinearize(6, 3);
83 BOOST_TEST(delin6(0) == -1.0);
84 BOOST_TEST(delin6(1) == 1.0);
85 BOOST_TEST(delin6(2) == 1.0);
86
87 Vector3d delin7 = delinearize(7, 3);
88 BOOST_TEST(delin7(0) == 1.0);
89 BOOST_TEST(delin7(1) == 1.0);
90 BOOST_TEST(delin7(2) == 1.0);
91 }
92}
93
BOOST_AUTO_TEST_CASE(LinearizeDelinearize)
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST(...)
Definition Testing.hpp:27
contains precice-related utilities.
const Eigen::VectorXd & delinearize(int toDelinearize, int dimensions)
int linearize(const VECTOR_T &toLinearize)
Main namespace of the precice library.