mirror of https://gitlab.com/pamhyr/pamhyr2
Model, Solver: Some minor fix for multi reach study.
parent
c2c1667a73
commit
651061ede0
|
|
@ -55,8 +55,8 @@ class Reach(SQLSubModel):
|
|||
|
||||
def _sql_save(self, execute, data = None):
|
||||
# Delete old data
|
||||
execute(f"DELETE FROM geometry_profileXYZ")
|
||||
execute(f"DELETE FROM geometry_pointXYZ")
|
||||
execute(f"DELETE FROM geometry_profileXYZ WHERE reach = {self.id}")
|
||||
# execute(f"DELETE FROM geometry_pointXYZ")
|
||||
|
||||
if data is None:
|
||||
data = {}
|
||||
|
|
|
|||
|
|
@ -119,18 +119,11 @@ class Mage(AbstractSolver):
|
|||
return files
|
||||
|
||||
@timer
|
||||
def _export_BC(self, bound, repertory, qlog):
|
||||
def _export_BC(self, t, bounds, repertory, qlog):
|
||||
files = []
|
||||
|
||||
t = "XX"
|
||||
if bound.bctype == "ZD":
|
||||
t = "AVA"
|
||||
elif bound.bctype == "TD":
|
||||
t = "HYD"
|
||||
elif bound.bctype == "TZ":
|
||||
t = "LIM"
|
||||
else:
|
||||
return None
|
||||
if len(bounds) == 0:
|
||||
return files
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put(f"Export {t} file")
|
||||
|
|
@ -140,14 +133,15 @@ class Mage(AbstractSolver):
|
|||
|
||||
f.write("* This file is generate by PAMHYR, please don't modify\n")
|
||||
|
||||
name = f"{bound.node.id:3}".replace(" ", "x")
|
||||
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
|
||||
f.write(f"${name}\n")
|
||||
header = bound.header
|
||||
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||
for bound in bounds:
|
||||
name = f"{bound.node.id:3}".replace(" ", "x")
|
||||
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
|
||||
f.write(f"${name}\n")
|
||||
header = bound.header
|
||||
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||
|
||||
for d in bound.data:
|
||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
for d in bound.data:
|
||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
|
||||
return files
|
||||
|
||||
|
|
@ -156,9 +150,22 @@ class Mage(AbstractSolver):
|
|||
files = []
|
||||
lst = study.river.boundary_condition
|
||||
|
||||
AVA = []
|
||||
HYD = []
|
||||
LIM = []
|
||||
|
||||
for tab in ["liquid", "solid", "suspenssion"]:
|
||||
for bound in lst.get_tab(tab):
|
||||
files = files + self._export_BC(bound, repertory, qlog)
|
||||
if bound.bctype == "ZD":
|
||||
AVA.append(bound)
|
||||
elif bound.bctype == "TD" or bound.bctype == "PC":
|
||||
HYD.append(bound)
|
||||
elif bound.bctype == "TZ":
|
||||
LIM.append(bound)
|
||||
|
||||
files = files + self._export_BC("AVA", AVA, repertory, qlog)
|
||||
files = files + self._export_BC("HYD", HYD, repertory, qlog)
|
||||
files = files + self._export_BC("LIM", LIM, repertory, qlog)
|
||||
|
||||
return files
|
||||
|
||||
|
|
@ -247,12 +254,7 @@ class Mage(AbstractSolver):
|
|||
|
||||
# Write header
|
||||
with open(os.path.join(repertory, "0.INI"), "w+") as f:
|
||||
files.append("0.INI")
|
||||
f.write("* This file is generate by PAMHYR, please don't modify\n")
|
||||
# TODO put real date...
|
||||
f.write(f"$ date en minutes : 0.00\n")
|
||||
f.write(f"* IB IS discharge elevation kp\n")
|
||||
|
||||
has_ini = False
|
||||
id = 1
|
||||
reachs = study.river.edges()
|
||||
reachs = list(
|
||||
|
|
@ -262,10 +264,19 @@ class Mage(AbstractSolver):
|
|||
)
|
||||
)
|
||||
|
||||
f.write("* This file is generate by PAMHYR, please don't modify\n")
|
||||
# TODO put real date...
|
||||
f.write(f"$ date en minutes : 0.00\n")
|
||||
f.write(f"* IB IS discharge elevation kp\n")
|
||||
|
||||
id = 1
|
||||
for reach in reachs:
|
||||
cond = study.river.initial_conditions.get(reach)
|
||||
data = cond.data
|
||||
if len(data) == 0:
|
||||
continue
|
||||
|
||||
has_ini = True
|
||||
|
||||
id_sec = 1
|
||||
for d in data:
|
||||
|
|
@ -280,6 +291,8 @@ class Mage(AbstractSolver):
|
|||
|
||||
id += 1
|
||||
|
||||
if has_ini:
|
||||
files.append("0.INI")
|
||||
return files
|
||||
|
||||
@timer
|
||||
|
|
|
|||
|
|
@ -111,24 +111,21 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
|||
|
||||
def open_file_dialog(self):
|
||||
options = QFileDialog.Options()
|
||||
DEFAULT_DIRECTORY = os.getenv("HOME")
|
||||
settings = QSettings(QSettings.IniFormat, QSettings.UserScope, 'MyOrg', )
|
||||
current_dir = settings.value('current_directory', DEFAULT_DIRECTORY, type=str)
|
||||
options |= QFileDialog.DontUseNativeDialog
|
||||
|
||||
filename, _ = QtWidgets.QFileDialog.getOpenFileName(
|
||||
self,
|
||||
_translate("MainWindow_reach", "Ouvrir un fichier"),
|
||||
current_dir,
|
||||
"",
|
||||
_translate("MainWindow_reach", "Fichiers .ST (*.ST)") +
|
||||
";; " +
|
||||
_translate("MainWindow_reach", "Fichiers textes (*.txt)") +
|
||||
_translate("MainWindow_reach", "Fichiers .M (*.M)") +
|
||||
";; " +
|
||||
_translate("MainWindow_reach", "Tous les fichiers (*)"),
|
||||
options=options
|
||||
)
|
||||
|
||||
current_dir = os.path.split(filename)[0] or DEFAULT_DIRECTORY
|
||||
if filename != "":
|
||||
size = os.stat(filename).st_size
|
||||
self._reach.import_geometry(filename)
|
||||
|
|
|
|||
Loading…
Reference in New Issue