diff --git a/src/GridGenerator/StreetPointFinder/JunctionReader.cpp b/src/GridGenerator/StreetPointFinder/JunctionReader.cpp index 1ce67fb89c8e40859210c6296a760d409ae54d65..c0ebd8b8847c7ad295b837522fabf0db7ea5c9f5 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 b57bf3bc5a0e05fdc0396ea1a03a1e1fb2cebd60..015e7d33daffd8650bd080218580b8e9a7e1feb9 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 1a275c759d086486c3f97a16611b0ec80aabcfd2..15eee8a3a9b9d0d5e875c43ac07ee1a9c376c07b 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 bc49c159f9b68f0a50288bd09f74dfa70061cac7..323d8acfc85999468cd2bef68db43b7afb67217d 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 85bcdc5a90111d09d119be154e844581f1d3eebb..f666047d478b1820b33ee0aebf621120c85211f3 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 9f9225760436c4303c0d825dd60217edab37c3f9..c352f87f01abb17ea10028c23045f84ff1012430 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 66d600752add05c10b9cb19acc5e87f8f436fb93..b924005d5f1cc85fcb6acd66417fd861ed72e448 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 f64cdd496ec9a8c6f9b2bb0538835470827a7ec1..20750f4e04c0af77258940a3dafa12bed8da9ea6 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 25c1e7445f1f9173a93d73dfc67cd0e9bf0495e5..b31291fd395c88d3862dc93caa869a90933503a6 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 c1b119ac631b4fa4d92c51694b86b7ce07c75e02..96d8e31b5cc357fff89d63282ad010b4043d6421 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 e54709fbbd03ed788446442e7ffa2691b66f2015..3010ac41c05d47a69a37148f9bd5e689cffa0833 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 68be7d5f1a50f999b906b4cd4d4e34d587cf8269..cf8d13a7047855ee10eb452e7ff74fad7b8be410 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 ca02a9cd8bc06b2e5702a6de3f59307d4c0035e1..c90752b521178e572fddd5376a0e3acd4d51d39b 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 cb578748849386b11b078b239426ca32c9211108..e60a107d0bd72a66bbbf0f4ffd05ffeea3b2a419 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 63a792ac2dc7f2a03d78852e43de68c563ff19eb..9e49f83d1b693eace90b285aafaaa54be0ee58c7 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 ed7426103b034f2e5f1549e169844897c0abadf0..c5c28bf778d49c3b88d4cb6567e2bd0011f41ae9 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 8fbcee3ef11000221e81f700e09e9327f1a5ec03..bb39cb95786c71e7246dc68d0365c6f4abaad8f2 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 7bf18889e16c07cbf9e22bc5987ec7b49d961d88..b7c6dac9a48190f15ccefd369d38dcfa8f431b1d 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 f3b0e0a3d729d341ebf709554e9dd08b1a88941a..1b9b53b00334b02feb9b21249d517b241c6fdf47 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 c1ae8b9dd5a34d7d986d14d5a2737d20311d5d37..12c08ef753f669ca13c382ef866246f99a5aafa4 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 69c6c1f5dd67fce3fecfbe232d09854c8656c648..ad28aa89b91649c0fc783a87ae37d2cae1480e46 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 26564a4ab175bbd131ff2e9b92097e1c1d828c9e..c5fa8b87ea91e728e8e9bc348bcfee5b0772a1b3 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 0000000000000000000000000000000000000000..d8db3d4407ef422199974b08e5cf5447fde556d2 --- /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 0000000000000000000000000000000000000000..1307b14e50b71e056f84454fcd0b2e127a9f0b4b --- /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 bc3f637df5a81cc7cc2bed23d36d4a134912e9d2..6d2544c96c37e4eed19f79b02bfe6b509f74cb28 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 176334f63b68a118c17a651c172aee7f541772b1..264dcd6eb9b5335914119a034f7e879b66126dd3 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 c4fc9c1ed98c94b05ababe0594af27156c1835db..c13164060a2346d02292c1b82eed0ab92c086d2e 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 ac5627748f4be25d93047f409b4aa6c7ecf7e0bd..a239991aa8f81d17efdb113457fc87cb3589842d 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 21161e670f70bbe0be69c9ae39000916359afa73..ee7bce7065e89be05e4fe3ffdb30a46313eeac29 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 12aae8bc5174b53080b66d5e061f86b63afb6684..9d72fd451fd080b176b3cf99ef6ffd251bfda9bb 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 96633c621428ee7ded55b5bf9bd4eb006816a9bb..fc50c3d6b3ab656699ca85b711c585ad69ed6ba7 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 0000000000000000000000000000000000000000..de197e65ee32f4efef0cc18960a0e54eebf45b72 --- /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 0000000000000000000000000000000000000000..aef3eef93f236d5d575119b6d2ed31038315b103 --- /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 0000000000000000000000000000000000000000..34986f41d940cdedde923034dd4c6f36a4672058 --- /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 0000000000000000000000000000000000000000..1c297ca830081d311dfe2d3673630e350c03a599 --- /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 ee4331ce9127c2e6a574fb8e3fedccac767265d3..7b630e648f2ea8a24d70d8e633b07d3edeedd10b 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);