mirror of https://gitlab.com/pamhyr/pamhyr2
Merge branch 'master' of gitlab-ssh.irstea.fr:theophile.terraz/pamhyr
commit
3805cc9932
|
|
@ -27,7 +27,7 @@ stages:
|
||||||
#############
|
#############
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
MAGE_VERSION: "v8.3.4"
|
MAGE_VERSION: "v8.3.3"
|
||||||
|
|
||||||
dl-mage-linux:
|
dl-mage-linux:
|
||||||
stage: downloads
|
stage: downloads
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@ from ctypes import (
|
||||||
POINTER, c_void_p,
|
POINTER, c_void_p,
|
||||||
c_int, c_double, c_bool
|
c_int, c_double, c_bool
|
||||||
)
|
)
|
||||||
|
from PyQt5.QtCore import QProcess
|
||||||
|
|
||||||
|
from tools import logger_color_red, logger_color_reset
|
||||||
from Meshing.AMeshingTool import AMeshingTool
|
from Meshing.AMeshingTool import AMeshingTool
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
@ -259,3 +261,60 @@ class MeshingWithMage(AMeshingTool):
|
||||||
|
|
||||||
logger.debug(f"meshing: Import geometry from {m}")
|
logger.debug(f"meshing: Import geometry from {m}")
|
||||||
reach.import_geometry(m)
|
reach.import_geometry(m)
|
||||||
|
|
||||||
|
|
||||||
|
class MeshingWithMageMailleurTT(AMeshingTool):
|
||||||
|
def __init__(self):
|
||||||
|
super(MeshingWithMageMailleurTT, self).__init__()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _exe_path(cls):
|
||||||
|
ext = "" if os.name == "posix" else ".exe"
|
||||||
|
|
||||||
|
return os.path.abspath(
|
||||||
|
os.path.join(
|
||||||
|
os.path.dirname(__file__),
|
||||||
|
"..", "..", "..", "mage", f"mailleurTT{ext}"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
###########
|
||||||
|
# Meshing #
|
||||||
|
###########
|
||||||
|
|
||||||
|
def meshing(self, reach, step: float = 50):
|
||||||
|
if reach is None or len(reach.profiles) == 0:
|
||||||
|
return reach
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
st_file = self.export_reach_to_st(reach, tmp)
|
||||||
|
m_file = st_file.rsplit(".ST", 1)[0] + ".M"
|
||||||
|
|
||||||
|
proc = QProcess()
|
||||||
|
proc.setWorkingDirectory(tmp)
|
||||||
|
|
||||||
|
proc.start(
|
||||||
|
self._exe_path(), [st_file, m_file, str(step)]
|
||||||
|
)
|
||||||
|
proc.waitForFinished()
|
||||||
|
|
||||||
|
errors = str(proc.readAllStandardError())
|
||||||
|
if len(errors) != 0:
|
||||||
|
logger.error(
|
||||||
|
f"{logger_color_red()}{errors}{logger_color_reset()}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.import_m_file(reach, m_file)
|
||||||
|
return reach
|
||||||
|
|
||||||
|
def export_reach_to_st(self, reach, tmp):
|
||||||
|
tmp_st = os.path.join(tmp, "meshing.ST")
|
||||||
|
|
||||||
|
logger.debug(f"meshing: Export ST to {tmp_st}")
|
||||||
|
|
||||||
|
reach.export_reach(tmp_st)
|
||||||
|
return tmp_st
|
||||||
|
|
||||||
|
def import_m_file(self, reach, m):
|
||||||
|
logger.debug(f"meshing: Import geometry from {m}")
|
||||||
|
reach.import_geometry(m)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from copy import deepcopy
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from tools import flatten, timer, trace
|
from tools import flatten, timer, trace, logger_exception
|
||||||
|
|
||||||
from Model.Tools.PamhyrDB import SQLSubModel
|
from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
|
|
||||||
|
|
@ -697,10 +697,14 @@ class Reach(SQLSubModel):
|
||||||
logger.debug(f"+{incline_acc}")
|
logger.debug(f"+{incline_acc}")
|
||||||
logger.debug(f"-{incline_set}")
|
logger.debug(f"-{incline_set}")
|
||||||
|
|
||||||
return (
|
try:
|
||||||
reduce(
|
return (
|
||||||
lambda acc, x: acc + x,
|
reduce(
|
||||||
incline_set,
|
lambda acc, x: acc + x,
|
||||||
0.0
|
incline_set,
|
||||||
) / (len(incline_set))
|
0.0
|
||||||
)
|
) / (len(incline_set))
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger_exception(e)
|
||||||
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,9 @@ from View.Tools.PamhyrWindow import PamhyrWindow
|
||||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
|
|
||||||
from Meshing.Mage import MeshingWithMage
|
from Meshing.Mage import (
|
||||||
|
MeshingWithMage, MeshingWithMageMailleurTT
|
||||||
|
)
|
||||||
|
|
||||||
from View.Geometry.Table import GeometryReachTableModel
|
from View.Geometry.Table import GeometryReachTableModel
|
||||||
from View.Geometry.PlotXY import PlotXY
|
from View.Geometry.PlotXY import PlotXY
|
||||||
|
|
@ -264,7 +266,7 @@ class GeometryWindow(PamhyrWindow):
|
||||||
|
|
||||||
def _edit_meshing(self):
|
def _edit_meshing(self):
|
||||||
try:
|
try:
|
||||||
mesher = MeshingWithMage()
|
mesher = MeshingWithMageMailleurTT()
|
||||||
self._table.meshing(mesher, -1)
|
self._table.meshing(mesher, -1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger_exception(e)
|
logger_exception(e)
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ class HydraulicStructuresWindow(PamhyrWindow):
|
||||||
float(profile_kp)
|
float(profile_kp)
|
||||||
)
|
)
|
||||||
|
|
||||||
if profiles is not None:
|
if len(profiles) != 0 and profiles is not None:
|
||||||
profile = profiles[0]
|
profile = profiles[0]
|
||||||
|
|
||||||
self.plot_kpc.set_profile(profile)
|
self.plot_kpc.set_profile(profile)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue