#include <OCPTable.hpp>
|
| OCPTable ()=default |
| Default constructor.
|
|
| OCPTable (const USI &row, const USI &col) |
| Construct a table of fixed size.
|
|
| OCPTable (const vector< vector< OCP_DBL >> &src) |
| Construct from existing data.
|
|
void | Setup (const vector< vector< OCP_DBL >> &src) |
| Setup tables from existing data of table.
|
|
OCP_BOOL | IsEmpty () const |
| judge if table is empty.
|
|
USI | GetColNum () const |
| return the column num of table.
|
|
OCP_INT | GetRowZero (const USI &mycol) const |
|
void | PushCol (const vector< OCP_DBL > &v) |
| push v into the last column of table.
|
|
vector< OCP_DBL > & | GetCol (const USI &j) |
| return the jth column in table to modify or use.
|
|
void | SetRowCol () |
| Setup row nums and col nums of tables, initialize the bId.
|
|
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. More...
|
|
USI | Eval_All0 (const OCP_DBL &val, vector< OCP_DBL > &outdata) |
|
OCP_DBL | Eval (const USI &j, const OCP_DBL &val, const USI &destj) |
|
OCP_DBL | Eval (const USI &j, const OCP_DBL &val, const USI &destj, OCP_DBL &myK) |
|
OCP_DBL | Eval_Inv (const USI &j, const OCP_DBL &val, const USI &destj) |
|
void | Display () const |
| Display the data of table on screen.
|
|
OCPTable is a Table class, which used to deal with everything about table in OpenCAEPoro such as PVT table, saturation table.
Definition at line 26 of file OCPTable.hpp.
◆ Eval() [1/2]
interpolate the specified monotonically increasing column in table to evaluate the target column.
Definition at line 126 of file OCPTable.cpp.
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();
unsigned int USI
Generic unsigned integer.
double OCP_DBL
Double precision.
◆ Eval() [2/2]
interpolate the specified monotonically increasing column in table to evaluate the target column, and return corresponding slope.
Definition at line 151 of file OCPTable.cpp.
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();
◆ Eval_All()
Careful: the memory outdata and slope have not be allocated before.
interpolate the specified monotonically increasing column in table to evaluate all columns and return slope
Definition at line 47 of file OCPTable.cpp.
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();
◆ Eval_All0()
interpolate the specified monotonically increasing column in table to evaluate all columns, j = 0 here and index of returning date begins from 1
Definition at line 88 of file OCPTable.cpp.
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();
◆ Eval_Inv()
interpolate the specified monotonically decreasing column in table to evaluate the target column.
Definition at line 178 of file OCPTable.cpp.
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();
◆ GetRowZero()
OCP_INT OCPTable::GetRowZero |
( |
const USI & |
mycol | ) |
const |
return the row index of the last zero of some colnum, which is sorted in increasing order.
Definition at line 35 of file OCPTable.cpp.
37 if (mycol > nCol)
OCP_ABORT(
"wrong specified column!");
38 for (
USI i = 0; i < nRow; i++) {
39 if (data[mycol][i] >=
TINY) {
const OCP_DBL TINY
Small constant.
#define OCP_ABORT(msg)
Abort if critical error happens.
References OCP_ABORT, and TINY.
The documentation for this class was generated from the following files: