Peano
Loading...
Searching...
No Matches
NodeTest.cpp
Go to the documentation of this file.
1#include "NodeTest.h"
2#include "../Node.h"
3
4#include "tarch/la/Vector.h"
5
7
8
9
10tarch::logging::Log peano4::parallel::tests::NodeTest::_log("peano4::parallel::tests::NodeTest");
11
12
13#ifdef UseTestSpecificCompilerSettings
14#pragma optimize("",off)
15#endif
16
17
19 TestCase( "peano4::parallel::tests::NodeTest" ) {
20}
21
22
36
37
39 #if Dimensions==2
40 //
41 // Top right corner
42 //
44 flagsTopRightVertex(0) = 0;
45
46 std::set< peano4::parallel::Node::PeriodicBoundaryStackIdentifier > resultTopRightVertex = peano4::parallel::Node::getOutputStacksForPeriodicBoundaryExchange(flagsTopRightVertex);
47 validateEqualsWithParams1( resultTopRightVertex.size(), 3, flagsTopRightVertex );
48
52
53 std::stringstream resultContentTopRightVertex;
54 for (auto& p: resultTopRightVertex) {
55 resultContentTopRightVertex << "(" << p.first << "," << std::bitset<2*Dimensions>(p.second) << ")";
56 }
57 validateWithParams3( resultTopRightVertex.count(key0)==1, key0.first, key0.second, resultContentTopRightVertex.str() );
58 validateWithParams3( resultTopRightVertex.count(key1)==1, key1.first, key1.second, resultContentTopRightVertex.str() );
59 validateWithParams3( resultTopRightVertex.count(key2)==1, key2.first, key2.second, resultContentTopRightVertex.str() );
60
64
65 //
66 // bottom left vertex
67 //
69 flagsBottomLeftVertex(3) = 0;
70
71 std::set< peano4::parallel::Node::PeriodicBoundaryStackIdentifier > resultBottomLeftVertex = peano4::parallel::Node::getOutputStacksForPeriodicBoundaryExchange(flagsBottomLeftVertex);
72 validateEqualsWithParams1( resultBottomLeftVertex.size(), 3, flagsBottomLeftVertex );
73
77
78 std::stringstream resultContentBottomLeftVertex;
79 for (auto& p: resultBottomLeftVertex) {
80 resultContentBottomLeftVertex << "(" << p.first << "," << std::bitset<2*Dimensions>(p.second) << ")";
81 }
82 validateWithParams3( resultBottomLeftVertex.count(key3)==1, key3.first, key3.second, resultContentBottomLeftVertex.str() );
83 validateWithParams3( resultBottomLeftVertex.count(key4)==1, key4.first, key4.second, resultContentBottomLeftVertex.str() );
84 validateWithParams3( resultBottomLeftVertex.count(key5)==1, key5.first, key5.second, resultContentBottomLeftVertex.str() );
85
89
93
97
98 //
99 // Third step
100 //
107 #endif
108 #if Dimensions==3
110 flags(0) = 0;
111
112 std::set< peano4::parallel::Node::PeriodicBoundaryStackIdentifier > result = peano4::parallel::Node::getOutputStacksForPeriodicBoundaryExchange(flags);
113 validateEqualsWithParams3( result.size(), 7, flags, peano4::parallel::Node::toString(result), "expected output={(stack=9,bnd=111),(stack=10,bnd=110),(stack=12,bnd=101),(stack=13,bnd=100),(stack=18,bnd=011),(stack=19,bnd=010),(stack=21,bnd=001)}" );
114 #endif
115}
116
117
128
129
131 logTraceIn( "run()" );
132 testMethod( testGetPeriodicBoundaryNumber );
133 testMethod( testTagCalculation );
134 testMethod( testGetOutputStacksForPeriodicBoundaryExchange )
135 logTraceOut( "run()" );
136}
137
138
139#ifdef UseTestSpecificCompilerSettings
140#pragma optimize("",on)
141#endif
#define logTraceOut(methodName)
Definition Log.h:379
#define logTraceIn(methodName)
Definition Log.h:369
#define validateEqualsWithParams3(actualValue, validValue, param0, param1, param2)
Definition TestMacros.h:339
#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 validateWithParams6(booleanExpr, param0, param1, param2, param3, param4, param5)
Definition TestMacros.h:119
#define validateWithParams3(booleanExpr, param0, param1, param2)
Definition TestMacros.h:80
#define validateEqualsWithParams2(actualValue, validValue, param0, param1)
Definition TestMacros.h:328
#define validateEquals(actualValue, validValue)
Definition TestMacros.h:299
static constexpr int RankOfPeriodicBoundaryCondition
Periodic boundary conditions are technically realised as domain decomposition, i.e.
Definition Spacetree.h:54
static std::bitset< 2 *Dimensions > getPeriodicBoundaryNumber(const tarch::la::Vector< TwoPowerD, int > &flags)
Analyse to which of the 2d faces it is adjacent.
Definition Node.cpp:231
static bool isPeriodicBoundaryExchangeOutputStackNumber(int number)
Definition Node.cpp:377
static constexpr int MaxSpacetreesPerRank
Definition Node.h:39
int getLocalTreeId(int treeId) const
Definition Node.cpp:125
static int mapPeriodicBoundaryExchangeOutputStackOntoInputStack(int outputStack)
Definition Node.cpp:203
std::pair< int, int > PeriodicBoundaryStackIdentifier
A periodic boundary stack is basically a stack (an integer), but I do augment it by a bitset which id...
Definition Node.h:216
std::pair< int, MPI_Comm > GridDataExchangeMetaInformation
Definition Node.h:382
static std::string toString(const std::set< PeriodicBoundaryStackIdentifier > &data)
Definition Node.cpp:262
static std::set< PeriodicBoundaryStackIdentifier > getOutputStacksForPeriodicBoundaryExchange(const tarch::la::Vector< TwoPowerD, int > &flags)
You hand in a the flags of a vertex and you get the boundary stack identifiers including their direct...
Definition Node.cpp:282
static constexpr int StacksPerCommunicationPartner
We need one stack for outgoing data, one for incoming data, and we distinguish horizontal and vertica...
Definition Node.h:62
static int getPeriodicBoundaryExchangeInputStackNumberForOutputStack(int outputStackNumber)
Hand in an output stack number of a face and you get back the input stack number.
Definition Node.cpp:355
GridDataExchangeMetaInformation getGridDataExchangeMetaInformation(int sendingTreeId, int receivingTreeId, ExchangeMode exchange) const
I use two tags per spacetree per rank: one for boundary data (horizontal) and one for up-down and syn...
Definition Node.cpp:476
static Node & getInstance()
This operation returns the singleton instance.
Definition Node.cpp:108
void testGetOutputStacksForPeriodicBoundaryExchange()
Boundary data exchange test case.
Definition NodeTest.cpp:38
static tarch::logging::Log _log
Logging device.
Definition NodeTest.h:26
virtual void run() override
This routine is triggered by the TestCaseCollection.
Definition NodeTest.cpp:130
Log Device.
Definition Log.h:516
static Rank & getInstance()
This operation returns the singleton instance.
Definition Rank.cpp:539
Simple vector class.
Definition Vector.h:150