forked from jaheyns/CfdOF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_TaskPanelCfdPhysicsSelection.py
180 lines (151 loc) · 8.25 KB
/
_TaskPanelCfdPhysicsSelection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# ***************************************************************************
# * *
# * Copyright (c) 2017-2018 Johan Heyns (CSIR) <[email protected]> *
# * Copyright (c) 2017-2018 Oliver Oxtoby (CSIR) <[email protected]> *
# * Copyright (c) 2017-2018 Alfred Bogaers (CSIR) <[email protected]> *
# * Copyright (c) 2019 Oliver Oxtoby <[email protected]> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
import FreeCAD
import os
import os.path
import CfdTools
from CfdTools import setQuantity
if FreeCAD.GuiUp:
import FreeCADGui
RANS_MODELS = ["kOmegaSST"]
class _TaskPanelCfdPhysicsSelection:
def __init__(self, obj):
# Update object with latest properties for backward-compatibility
obj.Proxy.initProperties(obj)
FreeCADGui.Selection.clearSelection()
self.sel_server = None
self.obj = obj
self.form = FreeCADGui.PySideUic.loadUi(os.path.join(os.path.dirname(__file__), "TaskPanelPhysics.ui"))
self.form.radioButtonSteady.toggled.connect(self.updateUI)
self.form.radioButtonTransient.toggled.connect(self.updateUI)
self.form.radioButtonSinglePhase.toggled.connect(self.updateUI)
self.form.radioButtonFreeSurface.toggled.connect(self.updateUI)
self.form.radioButtonIncompressible.toggled.connect(self.updateUI)
self.form.radioButtonCompressible.toggled.connect(self.updateUI)
self.form.viscousCheckBox.stateChanged.connect(self.updateUI)
self.form.radioButtonLaminar.toggled.connect(self.updateUI)
self.form.radioButtonRANS.toggled.connect(self.updateUI)
#self.form.radioButtonLES_DES.toggled.connect(self.updateUI)
self.load()
def load(self):
if self.obj.Time == 'Steady':
self.form.radioButtonSteady.toggle()
elif self.obj.Time == 'Transient':
self.form.radioButtonTransient.toggle()
if self.obj.Phase == 'Single':
self.form.radioButtonSinglePhase.toggle()
elif self.obj.Phase == 'FreeSurface':
self.form.radioButtonFreeSurface.toggle()
if self.obj.Flow == 'Incompressible':
self.form.radioButtonIncompressible.toggle()
elif self.obj.Flow == 'Compressible':
self.form.radioButtonCompressible.toggle()
self.form.checkBoxHighMach.setChecked(False)
elif self.obj.Flow == 'HighMachCompressible':
self.form.radioButtonCompressible.toggle()
self.form.checkBoxHighMach.setChecked(True)
if self.obj.Turbulence == 'Inviscid':
self.form.viscousCheckBox.setChecked(False)
self.form.radioButtonLaminar.toggle()
if self.obj.Turbulence == 'Laminar':
self.form.viscousCheckBox.setChecked(True)
self.form.radioButtonLaminar.toggle()
elif self.obj.Turbulence == 'RANS':
self.form.viscousCheckBox.setChecked(True)
self.form.radioButtonRANS.toggle()
ti = CfdTools.indexOrDefault(RANS_MODELS, self.obj.TurbulenceModel, 0)
self.form.turbulenceComboBox.setCurrentIndex(ti)
setQuantity(self.form.gx, self.obj.gx)
setQuantity(self.form.gy, self.obj.gy)
setQuantity(self.form.gz, self.obj.gz)
self.updateUI()
def updateUI(self):
self.form.TimeFrame.setVisible(True)
self.form.FlowFrame.setVisible(True)
self.form.turbulenceFrame.setVisible(True)
if self.form.radioButtonSteady.isChecked():
self.form.radioButtonFreeSurface.setEnabled(False)
if self.form.radioButtonFreeSurface.isChecked():
self.form.radioButtonSinglePhase.toggle()
else:
self.form.radioButtonFreeSurface.setEnabled(True)
self.form.gravityFrame.setEnabled(
self.form.radioButtonFreeSurface.isChecked() or
(self.form.radioButtonCompressible.isChecked() and not self.form.checkBoxHighMach.isChecked()))
if self.form.radioButtonFreeSurface.isChecked():
self.form.radioButtonCompressible.setEnabled(False)
if self.form.radioButtonCompressible.isChecked():
self.form.radioButtonIncompressible.toggle()
else:
self.form.radioButtonCompressible.setEnabled(True)
self.form.checkBoxHighMach.setEnabled(self.form.radioButtonCompressible.isChecked())
if self.form.viscousCheckBox.isChecked():
self.form.turbulenceFrame.setVisible(True)
if self.form.radioButtonRANS.isChecked():
self.form.turbulenceComboBox.clear()
self.form.turbulenceComboBox.addItems(RANS_MODELS)
self.form.turbulenceModelFrame.setVisible(True)
else:
self.form.turbulenceModelFrame.setVisible(False)
self.form.turbulenceComboBox.clear()
else:
self.form.turbulenceFrame.setVisible(False)
self.form.turbulenceModelFrame.setVisible(False)
def accept(self):
doc = FreeCADGui.getDocument(self.obj.Document)
doc.resetEdit()
FreeCADGui.doCommand("\nobj = FreeCAD.ActiveDocument.{}".format(self.obj.Name))
if self.form.radioButtonSteady.isChecked():
FreeCADGui.doCommand("obj.Time = 'Steady'")
elif self.form.radioButtonTransient.isChecked():
FreeCADGui.doCommand("obj.Time = 'Transient'")
if self.form.radioButtonSinglePhase.isChecked():
FreeCADGui.doCommand("obj.Phase = 'Single'")
elif self.form.radioButtonFreeSurface.isChecked():
FreeCADGui.doCommand("obj.Phase = 'FreeSurface'")
if self.form.radioButtonIncompressible.isChecked():
FreeCADGui.doCommand("obj.Flow = 'Incompressible'")
FreeCADGui.doCommand("obj.Thermal = 'None'")
elif self.form.radioButtonCompressible.isChecked():
if self.form.checkBoxHighMach.isChecked():
FreeCADGui.doCommand("obj.Flow = 'HighMachCompressible'")
else:
FreeCADGui.doCommand("obj.Flow = 'Compressible'")
FreeCADGui.doCommand("obj.Thermal = 'Energy'")
if self.form.viscousCheckBox.isChecked():
if self.form.radioButtonLaminar.isChecked():
FreeCADGui.doCommand("obj.Turbulence = 'Laminar'")
elif self.form.radioButtonRANS.isChecked():
FreeCADGui.doCommand("obj.Turbulence = 'RANS'")
FreeCADGui.doCommand("obj.TurbulenceModel = '{}'".format(
self.form.turbulenceComboBox.currentText()))
else:
FreeCADGui.doCommand("obj.Turbulence = 'Inviscid'")
FreeCADGui.doCommand("obj.gx = '{}'".format(self.form.gx.text()))
FreeCADGui.doCommand("obj.gy = '{}'".format(self.form.gy.text()))
FreeCADGui.doCommand("obj.gz = '{}'".format(self.form.gz.text()))
def reject(self):
doc = FreeCADGui.getDocument(self.obj.Document)
doc.resetEdit()