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 "physicalboundarycondition.h"
23 #include <QStringList>
26 PhysicalBoundaryCondition::PhysicalBoundaryCondition()
33 void PhysicalBoundaryCondition::setType(QString type
)
38 if (m_Type
== "symmetry") {
40 if (m_Type
== "wall") {
42 if (m_Type
== "slip") {
44 if (m_Type
== "inlet") {
45 m_VarNames
.push_back("velocity");
46 m_VarValues
.push_back(0);
47 m_VarNames
.push_back("turbulent-intensity");
48 m_VarValues
.push_back(0.04);
49 m_VarNames
.push_back("turbulent-length-scale");
50 m_VarValues
.push_back(1);
51 m_VarNames
.push_back("temperature");
52 m_VarValues
.push_back(300);
54 if (m_Type
== "outlet") {
55 m_VarNames
.push_back("pressure");
56 m_VarValues
.push_back(0);
60 QString
PhysicalBoundaryCondition::getFoamEpsilon(QString version
)
63 QTextStream
s(&str
, QIODevice::WriteOnly
);
64 if (m_Type
== "symmetry") {
65 s
<< " type symmetryPlane;\n";
67 if (m_Type
== "wall") {
68 if (version
>= "2.1") {
69 s
<< " type omegaWallFunction;\n";
71 s
<< " kappa 0.41;\n";
73 s
<< " beta1 0.075;\n";
74 s
<< " value uniform 0;\n";
76 s
<< " type zeroGradient;\n";
79 if (m_Type
== "slip") {
80 s
<< " type zeroGradient;\n";
82 if (m_Type
== "inlet") {
83 double k
= 1.5*sqr(getVarValue(0)*getVarValue(1));
84 double epsilon
= (pow(0.09, 0.75)*pow(k
, 1.5))/getVarValue(2);
85 s
<< " type fixedValue;\n";
86 s
<< " value uniform " << epsilon
<< ";\n";
88 if (m_Type
== "outlet") {
89 s
<< " type zeroGradient;\n";
94 QString
PhysicalBoundaryCondition::getFoamK(QString version
)
97 QTextStream
s(&str
, QIODevice::WriteOnly
);
98 if (m_Type
== "symmetry") {
99 s
<< " type symmetryPlane;\n";
101 if (m_Type
== "wall") {
102 if (version
>= "2.1") {
103 s
<< " type kqRWallFunction;\n";
104 s
<< " value uniform 0;\n";
106 s
<< " type zeroGradient;\n";
109 if (m_Type
== "slip") {
110 s
<< " type zeroGradient;\n";
112 if (m_Type
== "inlet") {
113 double k
= 1.5*sqr(getVarValue(0)*getVarValue(1));
114 double epsilon
= (pow(0.09, 0.75)*pow(k
, 1.5))/getVarValue(2);
115 s
<< " type fixedValue;\n";
116 s
<< " value uniform " << k
<< ";\n";
118 if (m_Type
== "outlet") {
119 s
<< " type zeroGradient;\n";
124 QString
PhysicalBoundaryCondition::getFoamOmega(QString version
)
127 QTextStream
s(&str
, QIODevice::WriteOnly
);
128 if (m_Type
== "symmetry") {
129 s
<< " type symmetryPlane;\n";
131 if (m_Type
== "wall") {
132 if (version
>= "2.1") {
133 s
<< " type omegaWallFunction;\n";
135 s
<< " kappa 0.41;\n";
137 s
<< " beta1 0.075;\n";
138 s
<< " value uniform 0;\n";
140 s
<< " type zeroGradient;\n";
143 if (m_Type
== "slip") {
144 s
<< " type zeroGradient;\n";
146 if (m_Type
== "inlet") {
147 double k
= 1.5*sqr(getVarValue(0)*getVarValue(1));
148 double epsilon
= (pow(0.09, 0.75)*pow(k
, 1.5))/getVarValue(2);
149 double omega
= epsilon
/(0.09*k
);
150 s
<< " type fixedValue;\n";
151 s
<< " value uniform " << omega
<< ";\n";
153 if (m_Type
== "outlet") {
154 s
<< " type zeroGradient;\n";
159 QString
PhysicalBoundaryCondition::getFoamNut(QString version
)
162 QTextStream
s(&str
, QIODevice::WriteOnly
);
163 if (m_Type
== "symmetry") {
164 s
<< " type symmetryPlane;\n";
166 if (m_Type
== "wall") {
167 if (version
>= "2.1") {
168 s
<< " type nutkWallFunction;\n";
170 s
<< " kappa 0.41;\n";
172 s
<< " value uniform 0;\n";
177 if (m_Type
== "slip") {
178 s
<< " type zeroGradient;\n";
180 if (m_Type
== "inlet") {
181 double k
= 1.5*sqr(getVarValue(0)*getVarValue(1));
182 double epsilon
= (pow(0.09, 0.75)*pow(k
, 1.5))/getVarValue(2);
183 double omega
= epsilon
/(0.09*k
);
184 s
<< " type calculated;\n";
185 s
<< " value uniform 0;\n";
187 if (m_Type
== "outlet") {
188 s
<< " type zeroGradient;\n";
193 QString
PhysicalBoundaryCondition::getFoamP(QString
)
196 QTextStream
s(&str
, QIODevice::WriteOnly
);
197 if (m_Type
== "symmetry") {
198 s
<< " type symmetryPlane;\n";
200 if (m_Type
== "wall") {
201 s
<< " type zeroGradient;\n";
203 if (m_Type
== "slip") {
204 s
<< " type zeroGradient;\n";
206 if (m_Type
== "inlet") {
207 s
<< " type zeroGradient;\n";
209 if (m_Type
== "outlet") {
210 s
<< " type fixedValue;\n";
211 s
<< " value uniform " << getVarValue(0) << ";\n";
216 QString
PhysicalBoundaryCondition::getFoamU(QString
, vec3_t n
)
219 QTextStream
s(&str
, QIODevice::WriteOnly
);
220 if (m_Type
== "symmetry") {
221 s
<< " type symmetryPlane;\n";
223 if (m_Type
== "wall") {
224 s
<< " type fixedValue;\n";
225 s
<< " value uniform (0 0 0);\n";
227 if (m_Type
== "slip") {
228 s
<< " type slip;\n";
230 if (m_Type
== "inlet") {
231 s
<< " type fixedValue;\n";
232 s
<< " value uniform (" << getVarValue(0)*n
[0] << " " << getVarValue(0)*n
[1] << " " << getVarValue(0)*n
[2] << ");\n";
234 if (m_Type
== "outlet") {
235 s
<< " type zeroGradient;\n";
240 QString
PhysicalBoundaryCondition::getFoamT(QString version
)
243 QTextStream
s(&str
, QIODevice::WriteOnly
);
244 if (m_Type
== "symmetry") {
245 s
<< " type symmetryPlane;\n";
247 if (m_Type
== "wall") {
248 s
<< " type zeroGradient;\n";
250 if (m_Type
== "slip") {
251 s
<< " type zeroGradient;\n";
253 if (m_Type
== "inlet") {
254 s
<< " type fixedValue;\n";
255 s
<< " value uniform " << getVarValue(3) << ";\n";
257 if (m_Type
== "outlet") {
258 s
<< " type zeroGradient;\n";
263 QString
PhysicalBoundaryCondition::getFoamType()
265 if (m_Type
== "symmetry") {
266 return ("symmetryPlane");
268 if (m_Type
== "wall") {
271 if (m_Type
== "slip") {
274 if (m_Type
== "inlet") {
277 if (m_Type
== "outlet") {