Commit 6fd2a795 authored by tobias schroedter's avatar tobias schroedter

WIP commit

parent 5f0a498d
......@@ -811,7 +811,7 @@ set(warning_flags "-Wall -Wextra")
# Initialize CXXFLAGS.
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${warning_flags}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${warning_flags} -O0 -g -Wunused-variable -Wunused-parameter -Wunused-function -Wshadow -Wunused -DTRACE_LOGGING")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${warning_flags} -Wunused-variable -Wunused-parameter -Wunused-function -Wshadow -Wunused -DTRACE_LOGGING")
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
endif ()
......
......@@ -625,6 +625,7 @@ void Simulation::ProcessAgentsQueue()
/* std::cout << "Add to building : " << ped->GetPos()._x << ", " << ped->GetPos()._y << " t: "<< Pedestrian::GetGlobalTime() << std::endl; */
_building->AddPedestrian(ped);
}
_building->UpdateGrid();
// for(auto pp: _building->GetAllPedestrians())
// std::cout<< KBLU << "BUL: Simulation: " << pp->GetPos()._x << ", " << pp->GetPos()._y << " t: "<< Pedestrian::GetGlobalTime() <<RESET << std::endl;
......
......@@ -38,6 +38,7 @@
#include "../mpi/LCGrid.h"
#include "../IO/GeoFileParser.h"
#include <filesystem>
#include <thread> // std::thread, std::thread::id, std::this_thread::get_id
namespace fs = std::filesystem;
......@@ -1156,6 +1157,7 @@ bool Building::SanityCheck()
void Building::UpdateGrid()
{
// std::cout << Pedestrian::GetGlobalTime() <<":\t\tBuilding::UpdateGrid from: " << std::this_thread::get_id() <<std::endl;
_linkedCellGrid->Update(_allPedestians);
}
......
......@@ -35,6 +35,9 @@
Point::Point(const Point& orig)
{
// std::cout << "Point: " << toString() << std::endl;
// std::cout << "orig: " << toString() << std::endl;
_x = orig._x;
_y = orig._y;
}
......
......@@ -39,8 +39,8 @@
class Point {
public:
double _x; //*<x-coordinate of a 2-d point*/
double _y; //*<y-coordinate of a 2-d point*/
double _x = 0.; //*<x-coordinate of a 2-d point*/
double _y = 0.; //*<y-coordinate of a 2-d point*/
public:
......
......@@ -178,6 +178,9 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
partSize = ((int)nSize > nThreads)? (int) (nSize / nThreads):(int)nSize;
if(partSize == (int)nSize)
nThreads = 1; // not worthy to parallelize
//TODO richtig parallelisieren!
#pragma omp parallel default(shared) num_threads(nThreads)
{
vector< Point > result_acc = vector<Point > ();
......@@ -199,11 +202,31 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
vector<Pedestrian*> neighbours;
building->GetGrid()->GetNeighbourhood(ped,neighbours);
double time = Pedestrian::GetGlobalTime();
int size = (int) neighbours.size();
//// if (ped->GetID() == 71) {
//// std::cout << "------------------------------------" << std::endl;
// std::cout << Pedestrian::GetGlobalTime() << ":\t\tVelocity Model debug ped: " << ped->GetID()
// << "\t" << ped->GetPos().toString() << "\t" << size<< std::endl;
//// }
for (int i = 0; i < size; i++) {
Pedestrian* ped1 = neighbours[i];
// if (ped->GetID() == 71) {
// std::cout << "Velocity Model debug ped1: " << ped1->GetID() << "\t" << ped1->GetPos().toString() <<std::endl;
// }
// std::cout << "Velocity Model debug ped1: " << ped1 << std::endl;
// std::cout << ped1->GetID() << std::endl;
if (ped1 == nullptr){
std::cout << "Velocity Model debug: " << size << std::endl;
}
//if they are in the same subroom
Point p1 = ped->GetPos();
Point p2 = ped1->GetPos();
//subrooms to consider when looking for neighbour for the 3d visibility
vector<SubRoom*> emptyVector;
......
......@@ -36,9 +36,13 @@
#include"LCGrid.h"
#include "../pedestrian/Pedestrian.h"
#include <mutex>
using namespace std;
std::mutex grid_mutex;
//FIXME:
#define MAX_AGENT_COUNT 10000 // 1000000
......@@ -99,11 +103,12 @@ void LCGrid::ShallowCopy(const vector<Pedestrian*>& peds)
void LCGrid::Update(const vector<Pedestrian*>& peds)
{
grid_mutex.lock();
ClearGrid();
for (auto& ped: peds)
{
//Pedestrian* ped = peds[p];
//Pedestrian* ped = peds[p];
int id=ped->GetID()-1;
// determine the cell coordinates of pedestrian i
int ix = (int) ((ped->GetPos()._x - _gridXmin) / _cellSize) + 1; // +1 because of dummy cells
......@@ -115,13 +120,22 @@ void LCGrid::Update(const vector<Pedestrian*>& peds)
_cellHead[iy][ix] = id;
_localPedsCopy[id]=ped;
// if (ped->GetID() == 71) {
// std::cout << "pos: " << ped->GetPos().toString() << " ix:" << ix << " iy:" << iy << std::endl;
// }
}
grid_mutex.unlock();
}
// I hope you had called Clear() first
// todo: can be used to solve the issue with MAX_AGENT_COUNT
void LCGrid::Update(Pedestrian* ped)
{
grid_mutex.lock();
int id=ped->GetID()-1;
// determine the cell coordinates of pedestrian i
int ix = (int) ((ped->GetPos()._x - _gridXmin) / _cellSize) + 1; // +1 because of dummy cells
......@@ -133,6 +147,8 @@ void LCGrid::Update(Pedestrian* ped)
// this is probably a pedestrian coming from the mpi routine, so made a copy
_localPedsCopy[id]=ped;
grid_mutex.unlock();
}
void LCGrid::ClearGrid()
......@@ -202,6 +218,7 @@ void LCGrid::HighlightNeighborhood(int pedID, Building* building)
*/
void LCGrid::GetNeighbourhood(const Pedestrian* ped, vector<Pedestrian*>& neighbourhood)
{
grid_mutex.lock();
double xPed=ped->GetPos()._x;
double yPed=ped->GetPos()._y;
......@@ -231,10 +248,25 @@ void LCGrid::GetNeighbourhood(const Pedestrian* ped, vector<Pedestrian*>& neighb
}
}
}
if ((myID == 70) && (fmod(Pedestrian::GetGlobalTime() , 45.) == 0) ){
std::cout << Pedestrian::GetGlobalTime() << ":\t\tNeighborhood of 71 " << neighbourhood.size() << std::endl;
for (auto& ped : neighbourhood){
std::cout << "Neighbor added: " << ped->GetID() << " at " << ped->GetPos().toString() << std::endl;
}
std::cout << "---------------------------" << std::endl;
}
grid_mutex.unlock();
}
void LCGrid::GetNeighbourhood(const Point& pos, std::vector<Pedestrian*>& neighbourhood)
{
grid_mutex.lock();
double xPed=pos._x;
double yPed=pos._y;
......@@ -255,6 +287,8 @@ void LCGrid::GetNeighbourhood(const Point& pos, std::vector<Pedestrian*>& neighb
}
}
}
grid_mutex.unlock();
}
......
......@@ -206,6 +206,9 @@ Pedestrian::Pedestrian(const StartDistribution& agentsParameters, Building& buil
Pedestrian::~Pedestrian()
{
if ((_id>72) && (_id<81)){
std::cout << "Ped destructor" << std::endl;
}
}
......
......@@ -142,6 +142,7 @@ public:
void SetTrips(const Trips& trips);
};
#endif /* _ROUTING_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment