20 for (
USI j = 0; j < nCol; j++) {
36 nRow = data[0].size();
45 for (
OCP_INT i = 0; i < nRow; i++) {
46 if (data[mycol][i] >=
TINY) {
54 vector<OCP_DBL>& slope)
58 if (val >= data[j][bId]) {
59 for (
USI i = bId + 1; i < nRow; i++) {
60 if (val < data[j][i]) {
62 for (
USI k = 0; k < nCol; k++) {
63 slope[k] = (data[k][bId + 1] - data[k][bId]) /
64 (data[j][bId + 1] - data[j][bId]);
65 outdata[k] = data[k][bId] + slope[k] * (val - data[j][bId]);
70 for (
USI k = 0; k < nCol; k++) {
72 outdata[k] = data[k].back();
75 for (
OCP_INT i = bId - 1; i >= 0; i--) {
76 if (val >= data[j][i]) {
78 for (
USI k = 0; k < nCol; k++) {
79 slope[k] = (data[k][bId + 1] - data[k][bId]) /
80 (data[j][bId + 1] - data[j][bId]);
81 outdata[k] = data[k][bId] + slope[k] * (val - data[j][bId]);
86 for (
USI k = 0; k < nCol; k++) {
88 outdata[k] = data[k].front();
99 if (val >= data[j][bId]) {
100 for (
USI i = bId + 1; i < nRow; i++) {
101 if (val < data[j][i]) {
103 for (
USI k = 1; k < nCol; k++) {
104 tmpk = (data[k][bId + 1] - data[k][bId]) /
105 (data[j][bId + 1] - data[j][bId]);
106 outdata[k - 1] = data[k][bId] + tmpk * (val - data[j][bId]);
111 for (
USI k = 1; k < nCol; k++) {
112 outdata[k - 1] = data[k].back();
116 for (
OCP_INT i = bId - 1; i >= 0; i--) {
117 if (val >= data[j][i]) {
119 for (
USI k = 1; k < nCol; k++) {
120 tmpk = (data[k][bId + 1] - data[k][bId]) /
121 (data[j][bId + 1] - data[j][bId]);
122 outdata[k - 1] = data[k][bId] + tmpk * (val - data[j][bId]);
127 for (
USI k = 1; k < nCol; k++) {
128 outdata[k - 1] = data[k].front();
139 if (val >= data[j][bId]) {
140 for (
USI i = bId + 1; i < nRow; i++) {
141 if (val < data[j][i]) {
143 OCP_DBL k = (data[destj][bId + 1] - data[destj][bId]) /
144 (data[j][bId + 1] - data[j][bId]);
145 return (data[destj][bId] + k * (val - data[j][bId]));
148 return data[destj].back();
150 for (
OCP_INT i = bId - 1; i >= 0; i--) {
151 if (val >= data[j][i]) {
153 OCP_DBL k = (data[destj][bId + 1] - data[destj][bId]) /
154 (data[j][bId + 1] - data[j][bId]);
155 return (data[destj][bId] + k * (val - data[j][bId]));
158 return data[destj].front();
167 if (val >= data[j][bId]) {
168 for (
USI i = bId + 1; i < nRow; i++) {
169 if (val < data[j][i]) {
171 myK = (data[destj][bId + 1] - data[destj][bId]) /
172 (data[j][bId + 1] - data[j][bId]);
173 return (data[destj][bId] + myK * (val - data[j][bId]));
176 return data[destj].back();
179 for (
OCP_INT i = bId - 1; i >= 0; i--) {
180 if (val >= data[j][i]) {
182 myK = (data[destj][bId + 1] - data[destj][bId]) /
183 (data[j][bId + 1] - data[j][bId]);
184 return (data[destj][bId] + myK * (val - data[j][bId]));
187 return data[destj].front();
196 if (val > data[j][bId]) {
197 for (
OCP_INT i = bId - 1; i >= 0; i--) {
198 if (val <= data[j][i]) {
200 OCP_DBL k = (data[destj][bId + 1] - data[destj][bId]) /
201 (data[j][bId + 1] - data[j][bId]);
202 return (data[destj][bId] + k * (val - data[j][bId]));
205 return data[destj].front();
207 for (
USI i = bId + 1; i < nRow; i++) {
208 if (val >= data[j][i]) {
210 OCP_DBL k = (data[destj][bId] - data[destj][bId - 1]) /
211 (data[j][bId] - data[j][bId - 1]);
212 return (data[destj][bId - 1] + k * (val - data[j][bId - 1]));
215 return data[destj].back();
221 cout <<
"---------------------" << endl
222 <<
"Pressure Distribution" << endl
223 <<
"---------------------" << endl;
229 for (
USI i = 0; i < nRow; i++) {
230 for (
USI j = 0; j < nCol; j++) {
231 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)
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
return the row index of the last zero of some colnum, which is sorted in increasing order.
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)