Commit dbf2ec47 authored by Mohcine Chraibi's avatar Mohcine Chraibi

merge into develop

parents d5202409 019a12c7
Pipeline #6292 canceled with stages
......@@ -36,6 +36,12 @@ endif ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${warnings}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${warnings}")
# TODO clean up. no flags.
#set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF)
if (NOT BUILD_TESTING)
set(BUILD_TESTING OFF) # test units & python tests are not generated.
endif (NOT BUILD_TESTING)
......@@ -477,6 +483,11 @@ set(header_files
)
add_library(core STATIC ${source_files})
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
add_library(cnpy SHARED "cnpy/cnpy.cpp")
target_link_libraries(cnpy ${ZLIB_LIBRARIES})
#add_library ( core SHARED ${source_files} )
......@@ -497,7 +508,7 @@ if (Boost_FOUND)
# suppress warnings in boost libraries with attribute SYSTEM
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
# todo: is this necessary?
target_link_libraries(core ${Boost_LIBRARIES})
target_link_libraries(core ${Boost_LIBRARIES} cnpy)
endif ()
target_link_libraries(jpscore core)
......
......@@ -21,7 +21,6 @@
#include "GeoFileParser.h"
#include "../tinyxml/tinyxml.h"
#include "../geometry/Goal.h"
#include "../geometry/SubRoom.h"
GeoFileParser::GeoFileParser(Configuration* configuration)
......
......@@ -33,8 +33,6 @@
#include "../mpi/LCGrid.h"
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
......
......@@ -28,11 +28,8 @@
#include "OutputHandler.h"
#include <stdio.h>
#include <stdarg.h>
#include <cstdlib>
#include <cmath>
#include <cstdarg> // va_start and va_end
using namespace std;
void OutputHandler::incrementWarnings()
......
......@@ -21,7 +21,7 @@
#include "PedDistributionParser.h"
#include "../tinyxml/tinyxml.h"
#include <cstdarg> // va_start and va_end
PedDistributionParser::PedDistributionParser(const Configuration* configuration)
:_configuration(configuration)
{
......
......@@ -29,9 +29,6 @@
/********* include files ******************************************************/
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "TraVisToClient.h"
#include "../general/Macros.h"
......
......@@ -104,17 +104,21 @@ void SmokeSensor::execute(const Pedestrian * pedestrian, CognitiveMap& cognitive
item->GetCrossing()->GetCentre(),
pedestrian->GetGlobalTime()).GetKnotValue(pedestrian->GetPos()._x,
pedestrian->GetPos()._y);
// std::cout << "\n =================================== \n";
// std::cout << "Ped: " << pedestrian->GetID() << ", at (" << pedestrian->GetPos()._x << ", " << pedestrian->GetPos()._y << ")" << std::endl;
// std::cout << "\tElevation: " << pedestrian->GetElevation() << std::endl;
// std::cout << "\titem->GetCrossing()->GetCentre(): " << item->GetCrossing()->GetCentre()._x << ", " << item->GetCrossing()->GetCentre()._y << std::endl;
// std::cout << "\t Time" << pedestrian->GetGlobalTime() << std::endl;
// std::cout << "\tKnotValue: " << _FMStorage->GetFDSMesh(pedestrian->GetElevation(), item->GetCrossing()->GetCentre(), pedestrian->GetGlobalTime()).GetKnotValue(pedestrian->GetPos()._x, pedestrian->GetPos()._y) << std::endl;
if(SmokeFactor > 2){
std::cout << "\n =================================== \n";
std::cout << "Ped: " << pedestrian->GetID() << ", at (" << pedestrian->GetPos()._x << ", " << pedestrian->GetPos()._y << ")" << std::endl;
std::cout << "\tElevation: " << pedestrian->GetElevation() << std::endl;
std::cout << "\titem->GetCrossing()->GetCentre(): " << item->GetCrossing()->GetCentre()._x << ", " << item->GetCrossing()->GetCentre()._y << std::endl;
std::cout << "\t Time: " << pedestrian->GetGlobalTime() << std::endl;
std::cout << "\tKnotValue: " << _FMStorage->GetFDSMesh(pedestrian->GetElevation(), item->GetCrossing()->GetCentre(), pedestrian->GetGlobalTime()).GetKnotValue(pedestrian->GetPos()._x, pedestrian->GetPos()._y) << std::endl;
std::cout << "SmokeFactor: " << SmokeFactor << std::endl;
std::cout << "Risktolerance: " << RiskTolerance << std::endl;
}
weight = 1 + (1-RiskTolerance) * SmokeFactor ;
}
/// Set Edge Weight
// std::cout << weight << std::endl;
//std::cout << "weight: "<< weight << std::endl;
item->SetFactor(weight,GetName());
}
......
......@@ -30,12 +30,7 @@
#include "../../pedestrian/Pedestrian.h"
#include "../generic/FDSMesh.h"
#include "../generic/FDSMeshStorage.h"
#include "../../pedestrian/PedDistributor.h"
#include "../../tinyxml/tinyxml.h"
#include <set>
#include <algorithm>
#include <math.h>
#include "../../IO/OutputHandler.h"
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
......
#include "FDSMesh.h"
#include <cmath>
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>
#include "../../cnpy/cnpy.h"
std::vector<std::string> &split2(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
......@@ -163,17 +159,23 @@ void FDSMesh::ReadMatrix(std::string line, std::ifstream &pFile)
while (std::getline(pFile, line)) {
n = 0;
strVec = split2(line, ',', strVec);
for (auto &elem : strVec)
{
for (auto &elem : strVec) {
//std::cout << elem << " col " << n << " line " << m << std::endl;
if (elem=="nan" || elem=="NAN" || elem=="NaN" || elem=="-inf" || elem=="inf")
{
if (elem=="nan" || elem=="NAN" || elem=="NaN" || elem=="-inf" || elem=="inf") {
_matrix[m][n].SetValue(1.0);
//Log->Write("ERROR: Mesh values consist of nan!");
//exit(EXIT_FAILURE);
}
else
_matrix[m][n].SetValue(std::stod(elem));
else {
double temp = 0;
try {
temp = std::stod(elem);
}
catch (...) {
std::cout << "can not convert " << elem << std::endl;
}
_matrix[m][n].SetValue(temp);
}
++n;
}
strVec.clear();
......@@ -188,46 +190,49 @@ void FDSMesh::SetKnotValuesFromFile(const std::string &filename)
{
///open File (reading)
std::ifstream pFile(filename);
if (pFile)
if(!pFile)
{
std::vector<std::string> strVec;
std::string line;
///skip two lines
std::getline(pFile, line);
std::getline(pFile, line);
std::getline(pFile, line);
//std::cout << line << std::endl;
/// to avoid multiple reading of the header and mesh setting
//if (statHeaderRead==false)
//{
/// read header
strVec = split2(line,',', strVec);
double cellsize = std::stod(strVec[0]);
double xmin = std::stod(strVec[2]);
double xmax = std::stod(strVec[3]);
double ymin = std::stod(strVec[4]);
double ymax = std::stod(strVec[5]);
Log->Write("ERROR:\tCould not open FDS slicefile: %s",filename.c_str());
//return false;
exit(EXIT_FAILURE);
}
strVec.clear();
//std::cout << "xmin=" << xmin << " , xmax=" << xmax << " , ymin=" << ymin << ", ymax=" << ymax << " , dx=" << cellsize << std::endl;
cnpy::NpyArray Header = cnpy::npz_load(filename,"header");
cnpy::NpyArray smoke_factor_grid_norm = cnpy::npz_load(filename,"smoke_factor_grid_norm");
auto c_header = Header.data<double>();
auto c_matrix = smoke_factor_grid_norm.data<double>();
SetUpMesh(xmin,ymin,xmax,ymax,cellsize);
for (int i=0; i< Header.num_vals ; i++)
std::cout << "Header i: " << i << ": " << c_header[i] << std::endl;
//statHeaderRead=true;
//}
//Read matrix
ReadMatrix(line, pFile);
for (int j=0; j< smoke_factor_grid_norm.num_vals; j++)
std::cout << "Matrix j: "<< c_matrix[j] << std::endl;
}
else
{
Log->Write("ERROR:\tCould not open FDS slicefile: %s",filename.c_str());
//return false;
exit(EXIT_FAILURE);
}
/// read header
double cellsize = c_header[0];
double xmin = c_header[1];
double xmax = c_header[2];
double ymin = c_header[3];
double ymax = c_header[4];
std::cout << "xmin=" << xmin << " , xmax=" << xmax << " , ymin=" << ymin << ", ymax=" << ymax << " , dx=" << cellsize << std::endl;
SetUpMesh(xmin,ymin,xmax,ymax,cellsize);
//Read matrix
int ncol = smoke_factor_grid_norm.shape[1];
int nrow = smoke_factor_grid_norm.shape[0];
for (unsigned int i=0; i< nrow; i++)
for (unsigned int j=0; j< ncol; j++) {
double tmp_value = c_matrix[i*ncol+j];
if(std::isnan(tmp_value) || std::isinf(tmp_value))
tmp_value = 1.0;
std::cout << "i = " << i << " j = " << j << ": " << tmp_value << std::endl;
_matrix[i][j].SetValue(tmp_value); //TODO: implement =operator
}
pFile.close();
_statMesh=true;
}
bool FDSMesh::statusMesh() const
......
......@@ -27,11 +27,8 @@
*
**/
#include "FDSMeshStorage.h"
#include "../../IO/OutputHandler.h"
//#include <unistd.h>
#include <stdio.h>
//#include <glob.h>
#include <string>
#include <boost/filesystem.hpp>
namespace fs=boost::filesystem;
......@@ -161,7 +158,7 @@ void FDSMeshStorage::CreateTimeList()
{
/// Create time list for mesh refreshment
_timelist.clear();
double i=0;
double i=0;
while (i<=_finalTime)
{
_timelist.push_back(i);
......@@ -173,20 +170,22 @@ void FDSMeshStorage::CreateTimeList()
for(auto elem : _timelist) {
if (_doorlist.size() > 0) { // Smoke sensor active
check_str = _filepath + _quantitylist[0] + "/" +
_doorlist[0] + "/t_" + std::to_string(elem) + ".csv";
// std::cout << "1: " << check_str << std::endl;
_doorlist[0] + "/t_" + std::to_string(elem) + ".npz";
std::cout << "1: " << check_str << std::endl;
}
else if (_doorlist.size() == 0) { // Smoke sensor not active
check_str = _filepath + _quantitylist[0] + "/Z_" +
std::to_string(_elevationlist[0]) + "/t_" + std::to_string(elem) + ".csv";
// std::cout << "2: " << check_str << std::endl;
std::to_string(_elevationlist[0]) + "/t_" + std::to_string(elem) + ".npz";
std::cout << "2: " << check_str << std::endl;
}
if (fs::exists(check_str) == false )
{
Log->Write("ERROR:\tSpecified times are not compliant with JPSfire data " + check_str);
std::cout << "Not found: " << check_str << std::endl;
exit(EXIT_FAILURE);
}
std::cout << "LEAVING \n" ;
}
}
......@@ -198,14 +197,20 @@ void FDSMeshStorage::CreateFDSMeshes()
if (_doorlist.size() > 0) { // Smoke sensor active
for (auto &h:_quantitylist) //list of quantities
{
std::cout << "H: " << h << std::endl;
for (auto &j:_doorlist) //list of doors
{
std::cout << "door: " << j << std::endl;
//std::cout << "door " << j << std::endl;
for (auto &k:_timelist) //list of times
{
std::cout << "time: " << k << std::endl;
std::string str = h + "/" + j + "/t_"+std::to_string(k);
//std::cout << _filepath + str + ".csv" << std::endl;
FDSMesh mesh(_filepath + str + ".csv");
std::cout << _filepath + str + ".npz" << std::endl;
FDSMesh mesh(_filepath + str + ".npz");
//std::string str = "t_"+std::to_string(i);
_fMContainer.insert(std::make_pair(str, mesh));
}
......@@ -223,11 +228,11 @@ void FDSMeshStorage::CreateFDSMeshes()
//std::cout << "k " << j << std::endl;
std::string str = h + "/Z_" + std::to_string(i) +
"/t_"+std::to_string(k);
//std::cout << _filepath + str + ".csv" << std::endl;
//std::cout << _filepath + str + ".npz" << std::endl;
FDSMesh mesh(_filepath + str + ".csv");
FDSMesh mesh(_filepath + str + ".npz");
//std::cout << _filepath + str + ".csv" << std::endl;
//std::cout << _filepath + str + ".npz" << std::endl;
//std::string str = "t_"+std::to_string(i);
_fMContainer.insert(std::make_pair(str, mesh));
}
......@@ -295,9 +300,9 @@ const FDSMesh &FDSMeshStorage::GetFDSMesh(const double &pedElev, const Point &do
throw -1;
}
if (_fMContainer.count(str) == 1) {
std::cout << "INFO: requested sfgrid: " << str << std::endl;
}
// if (_fMContainer.count(str) == 1) {
// std::cout << "INFO: requested sfgrid: " << str << std::endl;
// }
return _fMContainer.at(str);
}
......
......@@ -35,12 +35,9 @@
#include "math/GompertzModel.h"
#include "math/GradientModel.h"
#include "pedestrian/AgentsQueue.h"
#include "pedestrian/AgentsSourcesManager.h"
#ifdef _OPENMP
#include <omp.h>
#else
#define omp_get_thread_num() 0
#define omp_get_max_threads() 1
......
......@@ -7,12 +7,12 @@ See template_test/How_to_make_new_test.txt
import fnmatch
import glob
import logging
from os import path
import numpy as np
import os
from stat import S_ISREG, ST_MODE, ST_MTIME
import subprocess
import sys
import numpy as np
from os import path
from stat import S_ISREG, ST_MODE, ST_MTIME
__author__ = 'Oliver Schmidts'
__email__ = 'dev@jupedsim.org'
......
......@@ -2,11 +2,12 @@
measure the fundamental diagram in a 1d scenario.
return density, velocity
"""
import glob
import numpy as np
import os
import glob
from sys import *
import sys
from sys import *
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
path.append(utestdir)
from utils import *
......
......@@ -22,9 +22,10 @@ Source
"""
import matplotlib.pyplot as plt
import os
import sys
import matplotlib.pyplot as plt
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
......
......@@ -2,9 +2,9 @@
plot fundamental diagram produced by runtest
just to check the results without reruning the test
"""
import glob
import matplotlib.pyplot as plt
import numpy as np
import glob
simfiles = glob.glob("Output/Fundamental_Diagram/Individual_FD/*.dat")
expfiles = glob.glob("data/*.txt")
......
......@@ -16,9 +16,10 @@ Source
"""
import matplotlib.pyplot as plt
import os
import sys
import matplotlib.pyplot as plt
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
......
......@@ -17,9 +17,10 @@ Source
"""
import matplotlib.pyplot as plt
import os
import sys
import matplotlib.pyplot as plt
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
......
......@@ -17,9 +17,10 @@ Source
"""
import matplotlib.pyplot as plt
import os
import sys
import matplotlib.pyplot as plt
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
......
......@@ -18,9 +18,10 @@ Source
Table 4.4 Jun Zhang Diss.
"""
import matplotlib.pyplot as plt
import os
import sys
import matplotlib.pyplot as plt
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
......
......@@ -18,9 +18,10 @@ Source
"""
import matplotlib.pyplot as plt
import os
import sys
import matplotlib.pyplot as plt
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
......
#!/usr/bin/env python3
import glob
import logging
import matplotlib.pyplot as plt
import multiprocessing
import numpy as np
import os, logging, time, sys
from sys import argv, exit
import subprocess, glob
import os
import subprocess
import sys
import time
from os import path
import multiprocessing
import matplotlib.pyplot as plt
from sys import argv, exit
def get_empirical_flow():
files = glob.glob("experiments/*.txt")
......@@ -79,7 +84,7 @@ if __name__ == "__main__":
# lib_path = os.path.abspath(lib_path)
sys.path.append(lib_path)
from utils import SUCCESS, FAILURE
from utils import parse_file, flow, rolling_flow
from utils import parse_file, rolling_flow
# from utils import get_maxtime
os.chdir("..")
TRUNK = os.getcwd()
......
......@@ -2,14 +2,16 @@
# todo: spaghetti code. directory mess
import numpy as np
from xml.dom import minidom
import os, argparse, logging, time
from os import path, system
from sys import argv ,exit
import subprocess, glob, sys
import multiprocessing
import glob
import logging
import matplotlib.pyplot as plt
import numpy as np
import os
import subprocess
import sys
import time
from os import path
from sys import argv, exit
#=========================
testnr = 10
......
#! /usr/bin/env python
import glob
import logging
import numpy as np
import os
import subprocess
import sys
from os import path
from sys import argv, exit
from xml.dom import minidom
import os, argparse, logging, time
from os import path, system
from sys import argv ,exit
import subprocess, glob
import multiprocessing
import matplotlib.pyplot as plt
import re, sys
#=========================
testnr = 11
......
#! /usr/bin/env python
import glob
import logging
import numpy as np
import os
import subprocess
import sys
from os import path
from sys import argv, exit
from xml.dom import minidom
import os, argparse, logging, time
from os import path, system
from sys import argv ,exit
import subprocess, glob
import multiprocessing
import matplotlib.pyplot as plt
import re, sys
#=========================
testnr = 11
......
#! /usr/bin/env python
import logging
import numpy as np
from xml.dom import minidom
import os, argparse, logging, time
from os import path, system
from sys import argv ,exit
import subprocess, glob
import multiprocessing
import matplotlib.pyplot as plt
import re
import os