From 75c9b5e3971f8ebc656353383d84e5a443b0a224 Mon Sep 17 00:00:00 2001 From: hiwis <hiwis@irmb.tu-bs.de> Date: Fri, 12 Apr 2019 12:28:11 +0200 Subject: [PATCH] fixes for linux --- .../StreetPointFinder/JunctionReader.cpp | 10 ++- .../StreetPointFinder/JunctionReader.h | 6 +- .../StreetPointFinder/SinkReader.cpp | 4 +- .../StreetPointFinder/SinkReader.h | 6 +- .../StreetPointFinder/SourceReader.cpp | 4 +- .../StreetPointFinder/SourceReader.h | 6 +- src/Traffic/GPU/TrafficTimestep.h | 8 +- src/Traffic/Junction/Junction.h | 2 +- src/Traffic/Junction/JunctionRandom.cpp | 3 +- src/Traffic/Junction/JunctionRandom.h | 2 +- src/Traffic/Output/CarDisplay.cpp | 10 +-- src/Traffic/Output/ConcentrationOutwriter.cpp | 11 +-- src/Traffic/RoadNetwork/RoadMaker.cpp | 3 + src/Traffic/RoadNetwork/RoadNetworkData.h | 1 - src/Traffic/Sink/SinkRandom.cpp | 2 + src/Traffic/Sink/SinkRandom.h | 2 +- src/Traffic/Source/SourceRandom.cpp | 3 + src/Traffic/Source/SourceRandom.h | 4 +- src/Traffic/TrafficMovement.cpp | 11 +-- src/Traffic/TrafficMovementFactory - Kopie.h | 2 +- src/Traffic/TrafficMovementFactory.cpp | 9 ++- src/Traffic/TrafficMovementFactory.h | 2 +- src/Traffic/Utilities/ConsoleColor.cpp | 74 +++++++++++++++++++ src/Traffic/Utilities/ConsoleColor.h | 15 ++++ src/Traffic/Utilities/Logger.h | 1 - src/Traffic/Utilities/RandomHelper.cpp | 1 - src/Traffic/Utilities/RandomHelper.h | 1 + src/Traffic/Utilities/VectorHelper.cpp | 17 +++-- src/Traffic/Utilities/VectorHelper.h | 6 +- src/Traffic/Utilities/invalidInput_error.cpp | 3 + src/Traffic/Utilities/invalidInput_error.h | 1 - .../resources/testStreets/Junctions6.txt | 3 + .../Basel/resources/testStreets/Sinks6.txt | 4 + .../Basel/resources/testStreets/Sources6.txt | 4 + .../Basel/resources/testStreets/Streets6.txt | 7 ++ targets/apps/LBM/TrafficTest/Traffic_Main.cpp | 4 +- 36 files changed, 187 insertions(+), 65 deletions(-) create mode 100644 src/Traffic/Utilities/ConsoleColor.cpp create mode 100644 src/Traffic/Utilities/ConsoleColor.h create mode 100644 targets/apps/LBM/Basel/resources/testStreets/Junctions6.txt create mode 100644 targets/apps/LBM/Basel/resources/testStreets/Sinks6.txt create mode 100644 targets/apps/LBM/Basel/resources/testStreets/Sources6.txt create mode 100644 targets/apps/LBM/Basel/resources/testStreets/Streets6.txt diff --git a/src/GridGenerator/StreetPointFinder/JunctionReader.cpp b/src/GridGenerator/StreetPointFinder/JunctionReader.cpp index 1ce67fb89..c0ebd8b88 100644 --- a/src/GridGenerator/StreetPointFinder/JunctionReader.cpp +++ b/src/GridGenerator/StreetPointFinder/JunctionReader.cpp @@ -5,7 +5,7 @@ #include <string> -JunctionInReader::JunctionInReader(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell, uint trafficLightSwitchTime = 0) : +JunctionReaderData::JunctionReaderData(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell, uint trafficLightSwitchTime = 0) : inCells{ inCells }, outCells{ outCells }, carCanNotEnterThisOutCell{ carCanNotEnterThisOutCell }, trafficLightSwitchTime{ trafficLightSwitchTime } {} @@ -71,11 +71,13 @@ void JunctionReader::readJunctions(std::string filename, StreetPointFinder stree // only neighbors (used for curves) if (inOutDummy.compare("c") == 0) { onlyNeighbors = true; + file >> inOutDummy; } - //make Junction + + //make Junction or neighbors if (onlyNeighbors) { - if (inCells.size() == outCells.size()) { + if (inCells.size() == 2 && outCells.size()==2) { specialNeighbors.cells.insert(specialNeighbors.cells.end(), inCells.begin(), inCells.end()); std::reverse(outCells.begin(), outCells.end()); specialNeighbors.neighbors.insert(specialNeighbors.neighbors.end(), outCells.begin(), outCells.end()); @@ -84,7 +86,7 @@ void JunctionReader::readJunctions(std::string filename, StreetPointFinder stree else std::cerr << "can't add curve" << std::endl; continue; } else - junctions.push_back(JunctionInReader(inCells, outCells, carCanNotEnterThisOutCell, trafficLightTime)); + junctions.push_back(JunctionReaderData(inCells, outCells, carCanNotEnterThisOutCell, trafficLightTime)); } } diff --git a/src/GridGenerator/StreetPointFinder/JunctionReader.h b/src/GridGenerator/StreetPointFinder/JunctionReader.h index b57bf3bc5..015e7d33d 100644 --- a/src/GridGenerator/StreetPointFinder/JunctionReader.h +++ b/src/GridGenerator/StreetPointFinder/JunctionReader.h @@ -10,14 +10,14 @@ #include <VirtualFluidsDefinitions.h> -struct VF_PUBLIC JunctionInReader +struct VF_PUBLIC JunctionReaderData { std::vector<uint> inCells; std::vector<uint> outCells; std::vector<int> carCanNotEnterThisOutCell; uint trafficLightSwitchTime; - JunctionInReader(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell, uint trafficLightSwitchTime); + JunctionReaderData(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell, uint trafficLightSwitchTime); }; @@ -31,7 +31,7 @@ struct VF_PUBLIC Neighbors struct VF_PUBLIC JunctionReader { - std::vector<JunctionInReader> junctions; + std::vector<JunctionReaderData> junctions; Neighbors specialNeighbors; StreetPointFinder streetPointFinder; diff --git a/src/GridGenerator/StreetPointFinder/SinkReader.cpp b/src/GridGenerator/StreetPointFinder/SinkReader.cpp index 1a275c759..15eee8a3a 100644 --- a/src/GridGenerator/StreetPointFinder/SinkReader.cpp +++ b/src/GridGenerator/StreetPointFinder/SinkReader.cpp @@ -3,7 +3,7 @@ #include <fstream> #include <iostream> -SinkInReader::SinkInReader(uint sinkIndex, float sinkBlockedPossibility) : +SinkReaderData::SinkReaderData(uint sinkIndex, float sinkBlockedPossibility) : sinkIndex{ sinkIndex }, sinkBlockedPossibility{ sinkBlockedPossibility } {} @@ -26,7 +26,7 @@ void SinkReader::readSinks(std::string filename, StreetPointFinder streetPointFi for (uint i = 0; i < numberOfSinks; i++) { file >> streetIndex >> sinkBlockedPossibility; - sinks.push_back(SinkInReader(getCellIndexEnd(streetIndex), sinkBlockedPossibility)); + sinks.push_back(SinkReaderData(getCellIndexEnd(streetIndex), sinkBlockedPossibility)); } } diff --git a/src/GridGenerator/StreetPointFinder/SinkReader.h b/src/GridGenerator/StreetPointFinder/SinkReader.h index bc49c159f..323d8acfc 100644 --- a/src/GridGenerator/StreetPointFinder/SinkReader.h +++ b/src/GridGenerator/StreetPointFinder/SinkReader.h @@ -10,15 +10,15 @@ #include <VirtualFluidsDefinitions.h> -struct VF_PUBLIC SinkInReader{ +struct VF_PUBLIC SinkReaderData{ uint sinkIndex; float sinkBlockedPossibility; - SinkInReader(uint sinkIndex, float sinkBlockedPossibility); + SinkReaderData(uint sinkIndex, float sinkBlockedPossibility); }; struct VF_PUBLIC SinkReader { - std::vector<SinkInReader> sinks; + std::vector<SinkReaderData> sinks; StreetPointFinder streetPointFinder; void readSinks(std::string filename, StreetPointFinder streetPointFinder); diff --git a/src/GridGenerator/StreetPointFinder/SourceReader.cpp b/src/GridGenerator/StreetPointFinder/SourceReader.cpp index 85bcdc5a9..f666047d4 100644 --- a/src/GridGenerator/StreetPointFinder/SourceReader.cpp +++ b/src/GridGenerator/StreetPointFinder/SourceReader.cpp @@ -3,7 +3,7 @@ #include <fstream> #include <iostream> -SourceInReader::SourceInReader(unsigned int sourceIndex, float sourcePossibility): +SourceReaderData::SourceReaderData(unsigned int sourceIndex, float sourcePossibility): sourceIndex{sourceIndex}, sourcePossibility{sourcePossibility} {} @@ -27,7 +27,7 @@ void SourceReader::readSources(std::string filename, StreetPointFinder streetPoi for (uint i = 0; i < numberOfSources; i++) { file >> streetIndex >> sourcePossibility; - sources.push_back(SourceInReader(getCellIndexStart(streetIndex), sourcePossibility)); + sources.push_back(SourceReaderData(getCellIndexStart(streetIndex), sourcePossibility)); } } diff --git a/src/GridGenerator/StreetPointFinder/SourceReader.h b/src/GridGenerator/StreetPointFinder/SourceReader.h index 9f9225760..c352f87f0 100644 --- a/src/GridGenerator/StreetPointFinder/SourceReader.h +++ b/src/GridGenerator/StreetPointFinder/SourceReader.h @@ -10,15 +10,15 @@ #include <VirtualFluidsDefinitions.h> -struct VF_PUBLIC SourceInReader { +struct VF_PUBLIC SourceReaderData { unsigned int sourceIndex; float sourcePossibility; - SourceInReader(unsigned int sourceIndex, float sourcePossibility); + SourceReaderData(unsigned int sourceIndex, float sourcePossibility); }; struct VF_PUBLIC SourceReader { - std::vector<SourceInReader> sources; + std::vector<SourceReaderData> sources; StreetPointFinder streetPointFinder; void readSources(std::string filename, StreetPointFinder streetPointFinder); diff --git a/src/Traffic/GPU/TrafficTimestep.h b/src/Traffic/GPU/TrafficTimestep.h index 66d600752..b924005d5 100644 --- a/src/Traffic/GPU/TrafficTimestep.h +++ b/src/Traffic/GPU/TrafficTimestep.h @@ -6,15 +6,15 @@ #include <random> #include <thrust/device_vector.h> -#include <VirtualFluidsDefinitions.h> -#include "Utilities/RandomHelper.h" -#include "Core/PointerDefinitions.h" -#include "Core/DataTypes.h" #include <curand_kernel.h> #include <cuda.h> #include <cuda_runtime.h> #include <helper_cuda.h> +#include <VirtualFluidsDefinitions.h> +#include "Core/PointerDefinitions.h" +#include "Core/DataTypes.h" + struct RoadNetworkData; class Sink; class Junction; diff --git a/src/Traffic/Junction/Junction.h b/src/Traffic/Junction/Junction.h index f64cdd496..20750f4e0 100644 --- a/src/Traffic/Junction/Junction.h +++ b/src/Traffic/Junction/Junction.h @@ -13,7 +13,7 @@ class VF_PUBLIC Junction public: virtual void checkOutCellIndices(const uint roadLength) const = 0; - virtual void setCellIndexForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) = 0; + virtual void setCellIndecesForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) = 0; virtual bool acceptsCar(uint cellIndex) = 0; //determines if a car can enter the junction virtual void registerCar(uint cellIndex, uint numberOfCellsAlreadyMoved, uint speed, uint oldSpeed) = 0; //registers all cars entering the junction diff --git a/src/Traffic/Junction/JunctionRandom.cpp b/src/Traffic/Junction/JunctionRandom.cpp index 25c1e7445..b31291fd3 100644 --- a/src/Traffic/Junction/JunctionRandom.cpp +++ b/src/Traffic/Junction/JunctionRandom.cpp @@ -1,6 +1,7 @@ #include "JunctionRandom.h" #include <iostream> +#include <iomanip> //formatting output streams #include <algorithm> //used for find() #include <math.h> //used for floor() @@ -33,7 +34,7 @@ JunctionRandom::JunctionRandom(const std::vector<uint> &inCellIndices, const std } -void JunctionRandom::setCellIndexForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) +void JunctionRandom::setCellIndecesForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) { try { diff --git a/src/Traffic/Junction/JunctionRandom.h b/src/Traffic/Junction/JunctionRandom.h index c1b119ac6..96d8e31b5 100644 --- a/src/Traffic/Junction/JunctionRandom.h +++ b/src/Traffic/Junction/JunctionRandom.h @@ -20,7 +20,7 @@ public: JunctionRandom(const std::vector<uint> &inCellIndices, const std::vector<uint> &outCellIndices, uint trafficLightSwitchTime = 0); ~JunctionRandom() {}; - virtual void setCellIndexForNoUTurn(std::vector<int> carCanNotEnterThisOutCell); + virtual void setCellIndecesForNoUTurn(std::vector<int> carCanNotEnterThisOutCell); virtual bool acceptsCar(uint cellIndex); //determines if a car can enter the junction virtual void registerCar(uint cellIndex, uint numberOfCellsAlreadyMoved, uint speed, uint oldSpeed); //registers all cars entering the junction diff --git a/src/Traffic/Output/CarDisplay.cpp b/src/Traffic/Output/CarDisplay.cpp index e54709fbb..3010ac41c 100644 --- a/src/Traffic/Output/CarDisplay.cpp +++ b/src/Traffic/Output/CarDisplay.cpp @@ -3,11 +3,11 @@ #include <fstream> #include <iostream> #include <iomanip> //formatting output streams -#include <windows.h> //for colourful console output #include <stdexcept> #include "Utilities/VectorHelper.h" #include "Utilities/safe_casting.h" +#include "Utilities/ConsoleColor.h" CarDisplay::CarDisplay(std::vector<int> **pcurrent, const uint safetyDistance): safetyDistance{ safetyDistance } @@ -104,14 +104,14 @@ void CarDisplay::dispResults(const std::vector<int> * neighbors, const std::vect std::cout << std::endl; } std::cout << std::endl; - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); // set output default white 7; + ConsoleColor::setDefaultWhite(); } void CarDisplay::dispJunctionsAtCell(uint index, const std::vector<std::shared_ptr<Junction> > & junctions) const { for (auto& junc : junctions) { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); // set output default white 7; + ConsoleColor::setDefaultWhite(); junc->dispJunction(index, roadLength); } } @@ -121,7 +121,7 @@ void CarDisplay::dispSinksAtCell(uint index, const std::vector<std::shared_ptr<S { for (auto& sink : sinks) { if (sink->getIndex() == roadLength - index - 1) { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12); //set output bright green 10, bright red 12 + ConsoleColor::setBrightRed(); std::cout << std::setw(4) << 1 - (sink->getPossibilityBeingBlocked()); return; } @@ -134,7 +134,7 @@ void CarDisplay::dispSourcesAtCell(uint index, const std::vector<std::shared_pt { for (auto& source : sources) { if (source->getIndex() == roadLength - index - 1) { - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10); //set output bright green 10, bright red 12 + ConsoleColor::setBrightRed(); std::cout << std::setw(4) << source->getPossibility(); return; } diff --git a/src/Traffic/Output/ConcentrationOutwriter.cpp b/src/Traffic/Output/ConcentrationOutwriter.cpp index 68be7d5f1..cf8d13a70 100644 --- a/src/Traffic/Output/ConcentrationOutwriter.cpp +++ b/src/Traffic/Output/ConcentrationOutwriter.cpp @@ -2,7 +2,8 @@ #include <iostream> #include <iomanip> //formatting output streams -#include <windows.h> //for colourful console output + +#include "Utilities/ConsoleColor.h" void ConcentrationOutwriter::resetConcentrations() { @@ -51,16 +52,16 @@ void ConcentrationOutwriter::dispCurrentConcentrations() std::cout << std::endl; - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); -} + ConsoleColor::setDefaultWhite(); +} void ConcentrationOutwriter::dispSingleConcentration(real conc) { if (conc > 0) - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12); + ConsoleColor::setBrightRed(); else - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 8); + ConsoleColor::setDarkGrey(); std::cout << std::setw(4) << conc; } diff --git a/src/Traffic/RoadNetwork/RoadMaker.cpp b/src/Traffic/RoadNetwork/RoadMaker.cpp index ca02a9cd8..c90752b52 100644 --- a/src/Traffic/RoadNetwork/RoadMaker.cpp +++ b/src/Traffic/RoadNetwork/RoadMaker.cpp @@ -1,9 +1,12 @@ #include "RoadMaker.h" +#include <iostream> + #include "Utilities/VectorHelper.h" #include "Utilities/invalidInput_error.h" #include "Utilities/safe_casting.h" + //random vehicle Distribution RoadMaker::RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength, const real vehicleDensity) { diff --git a/src/Traffic/RoadNetwork/RoadNetworkData.h b/src/Traffic/RoadNetwork/RoadNetworkData.h index cb5787488..e60a107d0 100644 --- a/src/Traffic/RoadNetwork/RoadNetworkData.h +++ b/src/Traffic/RoadNetwork/RoadNetworkData.h @@ -4,7 +4,6 @@ #include <VirtualFluidsDefinitions.h> - #include "Source/Source.h" #include "Sink/Sink.h" #include "Junction/Junction.h" diff --git a/src/Traffic/Sink/SinkRandom.cpp b/src/Traffic/Sink/SinkRandom.cpp index 63a792ac2..9e49f83d1 100644 --- a/src/Traffic/Sink/SinkRandom.cpp +++ b/src/Traffic/Sink/SinkRandom.cpp @@ -1,5 +1,7 @@ #include "SinkRandom.h" +#include <iostream> + #include "Utilities/invalidInput_error.h" SinkRandom::SinkRandom(uint sinkIndex, real sinkBlockedPossibility) diff --git a/src/Traffic/Sink/SinkRandom.h b/src/Traffic/Sink/SinkRandom.h index ed7426103..c5c28bf77 100644 --- a/src/Traffic/Sink/SinkRandom.h +++ b/src/Traffic/Sink/SinkRandom.h @@ -1,6 +1,6 @@ #pragma once -#include <iostream> + #include <random> #include "Sink.h" diff --git a/src/Traffic/Source/SourceRandom.cpp b/src/Traffic/Source/SourceRandom.cpp index 8fbcee3ef..bb39cb957 100644 --- a/src/Traffic/Source/SourceRandom.cpp +++ b/src/Traffic/Source/SourceRandom.cpp @@ -2,6 +2,9 @@ #include "SourceRandom.h" +#include <iostream> + +#include "Utilities/invalidInput_error.h" SourceRandom::SourceRandom(const uint sourceIndex, const real sourcePossibility, uint maxVelocity) { diff --git a/src/Traffic/Source/SourceRandom.h b/src/Traffic/Source/SourceRandom.h index 7bf18889e..b7c6dac9a 100644 --- a/src/Traffic/Source/SourceRandom.h +++ b/src/Traffic/Source/SourceRandom.h @@ -1,11 +1,11 @@ #pragma once #include <VirtualFluidsDefinitions.h> -#include <iostream> #include <random> + #include "Source.h" #include "Utilities/RandomHelper.h" -#include "Utilities/invalidInput_error.h" + class VF_PUBLIC SourceRandom: diff --git a/src/Traffic/TrafficMovement.cpp b/src/Traffic/TrafficMovement.cpp index f3b0e0a3d..1b9b53b00 100644 --- a/src/Traffic/TrafficMovement.cpp +++ b/src/Traffic/TrafficMovement.cpp @@ -9,7 +9,6 @@ #include "Output/ConcentrationOutwriter.h" #include "Output/CarDisplay.h" #include "Utilities/Logger.h" - #include "GPU/TrafficTimestep.h" TrafficMovement::TrafficMovement(std::shared_ptr<RoadNetworkData> road, const real dawdlePossibility) @@ -532,14 +531,15 @@ void TrafficMovement::visualizeVehicleLengthForVTK() { if (useGPU) copyDevToHost(); - road->currentWithLongVehicles = *(road->pcurrent); + int speed; if (road->safetyDistance != 0) { for (uint i = 0; i < road->roadLength; i++) { - if ((*(road->pcurrent))[i] > -1) { + speed = (*(road->pcurrent))[i]; + road->currentWithLongVehicles[i] = speed; + if (speed > -1) { //checkSpeed((*(road->pcurrent))[i]); int neighbor = road->neighbors[i]; - for (uint j = 1; j <= road->safetyDistance; j++) { if (neighbor <= -1000) @@ -550,8 +550,9 @@ void TrafficMovement::visualizeVehicleLengthForVTK() break; } else - (road->currentWithLongVehicles)[neighbor] = (*(road->pcurrent))[i]; + (road->currentWithLongVehicles)[neighbor] = speed; neighbor = road->neighbors[neighbor]; + i++; } } } diff --git a/src/Traffic/TrafficMovementFactory - Kopie.h b/src/Traffic/TrafficMovementFactory - Kopie.h index c1ae8b9dd..12c08ef75 100644 --- a/src/Traffic/TrafficMovementFactory - Kopie.h +++ b/src/Traffic/TrafficMovementFactory - Kopie.h @@ -1,12 +1,12 @@ # pragma once #include <VirtualFluidsDefinitions.h> +#include "Core/DataTypes.h" #include <vector> #include <memory> #include "TrafficMovementFactory.h" -#include "Core/DataTypes.h" #include "GridGenerator/StreetPointFinder/StreetPointFinder.h" diff --git a/src/Traffic/TrafficMovementFactory.cpp b/src/Traffic/TrafficMovementFactory.cpp index 69c6c1f5d..ad28aa89b 100644 --- a/src/Traffic/TrafficMovementFactory.cpp +++ b/src/Traffic/TrafficMovementFactory.cpp @@ -21,6 +21,7 @@ TrafficMovementFactory::TrafficMovementFactory() { } + void TrafficMovementFactory::initTrafficMovement(std::string path, real * pConcArray) { //Variables @@ -34,11 +35,11 @@ void TrafficMovementFactory::initTrafficMovement(std::string path, real * pConcA real dawdlePossibility = (real) 0.2; //typical value: 0.2 real slowToStartPossibility = (real) 0.3; - bool useGPU = false; + bool useGPU = true; bool useSlowToStart = true; useLogger = true; - std::string info = "Only Traffic, writing vtk"; + std::string info = "Only Traffic, full writing"; @@ -58,7 +59,7 @@ void TrafficMovementFactory::initTrafficMovement(std::string path, real * pConcA } - //StreetPointFinder M:\Basel2019 C:\Users\schoen\Desktop\git\MS2 + //StreetPointFinder M:/Basel2019 C:/Users/schoen/Desktop/git/MS2 //finder.readStreets("C:/Users/schoen/Desktop/git/MS2/git/targets/apps/LBM/streetTest/resources/ExampleStreets.txt"); //finder.writeVTK("M:/Basel2019/results/ExampleStreets.vtk"); finder.readStreets(inputPath + "Streets.txt"); @@ -110,7 +111,7 @@ void TrafficMovementFactory::initTrafficMovement(std::string path, real * pConcA std::vector <std::unique_ptr<Junction> > junctions; for (uint i = 0; i < junctionReader.junctions.size(); i++) { junctions.push_back(std::make_unique <JunctionRandom>(junctionReader.junctions[i].inCells, junctionReader.junctions[i].outCells, junctionReader.junctions[i].trafficLightSwitchTime)); - junctions[i]->setCellIndexForNoUTurn(junctionReader.junctions[i].carCanNotEnterThisOutCell); + junctions[i]->setCellIndecesForNoUTurn(junctionReader.junctions[i].carCanNotEnterThisOutCell); } roadNetwork->setJunctions(move(junctions)); diff --git a/src/Traffic/TrafficMovementFactory.h b/src/Traffic/TrafficMovementFactory.h index 26564a4ab..c5fa8b87e 100644 --- a/src/Traffic/TrafficMovementFactory.h +++ b/src/Traffic/TrafficMovementFactory.h @@ -1,11 +1,11 @@ # pragma once #include <VirtualFluidsDefinitions.h> +#include "Core/DataTypes.h" #include <vector> #include <memory> -#include "Core/DataTypes.h" #include "GridGenerator/StreetPointFinder/StreetPointFinder.h" class TrafficMovement; diff --git a/src/Traffic/Utilities/ConsoleColor.cpp b/src/Traffic/Utilities/ConsoleColor.cpp new file mode 100644 index 000000000..d8db3d440 --- /dev/null +++ b/src/Traffic/Utilities/ConsoleColor.cpp @@ -0,0 +1,74 @@ +#include "ConsoleColor.h" + + + +#include <VirtualFluidsDefinitions.h> +#include "Core/DataTypes.h" + + +//// Windows ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#ifdef WIN32 + +#include <iostream> +#include <iomanip> //formatting output streams +#include <windows.h> //for colourful console output + + +void ConsoleColor::setDefaultWhite() +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); // set output default white 7; +} + + +void ConsoleColor::setDarkGrey() +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 8); //set output dark grey 8, dark blue 1, black 0; +} + + +void ConsoleColor::setBrightRed() +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12); //set output bright green 10, bright red 12; +} + + +void ConsoleColor::setBlack() +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0); //set output dark grey 8, dark blue 1, black 0; +} + + +void ConsoleColor::setBrightGreen() +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10); //set output bright green 10, bright red 12; +} + + +#endif WIN32 + + + + + +//// Linux ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef WIN32 + +void ConsoleColor::setDefaultWhite() +{} + +void ConsoleColor::setDarkGrey() +{} + +void ConsoleColor::setBrightRed() +{} + +void ConsoleColor::setBlack() +{} + +void ConsoleColor::setBrightGreen() +{} + +#endif // !WIN32 + + diff --git a/src/Traffic/Utilities/ConsoleColor.h b/src/Traffic/Utilities/ConsoleColor.h new file mode 100644 index 000000000..1307b14e5 --- /dev/null +++ b/src/Traffic/Utilities/ConsoleColor.h @@ -0,0 +1,15 @@ +#pragma once + + + +class VF_PUBLIC ConsoleColor +{ +public: + static void setDefaultWhite(); + static void setDarkGrey(); + static void setBrightRed(); + static void setBlack(); + static void setBrightGreen(); + +}; + diff --git a/src/Traffic/Utilities/Logger.h b/src/Traffic/Utilities/Logger.h index bc3f637df..6d2544c96 100644 --- a/src/Traffic/Utilities/Logger.h +++ b/src/Traffic/Utilities/Logger.h @@ -16,7 +16,6 @@ private: public: TrafficLogger() {}; TrafficLogger(const TrafficLogger& logger) {} - // TrafficLogger& operator = (const TrafficLogger& logger) {}; static void startLogger(std::string filename); static void writeSimulationStart(std::string info, bool useGPU); diff --git a/src/Traffic/Utilities/RandomHelper.cpp b/src/Traffic/Utilities/RandomHelper.cpp index 176334f63..264dcd6eb 100644 --- a/src/Traffic/Utilities/RandomHelper.cpp +++ b/src/Traffic/Utilities/RandomHelper.cpp @@ -1,7 +1,6 @@ #include "RandomHelper.h" - std::mt19937 RandomHelper::make_engine() { std::random_device r; diff --git a/src/Traffic/Utilities/RandomHelper.h b/src/Traffic/Utilities/RandomHelper.h index c4fc9c1ed..c13164060 100644 --- a/src/Traffic/Utilities/RandomHelper.h +++ b/src/Traffic/Utilities/RandomHelper.h @@ -1,4 +1,5 @@ #pragma once + #include <random> #include <VirtualFluidsDefinitions.h> diff --git a/src/Traffic/Utilities/VectorHelper.cpp b/src/Traffic/Utilities/VectorHelper.cpp index ac5627748..a239991aa 100644 --- a/src/Traffic/Utilities/VectorHelper.cpp +++ b/src/Traffic/Utilities/VectorHelper.cpp @@ -1,5 +1,10 @@ #include "VectorHelper.h" +#include <iostream> +#include <iomanip> //formatting output streams + +#include "ConsoleColor.h" + void VectorHelper::fillVector(std::vector<int> &vector, int insertNumber) { fill(vector.begin(), vector.end(), insertNumber); } @@ -36,7 +41,7 @@ void VectorHelper::dispVectorColour(const std::vector<int> &vector) std::cout << std::setw(4) << number; } std::cout << std::endl; - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); // set output default white 7; + ConsoleColor::setDefaultWhite(); } void VectorHelper::dispVectorColour(const std::vector<std::vector<int>>& vector) @@ -49,23 +54,23 @@ void VectorHelper::dispVectorColour(const std::vector<std::vector<int>>& vector) std::cout << std::endl; } std::cout << std::endl; - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); // set output default white 7; + ConsoleColor::setDefaultWhite(); } void VectorHelper::makeVectorOutputColourful(int outputNumber) { switch (outputNumber) { case -1: - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 8); //set output dark grey 8, dark blue 1, black 0; + ConsoleColor::setDarkGrey(); break; case 0: - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12); //set output bright green 10, bright red 12; + ConsoleColor::setBrightRed(); break; case -5: - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0); //set output dark grey 8, dark blue 1, black 0; + ConsoleColor::setBlack(); break; default: - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10); //set output bright green 10, bright red 12; + ConsoleColor::setBrightGreen(); } } \ No newline at end of file diff --git a/src/Traffic/Utilities/VectorHelper.h b/src/Traffic/Utilities/VectorHelper.h index 21161e670..ee7bce706 100644 --- a/src/Traffic/Utilities/VectorHelper.h +++ b/src/Traffic/Utilities/VectorHelper.h @@ -1,9 +1,6 @@ #pragma once -#include <vector> -#include <iostream> -#include <windows.h> //for colourful console output -#include <iomanip> //formatting output streams +#include <vector> #include <VirtualFluidsDefinitions.h> #include "Core/DataTypes.h" @@ -11,7 +8,6 @@ class VF_PUBLIC VectorHelper { public: - static void fillVector(std::vector<int>& vector, int insertNumber); static void fillVector(std::vector<std::vector<int> > &vector, int insertNumber); diff --git a/src/Traffic/Utilities/invalidInput_error.cpp b/src/Traffic/Utilities/invalidInput_error.cpp index 12aae8bc5..9d72fd451 100644 --- a/src/Traffic/Utilities/invalidInput_error.cpp +++ b/src/Traffic/Utilities/invalidInput_error.cpp @@ -1,5 +1,8 @@ #include "invalidInput_error.h" +#include <iostream> + + invalidInput_error::invalidInput_error(char const * const message) throw() : runtime_error(message) { } diff --git a/src/Traffic/Utilities/invalidInput_error.h b/src/Traffic/Utilities/invalidInput_error.h index 96633c621..fc50c3d6b 100644 --- a/src/Traffic/Utilities/invalidInput_error.h +++ b/src/Traffic/Utilities/invalidInput_error.h @@ -2,7 +2,6 @@ #include <VirtualFluidsDefinitions.h> // using standard exceptions -#include <iostream> #include <stdexcept> class VF_PUBLIC invalidInput_error : diff --git a/targets/apps/LBM/Basel/resources/testStreets/Junctions6.txt b/targets/apps/LBM/Basel/resources/testStreets/Junctions6.txt new file mode 100644 index 000000000..de197e65e --- /dev/null +++ b/targets/apps/LBM/Basel/resources/testStreets/Junctions6.txt @@ -0,0 +1,3 @@ +1 +in 3 5 1 out -2 -2 -2 2 4 0 t 30 +end \ No newline at end of file diff --git a/targets/apps/LBM/Basel/resources/testStreets/Sinks6.txt b/targets/apps/LBM/Basel/resources/testStreets/Sinks6.txt new file mode 100644 index 000000000..aef3eef93 --- /dev/null +++ b/targets/apps/LBM/Basel/resources/testStreets/Sinks6.txt @@ -0,0 +1,4 @@ +3 +0 0.5 +2 0.5 +4 0.5 diff --git a/targets/apps/LBM/Basel/resources/testStreets/Sources6.txt b/targets/apps/LBM/Basel/resources/testStreets/Sources6.txt new file mode 100644 index 000000000..34986f41d --- /dev/null +++ b/targets/apps/LBM/Basel/resources/testStreets/Sources6.txt @@ -0,0 +1,4 @@ +3 +1 0.4 +3 0.4 +5 0.4 \ No newline at end of file diff --git a/targets/apps/LBM/Basel/resources/testStreets/Streets6.txt b/targets/apps/LBM/Basel/resources/testStreets/Streets6.txt new file mode 100644 index 000000000..1c297ca83 --- /dev/null +++ b/targets/apps/LBM/Basel/resources/testStreets/Streets6.txt @@ -0,0 +1,7 @@ +6 + -2 0 256 0 1 + 256 5 0 5 1 + 0 5 0 256 1 + -5 256 -5 5 1 + -5 5 -256 5 1 + -256 0 -2 0 1 diff --git a/targets/apps/LBM/TrafficTest/Traffic_Main.cpp b/targets/apps/LBM/TrafficTest/Traffic_Main.cpp index ee4331ce9..7b630e648 100644 --- a/targets/apps/LBM/TrafficTest/Traffic_Main.cpp +++ b/targets/apps/LBM/TrafficTest/Traffic_Main.cpp @@ -12,9 +12,9 @@ int main() { - ////Basel + //////Basel { - uint numberOfTimesteps = 100; + uint numberOfTimesteps = 1000; //Stephans Logger logging::Logger::addStream(&std::cout); -- GitLab