Commit 152ad13d authored by Mohcine Chraibi's avatar Mohcine Chraibi

Add periodic option

- only used in model 3
- needs two parameters xRight and xLeft. At the
  moment hard-coded in VelocityModel.
- These changes are necessary for validation tests
- DO NOT use this option for fun.
parent a01547df
......@@ -207,6 +207,8 @@ bool Simulation::InitArgs(const ArgumentParser& args)
s.append(tmp);
_deltaT = args.Getdt();
sprintf(tmp, "\tdt: %f\n", _deltaT);
_periodic = args.IsPeriodic();
sprintf(tmp, "\t periodic: %d\n", _periodic);
s.append(tmp);
_fps = args.Getfps();
......@@ -509,7 +511,7 @@ int Simulation::RunBody(double maxSimTime)
_building->UpdateGrid();
// update the positions
_operationalModel->ComputeNextTimeStep(t, _deltaT, _building.get());
_operationalModel->ComputeNextTimeStep(t, _deltaT, _building.get(), _periodic);
//update the events
_em->ProcessEvent();
......
......@@ -90,7 +90,7 @@ private:
/// hybrid simulation manager
//HybridSimulationManager
std::shared_ptr<HybridSimulationManager>_hybridSimManager=nullptr;
int _periodic;
public:
/**
* Constructor
......
......@@ -115,6 +115,7 @@ ArgumentParser::ArgumentParser()
pbWall=0.7;
pDWall = 0.1; //Tordeux2015
pDPed = 0.1; //Tordeux2015
pPeriodic = 0; // use only for Tordeux2015 with "trivial" geometries
pcWall=3;
pLog = 0;
pModel=MODEL_GFCM;
......@@ -708,6 +709,11 @@ bool ArgumentParser::ParseVelocityModel(TiXmlElement* xVelocity)
if(ParseLinkedCells(*xModelPara)==false)
return false;
//periodic
if(ParsePeriodic(*xModelPara)==false)
return false;
//force_ped
if (xModelPara->FirstChild("force_ped"))
{
......@@ -1124,6 +1130,11 @@ double ArgumentParser::Getdt() const
return pdt;
}
int ArgumentParser::IsPeriodic() const
{
return pPeriodic;
}
double ArgumentParser::Getfps() const
{
return pfps;
......@@ -1404,4 +1415,16 @@ bool ArgumentParser::ParseStepSize(TiXmlNode &stepNode)
return false;
}
bool ArgumentParser::ParsePeriodic(TiXmlNode &Node)
{
if (Node.FirstChild("periodic"))
{
const char* periodic = Node.FirstChild("periodic")->FirstChild()->Value();
if (periodic)
pPeriodic = atof(periodic);
Log->Write("INFO: \tperiodic <%d>", pPeriodic);
return true;
}
return true; //default is periodic=0. If not specified than is OK
}
......@@ -100,6 +100,7 @@ private:
int pExitStrategy; // Strategie zur Richtungswahl (v0)
int pLog;
int pPort;
int pPeriodic;
int _embedMesh;
int _maxOpenMPThreads;
int pModel;
......@@ -155,6 +156,7 @@ private:
bool ParseStepSize(TiXmlNode &stepNode);
bool ParsePeriodic(TiXmlNode &Node);
public:
// constructor
ArgumentParser();
......@@ -180,6 +182,7 @@ public:
std::shared_ptr<OperationalModel> GetModel() const;
double GetTmax() const;
double Getdt() const;
int IsPeriodic() const;
double GetV0Mu() const;
double GetV0Sigma() const;
double GetBmaxMu() const;
......@@ -246,6 +249,7 @@ public:
*/
bool ParseIniFile(string inifile);
};
#endif /*ARGPARSER_H_*/
......@@ -103,7 +103,7 @@ bool GCFMModel::Init (Building* building) const
return true;
}
void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* building) const
void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic) const
{
double delta = 1.5;
......
......@@ -71,7 +71,7 @@ public:
* @param deltaT the next timestep
* @param building the geometry object
*/
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building) const;
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic) const;
virtual std::string GetDescription() const;
virtual bool Init (Building* building) const;
......
......@@ -107,7 +107,7 @@ bool GompertzModel::Init (Building* building) const
return true;
}
void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building* building) const
void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic) const
{
double delta = 0.5;
// collect all pedestrians in the simulation.
......
......@@ -181,7 +181,7 @@ public:
* @param deltaT the next timestep
* @param building the geometry object
*/
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building) const;
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic) const;
};
......
......@@ -69,7 +69,7 @@ public:
* @param deltaT, the timestep
* @param building, the representation of the building
*/
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building) const = 0 ;
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic) const = 0 ;
};
#endif /* OPERATIONALMODEL_H_ */
......@@ -43,6 +43,10 @@
#define omp_get_max_threads() 1
#endif
double xRight = 26.0;
double xLeft = 0.0;
double cutoff = 2.0;
using std::vector;
using std::string;
......@@ -102,7 +106,7 @@ bool VelocityModel::Init (Building* building) const
return true;
}
void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building* building) const
void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic) const
{
double delta = 0.5;
// collect all pedestrians in the simulation.
......@@ -167,12 +171,12 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
if (!isVisible)
continue;
if (ped->GetUniqueRoomID() == ped1->GetUniqueRoomID()) {
repPed += ForceRepPed(ped, ped1);
repPed += ForceRepPed(ped, ped1, periodic);
} else {
// or in neighbour subrooms
SubRoom* sb2=building->GetRoom(ped1->GetRoomID())->GetSubRoom(ped1->GetSubRoomID());
if(subroom->IsDirectlyConnectedWith(sb2)) {
repPed += ForceRepPed(ped, ped1);
repPed += ForceRepPed(ped, ped1, periodic);
}
}
} // for i
......@@ -185,7 +189,7 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
Pedestrian* ped1 = neighbours[i];
// calculate spacing
// my_pair spacing_winkel = GetSpacing(ped, ped1);
spacings.push_back(GetSpacing(ped, ped1, direction));
spacings.push_back(GetSpacing(ped, ped1, direction, periodic));
}
// @todo: update direction every DT?
......@@ -247,6 +251,11 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
ped->SetPhiPed();
}
ped->SetPos(pos_neu);
if(periodic){
if(ped->GetPos().GetX() >= xRight){
ped->SetPos(Point(ped->GetPos().GetX() - (xRight - xLeft), ped->GetPos().GetY()));
}
}
ped->SetV(v_neu);
}
}//end parallel
......@@ -281,9 +290,17 @@ double VelocityModel::OptimalSpeed(Pedestrian* ped, double spacing, double winke
return speed;
}
my_pair VelocityModel::GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei) const
my_pair VelocityModel::GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei, int periodic) const
{
Point distp12 = ped2->GetPos() - ped1->GetPos(); // inversed sign
if(periodic){
double x = ped1->GetPos().GetX();
double x_j = ped2->GetPos().GetX();
if((xRight-x) + (x_j-xLeft) <= cutoff){
distp12.SetX(distp12.GetX() + xRight - xLeft);
}
}
double Distance = distp12.Norm();
double l = 2*ped1->GetEllipse().GetBmax();
Point ep12;
......@@ -306,16 +323,25 @@ my_pair VelocityModel::GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei)
else
return my_pair(std::numeric_limits<double>::max(), condition1);
}
Point VelocityModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const
{
Point VelocityModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2, int periodic) const
{
Point F_rep(0.0, 0.0);
// x- and y-coordinate of the distance between p1 and p2
Point distp12 = ped2->GetPos() - ped1->GetPos();
if(periodic){
double x = ped1->GetPos().GetX();
double x_j = ped2->GetPos().GetX();
if((xRight-x) + (x_j-xLeft) <= cutoff){
distp12.SetX(distp12.GetX() + xRight - xLeft);
}
}
double Distance = distp12.Norm();
Point ep12; // x- and y-coordinate of the normalized vector between p1 and p2
double R_ij;
double l = 2*ped1->GetEllipse().GetBmax();
if (Distance >= J_EPS) {
ep12 = distp12.Normalized();
} else {
......
......@@ -97,7 +97,7 @@ private:
* and should be calculated *before* calling OptimalSpeed
* @return Point
*/
my_pair GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei) const;
my_pair GetSpacing(Pedestrian* ped1, Pedestrian* ped2, Point ei, int periodic) const;
/**
* Repulsive force between two pedestrians ped1 and ped2 according to
* the Velocity model (to be published in TGF15)
......@@ -107,7 +107,7 @@ private:
*
* @return Point
*/
Point ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const;
Point ForceRepPed(Pedestrian* ped1, Pedestrian* ped2, int periodic) const;
/**
* Repulsive force acting on pedestrian <ped> from the walls in
* <subroom>. The sum of all repulsive forces of the walls in <subroom> is calculated
......@@ -183,7 +183,7 @@ public:
* @param deltaT the next timestep
* @param building the geometry object
*/
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building) const;
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic) const;
};
......
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