Peano
Loading...
Searching...
No Matches
IandRSecondOrderTest.cpp
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
4
5#include "../Interpolation.h"
6#include "../Restriction.h"
7
9 TestCase("toolbox::blockstructured::tests::IandRSecondOrderTest") {}
10
12 testMethod(compareInterpolateLinearCaseToTensorProduct);
13 testMethod(compareRestrictLinearCaseToTensorProduct);
14}
15
17 const double normalInterp[] = {
18 0.0000, 0.3333, 0.6667, 0.0000, 0.0000, 0.0000,
19 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000,
20 0.0000, 0.0000, 0.6667, 0.3333, 0.0000, 0.0000
21 };
22
23 const double tangentInterp[] = {
24 1.3333, -0.3333, 0.0000, 0.0000, 0.0000,
25 1.0000, 0.0000, 0.0000, 0.0000, 0.0000,
26 0.6667, 0.3333, 0.0000, 0.0000, 0.0000,
27 0.3333, 0.6667, 0.0000, 0.0000, 0.0000,
28 0.0000, 1.0000, 0.0000, 0.0000, 0.0000,
29 0.0000, 0.6667, 0.3333, 0.0000, 0.0000,
30 0.0000, 0.3333, 0.6667, 0.0000, 0.0000,
31 0.0000, 0.0000, 1.0000, 0.0000, 0.0000,
32 0.0000, 0.0000, 0.6667, 0.3333, 0.0000,
33 0.0000, 0.0000, 0.3333, 0.6667, 0.0000,
34 0.0000, 0.0000, 0.0000, 1.0000, 0.0000,
35 0.0000, 0.0000, 0.0000, 0.6667, 0.3333,
36 0.0000, 0.0000, 0.0000, 0.3333, 0.6667,
37 0.0000, 0.0000, 0.0000, 0.0000, 1.0000,
38 0.0000, 0.0000, 0.0000, -0.3333, 1.3333
39 };
40
41 constexpr int patchSize = 5;
42 constexpr int overlap = 3;
43 constexpr int unknowns = 59;
44 const int faceSize = unknowns * patchSize * patchSize * overlap * 2;
45
46 double coarseData[faceSize];
47 double fineDataTensorProduct[faceSize];
48 double fineDataSecondOrder[faceSize];
49
50 for (int i = 0; i < 3; i++) {
51 for (int j = 0; j < 3; j++) {
52 for (int k = 0; k < 3; k++) {
56 );
57
58 for (int axis = 0; axis < 3; axis++) {
59 peano4::datamanagement::FaceMarker faceMarker1(dummyEvent, axis);
61 faceMarker2(dummyEvent, axis + Dimensions);
62
63 for (int n = 0; n < faceSize; n++)
64 coarseData[n] = static_cast<double>(n + 1) / 16.0;
65 for (int n = 0; n < faceSize; n++)
66 fineDataTensorProduct[n] = 0;
67 for (int n = 0; n < faceSize; n++)
68 fineDataSecondOrder[n] = 0;
69
71 faceMarker1,
72 patchSize,
73 overlap,
74 unknowns,
75 normalInterp,
76 tangentInterp,
77 coarseData,
78 fineDataTensorProduct
79 );
81 faceMarker1,
82 patchSize,
83 overlap,
84 unknowns,
85 coarseData,
86 fineDataSecondOrder
87 );
88 for (int n = 0; n < faceSize; n++)
90 fineDataTensorProduct[n],
91 fineDataSecondOrder[n],
92 0.01,
94 axis,
95 n
96 );
97
98 for (int n = 0; n < faceSize; n++)
99 fineDataTensorProduct[n] = 0;
100 for (int n = 0; n < faceSize; n++)
101 fineDataSecondOrder[n] = 0;
102
104 faceMarker2,
105 patchSize,
106 overlap,
107 unknowns,
108 normalInterp,
109 tangentInterp,
110 coarseData,
111 fineDataTensorProduct
112 );
114 faceMarker2,
115 patchSize,
116 overlap,
117 unknowns,
118 coarseData,
119 fineDataSecondOrder
120 );
121 for (int n = 0; n < faceSize; n++)
123 fineDataTensorProduct[n],
124 fineDataSecondOrder[n],
125 0.01,
127 axis + 3,
128 n
129 );
130 }
131 }
132 }
133 }
134}
135
137 const double normalRestrict[] = {
138 0.0000, 0.0000, 0.0000, 0.333333, 0.333333, 0.333333,
139 0.0000, 0.0000, 0.0000, 0.0000, -2.0000, 3.0000,
140 0.0000, 0.0000, 0.0000, 0.0000, -5.0000, 6.0000
141 };
142
143 const double tangentRestrict[] = {
144 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
145 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
146 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
147 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000,
148 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000
149 };
150
151 constexpr int patchSize = 5;
152 constexpr int overlap = 3;
153 constexpr int unknowns = 59;
154 const int faceSize = unknowns * patchSize * patchSize * overlap * 2;
155
156 double fineData[faceSize];
157 double coarseDataTensorProduct[faceSize];
158 double coarseDataSecondOrder[faceSize];
159
160 for (int i = 0; i < 3; i++) {
161 for (int j = 0; j < 3; j++) {
162 for (int k = 0; k < 3; k++) {
166 );
167
168 for (int axis = 0; axis < 3; axis++) {
169 peano4::datamanagement::FaceMarker faceMarker1(dummyEvent, axis);
171 faceMarker2(dummyEvent, axis + Dimensions);
172
173 for (int n = 0; n < faceSize; n++)
174 fineData[n] = static_cast<double>(n + 1) / 16.0;
175 for (int n = 0; n < faceSize; n++)
176 coarseDataTensorProduct[n] = 0;
177 for (int n = 0; n < faceSize; n++)
178 coarseDataSecondOrder[n] = 0;
179
181 faceMarker1,
182 patchSize,
183 overlap,
184 unknowns,
185 normalRestrict,
186 tangentRestrict,
187 fineData,
188 coarseDataTensorProduct
189 );
191 faceMarker1,
192 patchSize,
193 overlap,
194 unknowns,
195 fineData,
196 coarseDataSecondOrder
197 );
198 for (int n = 0; n < faceSize; n++)
200 coarseDataTensorProduct[n],
201 coarseDataSecondOrder[n],
202 0.01,
204 axis,
205 n
206 );
207
208 for (int n = 0; n < faceSize; n++)
209 coarseDataTensorProduct[n] = 0;
210 for (int n = 0; n < faceSize; n++)
211 coarseDataSecondOrder[n] = 0;
212
214 faceMarker2,
215 patchSize,
216 overlap,
217 unknowns,
218 normalRestrict,
219 tangentRestrict,
220 fineData,
221 coarseDataTensorProduct
222 );
224 faceMarker2,
225 patchSize,
226 overlap,
227 unknowns,
228 fineData,
229 coarseDataSecondOrder
230 );
231 for (int n = 0; n < faceSize; n++)
233 coarseDataTensorProduct[n],
234 coarseDataSecondOrder[n],
235 0.01,
237 axis + 3,
238 n
239 );
240 }
241 }
242 }
243 }
244}
#define testMethod(name)
Run a test method and check for errors.
Definition TestMacros.h:24
#define validateNumericalEqualsWithEpsWithParams3(actualValue, validValue, eps, param0, param1, param2)
Definition TestMacros.h:473
void compareInterpolateLinearCaseToTensorProduct()
The second order interpolation and restriction scheme is tested by comparing the results to the tenso...
virtual void run() override
This routine is triggered by the TestCaseCollection.
void interpolateHaloLayer_AoS_tensor_product(const peano4::datamanagement::FaceMarker &marker, int numberOfDoFsPerAxisInPatch, int overlap, int unknowns, const double *__restrict__ coarseGridFaceValues, double *__restrict__ fineGridFaceValues)
This is a wrapper around the toolbox routines.
void restrictHaloLayer_AoS_tensor_product(const peano4::datamanagement::FaceMarker &marker, int numberOfDoFsPerAxisInPatch, int overlap, int unknowns, double *fineGridValues, double *coarseGridValues)
void interpolateHaloLayer_AoS_second_order(const peano4::datamanagement::FaceMarker &marker, int numberOfDoFsPerAxisInPatch, int overlap, int unknowns, const double *__restrict__ coarseGridCellValues, const double *__restrict__ coarseGridFaceValues, double *__restrict__ fineGridFaceValues)
void restrictHaloLayer_AoS_second_order(const peano4::datamanagement::FaceMarker &marker, int numberOfDoFsPerAxisInPatch, int overlap, int unknowns, double *fineGridValues, double *coarseGridValues)
Provide information about selected face.
Definition FaceMarker.h:35
tarch::la::Vector< Dimensions-1, int > getRelativePositionWithinFatherFace() const
Return relative position of a subface within its father face.
void setRelativePositionToFather(const tarch::la::Vector< Dimensions, int > &value)
Simple vector class.
Definition Vector.h:150