13 for(
int m=0; m < meshes.size( ); ++m )
15 std::ostringstream oss; oss.clear( );
16 oss <<
Program.outputfile <<
"." <<
Program.paneIds[ m ] <<
".vtk";
19 ofs.open( oss.str( ).c_str( ) );
23 std::cerr <<
"Cannot write VTK file: " << oss.str( ) << std::endl;
24 std::cerr <<
"File: " << __FILE__ << std::endl;
25 std::cerr <<
"Line: " << __LINE__ << std::endl;
29 ofs <<
"# vtk DataFile Version 3.0\n";
30 ofs << oss.str( ) << std::endl;
32 ofs <<
"DATASET UNSTRUCTURED_GRID\n";
33 ofs <<
"POINTS " << meshes[ m ].nc.Size( ) <<
" double\n";
35 for(
int i=1;
i <= meshes[ m ].nc.Size( ); ++
i )
37 ofs << meshes[ m ].nc.x(
i ) <<
" ";
38 ofs << meshes[ m ].nc.y(
i ) <<
" ";
39 ofs << meshes[ m ].nc.z(
i ) <<
"\n";
42 ofs <<
"CELLS " << meshes[ m ].con.Nelem( ) <<
" " << meshes[ m ].con.Nelem( )*9 <<
"\n";
43 for(
int e=1; e <= meshes[ m ].con.Nelem( ); ++e )
46 for(
int j=1;
j <= 8; ++
j )
47 ofs << meshes[ m ].con.Node( e,
j )-1<<
" ";
51 ofs <<
"CELL_TYPES " << meshes[ m ].con.Nelem( ) << std::endl;
52 for(
int e=1; e <= meshes[ m ].con.Nelem( ); ++ e )
55 ofs <<
"POINT_DATA " <<
Program.mask[ m ].size( ) << std::endl;
56 ofs <<
"SCALARS SharedNodes double\nLOOKUP_TABLE default\n";
57 for(
int i=0;
i <
Program.mask[ m ].size( ); ++
i )
73 void printVtk( std::vector< double > &vlist, std::vector< std::vector< int > > &elist )
76 ofs.open( std::string(
"global_mesh.vtk" ).c_str( ) );
80 std::cerr <<
"Cannot write global VTK file! " << std::endl;
81 std::cerr <<
"File: " << __FILE__ << std::endl;
82 std::cerr <<
"Line: " << __LINE__ << std::endl;
86 ofs <<
"# vtk DataFile Version 3.0\n";
87 ofs <<
"Global Mesh Output" << std::endl;
89 ofs <<
"DATASET UNSTRUCTURED_GRID\n";
90 ofs <<
"POINTS " << vlist.size( )/3 <<
" double\n";
92 for(
int i=0;
i < vlist.size( )/3; ++
i )
94 ofs << vlist[
i*3 ] <<
" ";
95 ofs << vlist[
i*3+1 ] <<
" ";
96 ofs << vlist[
i*3+2 ] <<
"\n";
100 for(
int i=0;
i < elist.size( ); ++
i )
102 if( maxnodes < elist[
i ].size( ) )
103 maxnodes = elist[
i ].size( );
106 ofs <<
"CELLS " << elist.size( ) <<
" " << elist.size( )*( maxnodes+1) <<
"\n";
107 for(
int i=0;
i < elist.size( ); ++
i )
109 ofs << elist[
i ].size( ) <<
" ";
110 for(
int j=0;
j < elist[
i ].size( ); ++
j )
111 ofs << elist[
i ][
j ]<<
" ";
115 ofs <<
"CELL_TYPES " << elist.size( ) << std::endl;
116 for(
int i=0;
i < elist.size( ); ++
i )
119 if( elist[
i ].size( ) == 8 )
121 else if( elist[
i ].size( ) == 4 )
124 std::cerr <<
"Undefined element type!\n";
125 std::cerr <<
"File: " << __FILE__ << std::endl;
126 std::cerr <<
"Line: " << __LINE__ << std::endl;
146 std::cout <<
"Writing VTK data...";
150 ofs.open( filename.c_str());
152 if( !ofs.is_open( ) )
154 std::cerr <<
"Cannot write VTK file: " << filename << std::endl;
155 std::cerr <<
"File: " << __FILE__ << std::endl;
156 std::cerr <<
"Line: " << __LINE__ << std::endl;
160 unsigned int nnodes = nc.
NNodes();
162 ofs <<
"# vtk DataFile Version 3.0\n";
163 ofs <<
"Global Mesh Output" << std::endl;
165 ofs <<
"DATASET UNSTRUCTURED_GRID\n";
166 ofs <<
"POINTS " << nnodes <<
" double\n";
169 for(
int i=1;
i < nnodes; ++
i )
176 unsigned int nelem = con.size();
178 for(
int i=0;
i < nelem; ++
i )
180 unsigned int esize = con[
i].size();
186 ofs <<
"CELLS " << nelem <<
" " << nelem*( maxnodes+1) <<
"\n";
187 for(
int i=0;
i < nelem; ++
i )
189 ofs << con.
Esize(
i) <<
" ";
191 ofs << con[
i ][
j ]-1 <<
" ";
196 ofs <<
"CELL_TYPES " << nelem << std::endl;
197 for(
int i=0;
i < nelem; ++
i )
202 else if( con.
Esize(
i) == 4 )
205 std::cerr <<
"Undefined element type!\n";
206 std::cerr <<
"File: " << __FILE__ << std::endl;
207 std::cerr <<
"Line: " << __LINE__ << std::endl;
213 bool wroteHeader =
false;
214 std::vector<std::string> Name(5);
221 for(
int i=0;
i < 5; ++
i )
225 ofs <<
"CELL_DATA " << nelem << std::endl;
228 ofs <<
"SCALARS " << Name[
i] <<
" double" << std::endl;
229 ofs <<
"LOOKUP_TABLE default\n";
230 for(
int j=0;
j < nelem; ++
j )
232 ofs << soln[
i*nelem +
j ] <<
" ";
238 std::cout <<
"[DONE]\n";
std::vector< Mesh::UnstructuredMesh > meshes
The list of grids to write.
void writeVtkFiles(std::vector< Mesh::UnstructuredMesh > &m)
Writes the set of meshes into separate VTK files that can be visualized with Paraview.
General connectivity object.
A struct that holds all the global program data.
Class Mesh is the main class that holds all information to describe the current state of the mesh...
IndexType Esize(IndexType n) const
void writeVtkData()
Writes the merged grid and its data in VTK UNSTRUCTURED_GRID file format.
void printVtk(std::vector< double > &vlist, std::vector< std::vector< int > > &elist)
This method prints the global grid in VTK file format.