compiles on openSUSE 15.4 part 2
[engrid-github.git] / src / libengrid / guiypluscalculator.cpp
bloba6f1a4e7491408af12f9e1c07944654f22841f58
1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // + +
3 // + This file is part of enGrid. +
4 // + +
5 // + Copyright 2008-2016 enGits GmbH +
6 // + +
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. +
11 // + +
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. +
16 // + +
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/>. +
19 // + +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "guiypluscalculator.h"
24 GuiYPlusCalculator::GuiYPlusCalculator()
26 m_Ui.m_LineEditL->setValidator(new QDoubleValidator());
27 m_Ui.m_LineEditRe->setValidator(new QDoubleValidator());
28 m_Ui.m_LineEditMu->setValidator(new QDoubleValidator());
29 m_Ui.m_LineEditU->setValidator(new QDoubleValidator());
30 m_Ui.m_LineEditRho->setValidator(new QDoubleValidator());
31 m_Ui.m_LineEditY->setValidator(new QDoubleValidator());
32 m_Ui.m_LineEditYPlus->setValidator(new QDoubleValidator());
33 connect(m_Ui.m_LineEditL, SIGNAL(editingFinished()), this, SLOT(changedL()));
34 connect(m_Ui.m_LineEditMu, SIGNAL(editingFinished()), this, SLOT(changedMu()));
35 connect(m_Ui.m_LineEditRe, SIGNAL(editingFinished()), this, SLOT(changedRe()));
36 connect(m_Ui.m_LineEditRho, SIGNAL(editingFinished()), this, SLOT(changedRho()));
37 connect(m_Ui.m_LineEditU, SIGNAL(editingFinished()), this, SLOT(changedU()));
38 connect(m_Ui.m_LineEditY, SIGNAL(editingFinished()), this, SLOT(changedY()));
39 connect(m_Ui.m_LineEditYPlus, SIGNAL(editingFinished()), this, SLOT(changedYPlus()));
40 connect(m_Ui.m_ComboBoxFlowType, SIGNAL(currentIndexChanged(QString)), this, SLOT(changedFlowType(QString)));
43 double GuiYPlusCalculator::cfPlate(double Re_x)
45 return 0.455/pow(log(0.06*Re_x), 2.0);
48 double GuiYPlusCalculator::cfPipe(double Re)
50 double lam = 0.01;
51 for (int iter = 0; iter < 100; ++iter) {
52 lam = 1.0/pow((2*log10(Re*sqrt(lam)) - 0.8), 2.0);
54 return 0.25*lam;
57 void GuiYPlusCalculator::before()
59 m_Calculating = false;
60 m_ExternalFlow = false;
61 getValues();
62 calc();
65 void GuiYPlusCalculator::getValues()
67 m_Calculating = true;
68 m_L = m_Ui.m_LineEditL->text().toDouble();
69 m_U = m_Ui.m_LineEditU->text().toDouble();
70 m_Re = m_Ui.m_LineEditRe->text().toDouble();
71 m_Mu = m_Ui.m_LineEditMu->text().toDouble();
72 m_Rho = m_Ui.m_LineEditRho->text().toDouble();
73 m_Y = m_Ui.m_LineEditY->text().toDouble();
74 m_YPlus = m_Ui.m_LineEditYPlus->text().toDouble();
75 m_ExternalFlow = m_Ui.m_ComboBoxFlowType->currentText() == "external";
78 void GuiYPlusCalculator::setValues()
80 QString num;
81 num.setNum(m_L); m_Ui.m_LineEditL->setText(num);
82 num.setNum(m_U); m_Ui.m_LineEditU->setText(num);
83 num.setNum(m_Re); m_Ui.m_LineEditRe->setText(num);
84 num.setNum(m_Mu); m_Ui.m_LineEditMu->setText(num);
85 num.setNum(m_Rho); m_Ui.m_LineEditRho->setText(num);
86 num.setNum(m_Y); m_Ui.m_LineEditY->setText(num);
87 num.setNum(m_YPlus); m_Ui.m_LineEditYPlus->setText(num);
88 m_Calculating = false;
91 void GuiYPlusCalculator::calc()
93 double nu = m_Mu/m_Rho;
94 m_Re = m_U*m_L/nu;
95 double cf = cfPlate(m_Re);
96 if (!m_ExternalFlow) {
97 cf = cfPipe(m_Re);
99 m_YPlus = m_U*m_Y/nu*sqrt(0.5*cf);
100 setValues();
103 void GuiYPlusCalculator::changedFlowType(QString)
105 if (m_Calculating) {
106 return;
108 getValues();
109 calc();
112 void GuiYPlusCalculator::changedL()
114 if (m_Calculating) {
115 return;
117 getValues();
118 calc();
121 void GuiYPlusCalculator::changedMu()
123 if (m_Calculating) {
124 return;
126 getValues();
127 calc();
130 void GuiYPlusCalculator::changedRe()
132 if (m_Calculating) {
133 return;
135 getValues();
136 m_Re = m_Ui.m_LineEditRe->text().toDouble();
137 m_U = m_Re*m_Mu/(m_Rho*m_L);
138 calc();
141 void GuiYPlusCalculator::changedRho()
143 if (m_Calculating) {
144 return;
146 getValues();
147 m_Rho = m_Ui.m_LineEditRho->text().toDouble();
148 calc();
151 void GuiYPlusCalculator::changedU()
153 if (m_Calculating) {
154 return;
156 getValues();
157 calc();
160 void GuiYPlusCalculator::changedY()
162 if (m_Calculating) {
163 return;
165 getValues();
166 calc();
169 void GuiYPlusCalculator::changedYPlus()
171 if (m_Calculating) {
172 return;
174 getValues();
175 double nu = m_Mu/m_Rho;
176 m_Re = m_U*m_L/nu;
177 double cf = cfPlate(m_Re);
178 if (!m_ExternalFlow) {
179 cf = cfPipe(m_Re);
181 m_YPlus = m_Ui.m_LineEditYPlus->text().toDouble();
182 m_Y = sqrt(2.0/cf)*m_YPlus*nu/m_U;
183 calc();