15 const string& shortInfo,
16 const string& myCodeWay,
17 const string& girdType,
21 ofstream myVtk(myFile);
22 if (!myVtk.is_open()) {
23 OCP_ABORT(
"Can not open file: " + myFile);
26 ios::sync_with_stdio(
false);
30 myVtk << VTK_HEADER <<
"\n";
33 if (shortInfo.size() > VTK_MAX_TITLE_LENGTH) {
34 OCP_WARNING(
"Length of title is beyond the limit: 256");
35 myVtk <<
"Invalid short info, Too many characters\n";
37 myVtk << shortInfo <<
"\n";
41 myVtk << myCodeWay <<
"\n";
44 myVtk << VTK_DATASET <<
" " << girdType <<
"\n";
52 numCell = numGrid + numWell;
55 void Output4Vtk::OutputPOINTS(
const string& myFile,
56 const vector<OCPpolyhedron>& myHexGrid,
57 const vector<OCPpolyhedron>& myHexWell,
58 const string& dataType)
const
61 myVtk.open(myFile, ios::app);
62 if (!myVtk.is_open()) {
63 OCP_ABORT(
"Can not open file: " + myFile);
66 ios::sync_with_stdio(
false);
70 VTK_USI numWellPoints = numGrid * 8;
71 for (
auto& w : myHexWell) {
72 numWellPoints += w.numPoints;
74 myVtk << VTK_POINTS <<
" " << numWellPoints <<
" " << VTK_FLOAT <<
"\n";
76 for (VTK_USI i = 0; i < numGrid; i++) {
77 for (
USI j = 0; j < myHexGrid[i].numPoints; j++) {
78 myVtk << setw(6) << myHexGrid[i].Points[j].x <<
" " << setw(6)
79 << myHexGrid[i].Points[j].y <<
" " << setw(6)
80 << myHexGrid[i].Points[j].z <<
"\n";
85 for (VTK_USI w = 0; w < numWell; w++) {
86 for (
USI j = 0; j < myHexWell[w].numPoints; j++) {
87 myVtk << setw(6) << myHexWell[w].Points[j].x <<
" " << setw(6)
88 << myHexWell[w].Points[j].y <<
" " << setw(6)
89 << myHexWell[w].Points[j].z <<
"\n";
97 void Output4Vtk::OutputCELLS(
const string& myFile,
98 const vector<OCPpolyhedron>& myHexGrid,
99 const vector<OCPpolyhedron>& myHexWell)
const
102 myVtk.open(myFile, ios::app);
103 if (!myVtk.is_open()) {
104 OCP_ABORT(
"Can not open file: " + myFile);
107 ios::sync_with_stdio(
false);
110 USI numSize = numCell;
111 for (VTK_USI n = 0; n < numGrid; n++) {
112 numSize += myHexGrid[n].numPoints;
114 for (
USI w = 0; w < numWell; w++) {
115 numSize += myHexWell[w].numPoints;
118 myVtk << VTK_CELLS <<
" " << numCell <<
" " << numSize <<
"\n";
123 for (VTK_USI n = 0; n < numGrid; n++) {
125 for (VTK_USI j = 0; j < 8; j++) {
126 myVtk << j + tmp <<
" ";
133 for (
USI w = 0; w < numWell; w++) {
134 myVtk << myHexWell[w].numPoints <<
" ";
135 for (VTK_USI j = 0; j < myHexWell[w].numPoints; j++) {
136 myVtk << j + tmp <<
" ";
139 tmp += myHexWell[w].numPoints;
146 void Output4Vtk::OutputCELL_TYPES(
const string& myFile,
147 const vector<OCPpolyhedron>& myHexGrid,
148 const vector<OCPpolyhedron>& myHexWell)
const
151 myVtk.open(myFile, ios::app);
152 if (!myVtk.is_open()) {
153 OCP_ABORT(
"Can not open file: " + myFile);
156 ios::sync_with_stdio(
false);
159 myVtk << VTK_CELL_TYPES <<
" " << numCell <<
"\n";
163 for (VTK_USI n = 0; n < numGrid; n++) {
164 myVtk << VTK_HEXAHEDRON <<
"\n";
168 for (
USI w = 0; w < numWell; w++) {
169 myVtk << VTK_POLY_LINE <<
"\n";
unsigned int USI
Generic unsigned integer.
Output reservoir information in vtk format.
#define OCP_WARNING(msg)
Log warning messages.
#define OCP_ABORT(msg)
Abort if critical error happens.
void Init(const string &myFile, const string &shortInfo, const string &myCodeWay, const string &girdType, const VTK_USI &nG, const VTK_USI &nW)
create a new file and write basic information