From 2f22e64953cd5e4a383bf8b91f09d511f6aec526 Mon Sep 17 00:00:00 2001
From: hiwis <hiwis@irmb.tu-bs.de>
Date: Wed, 17 Apr 2019 10:09:10 +0200
Subject: [PATCH] correctedStreet double street, refactored TrafficTimestep

---
 src/Traffic/GPU/TrafficTimestep.cu            |  57 +--
 src/Traffic/GPU/TrafficTimestep.h             |  23 +-
 src/Traffic/TrafficMovement.cpp               |   4 +-
 .../Basel/resources/allStreets/Streets.txt    |   8 +-
 .../allStreetsQuadruple/Junctions.txt         | 122 +++++
 .../resources/allStreetsQuadruple/Sinks.txt   |  77 +++
 .../resources/allStreetsQuadruple/Sources.txt |  77 +++
 .../resources/allStreetsQuadruple/Streets.txt | 481 ++++++++++++++++++
 targets/apps/LBM/TrafficTest/Traffic_Main.cpp |  61 +--
 9 files changed, 835 insertions(+), 75 deletions(-)
 create mode 100644 targets/apps/LBM/Basel/resources/allStreetsQuadruple/Junctions.txt
 create mode 100644 targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sinks.txt
 create mode 100644 targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sources.txt
 create mode 100644 targets/apps/LBM/Basel/resources/allStreetsQuadruple/Streets.txt

diff --git a/src/Traffic/GPU/TrafficTimestep.cu b/src/Traffic/GPU/TrafficTimestep.cu
index 8eab929ca..8f8f3ca44 100644
--- a/src/Traffic/GPU/TrafficTimestep.cu
+++ b/src/Traffic/GPU/TrafficTimestep.cu
@@ -73,8 +73,6 @@ TrafficTimestep::TrafficTimestep(std::shared_ptr<RoadNetworkData> road, real * p
 	this->roadNext.resize(size_roads);
 	thrust::fill(roadNext.begin(), roadNext.end(), -1);
 
-	switchCurrentNext();
-
 	//prepare junctions
 	combineJuncInCellIndices(road->junctions);
 	combineJuncOutCellIndices(road->junctions);
@@ -122,13 +120,16 @@ TrafficTimestep::TrafficTimestep(std::shared_ptr<RoadNetworkData> road, real * p
 }
 
 
-void TrafficTimestep::run(std::shared_ptr<RoadNetworkData> road)
+void TrafficTimestep::calculateTimestep(std::shared_ptr<RoadNetworkData> road)
 {
 	switchCurrentNext();
 
 	//reset Junction open outcells
 	resetOutCellIsOpen();
 
+	//resetNext
+	resetNext();
+
 	callTrafficTimestepKernel();
 	getLastCudaError("trafficTimestepKernel execution failed");
 
@@ -144,8 +145,16 @@ void TrafficTimestep::run(std::shared_ptr<RoadNetworkData> road)
 
 void TrafficTimestep::switchCurrentNext()
 {
-	if (timestepIsEven) timestepIsEven = false;
-	else timestepIsEven = true;
+	if (timestepIsEven) {
+		timestepIsEven = false;
+		pRoadCurrent = roadCurrent.data().get();
+		pRoadNext = roadNext.data().get();
+	}
+	else {
+		timestepIsEven = true;
+		pRoadCurrent = roadNext.data().get();
+		pRoadNext = roadCurrent.data().get();
+	}
 }
 
 
@@ -168,18 +177,6 @@ void TrafficTimestep::cleanUp()
 
 void TrafficTimestep::callTrafficTimestepKernel()
 {
-	int* pRoadCurrent = roadCurrent.data().get();
-	int* pRoadNext = roadNext.data().get();
-	if (!timestepIsEven) {
-		pRoadCurrent = roadNext.data().get();
-		pRoadNext = roadCurrent.data().get();
-	}
-
-	resetNext << < gridRoad, threadsRoads >> > (
-		pRoadNext,
-		size_roads
-		);
-
 	trafficTimestepKernel << < gridRoad, threadsRoads >> > (
 		pRoadCurrent,
 		pRoadNext,
@@ -205,13 +202,6 @@ void TrafficTimestep::callTrafficTimestepKernel()
 
 void TrafficTimestep::callSourceTimestepKernel()
 {
-	int*pRoadCurrent = roadCurrent.data().get();
-	int*pRoadNext = roadNext.data().get();
-	if (!timestepIsEven) {
-		pRoadCurrent = roadNext.data().get();
-		pRoadNext = roadCurrent.data().get();
-	}
-
 	sourceTimestepKernel << < gridSources, threadsSources >> > (
 		pRoadCurrent,
 		pRoadNext,
@@ -229,13 +219,6 @@ void TrafficTimestep::callSourceTimestepKernel()
 
 void TrafficTimestep::callJunctionTimestepKernel()
 {
-	int*pRoadCurrent = roadCurrent.data().get();
-	int*pRoadNext = roadNext.data().get();
-	if (!timestepIsEven) {
-		pRoadCurrent = roadNext.data().get();
-		pRoadNext = roadCurrent.data().get();
-	}
-
 	junctionTimestepKernel << < gridJunctions, threadsJunctions >> > (
 		juncCarsOnJunction.data().get(),
 		juncInCellIndices.data().get(),
@@ -319,7 +302,7 @@ __global__ void trafficTimestepKernel(int* roadCurrent, int* roadNext, int* neig
 	uint gap = speed;
 	uint idx = 0;
 	int neighbor = neighbors[index];
-	uint currentCell = index;	
+	uint currentCell = index;
 
 	for (uint i = 0; i < (speed + safetyDistance); i++) {
 
@@ -510,7 +493,7 @@ __global__ void junctionTimestepKernel(int* juncCarsOnJunction, uint* juncInCell
 				//// calc numberOfPossibleOutCells ////////////////////////////////////////////////////////////////
 				uint numberOfPossibleOutCells = 0;
 
-				for (uint outCellIndex = firstOutCellIndex; outCellIndex < firstOutCellIndex + outCellSize; outCellIndex++) 
+				for (uint outCellIndex = firstOutCellIndex; outCellIndex < firstOutCellIndex + outCellSize; outCellIndex++)
 					if (juncCarCanNotEnterThisOutCell[inCellVectorIndex] != juncOutCellIndices[outCellIndex] && juncOutCellIsOpen[outCellIndex] == true)
 						numberOfPossibleOutCells++;
 
@@ -820,6 +803,14 @@ void TrafficTimestep::resetOutCellIsOpen()
 	thrust::fill(juncOutCellIsOpen.begin(), juncOutCellIsOpen.end(), true);
 }
 
+void TrafficTimestep::resetNext()
+{
+	if (timestepIsEven)
+		thrust::fill(roadCurrent.begin(), roadCurrent.end(), -1);
+	else
+		thrust::fill(roadNext.begin(), roadNext.end(), -1);
+}
+
 
 void TrafficTimestep::calculateTrafficTimestepKernelDimensions()
 {
diff --git a/src/Traffic/GPU/TrafficTimestep.h b/src/Traffic/GPU/TrafficTimestep.h
index be05d404d..b547690ed 100644
--- a/src/Traffic/GPU/TrafficTimestep.h
+++ b/src/Traffic/GPU/TrafficTimestep.h
@@ -19,10 +19,11 @@ class Source;
 class VF_PUBLIC TrafficTimestep
 {
 private:
+
 	bool timestepIsEven = true;
 	uint numTimestep = 0;
 
-	uint size_roads;
+
 	uint maxVelocity;
 	uint safetyDistance;
 	real dawdlePossibility;
@@ -32,6 +33,7 @@ private:
 
 
 	//sizes
+	uint size_roads;
 	uint size_junctions;
 	uint size_juncInCells;
 	uint size_juncOutCells;
@@ -69,6 +71,7 @@ private:
 	thrust::device_vector<uint> juncStartInIncells;
 	thrust::device_vector<uint> juncStartInOutcells;
 
+
 	//sinks
 	thrust::device_vector<real> sinkCarBlockedPossibilities;;
 
@@ -81,47 +84,55 @@ private:
 	//concentrations
 	real * pConcArray;
 
+
 	//curandStates
 	curandState *statesJunctions;
 	curandState *statesSources;
 	curandState *statesRoad;
 
+	int* pRoadCurrent;
+	int* pRoadNext;
 
 public:
 
 	TrafficTimestep(std::shared_ptr<RoadNetworkData> road, real * pConcArray);
-	void run(std::shared_ptr<RoadNetworkData> road);
+	void calculateTimestep(std::shared_ptr<RoadNetworkData> road);
 	void cleanUp();
 	uint getNumCarsOnJunctions(); //only used for debugging
 	void copyCurrentDeviceToHost(std::shared_ptr<RoadNetworkData> road);
 
 private:
-	;
+	
 	//timestep
 	void switchCurrentNext();
 	void resetOutCellIsOpen();
+	void resetNext();
 
+	//kernel calls
 	void callTrafficTimestepKernel();
 	void callSourceTimestepKernel();
 	void callJunctionTimestepKernel();
 
-	//init
+	//init grids
 	void calculateTrafficTimestepKernelDimensions();
 	void calculateJunctionKernelDimensions();
 	void calculateSourceKernelDimensions();
 
+	//init junctions
 	void combineJuncInCellIndices(std::vector<std::shared_ptr<Junction> > &junctions);
 	void combineJuncOutCellIndices(std::vector<std::shared_ptr<Junction> > &junctions);
 	void combineJuncCarCanNotEnterThisOutCell(std::vector<std::shared_ptr<Junction> > &junctions);
+	void combineUseTrafficLights(std::vector<std::shared_ptr<Junction>>& junctions);
 	void initjuncOutCellIsOpen();
 	void initJuncCarCanEnter();
 	void initJuncCarsOnJunction();
 	void initJuncAlreadyMoved();
 	void initJuncOldSpeeds();
-	void combineUseTrafficLights(std::vector<std::shared_ptr<Junction>>& junctions);
-
+	
+	//init sinks
 	void combineSinkBlockedPossibilities(std::vector<std::shared_ptr<Sink>>& sinks);
 
+	//init sources
 	void combineSourcePossibilities(std::vector<std::shared_ptr<Source> > &sources);
 	void combineSourceIndices(std::vector<std::shared_ptr<Source> > &sources);
 };
diff --git a/src/Traffic/TrafficMovement.cpp b/src/Traffic/TrafficMovement.cpp
index f0d544351..1dd4c6f6c 100644
--- a/src/Traffic/TrafficMovement.cpp
+++ b/src/Traffic/TrafficMovement.cpp
@@ -77,8 +77,6 @@ void TrafficMovement::setUseGPU(real * pConcArray)
 {
 	std::cout << "usingGPU for calculation" << std::endl;
 	this->useGPU = true;
-	this->road->oldSpeeds.resize(this->road->roadLength);
-	VectorHelper::fillVector(this->road->oldSpeeds, -1);
 	this->gpuCalculation = std::make_unique<TrafficTimestep>(TrafficTimestep(this->road, pConcArray));
 }
 
@@ -172,7 +170,7 @@ void TrafficMovement::calculateTimestep(uint step)
 		//GPU
 
 		copiedDevToHost = false;
-		this->gpuCalculation->run(road);
+		this->gpuCalculation->calculateTimestep(road);
 
 
 	}
diff --git a/targets/apps/LBM/Basel/resources/allStreets/Streets.txt b/targets/apps/LBM/Basel/resources/allStreets/Streets.txt
index d982a2b6e..f82c1e9ae 100644
--- a/targets/apps/LBM/Basel/resources/allStreets/Streets.txt
+++ b/targets/apps/LBM/Basel/resources/allStreets/Streets.txt
@@ -101,9 +101,9 @@
   256  -194   244  -192  1
   227  -256   243  -196  1
   238  -195   222  -256  1
-  244  -192   251   -93  1
+  244  -192   250   -93  1
   244   -92   239  -191  1
-  251   -88   223     0  1
+  250   -88   223     0  1
   218     0   244   -87  1
   244   -87   177   -79  1
   177   -79    73   -68  1
@@ -117,8 +117,8 @@
    68   -67  -105   -48  1
  -241  -188  -256  -177  1
  -256  -184  -246  -191  1
-  251   -93   256   -94  1
-  256   -89   251   -88  1
+  250   -93   256   -94  1
+  256   -89   250   -88  1
   
     
   
diff --git a/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Junctions.txt b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Junctions.txt
new file mode 100644
index 000000000..4193493b7
--- /dev/null
+++ b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Junctions.txt
@@ -0,0 +1,122 @@
+120	
+in	40	14	4			out	56	5	15			t	43	
+in	41	56	37			out	42	40	39	
+in	49	35	39	45		out	48	34	37	57	
+in	47	57	44			out	46	45	43	
+in	33	15	3			out	31	4	16			t	45	
+in	42	31	32			out	41	33	29	
+in	34	28	29	38		out	35	32	30	36	
+in	30	27				out	28	26				c	
+in	16	12	18	2		out	3	21	6	13		t	54	
+in	26	112	13	1		out	27	113	2	19		t	31	
+in	104	19	0			out	105	1	20			t	35	
+in	115	21	11			out	114	12	22			t	42	
+in	113	93	114	107		out	112	92	115	111	
+in	108	106	111			out	110	107	109	
+in	105	102	109	119		out	104	103	106	118	
+in	22	10	63	89		out	11	23	62	86		t	57	
+in	84	86	88			out	85	89	87	
+in	92	82	87	91		out	93	83	88	90	
+in	110	95	90	97		out	108	94	91	96	
+in	103	100	96	99		out	102	101	97	98	
+in	74	23	9			out	75	10	24			t	52	
+in	85	77	75	79		out	84	76	74	78	
+in	83	78	81			out	82	79	80	
+in	69	24	8			out	68	25	9			t	50	
+in	55	53	50			out	54	51	52	
+in	52	59	17	6		out	50	58	7	18		t	30	
+in	58	65	61	62		out	59	64	60	63	
+in	66	72	71	68		out	67	73	69	70	
+in	64	67				out	65	66				c	
+in	117	70				out	116	71				c	
+in	160	134	124			out	176	125	135			t	63	
+in	161	176	157			out	162	160	159	
+in	169	155	159	165		out	168	154	157	177	
+in	167	177	164			out	166	165	163	
+in	153	135	123			out	151	124	136			t	65	
+in	162	151	152			out	161	153	149	
+in	154	148	149	158		out	155	152	150	156	
+in	150	147				out	148	146				c	
+in	136	132	138	122		out	123	141	126	133		t	74	
+in	146	232	133	121		out	147	233	122	139		t	51	
+in	224	139	120			out	225	121	140			t	55	
+in	235	141	131			out	234	132	142			t	62	
+in	233	213	234	227		out	232	212	235	231	
+in	228	226	231			out	230	227	229	
+in	225	222	229	239		out	224	223	226	238	
+in	142	130	183	209		out	131	143	182	206		t	77	
+in	204	206	208			out	205	209	207	
+in	212	202	207	211		out	213	203	208	210	
+in	230	215	210	217		out	228	214	211	216	
+in	223	220	216	219		out	222	221	217	218	
+in	194	143	129			out	195	130	144			t	72	
+in	205	197	195	199		out	204	196	194	198	
+in	203	198	201			out	202	199	200	
+in	189	144	128			out	188	145	129			t	70	
+in	175	173	170			out	174	171	172	
+in	172	179	137	126		out	170	178	127	138		t	50	
+in	178	185	181	182		out	179	184	180	183	
+in	186	192	191	188		out	187	193	189	190	
+in	184	187				out	185	186				c	
+in	237	190				out	236	191				c
+in	280	254	244			out	296	245	255			t	283	
+in	281	296	277			out	282	280	279	
+in	289	275	279	285		out	288	274	277	297	
+in	287	297	284			out	286	285	283	
+in	273	255	243			out	271	244	256			t	285	
+in	282	271	272			out	281	273	269	
+in	274	268	269	278		out	275	272	270	276	
+in	270	267				out	268	266				c	
+in	256	252	258	242		out	243	261	246	253		t	294	
+in	266	352	253	241		out	267	353	242	259		t	271	
+in	344	259	240			out	345	241	260			t	275	
+in	355	261	251			out	354	252	262			t	282	
+in	353	333	354	347		out	352	332	355	351	
+in	348	346	351			out	350	347	349	
+in	345	342	349	359		out	344	343	346	358	
+in	262	250	303	329		out	251	263	302	326		t	297	
+in	324	326	328			out	325	329	327	
+in	332	322	327	331		out	333	323	328	330	
+in	350	335	330	337		out	348	334	331	336	
+in	343	340	336	339		out	342	341	337	338	
+in	314	263	249			out	315	250	264			t	292	
+in	325	317	315	319		out	324	316	314	318	
+in	323	318	321			out	322	319	320	
+in	309	264	248			out	308	265	249			t	290	
+in	295	293	290			out	294	291	292	
+in	292	299	257	246		out	290	298	247	258		t	270	
+in	298	305	301	302		out	299	304	300	303	
+in	306	312	311	308		out	307	313	309	310	
+in	304	307				out	305	306				c	
+in	357	310				out	356	311				c	
+in	400	374	364			out	416	365	375			t	403	
+in	401	416	397			out	402	400	399	
+in	409	395	399	405		out	408	394	397	417	
+in	407	417	404			out	406	405	403	
+in	393	375	363			out	391	364	376			t	405	
+in	402	391	392			out	401	393	389	
+in	394	388	389	398		out	395	392	390	396	
+in	390	387				out	388	386				c	
+in	376	372	378	362		out	363	381	366	373		t	414	
+in	386	472	373	361		out	387	473	362	379		t	391	
+in	464	379	360			out	465	361	380			t	395	
+in	475	381	371			out	474	372	382			t	402	
+in	473	453	474	467		out	472	452	475	471	
+in	468	466	471			out	470	467	469	
+in	465	462	469	479		out	464	463	466	478	
+in	382	370	423	449		out	371	383	422	446		t	417	
+in	444	446	448			out	445	449	447	
+in	452	442	447	451		out	453	443	448	450	
+in	470	455	450	457		out	468	454	451	456	
+in	463	460	456	459		out	462	461	457	458	
+in	434	383	369			out	435	370	384			t	412	
+in	445	437	435	439		out	444	436	434	438	
+in	443	438	441			out	442	439	440	
+in	429	384	368			out	428	385	369			t	410	
+in	415	413	410			out	414	411	412	
+in	412	419	377	366		out	410	418	367	378		t	390	
+in	418	425	421	422		out	419	424	420	423	
+in	426	432	431	428		out	427	433	429	430	
+in	424	427				out	425	426				c	
+in	477	430				out	476	431				c	
+end
\ No newline at end of file
diff --git a/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sinks.txt b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sinks.txt
new file mode 100644
index 000000000..12245da9e
--- /dev/null
+++ b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sinks.txt
@@ -0,0 +1,77 @@
+76
+25	0.5
+98	0.5
+5	0.5
+60	0.5
+7	0.4
+20	0.4
+51	0.2
+54	0.2
+116	0.2
+73	0.2
+76	0.2
+80	0.2
+94	0.2
+101	0.2
+36	0.2
+43	0.2
+46	0.2
+48	0.2
+118	0.2
+145	0.5
+218	0.5
+125	0.5
+180	0.5
+127	0.4
+140	0.4
+171	0.2
+174	0.2
+236	0.2
+193	0.2
+196	0.2
+200	0.2
+214	0.2
+221	0.2
+156	0.2
+163	0.2
+166	0.2
+168	0.2
+238	0.2
+265	0.5
+338	0.5
+245	0.5
+300	0.5
+247	0.4
+260	0.4
+291	0.2
+294	0.2
+356	0.2
+313	0.2
+316	0.2
+320	0.2
+334	0.2
+341	0.2
+276	0.2
+283	0.2
+286	0.2
+288	0.2
+358	0.2
+385	0.5
+458	0.5
+365	0.5
+420	0.5
+367	0.4
+380	0.4
+411	0.2
+414	0.2
+476	0.2
+433	0.2
+436	0.2
+440	0.2
+454	0.2
+461	0.2
+396	0.2
+403	0.2
+406	0.2
+408	0.2
+478	0.2
\ No newline at end of file
diff --git a/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sources.txt b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sources.txt
new file mode 100644
index 000000000..0bf91e6c7
--- /dev/null
+++ b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Sources.txt
@@ -0,0 +1,77 @@
+76
+61	0.7
+8	0.7
+99	0.7
+14	0.7
+17	0.6
+0	0.6
+53	0.2
+55	0.2
+117	0.2
+72	0.2
+77	0.2
+81	0.2
+95	0.2
+100	0.2
+38	0.2
+44	0.2
+47	0.2
+49	0.2
+119	0.2
+181	0.7
+128	0.7
+219	0.7
+134	0.7
+137	0.6
+120	0.6
+173	0.2
+175	0.2
+237	0.2
+192	0.2
+197	0.2
+201	0.2
+215	0.2
+220	0.2
+158	0.2
+164	0.2
+167	0.2
+169	0.2
+239	0.2
+301	0.7
+248	0.7
+339	0.7
+254	0.7
+257	0.6
+240	0.6
+293	0.2
+295	0.2
+357	0.2
+312	0.2
+317	0.2
+321	0.2
+335	0.2
+340	0.2
+278	0.2
+284	0.2
+287	0.2
+289	0.2
+359	0.2
+421	0.7
+368	0.7
+459	0.7
+374	0.7
+377	0.6
+360	0.6
+413	0.2
+415	0.2
+477	0.2
+432	0.2
+437	0.2
+441	0.2
+455	0.2
+460	0.2
+398	0.2
+404	0.2
+407	0.2
+409	0.2
+479	0.2
diff --git a/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Streets.txt b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Streets.txt
new file mode 100644
index 000000000..8ed4aeff8
--- /dev/null
+++ b/targets/apps/LBM/Basel/resources/allStreetsQuadruple/Streets.txt
@@ -0,0 +1,481 @@
+480
+  256     5   220     5  1
+  220     5    93     5  1
+   88     5   -86     5  1
+  -86     5   -82   134  1
+  -82   139   -80   224  1
+  -80 	229   -80 	256  1
+  -92     5  -200     5  1
+ -205     5  -256     5  1
+ -184  -256  -179  -244  1
+ -179  -244  -165  -210  1
+ -163  -205  -134  -131  1
+ -133  -126  -106   -53  1 
+ -105   -48   -87     0  1
+  -87     0    87     0  1
+  -85   256   -85   226  1
+  -85   226   -87   137  1
+  -87   137   -92     5  1
+ -256     0  -209     0  1 
+ -204     0   -92     0  1
+   92     0   218     0  1
+  223     0   256     0  1
+  -92     0  -110   -49  1
+ -110   -49  -138  -125  1
+ -139  -130  -168  -204  1
+ -168  -204  -183  -240  1
+ -185  -245  -189  -256  1 
+  122	 83    88	  5  1
+   93	  5	  127	 83  1
+  127	 83	  137   137  1
+   25   136   132   137  1
+  132   137   122    83  1
+  -82   134	   25   136  1
+  132   142    27 	141  1
+   22   141   -82   139  1
+  129   224   132   142  1
+  137   142   134   224  1
+  137   137   256   137  1
+  129   229    24   229  1
+  256   142   137   142  1
+   27   224   129   224  1
+   24   229   -80   229  1
+   27   141    27   224  1
+   22   224    22   141  1   
+  237   222   256   222  1
+  256   227   239   227  1
+  234   227   134   229  1
+  239   227   239   256  1
+  234   256   234   227  1  
+  134   229   134   256  1
+  129   256   129   229  1
+ -200     5  -196   124  1
+ -196   124  -195   256  1
+ -201   121  -205     5  1
+ -200   256  -201   126  1
+ -201   126  -256   130  1
+ -256   125  -201   121  1 
+  -80   224    22   224  1
+  134   224   237   222  1
+ -209     0  -211  -109  1
+ -206  -110  -204     0  1
+ -211  -109  -256  -101  1
+ -256  -106  -210  -114  1
+ -138  -125  -206  -110  1
+ -205  -115  -139  -130  1
+ -210  -114  -217  -158  1
+ -212  -160  -205  -115  1
+ -217  -158  -239  -208  1
+ -236  -213  -212  -160  1
+ -183  -240  -236  -213  1
+ -238  -218  -185  -245  1
+ -239  -208  -241  -188  1
+ -246  -191  -243  -215  1
+ -256  -251  -238  -218  1
+ -243  -215  -256  -240  1
+  -87  -221  -163  -205  1
+ -165  -210   -90  -226  1
+  -90  -226  -100  -256  1
+  -95  -256   -85  -227  1
+  -85  -227    22  -252  1
+   20  -247   -83  -222  1
+   22  -252    29  -256  1
+   38  -256    25  -248  1
+   25  -248    49  -165  1
+   44  -164    20  -247  1
+  -83  -222   -53  -146  1
+  -58  -145   -87  -221  1 
+ -134  -131   -58  -145  1
+  -53  -146    44  -164  1
+   46  -159   -54  -141  1
+  -54  -141  -133  -126  1
+   49  -165   157  -183  1
+  158  -178    50  -159  1
+   66   -73    46  -159  1
+   50  -159    72   -73  1
+  157  -183   140  -256  1
+  145  -256   162  -184  1
+  162  -184   238  -195  1
+  239  -191   163  -179  1
+  243  -196   256  -199  1
+  256  -194   244  -192  1
+  227  -256   243  -196  1
+  238  -195   222  -256  1
+  244  -192   251   -93  1
+  244   -92   239  -191  1
+  251   -88   223     0  1
+  218     0   244   -87  1
+  244   -87   177   -79  1
+  177   -79    73   -68  1
+  163  -179   179   -84  1
+  179   -84   244   -92  1
+  174   -84   158  -178  1
+   72   -73   174   -84  1
+   73   -68    92     0  1
+   87     0    68   -67  1
+ -106   -53    66   -72  1
+   68   -67  -105   -48  1
+ -241  -188  -256  -177  1
+ -256  -184  -246  -191  1
+  251   -93   256   -94  1
+  256   -89   251   -88  1
+  256     5   220     5  1
+  220     5    93     5  1
+   88     5   -86     5  1
+  -86     5   -82   134  1
+  -82   139   -80   224  1
+  -80 	229   -80 	256  1
+  -92     5  -200     5  1
+ -205     5  -256     5  1
+ -184  -256  -179  -244  1
+ -179  -244  -165  -210  1
+ -163  -205  -134  -131  1
+ -133  -126  -106   -53  1 
+ -105   -48   -87     0  1
+  -87     0    87     0  1
+  -85   256   -85   226  1
+  -85   226   -87   137  1
+  -87   137   -92     5  1
+ -256     0  -209     0  1 
+ -204     0   -92     0  1
+   92     0   218     0  1
+  223     0   256     0  1
+  -92     0  -110   -49  1
+ -110   -49  -138  -125  1
+ -139  -130  -168  -204  1
+ -168  -204  -183  -240  1
+ -185  -245  -189  -256  1 
+  122	 83    88	  5  1
+   93	  5	  127	 83  1
+  127	 83	  137   137  1
+   25   136   132   137  1
+  132   137   122    83  1
+  -82   134	   25   136  1
+  132   142    27 	141  1
+   22   141   -82   139  1
+  129   224   132   142  1
+  137   142   134   224  1
+  137   137   256   137  1
+  129   229    24   229  1
+  256   142   137   142  1
+   27   224   129   224  1
+   24   229   -80   229  1
+   27   141    27   224  1
+   22   224    22   141  1   
+  237   222   256   222  1
+  256   227   239   227  1
+  234   227   134   229  1
+  239   227   239   256  1
+  234   256   234   227  1  
+  134   229   134   256  1
+  129   256   129   229  1
+ -200     5  -196   124  1
+ -196   124  -195   256  1
+ -201   121  -205     5  1
+ -200   256  -201   126  1
+ -201   126  -256   130  1
+ -256   125  -201   121  1 
+  -80   224    22   224  1
+  134   224   237   222  1
+ -209     0  -211  -109  1
+ -206  -110  -204     0  1
+ -211  -109  -256  -101  1
+ -256  -106  -210  -114  1
+ -138  -125  -206  -110  1
+ -205  -115  -139  -130  1
+ -210  -114  -217  -158  1
+ -212  -160  -205  -115  1
+ -217  -158  -239  -208  1
+ -236  -213  -212  -160  1
+ -183  -240  -236  -213  1
+ -238  -218  -185  -245  1
+ -239  -208  -241  -188  1
+ -246  -191  -243  -215  1
+ -256  -251  -238  -218  1
+ -243  -215  -256  -240  1
+  -87  -221  -163  -205  1
+ -165  -210   -90  -226  1
+  -90  -226  -100  -256  1
+  -95  -256   -85  -227  1
+  -85  -227    22  -252  1
+   20  -247   -83  -222  1
+   22  -252    29  -256  1
+   38  -256    25  -248  1
+   25  -248    49  -165  1
+   44  -164    20  -247  1
+  -83  -222   -53  -146  1
+  -58  -145   -87  -221  1 
+ -134  -131   -58  -145  1
+  -53  -146    44  -164  1
+   46  -159   -54  -141  1
+  -54  -141  -133  -126  1
+   49  -165   157  -183  1
+  158  -178    50  -159  1
+   66   -73    46  -159  1
+   50  -159    72   -73  1
+  157  -183   140  -256  1
+  145  -256   162  -184  1
+  162  -184   238  -195  1
+  239  -191   163  -179  1
+  243  -196   256  -199  1
+  256  -194   244  -192  1
+  227  -256   243  -196  1
+  238  -195   222  -256  1
+  244  -192   251   -93  1
+  244   -92   239  -191  1
+  251   -88   223     0  1
+  218     0   244   -87  1
+  244   -87   177   -79  1
+  177   -79    73   -68  1
+  163  -179   179   -84  1
+  179   -84   244   -92  1
+  174   -84   158  -178  1
+   72   -73   174   -84  1
+   73   -68    92     0  1
+   87     0    68   -67  1
+ -106   -53    66   -72  1
+   68   -67  -105   -48  1
+ -241  -188  -256  -177  1
+ -256  -184  -246  -191  1
+  251   -93   256   -94  1
+  256   -89   251   -88  1
+  256     5   220     5  1
+  220     5    93     5  1
+   88     5   -86     5  1
+  -86     5   -82   134  1
+  -82   139   -80   224  1
+  -80 	229   -80 	256  1
+  -92     5  -200     5  1
+ -205     5  -256     5  1
+ -184  -256  -179  -244  1
+ -179  -244  -165  -210  1
+ -163  -205  -134  -131  1
+ -133  -126  -106   -53  1 
+ -105   -48   -87     0  1
+  -87     0    87     0  1
+  -85   256   -85   226  1
+  -85   226   -87   137  1
+  -87   137   -92     5  1
+ -256     0  -209     0  1 
+ -204     0   -92     0  1
+   92     0   218     0  1
+  223     0   256     0  1
+  -92     0  -110   -49  1
+ -110   -49  -138  -125  1
+ -139  -130  -168  -204  1
+ -168  -204  -183  -240  1
+ -185  -245  -189  -256  1 
+  122	 83    88	  5  1
+   93	  5	  127	 83  1
+  127	 83	  137   137  1
+   25   136   132   137  1
+  132   137   122    83  1
+  -82   134	   25   136  1
+  132   142    27 	141  1
+   22   141   -82   139  1
+  129   224   132   142  1
+  137   142   134   224  1
+  137   137   256   137  1
+  129   229    24   229  1
+  256   142   137   142  1
+   27   224   129   224  1
+   24   229   -80   229  1
+   27   141    27   224  1
+   22   224    22   141  1   
+  237   222   256   222  1
+  256   227   239   227  1
+  234   227   134   229  1
+  239   227   239   256  1
+  234   256   234   227  1  
+  134   229   134   256  1
+  129   256   129   229  1
+ -200     5  -196   124  1
+ -196   124  -195   256  1
+ -201   121  -205     5  1
+ -200   256  -201   126  1
+ -201   126  -256   130  1
+ -256   125  -201   121  1 
+  -80   224    22   224  1
+  134   224   237   222  1
+ -209     0  -211  -109  1
+ -206  -110  -204     0  1
+ -211  -109  -256  -101  1
+ -256  -106  -210  -114  1
+ -138  -125  -206  -110  1
+ -205  -115  -139  -130  1
+ -210  -114  -217  -158  1
+ -212  -160  -205  -115  1
+ -217  -158  -239  -208  1
+ -236  -213  -212  -160  1
+ -183  -240  -236  -213  1
+ -238  -218  -185  -245  1
+ -239  -208  -241  -188  1
+ -246  -191  -243  -215  1
+ -256  -251  -238  -218  1
+ -243  -215  -256  -240  1
+  -87  -221  -163  -205  1
+ -165  -210   -90  -226  1
+  -90  -226  -100  -256  1
+  -95  -256   -85  -227  1
+  -85  -227    22  -252  1
+   20  -247   -83  -222  1
+   22  -252    29  -256  1
+   38  -256    25  -248  1
+   25  -248    49  -165  1
+   44  -164    20  -247  1
+  -83  -222   -53  -146  1
+  -58  -145   -87  -221  1 
+ -134  -131   -58  -145  1
+  -53  -146    44  -164  1
+   46  -159   -54  -141  1
+  -54  -141  -133  -126  1
+   49  -165   157  -183  1
+  158  -178    50  -159  1
+   66   -73    46  -159  1
+   50  -159    72   -73  1
+  157  -183   140  -256  1
+  145  -256   162  -184  1
+  162  -184   238  -195  1
+  239  -191   163  -179  1
+  243  -196   256  -199  1
+  256  -194   244  -192  1
+  227  -256   243  -196  1
+  238  -195   222  -256  1
+  244  -192   251   -93  1
+  244   -92   239  -191  1
+  251   -88   223     0  1
+  218     0   244   -87  1
+  244   -87   177   -79  1
+  177   -79    73   -68  1
+  163  -179   179   -84  1
+  179   -84   244   -92  1
+  174   -84   158  -178  1
+   72   -73   174   -84  1
+   73   -68    92     0  1
+   87     0    68   -67  1
+ -106   -53    66   -72  1
+   68   -67  -105   -48  1
+ -241  -188  -256  -177  1
+ -256  -184  -246  -191  1
+  251   -93   256   -94  1
+  256   -89   251   -88  1
+  256     5   220     5  1
+  220     5    93     5  1
+   88     5   -86     5  1
+  -86     5   -82   134  1
+  -82   139   -80   224  1
+  -80 	229   -80 	256  1
+  -92     5  -200     5  1
+ -205     5  -256     5  1
+ -184  -256  -179  -244  1
+ -179  -244  -165  -210  1
+ -163  -205  -134  -131  1
+ -133  -126  -106   -53  1 
+ -105   -48   -87     0  1
+  -87     0    87     0  1
+  -85   256   -85   226  1
+  -85   226   -87   137  1
+  -87   137   -92     5  1
+ -256     0  -209     0  1 
+ -204     0   -92     0  1
+   92     0   218     0  1
+  223     0   256     0  1
+  -92     0  -110   -49  1
+ -110   -49  -138  -125  1
+ -139  -130  -168  -204  1
+ -168  -204  -183  -240  1
+ -185  -245  -189  -256  1 
+  122	 83    88	  5  1
+   93	  5	  127	 83  1
+  127	 83	  137   137  1
+   25   136   132   137  1
+  132   137   122    83  1
+  -82   134	   25   136  1
+  132   142    27 	141  1
+   22   141   -82   139  1
+  129   224   132   142  1
+  137   142   134   224  1
+  137   137   256   137  1
+  129   229    24   229  1
+  256   142   137   142  1
+   27   224   129   224  1
+   24   229   -80   229  1
+   27   141    27   224  1
+   22   224    22   141  1   
+  237   222   256   222  1
+  256   227   239   227  1
+  234   227   134   229  1
+  239   227   239   256  1
+  234   256   234   227  1  
+  134   229   134   256  1
+  129   256   129   229  1
+ -200     5  -196   124  1
+ -196   124  -195   256  1
+ -201   121  -205     5  1
+ -200   256  -201   126  1
+ -201   126  -256   130  1
+ -256   125  -201   121  1 
+  -80   224    22   224  1
+  134   224   237   222  1
+ -209     0  -211  -109  1
+ -206  -110  -204     0  1
+ -211  -109  -256  -101  1
+ -256  -106  -210  -114  1
+ -138  -125  -206  -110  1
+ -205  -115  -139  -130  1
+ -210  -114  -217  -158  1
+ -212  -160  -205  -115  1
+ -217  -158  -239  -208  1
+ -236  -213  -212  -160  1
+ -183  -240  -236  -213  1
+ -238  -218  -185  -245  1
+ -239  -208  -241  -188  1
+ -246  -191  -243  -215  1
+ -256  -251  -238  -218  1
+ -243  -215  -256  -240  1
+  -87  -221  -163  -205  1
+ -165  -210   -90  -226  1
+  -90  -226  -100  -256  1
+  -95  -256   -85  -227  1
+  -85  -227    22  -252  1
+   20  -247   -83  -222  1
+   22  -252    29  -256  1
+   38  -256    25  -248  1
+   25  -248    49  -165  1
+   44  -164    20  -247  1
+  -83  -222   -53  -146  1
+  -58  -145   -87  -221  1 
+ -134  -131   -58  -145  1
+  -53  -146    44  -164  1
+   46  -159   -54  -141  1
+  -54  -141  -133  -126  1
+   49  -165   157  -183  1
+  158  -178    50  -159  1
+   66   -73    46  -159  1
+   50  -159    72   -73  1
+  157  -183   140  -256  1
+  145  -256   162  -184  1
+  162  -184   238  -195  1
+  239  -191   163  -179  1
+  243  -196   256  -199  1
+  256  -194   244  -192  1
+  227  -256   243  -196  1
+  238  -195   222  -256  1
+  244  -192   251   -93  1
+  244   -92   239  -191  1
+  251   -88   223     0  1
+  218     0   244   -87  1
+  244   -87   177   -79  1
+  177   -79    73   -68  1
+  163  -179   179   -84  1
+  179   -84   244   -92  1
+  174   -84   158  -178  1
+   72   -73   174   -84  1
+   73   -68    92     0  1
+   87     0    68   -67  1
+ -106   -53    66   -72  1
+   68   -67  -105   -48  1
+ -241  -188  -256  -177  1
+ -256  -184  -246  -191  1
+  251   -93   256   -94  1
+  256   -89   251   -88  1
\ No newline at end of file
diff --git a/targets/apps/LBM/TrafficTest/Traffic_Main.cpp b/targets/apps/LBM/TrafficTest/Traffic_Main.cpp
index 6ef651e94..487b51e75 100644
--- a/targets/apps/LBM/TrafficTest/Traffic_Main.cpp
+++ b/targets/apps/LBM/TrafficTest/Traffic_Main.cpp
@@ -11,49 +11,52 @@
 
 int main()
 {
-
+	 
 	//////Basel
-	{
-		uint numberOfTimesteps = 100000;
-		bool useGPU = true;		
 
+	for (uint i = 0; i < 2; i++) {
 
-		//Stephans Logger
-		logging::Logger::addStream(&std::cout);
-		logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW);
-		logging::Logger::timeStamp(logging::Logger::ENABLE);
-		logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE);
+		{
+			uint numberOfTimesteps = 1000*1000;
+			bool useGPU = false;
 
 
-		//init TrafficMovement
-		TrafficMovementFactory * factory = new TrafficMovementFactory();
-		std::string path = "C:/Users/hiwi/BaselDokumente/";
-		factory->initTrafficMovement(path, useGPU);
+			//Stephans Logger
+			logging::Logger::addStream(&std::cout);
+			logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW);
+			logging::Logger::timeStamp(logging::Logger::ENABLE);
+			logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE);
 
 
-		//clock
-		std::clock_t start;
-		double duration;
-		start = std::clock();
+			//init TrafficMovement
+			TrafficMovementFactory * factory = new TrafficMovementFactory();
+			std::string path = "C:/Users/hiwi/BaselDokumente/";
+			factory->initTrafficMovement(path, useGPU);
 
 
-		//loop through timestep
-		for (uint step = 1; step <= numberOfTimesteps; step++) {
-			factory->calculateTimestep(step);
-			//factory->writeReducedTimestep(step);
-		}		
+			//clock
+			std::clock_t start;
+			double duration;
+			start = std::clock();
 
 
-		//end simulation
-		duration = (std::clock() - start) / (double)CLOCKS_PER_SEC;
+			//loop through timestep
+			for (uint step = 1; step <= numberOfTimesteps; step++) {
+				factory->calculateTimestep(step);
+				factory->writeReducedTimestep(step);
+			}
 
-		factory->endSimulation(numberOfTimesteps, duration);
-         
-		std::cout << "Dauer: " << duration << '\n';
 
-		factory->writeTimestep(numberOfTimesteps);	
-	}
+			//end simulation
+			duration = (std::clock() - start) / (double)CLOCKS_PER_SEC;
+
+			factory->endSimulation(numberOfTimesteps, duration);
 
+			std::cout << "Dauer: " << duration << '\n';
+
+			factory->writeTimestep(numberOfTimesteps);
+		}
+	}
 
 
 
-- 
GitLab