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