Commit 88cb9470 authored by f.mack's avatar f.mack

Revert "merged reroute"

This reverts commit e99ef625, reversing
changes made to d6a408b2.
parent 993fd826
......@@ -190,10 +190,9 @@ endif (OPENMP_FOUND)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
# test all cpp-files in Utest
if (BUILD_TESTING OR BUILD_CPPUNIT_TEST)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
find_package(Boost COMPONENTS system filesystem unit_test_framework REQUIRED)
IF (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
IF (USE_DUAL_ABI)
......@@ -315,7 +314,11 @@ set(source_files
routing/cognitive_map/sensor/DiscoverDoorsSensor.cpp
routing/cognitive_map/sensor/JamSensor.cpp
routing/cognitive_map/sensor/LastDestinationsSensor.cpp
routing/cognitive_map/sensor/SmokeSensor.cpp
routing/cognitive_map/sensor/locater.cpp
routing/cognitive_map/fire_mesh/FireMesh.cpp
routing/cognitive_map/fire_mesh/Knot.cpp
routing/cognitive_map/fire_mesh/FireMeshStorage.cpp
routing/cognitive_map/cognitiveMap/associations.cpp
routing/cognitive_map/cognitiveMap/cognitivemap.cpp
routing/cognitive_map/cognitiveMap/waypoints.cpp
......@@ -333,15 +336,6 @@ set(source_files
poly2tri/sweep/cdt.cpp
events/EventManager.cpp
events/Event.cpp
JPSfire/generic/FDSMesh.cpp
JPSfire/generic/Knot.cpp
JPSfire/generic/FDSMeshStorage.cpp
JPSfire/A_smoke_sensor/SmokeSensor.cpp
JPSfire/B_walking_speed/WalkingSpeed.cpp
JPSfire/C_toxicity_analysis/ToxicityAnalysis.cpp
JPSfire/C_toxicity_analysis/ToxicityOutputhandler.cpp
math/KrauszModel.cpp)
set(header_files
......@@ -382,7 +376,11 @@ set(header_files
routing/cognitive_map/sensor/DiscoverDoorsSensor.h
routing/cognitive_map/sensor/JamSensor.h
routing/cognitive_map/sensor/LastDestinationsSensor.h
routing/cognitive_map/sensor/SmokeSensor.h
routing/cognitive_map/sensor/locater.h
routing/cognitive_map/fire_mesh/FireMesh.h
routing/cognitive_map/fire_mesh/Knot.h
routing/cognitive_map/fire_mesh/FireMeshStorage.h
routing/cognitive_map/cognitiveMap/associations.h
routing/cognitive_map/cognitiveMap/cognitivemap.h
routing/cognitive_map/cognitiveMap/waypoints.h
......@@ -452,20 +450,10 @@ set(header_files
poly2tri/sweep/sweep.h
events/EventManager.h
events/Event.h
JPSfire/generic/FDSMesh.h
JPSfire/generic/Knot.h
JPSfire/generic/FDSMeshStorage.h
JPSfire/A_smoke_sensor/SmokeSensor.h
JPSfire/B_walking_speed/WalkingSpeed.h
JPSfire/C_toxicity_analysis/ToxicityAnalysis.h
JPSfire/C_toxicity_analysis/ToxicityOutputhandler.h
)
add_library(core STATIC ${source_files})
if(Boost_FOUND)
target_link_libraries(core ${Boost_LIBRARIES})
endif()
add_library(core STATIC ${source_files})
#add_library ( core SHARED ${source_files} )
......@@ -473,7 +461,6 @@ set(header_files
#add_executable(
# jpscore Utest/Fastmarchtest.h
#)
add_executable(jpscore main.cpp)
if (Boost_FOUND)
......@@ -488,13 +475,12 @@ if (Boost_FOUND)
target_link_libraries(jpscore ${Boost_LIBRARIES})
endif ()
target_link_libraries(jpscore core )
target_link_libraries(jpscore core)
if (WIN32)
target_link_libraries(jpscore core wsock32)
endif (WIN32)
# if(CGAL_FOUND)
# target_link_libraries (jpscore ${CGAL_CORE_LIBRARY})
# endif(CGAL_FOUND)
......
......@@ -54,9 +54,6 @@ bool GeoFileParser::LoadGeometry(Building* building)
std::string geoFilenameWithPath = _configuration->GetProjectRootDir()+_configuration->GetGeometryFile();
TiXmlDocument docGeo(geoFilenameWithPath);
if (!docGeo.LoadFile()) {
Log->Write(_configuration->GetProjectRootDir());
Log->Write(_configuration->GetGeometryFile());
Log->Write(geoFilenameWithPath);
Log->Write("ERROR: \t%s", docGeo.ErrorDesc());
Log->Write("\t could not parse the geometry file");
return false;
......
This diff is collapsed.
......@@ -39,7 +39,6 @@ class IniFileParser {
public:
IniFileParser(Configuration* config);
~IniFileParser(){};
bool Parse(std::string iniFile);
......@@ -58,7 +57,7 @@ private:
bool ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* agentDistri);
bool ParseFfRouterOps(TiXmlNode* routingNode, RoutingStrategy s);
bool ParseFfRouterOps(TiXmlNode* routingNode);
bool ParseCogMapOpts(TiXmlNode* routingNode);
......
......@@ -60,8 +60,6 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
int group_id = xmltoi(e->Attribute("group_id"));
int subroom_id = xmltoi(e->Attribute("subroom_id"), -1);
int number = xmltoi(e->Attribute("number"), 0);
double density = xmltof(e->Attribute("density"), 0);
string social_group = xmltoa(e->Attribute("social_group"), "false");
int agent_para_id = xmltoi(e->Attribute("agent_parameter_id"), -1);
int goal_id = xmltoi(e->Attribute("goal_id"), FINAL_DEST_OUT);
......@@ -73,10 +71,8 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
double patience = xmltof(e->Attribute("patience"), 5);
double premovement_mean = xmltof(e->Attribute("pre_movement_mean"), 0);
double premovement_sigma = xmltof(e->Attribute("pre_movement_sigma"), 0);
double premovement_min = xmltof(e->Attribute("pre_movement_min"), 0);
double premovement_max = xmltof(e->Attribute("pre_movement_max"), 0);
double risk_tolerance_mean = xmltof(e->Attribute("risk_tolerance_mean"), 0);
double risk_tolerance_sigma = xmltof(e->Attribute("risk_tolerance_sigma"), 0);
//double risk_tolerance_mean = xmltof(e->Attribute("risk_tolerance_mean"), 0);
//double risk_tolerance_sigma = xmltof(e->Attribute("risk_tolerance_sigma"), 0);
double x_min = xmltof(e->Attribute("x_min"), -FLT_MAX);
double x_max = xmltof(e->Attribute("x_max"), FLT_MAX);
......@@ -98,51 +94,37 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
dis->SetGroupId(group_id);
dis->Setbounds(bounds);
dis->SetAgentsNumber(number);
dis->SetAgentsDensity(density);
dis->SetAge(age);
dis->SetGender(gender);
dis->SetSocialGroup(social_group);
dis->SetGoalId(goal_id);
dis->SetRouteId(route_id);
dis->SetRouterId(router_id);
dis->SetHeight(height);
dis->SetPatience(patience);
if (e->Attribute("pre_movement_mean") && e->Attribute("pre_movement_sigma")) {
std::string distribution_type = "normal";
dis->InitPremovementTime(distribution_type, premovement_mean, premovement_sigma);
}
if (e->Attribute("pre_movement_min") && e->Attribute("pre_movement_max")) {
std::string distribution_type = "uniform";
if(premovement_min > premovement_max){
Log->Write("ERROR:\tpremovement_min > premovement_max!");
return false;
}
dis->InitPremovementTime(distribution_type, premovement_min, premovement_max);
}
dis->InitPremovementTime(premovement_mean, premovement_sigma);
if (e->Attribute("risk_tolerance_mean") && e->Attribute("risk_tolerance_sigma")) {
std::string distribution_type = "normal";
double risk_tolerance_mean = xmltof(e->Attribute("risk_tolerance_mean"), NAN);
double risk_tolerance_sigma = xmltof(e->Attribute("risk_tolerance_sigma"), NAN);
//Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
// risk_tolerance_sigma);
Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
risk_tolerance_sigma);
dis->InitRiskTolerance(distribution_type, risk_tolerance_mean, risk_tolerance_sigma);
}
else if (e->Attribute("risk_tolerance_alpha") && e->Attribute("risk_tolerance_beta")) {
std::string distribution_type = "beta";
double risk_tolerance_alpha = xmltof(e->Attribute("risk_tolerance_alpha"), NAN);
double risk_tolerance_beta = xmltof(e->Attribute("risk_tolerance_beta"), NAN);
//Log->Write("INFO:\trisk tolerance alpha = %f, risk tolerance beta = %f\n", risk_tolerance_alpha,
// risk_tolerance_beta);
Log->Write("INFO:\trisk tolerance alpha = %f, risk tolerance beta = %f\n", risk_tolerance_alpha,
risk_tolerance_beta);
dis->InitRiskTolerance(distribution_type, risk_tolerance_alpha, risk_tolerance_beta);
}
else {
std::string distribution_type = "normal";
double risk_tolerance_mean = 0.;
double risk_tolerance_sigma = 1.;
//Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
// risk_tolerance_sigma);
Log->Write("INFO:\trisk tolerance mu = %f, risk tolerance sigma = %f\n", risk_tolerance_mean,
risk_tolerance_sigma);
dis->InitRiskTolerance(distribution_type, risk_tolerance_mean, risk_tolerance_sigma);
}
......
/**
* \file WalkingSpeed.cpp
* \date Jan 1, 2014
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
* detects smoke in the next rooms
*
*
**/
#include "WalkingSpeed.h"
#include "../../geometry/Building.h"
#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 <string>
WalkingSpeed::WalkingSpeed(const Building * b)
{
_FMStorage = nullptr;
_building = b;
LoadJPSfireInfo(_building->GetProjectFilename());
}
WalkingSpeed::~WalkingSpeed()
{
}
bool WalkingSpeed::LoadJPSfireInfo(const std::string projectFilename )
{
TiXmlDocument doc(projectFilename);
if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("ERROR: \t could not parse the project file");
return false;
}
TiXmlNode* JPSfireNode = doc.RootElement()->FirstChild("JPSfire");
if( ! JPSfireNode ) {
Log->Write("INFO:\tcould not find any JPSfire information");
return true;
}
TiXmlElement* JPSfireCompElem = JPSfireNode->FirstChildElement("B_walking_speed");
if(JPSfireCompElem) {
if(JPSfireCompElem->FirstAttribute()){
std::string study = xmltoa(JPSfireCompElem->Attribute("study"), "");
std::string irritant = xmltoa(JPSfireCompElem->Attribute("irritant"), "");
//std::string filepath = xmltoa(JPSfireCompElem->Attribute("extinction_grids"), "");
std::string filepath = _building->GetProjectRootDir() + xmltoa(JPSfireCompElem->Attribute("extinction_grids"), "");
double updateIntervall = xmltof(JPSfireCompElem->Attribute("update_time"), 0.);
double finalTime = xmltof(JPSfireCompElem->Attribute("final_time"), 0.);
Log->Write("INFO:\tJPSfire Module B_walking_speed: \n \tstudy: %s \n\tdata: %s \n\tupdate time: %.1f s | final time: %.1f s | irritant: %s",
study.c_str(), filepath.c_str(), updateIntervall, finalTime, irritant.c_str());
_FMStorage = std::make_shared<FDSMeshStorage>(filepath, finalTime, updateIntervall, study, irritant);
return true;
}
}
return false;
}
double WalkingSpeed::GetExtinction(const Pedestrian * pedestrian)
{
std::string quantity = "SOOT_EXTINCTION_COEFFICIENT";
double ExtinctionCoefficient = _FMStorage->GetFDSMesh(pedestrian->GetGlobalTime(), pedestrian->GetElevation(), quantity).GetKnotValue(pedestrian->GetPos()._x , pedestrian->GetPos()._y);
return ExtinctionCoefficient;
}
void WalkingSpeed::set_FMStorage(const std::shared_ptr<FDSMeshStorage> fmStorage)
{
_FMStorage=fmStorage;
}
const std::shared_ptr<FDSMeshStorage> WalkingSpeed::get_FMStorage()
{
return _FMStorage;
}
double WalkingSpeed::FrantzichNilsson2003(double &walking_speed, double ExtinctionCoefficient)
{
//According to Frantzich+Nilsson2003
walking_speed = std::fmax(0.3, walking_speed * (1 + (-0.057 / 0.706) * ExtinctionCoefficient) );
return walking_speed;
}
double WalkingSpeed::Jin1978(double &walking_speed, double ExtinctionCoefficient)
{
//According to Jin1978
std::string irritant = _FMStorage->IrritantOrNot();
if(irritant=="false") {
walking_speed = std::fmax(0.3, walking_speed * ( -0.54991616 * std::pow(ExtinctionCoefficient, 3) +
-0.05957671 * std::pow(ExtinctionCoefficient, 2)
-0.06606845 * ExtinctionCoefficient + 1.0025715) );
}
else if(irritant=="true") {
walking_speed = std::fmax(0.3, walking_speed *
(- std::pow( 112236.0553, (ExtinctionCoefficient-0.532027513) ) + 0.988158598 ));
}
else {
Log->Write("ERROR:\tSpecify if irritant or non-irritant smoke shall be cosidered");
exit(EXIT_FAILURE);
}
return walking_speed;
}
double WalkingSpeed::WalkingInSmoke(const Pedestrian* p, double walking_speed)
{
double ExtinctionCoefficient = GetExtinction(p);
//std::cout << ExtinctionCoefficient << std::endl;
//fprintf(stderr, "%f\n", ExtinctionCoefficient);
std::string study = _FMStorage->GetStudy();
if((ExtinctionCoefficient < 10E-6) || (std::isnan(ExtinctionCoefficient))) //no obstruction by smoke or NaN check
{
//fprintf(stderr, "%f \t%f\n", ExtinctionCoefficient, p->GetEllipse().GetV0());
return walking_speed; // walking_speed is returned as V0 for plane or stairs
}
else {
if (study=="Frantzich+Nilsson2003"){
walking_speed = FrantzichNilsson2003(walking_speed, ExtinctionCoefficient);
}
else if (study=="Jin1978"){
walking_speed = Jin1978(walking_speed, ExtinctionCoefficient);
}
else {
Log->Write("ERROR:\tNo study specified");
exit(EXIT_FAILURE);
}
}
//fprintf(stderr, "%f \t%f \t%f \t%f \n", p->GetGlobalTime(), ExtinctionCoefficient, walking_speed, p->GetV().Norm() );
return walking_speed;
}
bool WalkingSpeed::ReduceWalkingSpeed()
{
return _FMStorage!=nullptr;
}
/**
* \file WalkingSpeed.cpp
* \date Jan 1, 2014
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
* detects smoke in the next rooms
*
*
**/
#include "ToxicityAnalysis.h"
#include "../../geometry/Building.h"
#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"
ToxicityAnalysis::ToxicityAnalysis(const Building * b)
{
_building = b;
_FMStorage = nullptr;
LoadJPSfireInfo(_building->GetProjectFilename());
_dt = 1/20.; //time fraction for which doses are cumulated
}
ToxicityAnalysis::~ToxicityAnalysis()
{
}
bool ToxicityAnalysis::LoadJPSfireInfo(const std::string projectFilename )
{
TiXmlDocument doc(projectFilename);
if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("ERROR: \t could not parse the project file");
return false;
}
TiXmlNode* JPSfireNode = doc.RootElement()->FirstChild("JPSfire");
if( ! JPSfireNode ) {
Log->Write("INFO:\tcould not find any JPSfire information");
return true;
}
TiXmlElement* JPSfireCompElem = JPSfireNode->FirstChildElement("C_toxicity_analysis");
if(JPSfireCompElem) {
if(JPSfireCompElem->FirstAttribute()){
//std::string filepath = xmltoa(JPSfireCompElem->Attribute("toxicity_grids"), "");
std::string filepath = _building->GetProjectRootDir() + xmltoa(JPSfireCompElem->Attribute("toxicity_grids"), "");
double updateIntervall = xmltof(JPSfireCompElem->Attribute("update_time"), 0.);
double finalTime = xmltof(JPSfireCompElem->Attribute("final_time"), 0.);
std::string study = "";
std::string irritant = "";
Log->Write("INFO:\tJPSfire Module C_toxicity_analysis: \n \tdata: %s \n\tupdate time: %.1f s | final time: %.1f s",
filepath.c_str(), updateIntervall, finalTime);
//TODO Is there a posibility to pass a variable number of arguments to a function?
_FMStorage = std::make_shared<FDSMeshStorage>(filepath, finalTime, updateIntervall, study, irritant);
InitializeWriteOut();
return true;
}
}
return false;
}
double ToxicityAnalysis::GetFDSQuantity(const Pedestrian * pedestrian, std::string quantity)
{
//std::cout << "\n" << quantity << std::endl;
//try to get gas components, 0 if gas component is not provided by JPSfire
double concentration;
try {
const FDSMesh& meshref = _FMStorage->GetFDSMesh(pedestrian->GetGlobalTime(), pedestrian->GetElevation(), quantity);
concentration = (meshref.GetKnotValue(pedestrian->GetPos()._x , pedestrian->GetPos()._y));
if(concentration != concentration){
concentration = 0.0;
}
return concentration ;
} catch (int e) {
//std::cout << pedestrian->GetPos()._x << pedestrian->GetPos()._y << pedestrian->GetElevation() << quantity << std::endl;
return 0.0;
}
}
void ToxicityAnalysis::set_FMStorage(const std::shared_ptr<FDSMeshStorage> fmStorage)
{
_FMStorage=fmStorage;
}
const std::shared_ptr<FDSMeshStorage> ToxicityAnalysis::get_FMStorage()
{
return _FMStorage;
}
double ToxicityAnalysis::CalculateFEDIn(Pedestrian* p, double CO2, double CO, double O2, double HCN, double FED_In)
{
double VE = 50.; //breath rate (L/min)
double D = 20.; //Exposure dose (percent COHb) for incapacitation
double FED_In_CO = (3.317/(1E5 * D) * pow(CO, 1.036)) * _dt ;
double FED_In_HCN = (pow(HCN, 2.36)/(2.43*1E7)) * _dt ;
double FED_In_O2;
//this if statement is necessary since Pursers correlation is not considering
//normal O2 concentrations (20.9%). It would thus increase the FED_in slightly
if(O2==209000){
FED_In_O2 = 0.;
}
else if(O2<209000){
FED_In_O2 = 1/exp(8.13-0.54*(20.9-O2/10000)) * _dt ; //Vol%
}
double VCO2 = exp(CO2/10000/5) ; //Vol%
// overall FED_In Fractional Effective Dose until incapacitation
FED_In = p->GetFEDIn();
FED_In += ( ( FED_In_CO + FED_In_HCN ) * VE * VCO2 + FED_In_O2 ) ;
p->SetFEDIn(FED_In);
return FED_In;
}
double ToxicityAnalysis::CalculateFEDHeat(Pedestrian* p, double T, double FED_Heat)
{
double tolerance_time = 2 * pow(10,31) * pow(T,-16.963) + 4*1E8 * pow(T, -3.7561);
// overall FED_Heat Fractional Effective Dose
FED_Heat = p->GetFEDHeat();
FED_Heat += ( 1/tolerance_time ) * _dt;
p->SetFEDHeat(FED_Heat);
return FED_Heat;
}
void ToxicityAnalysis::HazardAnalysis(Pedestrian* p)
{
double FEC_Smoke, FED_In, FED_Heat, FIC_Im, FIC_In;
// Smoke extinction in 1/m
double E = GetFDSQuantity(p, "SOOT_EXTINCTION_COEFFICIENT");