Peano 4
Loading...
Searching...
No Matches
GridControlEventTest.cpp
Go to the documentation of this file.
2
3#include "../grid.h"
5
6tarch::logging::Log peano4::grid::tests::GridControlEventTest::_log("peano4::grid::tests::GridControlEventTest");
7
8#ifdef UseTestSpecificCompilerSettings
9#pragma optimize("", off)
10#endif
11
13 TestCase("peano4::grid::tests::GridControlEventTest") {}
14
16#if Dimensions == 2
17 std::vector<GridControlEvent> events;
18
19 events.push_back(GridControlEvent(
20 GridControlEvent::RefinementControl::Refine, {-0.0333333, -0.0333333}, {0.4, 0.4}, {0.111111, 0.111111}
21 ));
22 events.push_back(
23 GridControlEvent(GridControlEvent::RefinementControl::Refine, {-0.0333333, 0.3}, {0.4, 0.4}, {0.111111, 0.111111})
24 );
25 events.push_back(GridControlEvent(
26 GridControlEvent::RefinementControl::Refine, {-0.0333333, 0.633333}, {0.4, 0.4}, {0.111111, 0.111111}
27 ));
28 events.push_back(
29 GridControlEvent(GridControlEvent::RefinementControl::Refine, {0.3, -0.0333333}, {0.4, 0.4}, {0.111111, 0.111111})
30 );
31 events.push_back(GridControlEvent(
32 GridControlEvent::RefinementControl::Refine, {0.633333, -0.0333333}, {0.4, 0.4}, {0.111111, 0.111111}
33 ));
34 events.push_back(
35 GridControlEvent(GridControlEvent::RefinementControl::Refine, {0.633333, 0.3}, {0.4, 0.4}, {0.111111, 0.111111})
36 );
37 events.push_back(
38 GridControlEvent(GridControlEvent::RefinementControl::Refine, {0.3, 0.3}, {0.4, 0.4}, {0.111111, 0.111111})
39 );
40 events.push_back(
41 GridControlEvent(GridControlEvent::RefinementControl::Refine, {0.3, 0.633333}, {0.4, 0.4}, {0.111111, 0.111111})
42 );
43 events.push_back(GridControlEvent(
44 GridControlEvent::RefinementControl::Refine, {0.633333, 0.633333}, {0.4, 0.4}, {0.111111, 0.111111}
45 ));
46
47 const double tolerance = 0.1;
48 events = peano4::grid::merge(events, tolerance);
49
50 validateEquals(events.size(), 1);
51 validateWithParams1(tarch::la::equals(events[0].getOffset(), -0.0333333, 0.001), events[0].toString());
52 validateWithParams1(tarch::la::equals(events[0].getWidth(), 1.06667, 0.001), events[0].toString());
53
54#endif
55}
56
58#if Dimensions == 2
59 const double tolerance = 0.1;
60
61 GridControlEvent event0(
62 GridControlEvent::RefinementControl::Refine, {0.316667, 0.316667}, {0.366667, 0.366667}, {0.111111, 0.111111}
63 );
64 GridControlEvent event1(
65 GridControlEvent::RefinementControl::Refine, {0.65, 0.316667}, {0.366667, 0.366667}, {0.111111, 0.111111}
66 );
67 GridControlEvent event2(
68 GridControlEvent::RefinementControl::Refine, {0.65, -0.0166667}, {0.366667, 0.366667}, {0.111111, 0.111111}
69 );
70 GridControlEvent event3(
71 GridControlEvent::RefinementControl::Refine, {0.316667, -0.0166667}, {0.366667, 0.366667}, {0.111111, 0.111111}
72 );
73 GridControlEvent event4(
74 GridControlEvent::RefinementControl::Refine, {-0.0166667, -0.0166667}, {0.366667, 0.366667}, {0.111111, 0.111111}
75 );
76
78 peano4::grid::internal::twoEventsAreAdjacent(event0, event1, tolerance), event0.toString(), event1.toString()
79 );
81 peano4::grid::internal::twoEventsAreAdjacent(event1, event2, tolerance), event1.toString(), event2.toString()
82 );
84 not peano4::grid::internal::twoEventsAreAdjacent(event0, event2, tolerance), event0.toString(), event2.toString()
85 );
86
87 std::vector<GridControlEvent> events;
88 events.push_back(event0);
89 events.push_back(event1);
90 events.push_back(event2);
91 events.push_back(event3);
92 events.push_back(event4);
93
94 events = peano4::grid::merge(events, 0.1);
95
96 validate(events.size() > 1);
97#endif
98}
99
101#if Dimensions == 2
102 std::vector<GridControlEvent> events;
103
104 events.push_back(GridControlEvent(
105 GridControlEvent::RefinementControl::Refine, {0.65, 0.65}, {0.366667, 0.366667}, {0.111111, 0.111111}
106 ));
107 events.push_back(GridControlEvent(
108 GridControlEvent::RefinementControl::Refine, {0.883333, 0.883333}, {0.122222, 0.122222}, {0.037037, 0.037037}
109 ));
110
111 events = peano4::grid::merge(events, 0.4);
112
113 validateEquals(events.size(), 2);
114#endif
115}
116
117// Der erste Fehler ist, dass der Merge in 3d net geht
118// Der zweite Fehler ist, dass offensichtlich Merge Events nicht ausgetauscht werden oder nicht lange genug ueberleben
119
121#if Dimensions == 3
122 std::list<GridControlEvent> events;
123
124 events.push_back(GridControlEvent(
126 {-0.0611111, 0.05, 0.272222},
127 {0.122222, 0.122222, 0.122222},
128 {0.037037, 0.037037, 0.037037}
129 ));
130 events.push_back(GridControlEvent(
132 {-0.172222, -0.0611111, 0.272222},
133 {0.122222, 0.233333, 0.122222},
134 {0.037037, 0.037037, 0.037037}
135 ));
136 events.push_back(GridControlEvent(
138 {-0.172222, -0.0611111, 0.383333},
139 {0.122222, 0.455556, 0.122222},
140 {0.037037, 0.037037, 0.037037}
141 ));
142 events.push_back(GridControlEvent(
144 {-0.172222, 0.161111, 0.272222},
145 {0.233333, 0.233333, 0.122222},
146 {0.037037, 0.037037, 0.037037}
147 ));
148 events.push_back(GridControlEvent(
150 {-0.505556, 0.383333, 0.383333},
151 {0.455556, 0.122222, 0.122222},
152 {0.037037, 0.037037, 0.037037}
153 ));
154 events.push_back(GridControlEvent(
156 {-0.0611111, 0.05, 0.383333},
157 {0.122222, 0.455556, 0.122222},
158 {0.037037, 0.037037, 0.037037}
159 ));
160 events.push_back(GridControlEvent(
162 {-0.505556, 0.383333, 0.272222},
163 {0.566667, 0.122222, 0.122222},
164 {0.037037, 0.037037, 0.037037}
165 ));
166 events.push_back(GridControlEvent(
168 {-0.0611111, -0.0611111, 0.272222},
169 {0.566667, 0.122222, 0.233333},
170 {0.037037, 0.037037, 0.037037}
171 ));
172 events.push_back(GridControlEvent(
174 {-0.505556, -0.0611111, 0.272222},
175 {0.344444, 0.455556, 0.233333},
176 {0.037037, 0.037037, 0.037037}
177 ));
178 events.push_back(GridControlEvent(
180 {0.272222, -0.505556, 0.272222},
181 {0.233333, 0.455556, 0.233333},
182 {0.037037, 0.037037, 0.037037}
183 ));
184
186
187 validateEqualsWithParams1(events.size(), 10, peano4::grid::toString(events));
188
189 std::list<GridControlEvent>::const_iterator p = events.begin();
190 validateNumericalEqualsWithParams1(p->getOffset(0), -0.505556, peano4::grid::toString(events));
191 p++;
192 validateNumericalEqualsWithParams1(p->getOffset(0), -0.505556, peano4::grid::toString(events));
193#endif
194}
195
197 testMethod(testMerge1);
198 testMethod(testMerge2);
199 testMethod(testMerge3);
200 testMethod(testSortWithinMerge);
201}
202
203#ifdef UseTestSpecificCompilerSettings
204#pragma optimize("", on)
205#endif
#define validateEqualsWithParams1(actualValue, validValue, param0)
Definition TestMacros.h:318
#define validate(booleanExpr)
Definition TestMacros.h:37
#define testMethod(name)
Run a test method and check for errors.
Definition TestMacros.h:24
#define validateWithParams2(booleanExpr, param0, param1)
Definition TestMacros.h:69
#define validateNumericalEqualsWithParams1(actualValue, validValue, param0)
Definition TestMacros.h:461
#define validateWithParams1(booleanExpr, param0)
Definition TestMacros.h:59
#define validateEquals(actualValue, validValue)
Definition TestMacros.h:299
void testSortWithinMerge()
For this 3d test, I use the following setup which arises from our infall tests:
void testMerge2()
From another debugging session:
static tarch::logging::Log _log
Logging device.
virtual void run() override
This routine is triggered by the TestCaseCollection.
Log Device.
Definition Log.h:516
bool twoEventsAreAdjacent(const peano4::grid::GridControlEvent &lhs, const peano4::grid::GridControlEvent &rhs, double Tolerance)
Are two events adjacent.
Definition grid.cpp:369
void sort(std::list< peano4::grid::GridControlEvent > &events)
Sort grid control events geometrically.
Definition grid.cpp:151
std::string toString(VertexType type)
Definition grid.cpp:277
std::vector< GridControlEvent > merge(std::vector< GridControlEvent > events, const double Tolerance=0.1)
Merge set of refinement/coarsening commands.
Definition grid.cpp:113
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.