Commit 3996c759 authored by Mohcine Chraibi's avatar Mohcine Chraibi

Parse and initialize Toxicity analysis

parent fd2f1078
Pipeline #5774 passed with stages
in 24 minutes and 2 seconds
......@@ -24,7 +24,19 @@ Utest/Validation/*/inifiles*/
/Utest/juelich_tests/*/*.txt
/Utest/juelich_tests/*/*.png
*~
/Utest/validation/test_13
/Utest/validation/1test_1D
/build*
/Utest/router_tests/test_router_9/inifiles/
/Utest/router_tests/test_router_1/inifiles/
/Utest/router_tests/test_router_2/inifiles/
/Utest/router_tests/test_router_3/inifiles/
/Utest/router_tests/test_router_4/inifiles/
/Utest/router_tests/test_router_5/inifiles/
/Utest/router_tests/test_router_6/inifiles/
/Utest/router_tests/test_router_7/inifiles/
/Utest/router_tests/test_router_8/inifiles/
Matrix.txt
# Compiled Object files
*.slo
*.lo
......@@ -89,16 +101,16 @@ vgcore.*
/Utest/test_8/routing.xml
/Utest/test_9/cpu.png
/Utest/utils.pyc
/auto/veloModel2.el
/auto/veloModel9.el
/cpu.png
/cscope.file
/gompertz.pdf
/veloModel2.org
/veloModel2.pdf
/veloModel2.tex
/veloModel10.org
/veloModel11.pdf
/veloModel12.tex
/.project
/#%2Aediff-merge%2A#14545CrI#
/#%2Aediff-merge%3C2%3E%2A#145452Th#
/#%13Aediff-merge%14A#14545CrI#
/#%15Aediff-merge%3C16%3E%17A#1454518Th#
/.idea/dictionaries/chraibi.xml
/Dumping
/Martella/corridor_8x3.xml
......@@ -115,7 +127,7 @@ vgcore.*
/Max/
*/old/*
README.html
Utest/r2.txt
Utest/r19.txt
Utest/r3.txt
Utest/rimea_tests/test_13/gauss.py
Utest/test_10/cell.png
......@@ -123,7 +135,7 @@ Utest/test_10/result.txt
Utest/test_10/times.txt
Utest/todo.org
html-dir/
inputfiles/Bottleneck/rimea_test_12_geo.xml
inputfiles/Bottleneck/rimea_test_120_geo.xml
inputfiles/Karthik/
inputfiles/U8/
inputfiles/VerteilerEbene/
......
......@@ -95,11 +95,6 @@ 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();
......@@ -241,6 +236,16 @@ bool IniFileParser::Parse(std::string iniFile)
}
}
// JPSfire
// -------------------------------------
// read walkingspeed
std::shared_ptr<WalkingSpeed> W( new WalkingSpeed(iniFile) );
_config->SetWalkingSpeed(W);
// read ToxicityAnalysis
std::shared_ptr<ToxicityAnalysis> T( new ToxicityAnalysis(iniFile, _config->GetFps()));
_config->SetToxicityAnalysis(T);
// -------------------------------------
//pick up which model to use
//get the wanted ped model id
_model = xmltoi(xMainNode->FirstChildElement("agents")->Attribute("operational_model_id"), -1);
......
......@@ -27,7 +27,6 @@
**/
#include "WalkingSpeed.h"
#include "../../geometry/Building.h"
#include "../../pedestrian/Pedestrian.h"
#include "../generic/FDSMesh.h"
#include "../generic/FDSMeshStorage.h"
......
......@@ -27,7 +27,6 @@
**/
#include "ToxicityAnalysis.h"
#include "../../geometry/Building.h"
#include "../../pedestrian/Pedestrian.h"
#include "../generic/FDSMesh.h"
#include "../generic/FDSMeshStorage.h"
......@@ -37,15 +36,17 @@
#include <algorithm>
#include <math.h>
#include "../../IO/OutputHandler.h"
#include "../../general/Configuration.h"
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
ToxicityAnalysis::ToxicityAnalysis(const Building * b)
ToxicityAnalysis::ToxicityAnalysis(const std::string & projectFileName, double fps): _projectFileName(projectFileName), _fps(fps)
{
_building = b;
_FMStorage = nullptr;
LoadJPSfireInfo(_building->GetProjectFilename());
_dt = 1/20.; //time fraction for which doses are cumulated
_dt = 1/20.; //time fraction for which doses are cumulated. TODO:
//parse in inifile?
_t_prev = -1;
LoadJPSfireInfo(projectFileName);
}
ToxicityAnalysis::~ToxicityAnalysis()
......@@ -55,6 +56,9 @@ ToxicityAnalysis::~ToxicityAnalysis()
bool ToxicityAnalysis::LoadJPSfireInfo(const std::string 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());
......@@ -71,8 +75,8 @@ bool ToxicityAnalysis::LoadJPSfireInfo(const std::string projectFilename )
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"), "");
std::string toxicity_grids = xmltoa(JPSfireCompElem->Attribute("toxicity_grids"), "");
std::string filepath = projectRootDir + "/" + toxicity_grids;
double updateIntervall = xmltof(JPSfireCompElem->Attribute("update_time"), 0.);
double finalTime = xmltof(JPSfireCompElem->Attribute("final_time"), 0.);
std::string study = "";
......@@ -198,7 +202,7 @@ void ToxicityAnalysis::HazardAnalysis(Pedestrian* p)
void ToxicityAnalysis::InitializeWriteOut()
{
string fileNameWithoutExtension = _building->GetProjectFilename().substr(0, _building->GetProjectFilename().find_last_of("."));
string fileNameWithoutExtension = _projectFileName.substr(0, _projectFileName.find_last_of("."));
std::string ToxAnalysisXML = "fire_" + fileNameWithoutExtension + ".xml";
_outputhandler = std::make_shared<ToxicityOutputHandler>(ToxAnalysisXML.c_str());
_outputhandler->WriteToFileHeader();
......@@ -208,9 +212,7 @@ void ToxicityAnalysis::WriteOutHazardAnalysis(const Pedestrian* p, double E, dou
{
string data;
char tmp[CLENGTH] = "";
_fps = _configuration->GetFps();
_fps = 1; // fixme: why 1?
//_fps = 1; // fixme: why 1?
int frameNr = int(p->GetGlobalTime()/_fps);
......@@ -239,3 +241,8 @@ bool ToxicityAnalysis::ConductToxicityAnalysis()
{
return _FMStorage!=nullptr;
}
const std::string ToxicityAnalysis::getProjectFileName(void)
{
return _projectFileName;
}
......@@ -34,18 +34,15 @@
#include <string>
class Pedestrian;
class Building;
class Point;
class FDSMeshStorage;
class Configuration;
class ToxicityAnalysis
{
public:
ToxicityAnalysis(const Building * b);
ToxicityAnalysis(const std::string & projectFilename, double _fps);
virtual ~ToxicityAnalysis();
void HazardAnalysis(Pedestrian *);
......@@ -62,17 +59,14 @@ public:
double CalculateFEDIn(Pedestrian *, double CO2, double CO, double O2, double HCN, double FED_In);
double CalculateFEDHeat(Pedestrian *, double T, double FED_Heat);
const std::string getProjectFileName(void);
private:
const Building* _building;
const Configuration* _configuration;
std::shared_ptr<FDSMeshStorage> _FMStorage;
std::shared_ptr<ToxicityOutputHandler> _outputhandler;
const std::string _projectFileName;
double _dt;
double _t_prev;
double _fps;
double _t_prev;
void InitializeWriteOut();
};
......
......@@ -86,13 +86,6 @@ bool Simulation::InitArgs()
switch (_config->GetLog()) {
case 0: {
// no log file. Use default log file
//Log = new OutputHandler();
// char default_name[CLENGTH] = "";
// sprintf(default_name, "%s/log.dat", _config->GetProjectRootDir().c_str());
// if (Log)
// delete Log;
// Log = new FileHandler(default_name);
break;
}
......
......@@ -36,6 +36,7 @@
#include "../routing/RoutingEngine.h"
#include "../math/OperationalModel.h"
#include "../JPSfire/B_walking_speed/WalkingSpeed.h"
#include "../JPSfire/C_toxicity_analysis/ToxicityAnalysis.h"
//This class provides a data container for all configuration parameters.
class AgentsParameters;
......@@ -53,6 +54,7 @@ public:
Configuration()
{
_walkingSpeed = nullptr;
_ToxicityAnalysis = nullptr;
_solver = 1;
_routingEngine = std::shared_ptr<RoutingEngine>(new RoutingEngine());
_maxOpenMPThreads = 1;
......@@ -113,8 +115,12 @@ public:
_has_specific_goals = false;
_write_VTK_files = false;
}
std::shared_ptr<WalkingSpeed> GetWalkingSpeed () {return _walkingSpeed; };
std::shared_ptr<WalkingSpeed> GetWalkingSpeed () {return _walkingSpeed; };
void SetWalkingSpeed(std::shared_ptr<WalkingSpeed> & w) {_walkingSpeed = w; };
std::shared_ptr<ToxicityAnalysis> GetToxicityAnalysis () {return _ToxicityAnalysis; };
void SetToxicityAnalysis(std::shared_ptr<ToxicityAnalysis> & t) {_ToxicityAnalysis = t; };
int GetSolver() const { return _solver; };
void SetSolver(int solver) { _solver = solver; };
......@@ -324,6 +330,7 @@ public:
private:
std::shared_ptr<WalkingSpeed> _walkingSpeed;
std::shared_ptr<ToxicityAnalysis> _ToxicityAnalysis;
int _solver;
std::shared_ptr<RoutingEngine> _routingEngine;
int _maxOpenMPThreads;
......
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