2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 #include "su2writer.h"
25 #include "guimainwindow.h"
27 Su2Writer::Su2Writer()
29 setFormat("SU2 mesh files(*.su2)");
32 void Su2Writer::writeHeader()
34 QTextStream
f(m_File
);
36 f
<< "% Problem dimension\n";
41 void Su2Writer::writeElements()
43 QTextStream
f(m_File
);
45 f
<< "% Inner element connectivity\n";
48 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfCells(); ++id_cell
) {
49 if (isVolume(id_cell
, m_Grid
)) {
53 f
<< "NELEM= " << N
<< "\n";
55 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfCells(); ++id_cell
) {
56 if (isVolume(id_cell
, m_Grid
)) {
57 f
<< m_Grid
->GetCellType(id_cell
);
58 vtkIdType N_pts
, *pts
;
59 m_Grid
->GetCellPoints(id_cell
, N_pts
, pts
);
60 for (int j
= 0; j
< N_pts
; ++j
) {
63 f
<< " " << i
<< "\n";
69 void Su2Writer::writeNodes()
71 QTextStream
f(m_File
);
73 f
<< "% Node coordinates\n";
75 f
<< "NPOIN= " << m_Grid
->GetNumberOfPoints() << "\n";
76 for (vtkIdType id_node
= 0; id_node
< m_Grid
->GetNumberOfPoints(); ++id_node
) {
78 m_Grid
->GetPoint(id_node
, x
.data());
79 f
.setRealNumberPrecision(16);
80 f
<< x
[0] << " " << x
[1] << " " << x
[2] << " " << id_node
<< "\n";
84 void Su2Writer::writeBoundaries()
86 QTextStream
f(m_File
);
88 f
<< "% Boundary elements\n";
90 QSet
<int> bcs
= GuiMainWindow::pointer()->getAllBoundaryCodes();
91 f
<< "NMARK= " << bcs
.size() << "\n";
92 EG_VTKDCC(vtkIntArray
, cell_code
, m_Grid
, "cell_code");
93 foreach (int bc
, bcs
) {
94 BoundaryCondition BC
= GuiMainWindow::pointer()->getBC(bc
);
95 f
<< "MARKER_TAG= " << BC
.getName() << "\n";
96 QList
<vtkIdType
> faces
;
97 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfCells(); ++id_cell
) {
98 if (isSurface(id_cell
, m_Grid
)) {
99 if (cell_code
->GetValue(id_cell
) == bc
) {
100 faces
.append(id_cell
);
104 f
<< "MARKER_ELEMS= " << faces
.size() << "\n";
105 foreach (vtkIdType id_cell
, faces
) {
106 f
<< m_Grid
->GetCellType(id_cell
);
107 vtkIdType N_pts
, *pts
;
108 m_Grid
->GetCellPoints(id_cell
, N_pts
, pts
);
109 for (int j
= 0; j
< N_pts
; ++j
) {
117 void Su2Writer::operate()
120 QFileInfo
file_info(GuiMainWindow::pointer()->getFilename());
121 readOutputFileName(file_info
.completeBaseName() + ".su2");
123 m_File
= new QFile(getFileName());
124 m_File
->open(QIODevice::WriteOnly
| QIODevice::Text
);
131 } catch (Error err
) {