FEM: gmsh mesh tool, better handling of min and max element size

This commit is contained in:
Bernd Hahnebach 2016-11-25 22:59:14 +01:00
parent e57febdf7b
commit 9e142fd156
3 changed files with 13 additions and 12 deletions

View File

@ -29,6 +29,7 @@ __url__ = "http://www.freecadweb.org"
import FreeCAD
import Fem
import Units
import subprocess
import tempfile
from platform import system
@ -48,12 +49,12 @@ class FemGmshTools():
self.part_obj = self.mesh_obj.Part
# clmax, ElementSizeMax: float, 0.0 = 1e+22
self.clmax = self.mesh_obj.ElementSizeMax
self.clmax = Units.Quantity(self.mesh_obj.ElementSizeMax).Value
if self.clmax == 0.0:
self.clmax = 1e+22
# clmin, ElementSizeMin: float
self.clmin = self.mesh_obj.ElementSizeMin
self.clmin = Units.Quantity(self.mesh_obj.ElementSizeMin).Value
# order, ElementOrder: ['Auto', '1st', '2nd']
self.order = self.mesh_obj.ElementOrder

View File

@ -44,10 +44,10 @@ class _FemMeshGmsh():
obj.addProperty("App::PropertyLink", "Part", "FEM Mesh", "Part object to mesh")
obj.Part = None
obj.addProperty("App::PropertyFloat", "ElementSizeMax", "FEM Mesh Params", "Max mesh element size (0.0 = infinity)")
obj.addProperty("App::PropertyLength", "ElementSizeMax", "FEM Mesh Params", "Max mesh element size (0.0 = infinity)")
obj.ElementSizeMax = 0.0 # will be 1e+22
obj.addProperty("App::PropertyFloat", "ElementSizeMin", "FEM Mesh Params", "Min mesh element size")
obj.addProperty("App::PropertyLength", "ElementSizeMin", "FEM Mesh Params", "Min mesh element size")
obj.ElementSizeMin = 0.0
obj.addProperty("App::PropertyEnumeration", "ElementDimension", "FEM Mesh Params", "Dimension of mesh elements (Auto = according ShapeType of part to mesh)")

View File

@ -48,8 +48,8 @@ class _TaskPanelFemMeshGmsh:
self.gmsh_runs = False
self.console_message_gmsh = ''
QtCore.QObject.connect(self.form.if_max, QtCore.SIGNAL("valueChanged(double)"), self.max_changed)
QtCore.QObject.connect(self.form.if_min, QtCore.SIGNAL("valueChanged(double)"), self.min_changed)
QtCore.QObject.connect(self.form.if_max, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.max_changed)
QtCore.QObject.connect(self.form.if_min, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.min_changed)
QtCore.QObject.connect(self.form.cb_dimension, QtCore.SIGNAL("activated(int)"), self.choose_dimension)
QtCore.QObject.connect(self.form.cb_order, QtCore.SIGNAL("activated(int)"), self.choose_order)
QtCore.QObject.connect(self.Timer, QtCore.SIGNAL("timeout()"), self.update_timer_text)
@ -91,8 +91,8 @@ class _TaskPanelFemMeshGmsh:
def update(self):
'fills the widgets'
self.form.if_max.setText("{} mm".format(self.clmax))
self.form.if_min.setText("{} mm".format(self.clmin))
self.form.if_max.setText(self.clmax.UserString)
self.form.if_min.setText(self.clmin.UserString)
index_dimension = self.form.cb_dimension.findText(self.dimension)
self.form.cb_dimension.setCurrentIndex(index_dimension)
index_order = self.form.cb_order.findText(self.order)
@ -111,11 +111,11 @@ class _TaskPanelFemMeshGmsh:
# print('Time: {0:4.1f}: '.format(time.time() - self.Start))
self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
def max_changed(self, value):
self.clmax = float(value)
def max_changed(self, base_quantity_value):
self.clmax = base_quantity_value
def min_changed(self, value):
self.clmin = float(value)
def min_changed(self, base_quantity_value):
self.clmin = base_quantity_value
def choose_dimension(self, index):
if index < 0: