Commit fd2f1078 authored by Mohcine Chraibi's avatar Mohcine Chraibi

Fixes #260

parent f0c9eec6
Pipeline #5769 passed with stages
in 24 minutes and 31 seconds
......@@ -95,13 +95,17 @@ bool IniFileParser::Parse(std::string iniFile)
Log->Write("ERROR:\t Wrong header version. Only version greater than %s is supported.", JPS_OLD_VERSION);
return false;
}
// JPSfire
// read walkingspeed
std::shared_ptr<WalkingSpeed> W( new WalkingSpeed(iniFile) );
//auto w = std::make_shared<WalkingSpeed>();
_config->SetWalkingSpeed(W);
//seed
if (xMainNode->FirstChild("seed")) {
TiXmlNode* seedNode = xMainNode->FirstChild("seed")->FirstChild();
if (seedNode) {
const char* seedValue = seedNode->Value();
_config->SetSeed((unsigned int) atoi(seedValue));
_config->SetSeed((unsigned int) atoi(seedValue));//strtol
}
else {
_config->SetSeed((unsigned int) time(NULL));
......
......@@ -37,12 +37,14 @@
#include <algorithm>
#include <math.h>
#include <string>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
WalkingSpeed::WalkingSpeed(const Building * b)
WalkingSpeed::WalkingSpeed(const std::string & projectFileName)
{
_FMStorage = nullptr;
_building = b;
LoadJPSfireInfo(_building->GetProjectFilename());
_FMStorage = nullptr;
LoadJPSfireInfo(projectFileName);
}
WalkingSpeed::~WalkingSpeed()
......@@ -51,9 +53,12 @@ WalkingSpeed::~WalkingSpeed()
bool WalkingSpeed::LoadJPSfireInfo(const std::string projectFilename )
bool WalkingSpeed::LoadJPSfireInfo(const std::string & projectFilename )
{
TiXmlDocument doc(projectFilename);
boost::filesystem::path p(projectFilename);
std::string projectRootDir = p.parent_path().string();
TiXmlDocument doc(projectFilename);
if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("ERROR: \t could not parse the project file");
......@@ -71,8 +76,9 @@ bool WalkingSpeed::LoadJPSfireInfo(const std::string projectFilename )
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"), "");
std::string extinction_grids = xmltoa(JPSfireCompElem->Attribute("extinction_grids"), "");
std::string projectRoot = projectRootDir;
std::string filepath = projectRoot + "/" + extinction_grids; //TODO: check compatibility
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",
......@@ -91,7 +97,7 @@ double WalkingSpeed::GetExtinction(const Pedestrian * pedestrian)
return ExtinctionCoefficient;
}
void WalkingSpeed::set_FMStorage(const std::shared_ptr<FDSMeshStorage> fmStorage)
void WalkingSpeed::set_FMStorage(const std::shared_ptr<FDSMeshStorage> & fmStorage)
{
_FMStorage=fmStorage;
}
......
......@@ -42,25 +42,24 @@ class WalkingSpeed
public:
WalkingSpeed(const Building * b);
explicit WalkingSpeed(const std::string & projectFilename);
virtual ~WalkingSpeed();
double WalkingInSmoke(const Pedestrian*, double);
double GetExtinction(const Pedestrian *);
void set_FMStorage(const std::shared_ptr<FDSMeshStorage> fmStorage);
void set_FMStorage(const std::shared_ptr<FDSMeshStorage>& fmStorage);
const std::shared_ptr<FDSMeshStorage> get_FMStorage();
bool LoadJPSfireInfo(const std::string projectFilename);
bool LoadJPSfireInfo(const std::string & projectFilename);
bool ReduceWalkingSpeed();
double FrantzichNilsson2003(double &walking_speed, double ExtinctionCoefficient);
double Jin1978(double &walking_speed, double ExtinctionCoefficient);
private:
const Building* _building;
std::shared_ptr<FDSMeshStorage> _FMStorage;
};
......
......@@ -35,7 +35,7 @@
#include "../routing/RoutingEngine.h"
#include "../math/OperationalModel.h"
#include "../JPSfire/B_walking_speed/WalkingSpeed.h"
//This class provides a data container for all configuration parameters.
class AgentsParameters;
......@@ -52,6 +52,7 @@ public:
Configuration()
{
_walkingSpeed = nullptr;
_solver = 1;
_routingEngine = std::shared_ptr<RoutingEngine>(new RoutingEngine());
_maxOpenMPThreads = 1;
......@@ -112,7 +113,8 @@ public:
_has_specific_goals = false;
_write_VTK_files = false;
}
std::shared_ptr<WalkingSpeed> GetWalkingSpeed () {return _walkingSpeed; };
void SetWalkingSpeed(std::shared_ptr<WalkingSpeed> & w) {_walkingSpeed = w; };
int GetSolver() const { return _solver; };
void SetSolver(int solver) { _solver = solver; };
......@@ -321,6 +323,7 @@ public:
#endif
private:
std::shared_ptr<WalkingSpeed> _walkingSpeed;
int _solver;
std::shared_ptr<RoutingEngine> _routingEngine;
int _maxOpenMPThreads;
......@@ -371,6 +374,7 @@ private:
std::string _geometryFile;
std::string _projectRootDir;
bool _showStatistics;
FileFormat _fileFormat;
std::map<int, std::shared_ptr<AgentsParameters> > _agentsParameters;
#ifdef _JPS_AS_A_SERVICE
......
......@@ -1108,7 +1108,7 @@ void Pedestrian::SetBuilding(Building* building)
_building = building;
}
void Pedestrian::SetWalkingSpeed(WalkingSpeed* walkingSpeed)
void Pedestrian::SetWalkingSpeed(std::shared_ptr<WalkingSpeed> walkingSpeed)
{
_WalkingSpeed = walkingSpeed;
}
......
......@@ -47,7 +47,7 @@ class Building;
class NavLine;
class Router;
class Knowledge;
class WalkingSpeed;
class Pedestrian
{
private:
......@@ -149,7 +149,7 @@ private:
double _FED_In;
double _FED_Heat;
WalkingSpeed * _WalkingSpeed = nullptr;
std::shared_ptr<WalkingSpeed> _WalkingSpeed = nullptr;
std::shared_ptr<ToxicityAnalysis> _ToxicityAnalysis = nullptr;
......@@ -473,7 +473,7 @@ public:
*/
void SetBuilding(Building* building);
void SetWalkingSpeed(WalkingSpeed* walkingSpeed);
void SetWalkingSpeed(std::shared_ptr<WalkingSpeed> walkingSpeed);
void WalkingUpstairs(double c, SubRoom* sub, double ped_elevation, double &walking_speed) const;
void WalkingDownstairs(double &walking_speed, double c, SubRoom* sub, double ped_elevation) const;
......
......@@ -203,6 +203,7 @@ Pedestrian* StartDistribution::GenerateAgent(Building* building, int* pid, vecto
Pedestrian* ped = new Pedestrian();
// PedIndex
ped->SetWalkingSpeed(building->GetConfig()->GetWalkingSpeed());
ped->SetID(*pid);
ped->SetAge(GetAge());
ped->SetGender(GetGender());
......
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