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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "meshquality.h"
23 MeshQuality::MeshQuality()
25 m_Name
= "unknown mesh quality";
28 void MeshQuality::computeNodesFromCells()
30 EG_VTKDCN(vtkDoubleArray
, node_mesh_quality
, m_Grid
, "node_mesh_quality");
31 EG_VTKDCC(vtkDoubleArray
, cell_mesh_quality
, m_Grid
, "cell_mesh_quality");
32 EG_FORALL_NODES(id_node
, m_Grid
) {
34 for (int i
= 0; i
< m_Part
.n2cGSize(id_node
); ++i
) {
35 vtkIdType id_cell
= m_Part
.n2cGG(id_node
, i
);
36 mq
= min(cell_mesh_quality
->GetValue(id_cell
), mq
);
38 node_mesh_quality
->SetValue(id_node
, mq
);
42 void MeshQuality::printCellInfo(int indent
)
44 double min_quality
= 1e99
;
45 double max_quality
= 0;
46 double mean_quality
= 0;
47 EG_VTKDCC(vtkDoubleArray
, cell_mesh_quality
, m_Grid
, "cell_mesh_quality");
48 EG_FORALL_CELLS(id_cell
, m_Grid
) {
49 double q
= cell_mesh_quality
->GetValue(id_cell
);
50 min_quality
= min(q
, min_quality
);
51 max_quality
= max(q
, max_quality
);
54 mean_quality
/= m_Grid
->GetNumberOfCells();
56 indent_str
.fill(' ', indent
);
57 cout
<< qPrintable(indent_str
) << qPrintable(name()) << endl
;
58 cout
<< qPrintable(indent_str
) << "min : " << min_quality
<< endl
;
59 cout
<< qPrintable(indent_str
) << "mean : " << mean_quality
<< endl
;
60 cout
<< qPrintable(indent_str
) << "max : " << max_quality
<< endl
;