17 int posdx = outfilename.rfind(
".dx");
18 int posvtk = outfilename.rfind(
".vtk");
19 int filelength = outfilename.size();
20 if(filelength-posdx == 3) {
22 }
else if(filelength-posvtk == 4) {
25 cout <<
"visualmatrix output was not created\n";
33 const int nelx = matrix.
Cols();
34 const int nely = matrix.
Rows();
35 const int neltotal = nelx * nely;
38 out <<
"# Graphical Visualization of Matrix.\n" ;
39 out <<
"# Positions as the indexes of the matrix, beginning by column.\n" ;
40 out <<
"# The number of elements in x direction correspond to the number of the columns of the matrix.\n" ;
41 out <<
"# The number of elements in y direction correspond to the number of the rows of the matrix.\n" ;
43 out <<
"object 1 class gridpositions counts " << nelx+1 <<
" " << nely +1 <<
"\n";
44 out <<
"origin 0. 0.\n" ;
45 out <<
"delta 1. 0.\n" ;
46 out <<
"delta 0. 1.\n" ;
47 out <<
"attribute \"dep\" string \"positions\"" <<
"\n" ;
48 out <<
"\n" << std::flush;
51 out <<
"object 2 class gridconnections counts " << nelx+1 <<
" " << nely +1 <<
"\n" ;
53 out <<
"attribute \"element type\" string \"quads\"" <<
"\n" ;
54 out <<
"attribute \"ref\" string \"positions\"" <<
"\n" ;
57 out <<
"object 3 class array type float rank 0 items " << neltotal <<
" data follows\n" ;
58 for (i = 0; i < nelx; i++) {
59 for(j=0; j< nely ; j++) out <<
matrix(i,j) <<
"\n" ;
61 out <<
"attribute \"dep\" string \"connections\" " <<
"\n" << std::flush;
62 out <<
"\n" << std::flush;
64 out <<
"object 4 class field\n" ;
65 out <<
"component \"data\" value 3\n" ;
66 out <<
"component \"positions\" value 1\n" ;
67 out <<
"component \"connections\" value 2\n" ;
68 out <<
"attribute \"name\" string \"Matrix\"" <<
"\n" << std::flush;
71 out <<
"end\n" << std::flush;
75 cout <<
"Data Explorer file " << outfilename <<
" was created with success!\n";
82 const int nelx = matrix.
Cols();
83 const int nely = matrix.
Rows();
84 const int neltotal = nelx * nely;
86 ofstream out(outfilename.c_str());
87 out <<
"# vtk DataFile Version 3.0\n";
88 out <<
"Generated by PZ\n";
90 out <<
"DATASET RECTILINEAR_GRID\n";
91 out <<
"DIMENSIONS " << (nelx+1) <<
" " << (nely+1) <<
" 1\n";
92 out <<
"X_COORDINATES " << nelx+1 <<
" float\n";
93 for (i=0; i<=nelx; i++) {
97 out <<
"Y_COORDINATES " << nely+1 <<
" float\n";
98 for (j=0; j<=nely; j++) {
102 out <<
"Z_COORDINATES " << 1 <<
" float\n0.\n";
103 out <<
"CELL_DATA " << nelx*nely << std::endl;
104 out <<
"SCALARS mat_value float 1\n";
105 out <<
"LOOKUP_TABLE default\n";
106 const TVar *elem = 0;
110 for (i=0; i<neltotal; i++) {
111 out << *(elem+i) << std::endl;
void VisualMatrix(TPZFMatrix< TVar > &matrix, const std::string &outfilename)
This function calls the function that create a Data Explorer file or VTK file that allow to visualiz...
template void VisualMatrix< long double >(TPZFMatrix< long double > &matrix, const std::string &outfilename)
template void VisualMatrix< float >(TPZFMatrix< float > &matrix, const std::string &outfilename)
Contains the declaration of the VisualMatrix functions to VTK and DX packages.
template void VisualMatrix< double >(TPZFMatrix< double > &matrix, const std::string &outfilename)
TPZSkylMatrix< REAL > matrix
void VisualMatrixDX(TPZFMatrix< TVar > &matrix, const std::string &outfilename)
This function creates a Data Explorer file that allow to visualization of the value of a matrix passe...
Contains TPZMatrixclass which implements full matrix (using column major representation).
int64_t Rows() const
Returns number of rows.
void VisualMatrixVTK(TPZFMatrix< TVar > &matrix, const std::string &outfilename)
This function creates a VTK file that allow to visualization of the value of a matrix passed as param...
Full matrix class. Matrix.
int64_t Cols() const
Returns number of cols.