1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "su2writer.h"
24 #include "guimainwindow.h"
26 Su2Writer::Su2Writer()
28 setFormat("SU2 mesh files(*.su2)");
31 void Su2Writer::writeHeader()
33 QTextStream
f(m_File
);
35 f
<< "% Problem dimension\n";
40 void Su2Writer::writeElements()
42 QTextStream
f(m_File
);
44 f
<< "% Inner element connectivity\n";
47 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfCells(); ++id_cell
) {
48 if (isVolume(id_cell
, m_Grid
)) {
52 f
<< "NELEM= " << N
<< "\n";
54 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfCells(); ++id_cell
) {
55 if (isVolume(id_cell
, m_Grid
)) {
56 f
<< m_Grid
->GetCellType(id_cell
);
57 EG_GET_CELL(id_cell
, m_Grid
);
58 for (int j
= 0; j
< num_pts
; ++j
) {
61 f
<< " " << i
<< "\n";
67 void Su2Writer::writeNodes()
69 QTextStream
f(m_File
);
71 f
<< "% Node coordinates\n";
73 f
<< "NPOIN= " << m_Grid
->GetNumberOfPoints() << "\n";
74 for (vtkIdType id_node
= 0; id_node
< m_Grid
->GetNumberOfPoints(); ++id_node
) {
76 m_Grid
->GetPoint(id_node
, x
.data());
77 f
.setRealNumberPrecision(16);
78 f
<< x
[0] << " " << x
[1] << " " << x
[2] << " " << id_node
<< "\n";
82 void Su2Writer::writeBoundaries()
84 QTextStream
f(m_File
);
86 f
<< "% Boundary elements\n";
88 QSet
<int> bcs
= GuiMainWindow::pointer()->getAllBoundaryCodes();
89 f
<< "NMARK= " << bcs
.size() << "\n";
90 EG_VTKDCC(vtkIntArray
, cell_code
, m_Grid
, "cell_code");
91 foreach (int bc
, bcs
) {
92 BoundaryCondition BC
= GuiMainWindow::pointer()->getBC(bc
);
93 f
<< "MARKER_TAG= " << BC
.getName() << "\n";
94 QList
<vtkIdType
> faces
;
95 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfCells(); ++id_cell
) {
96 if (isSurface(id_cell
, m_Grid
)) {
97 if (cell_code
->GetValue(id_cell
) == bc
) {
98 faces
.append(id_cell
);
102 f
<< "MARKER_ELEMS= " << faces
.size() << "\n";
103 foreach (vtkIdType id_cell
, faces
) {
104 f
<< m_Grid
->GetCellType(id_cell
);
105 EG_GET_CELL(id_cell
, m_Grid
);
106 for (int j
= 0; j
< num_pts
; ++j
) {
114 void Su2Writer::operate()
117 QFileInfo
file_info(GuiMainWindow::pointer()->getFilename());
118 readOutputFileName(file_info
.completeBaseName() + ".su2");
120 m_File
= new QFile(getFileName());
121 m_File
->open(QIODevice::WriteOnly
| QIODevice::Text
);
128 } catch (Error err
) {