Peano 4
Loading...
Searching...
No Matches
CopyPatchTest.cpp
Go to the documentation of this file.
1// This file is part of the ExaHyPE2 project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#include "CopyPatchTest.h"
4
5#include <vector>
6
7#include "peano4/utils/Loop.h"
9
11 TestCase("exahype2::fv::rusanov::tests::CopyPatchTest") {}
12
14
16 constexpr int NumberOfUnknowns = 5;
17 constexpr int NumberOfAuxiliaryVariables = 2;
18 constexpr int NumberOfVolumesPerAxisInPatch = 17;
19 constexpr int HaloSize = 1;
20 double* QinWithHalo = nullptr;
21 double* QOutWithoutHalo = nullptr;
22 std::vector<int> source{}, dest{}, source2{}, dest2{};
23
24 dfor(k, NumberOfVolumesPerAxisInPatch) {
26 int tmpSourceSerialised = peano4::utils::dLinearised(tmpSource, NumberOfVolumesPerAxisInPatch + HaloSize * 2);
27 int tmpDestinationSerialised = peano4::utils::dLinearised(k, NumberOfVolumesPerAxisInPatch);
28 source.push_back(tmpSourceSerialised);
29 dest.push_back(tmpDestinationSerialised);
30 }
31
32#if Dimensions == 2
33 constexpr int SourceSerialised = NumberOfVolumesPerAxisInPatch + 3 * HaloSize;
34 constexpr int Offset = NumberOfVolumesPerAxisInPatch;
35 for (int y = 0; y < NumberOfVolumesPerAxisInPatch; y++) {
36 for (int x = 0; x < NumberOfVolumesPerAxisInPatch; x++) {
37 source2.push_back((y + 1) * (Offset + 3 * HaloSize) + x - y);
38 dest2.push_back(y * Offset + x);
39 }
40 }
41#else
42 constexpr int Offset = NumberOfVolumesPerAxisInPatch;
43 constexpr int Offset2 = (NumberOfVolumesPerAxisInPatch + HaloSize * 2) * (NumberOfVolumesPerAxisInPatch + HaloSize * 2) + NumberOfVolumesPerAxisInPatch + HaloSize * 2 + HaloSize;
44 constexpr int Offset3 = NumberOfVolumesPerAxisInPatch + HaloSize * 2;
45 for (int z = 0; z < NumberOfVolumesPerAxisInPatch; z++) {
46 for (int y = 0; y < NumberOfVolumesPerAxisInPatch; y++) {
47 for (int x = 0; x < NumberOfVolumesPerAxisInPatch; x++) {
48 int mydest = z * Offset * Offset + y * Offset + x;
49 int mysrc = z * Offset3 * Offset3 + y * Offset3 + x + Offset2;
50 source2.push_back(mysrc);
51 dest2.push_back(mydest);
52 }
53 }
54 }
55#endif
56
57 for (std::size_t idx = 0; idx < source.size(); idx++) {
58 validateEquals(source[idx], source2[idx]);
59 }
60
61 for (std::size_t idx = 0; idx < dest.size(); idx++) {
62 validateEquals(dest[idx], dest2[idx]);
63 }
64}
we integrate over each cell and then take the sum across each of the cells We also consider the terms that enter the f$ k
static constexpr int HaloSize
#define dfor(counter, max)
d-dimensional Loop
Definition Loop.h:308
#define testMethod(name)
Run a test method and check for errors.
Definition TestMacros.h:24
#define validateEquals(actualValue, validValue)
Definition TestMacros.h:299
virtual void run() override
This routine is triggered by the TestCaseCollection.
CPUGPUMethod int dLinearised(const tarch::la::Vector< Dimensions, int > &counter, int max)
Map d-dimensional vector onto integer index.
Definition Loop.cpp:106
Simple vector class.
Definition Vector.h:134