20 for (
USI j = 0; j < nCol; j++) {
31 nRow = data[0].size();
37 if (mycol > nCol)
OCP_ABORT(
"wrong specified column!");
38 for (
USI i = 0; i < nRow; i++) {
39 if (data[mycol][i] >=
TINY) {
49 vector<OCP_DBL>& outdata,
50 vector<OCP_DBL>& slope)
52 if (val >= data[j][bId]) {
53 for (
USI i = bId + 1; i < nRow; i++) {
54 if (val < data[j][i]) {
56 for (
USI k = 0; k < nCol; k++) {
57 slope[k] = (data[k][bId + 1] - data[k][bId]) /
58 (data[j][bId + 1] - data[j][bId]);
59 outdata[k] = data[k][bId] + slope[k] * (val - data[j][bId]);
64 for (
USI k = 0; k < nCol; k++) {
66 outdata[k] = data[k].back();
69 for (
OCP_INT i = bId - 1; i >= 0; i--) {
70 if (val >= data[j][i]) {
72 for (
USI k = 0; k < nCol; k++) {
73 slope[k] = (data[k][bId + 1] - data[k][bId]) /
74 (data[j][bId + 1] - data[j][bId]);
75 outdata[k] = data[k][bId] + slope[k] * (val - data[j][bId]);
80 for (
USI k = 0; k < nCol; k++) {
82 outdata[k] = data[k].front();
92 if (val >= data[j][bId]) {
93 for (
USI i = bId + 1; i < nRow; i++) {
94 if (val < data[j][i]) {
96 for (
USI k = 1; k < nCol; k++) {
97 tmpk = (data[k][bId + 1] - data[k][bId]) /
98 (data[j][bId + 1] - data[j][bId]);
99 outdata[k - 1] = data[k][bId] + tmpk * (val - data[j][bId]);
104 for (
USI k = 1; k < nCol; k++) {
105 outdata[k - 1] = data[k].back();
108 for (
OCP_INT i = bId - 1; i >= 0; i--) {
109 if (val >= data[j][i]) {
111 for (
USI k = 1; k < nCol; k++) {
112 tmpk = (data[k][bId + 1] - data[k][bId]) /
113 (data[j][bId + 1] - data[j][bId]);
114 outdata[k - 1] = data[k][bId] + tmpk * (val - data[j][bId]);
119 for (
USI k = 1; k < nCol; k++) {
120 outdata[k - 1] = data[k].front();
128 if (val >= data[j][bId]) {
129 for (
USI i = bId + 1; i < nRow; i++) {
130 if (val < data[j][i]) {
132 OCP_DBL k = (data[destj][bId + 1] - data[destj][bId]) /
133 (data[j][bId + 1] - data[j][bId]);
134 return (data[destj][bId] + k * (val - data[j][bId]));
137 return data[destj].back();
139 for (
OCP_INT i = bId - 1; i >= 0; i--) {
140 if (val >= data[j][i]) {
142 OCP_DBL k = (data[destj][bId + 1] - data[destj][bId]) /
143 (data[j][bId + 1] - data[j][bId]);
144 return (data[destj][bId] + k * (val - data[j][bId]));
147 return data[destj].front();
155 if (val >= data[j][bId]) {
156 for (
USI i = bId + 1; i < nRow; i++) {
157 if (val < data[j][i]) {
159 myK = (data[destj][bId + 1] - data[destj][bId]) /
160 (data[j][bId + 1] - data[j][bId]);
161 return (data[destj][bId] + myK * (val - data[j][bId]));
164 return data[destj].back();
166 for (
OCP_INT i = bId - 1; i >= 0; i--) {
167 if (val >= data[j][i]) {
169 myK = (data[destj][bId + 1] - data[destj][bId]) /
170 (data[j][bId + 1] - data[j][bId]);
171 return (data[destj][bId] + myK * (val - data[j][bId]));
174 return data[destj].front();
182 if (val > data[j][bId]) {
183 for (
OCP_INT i = bId - 1; i >= 0; i--) {
184 if (val <= data[j][i]) {
186 OCP_DBL k = (data[destj][bId + 1] - data[destj][bId]) /
187 (data[j][bId + 1] - data[j][bId]);
188 return (data[destj][bId] + k * (val - data[j][bId]));
191 return data[destj].front();
193 for (
USI i = bId + 1; i < nRow; i++) {
194 if (val >= data[j][i]) {
196 OCP_DBL k = (data[destj][bId] - data[destj][bId - 1]) /
197 (data[j][bId] - data[j][bId - 1]);
198 return (data[destj][bId - 1] + k * (val - data[j][bId - 1]));
201 return data[destj].back();
207 cout <<
"\n---------------------" << endl
208 <<
"Pressure Distribution"
209 <<
"\n---------------------" << endl;
215 cout << fixed << setprecision(3);
216 for (
USI i = 0; i < nRow; i++) {
217 for (
USI j = 0; j < nCol; j++) {
218 cout << data[j][i] <<
"\t";
const OCP_DBL TINY
Small constant.
unsigned int USI
Generic unsigned integer.
double OCP_DBL
Double precision.
OCPTable class declaration.
#define OCP_ABORT(msg)
Abort if critical error happens.
USI Eval_All(const USI &j, const OCP_DBL &val, vector< OCP_DBL > &outdata, vector< OCP_DBL > &slope)
Careful: the memory outdata and slope have not be allocated before.
OCP_DBL Eval_Inv(const USI &j, const OCP_DBL &val, const USI &destj)
void Display() const
Display the data of table on screen.
void Setup(const vector< vector< OCP_DBL >> &src)
Setup tables from existing data of table.
OCP_INT GetRowZero(const USI &mycol) const
USI Eval_All0(const OCP_DBL &val, vector< OCP_DBL > &outdata)
OCPTable()=default
Default constructor.
OCP_DBL Eval(const USI &j, const OCP_DBL &val, const USI &destj)