-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathRecoveryInformation.cpp
114 lines (94 loc) · 2.92 KB
/
RecoveryInformation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright (c) 2015-2021 United States Government as represented by
* the National Aeronautics and Space Administration. No copyright
* is claimed in the United States under Title 17, U.S.Code. All Other
* Rights Reserved.
*/
#include "format.h"
#include "string_util.h"
#include "RecoveryInformation.h"
#include "Units.h"
#include <string>
#include <cmath>
namespace larcfm {
RecoveryInformation::RecoveryInformation(double t, int nfactor, double hs, double vs) {
time_ = t;
nfactor_ = nfactor;
horizontal_distance_ = hs;
vertical_distance_ = vs;
}
/**
* @return Number of time the recovery volume was reduced
*/
int RecoveryInformation::nFactor() const {
return nfactor_;
}
/**
* @return Time to recovery in seconds
*/
double RecoveryInformation::timeToRecovery() const {
return time_;
}
/**
* @return Time to recovery in given units
*/
double RecoveryInformation::timeToRecovery(const std::string& u) const {
return Units::to(u,time_);
}
/**
* @return Recovery horizontal distance in internal units, i.e., [m]
*/
double RecoveryInformation::recoveryHorizontalDistance() const {
return horizontal_distance_;
}
/**
* @return Recovery horizontal distance in given units
*/
double RecoveryInformation::recoveryHorizontalDistance(const std::string& u) const {
return Units::to(u,horizontal_distance_);
}
/**
* @return Recovery vertical distance in internal units, i.e., [m]
*/
double RecoveryInformation::recoveryVerticalDistance() const {
return vertical_distance_;
}
/**
* @return Recovery vertical distance in given units
*/
double RecoveryInformation::recoveryVerticalDistance(const std::string& u) const {
return Units::to(u,vertical_distance_);
}
/**
* @return True if recovery bands are computed.
*/
bool RecoveryInformation::recoveryBandsComputed() const {
return !ISNAN(time_) && nfactor_ >= 0;
}
/**
* @return True if recovery are computed, but they are saturated.
*/
bool RecoveryInformation::recoveryBandsSaturated() const {
return ISINF(time_) && time_ < 0;
}
std::string RecoveryInformation::toString() const {
std::string str = " [time_to_recovery: "+FmPrecision(time_)+
", horizontal_distance: "+FmPrecision(horizontal_distance_)+
", vertical_distance: "+FmPrecision(vertical_distance_)+
", nfactor: "+Fmi(nfactor_)+"]";
return str;
}
std::string RecoveryInformation::toStringUnits(const std::string& hunits,const std::string& vunits) const {
std::string str = "[time_to_recovery: "+Units::str("s",time_)+
", horizontal_distance: "+Units::str(hunits,horizontal_distance_)+
", vertical_distance: "+Units::str(vunits,vertical_distance_)+
", nfactor: "+Fmi(nfactor_)+"]";
return str;
}
std::string RecoveryInformation::toPVS() const {
return "(# time:="+double2PVS(time_)+
"::ereal,horizontal_distance:="+double2PVS(horizontal_distance_)+
"::ereal,vertical_distance:="+double2PVS(vertical_distance_)+
"::ereal,nfactor:="+Fmi(nfactor_)+" #)";
}
}