Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/GuiSlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ def messageBox(self, message):
information(self.parent, 'Information',
message, QtWidgets.QMessageBox.Ok)

@QtCore.Slot(str)
def yesnocancelQuestionBox(self, question):
return QtWidgets.QMessageBox.information(self.parent, 'Confirm?', question,
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Cancel)

@QtCore.Slot()
def onKeyBd(self):
# automatically populate shortcuts from PMenu.xml
Expand Down
56 changes: 56 additions & 0 deletions src/MatplotlibWindow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import sys
import threading
import random
import time

import pandas as pd

from PySide6.QtCore import Qt, QCoreApplication
from PySide6.QtGui import QWheelEvent

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.lines import Line2D


class MplCanvas(FigureCanvas):
"""
Provides an embeddable matplotlib canvas that can be live-updated
Preserves scrolling ability in GUI
"""
def __init__(self):
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
self.clear()
super().__init__(self.fig)

def clear(self):
self.ax.clear()
self.ax.grid()
self.ax.set_xlabel("Time iteration")
self.ax.set_ylabel("Value")
self.lines = {}

def update_plot(self, label: str, data: pd.Series, **kwargs):
if shift_max := kwargs.get(f"{label}_trend", 50):
trend = pd.DataFrame({"_dat": data.values}, index=data.index)["_dat"].ewm(halflife=shift_max).mean()
if not label in self.lines:
line_kwargs = kwargs.get(label, {})
if "label" in line_kwargs:
print("ERROR: passing label not allowed.")
self.lines[label] = self.ax.plot(list(data.index), list(data.values), **line_kwargs, alpha=0.5, label=label)[0]
# ax.plot returns a list of Line2D objects (hence the [0])
if shift_max:
line_kwargs["color"] = self.lines[label].get_color()
self.lines[f"{label}_trend"] = self.ax.plot(list(trend.index), list(trend.values), **line_kwargs, label=f"{label}_trend")[0]
self.ax.legend()
else:
self.lines[label].set_data(list(data.index), list(data.values))
if shift_max:
self.lines[f"{label}_trend"].set_data(list(trend.index), list(trend.values))

def wheelEvent(self, event: QWheelEvent):
if event.modifiers() & Qt.KeyboardModifier.ControlModifier:
super().wheelEvent(event) # Let Matplotlib zoom
else:
QCoreApplication.sendEvent(self.parent(), event)
31 changes: 6 additions & 25 deletions src/Meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,31 +1238,12 @@ def writeSU2_nolib(wind_tunnel, name=''):
# write boundary tags
f.write('NMARK= 5\n')

f.write('MARKER_TAG= airfoil\n')
f.write('MARKER_ELEMS= ' + str(num_airfoil_edges) + '\n')
for edge in tags['airfoil']:
f.write(f'3 {edge[0]} {edge[1]}\n')

f.write('MARKER_TAG= inlet\n')
f.write('MARKER_ELEMS= ' + str(num_inlet_edges) + '\n')
for edge in tags['inlet']:
f.write(f'3 {edge[0]} {edge[1]}\n')

f.write('MARKER_TAG= outlet\n')
f.write('MARKER_ELEMS= ' + str(num_outlet_edges) + '\n')
for edge in tags['outlet']:
f.write(f'3 {edge[0]} {edge[1]}\n')

f.write('MARKER_TAG= top\n')
f.write('MARKER_ELEMS= ' + str(num_top_edges) + '\n')
for edge in tags['top']:
f.write(f'3 {edge[0]} {edge[1]}\n')

f.write('MARKER_TAG= bottom\n')
f.write('MARKER_ELEMS= ' + str(num_bottom_edges) + '\n')
for edge in tags['bottom']:
f.write(f'3 {edge[0]} {edge[1]}\n')

for tag, edges in tags.items():
f.write(f'MARKER_TAG= {wind_tunnel.boundary_tags_names[tag]}\n')
f.write(f'MARKER_ELEMS= {str(len(edges))}\n')
for edge in edges:
f.write(f'3 {edge[0]} {edge[1]}\n')

basename = os.path.basename(name)
logger.info('SU2 type mesh saved as {}'.
format(os.path.join(OUTPUTDATA, basename)))
Expand Down
8 changes: 8 additions & 0 deletions src/PyAero.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ def keyPressEvent(self, event):
# progress event
super().keyPressEvent(event)

def closeEvent(self, event):
print("custom close event!")
try:
self.toolbox.abortSU2() # FIXME: this doesn't seem to do anything. wrong class's closeEvent?!
except Exception as excpt:
print(f"Aborting simulation processes failed with {excpt}")
self.deleteLater()


class CentralWidget(QtWidgets.QWidget):
"""
Expand Down
6 changes: 6 additions & 0 deletions src/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
# path to log files
LOGDATA = os.path.join(DATAPATH, 'LOGS')

# path to su2 master-config
SU2CONFIG = os.path.join(DATAPATH, "Config")

# path to SU2 executable
SU2EXEC = "SU2_CFD" # this should work if it's in PATH, otherwise just put the full path here

# set locale
# can be either 'C' or ''
# if string is empty then system default locale is used
Expand Down
Loading