FEM: mesh region, initialize new obj with length 0.0, do not use the obj for mesh creation if references are empty or lenght is 0.0
This commit is contained in:
parent
a245bf2abc
commit
3842f9c80b
|
@ -236,29 +236,35 @@ class FemGmshTools():
|
||||||
# print(mr_obj.Name)
|
# print(mr_obj.Name)
|
||||||
# print(mr_obj.CharacteristicLength)
|
# print(mr_obj.CharacteristicLength)
|
||||||
# print(Units.Quantity(mr_obj.CharacteristicLength).Value)
|
# print(Units.Quantity(mr_obj.CharacteristicLength).Value)
|
||||||
for sub in mr_obj.References:
|
if mr_obj.CharacteristicLength:
|
||||||
# print(sub[0]) # Part the elements belongs to
|
if mr_obj.References:
|
||||||
# check if the shape of the mesh region is an element of the Part to mesh, if not try to find the element in the shape to mesh
|
for sub in mr_obj.References:
|
||||||
search_ele_in_shape_to_mesh = False
|
# print(sub[0]) # Part the elements belongs to
|
||||||
if not self.part_obj.Shape.isSame(sub[0].Shape):
|
# check if the shape of the mesh region is an element of the Part to mesh, if not try to find the element in the shape to mesh
|
||||||
# print(" One element of the meshregion " + mr_obj.Name + " is not an element of the Part to mesh.")
|
search_ele_in_shape_to_mesh = False
|
||||||
# print(" But we gone try to find it in the Shape to mesh :-)")
|
if not self.part_obj.Shape.isSame(sub[0].Shape):
|
||||||
search_ele_in_shape_to_mesh = True
|
# print(" One element of the meshregion " + mr_obj.Name + " is not an element of the Part to mesh.")
|
||||||
for eles in sub[1]:
|
# print(" But we gone try to find it in the Shape to mesh :-)")
|
||||||
# print(eles) # element
|
search_ele_in_shape_to_mesh = True
|
||||||
if search_ele_in_shape_to_mesh:
|
for eles in sub[1]:
|
||||||
# we gone try to find the element it in the Shape to mesh and use the found element as eles
|
# print(eles) # element
|
||||||
ele_shape = FemMeshTools.get_element(sub[0], eles) # the method getElement(element) does not return Solid elements
|
if search_ele_in_shape_to_mesh:
|
||||||
found_element = FemMeshTools.find_element_in_shape(self.part_obj.Shape, ele_shape)
|
# we gone try to find the element it in the Shape to mesh and use the found element as eles
|
||||||
if found_element:
|
ele_shape = FemMeshTools.get_element(sub[0], eles) # the method getElement(element) does not return Solid elements
|
||||||
eles = found_element
|
found_element = FemMeshTools.find_element_in_shape(self.part_obj.Shape, ele_shape)
|
||||||
else:
|
if found_element:
|
||||||
FreeCAD.Console.PrintError("One element of the meshregion " + mr_obj.Name + " could not be found in the Part to mesh. It will be ignored.\n")
|
eles = found_element
|
||||||
# print(eles) # element
|
else:
|
||||||
if eles not in self.ele_length_map:
|
FreeCAD.Console.PrintError("One element of the meshregion " + mr_obj.Name + " could not be found in the Part to mesh. It will be ignored.\n")
|
||||||
self.ele_length_map[eles] = Units.Quantity(mr_obj.CharacteristicLength).Value
|
# print(eles) # element
|
||||||
else:
|
if eles not in self.ele_length_map:
|
||||||
FreeCAD.Console.PrintError("The element " + eles + " of the meshregion " + mr_obj.Name + " has been added to another mesh region.\n")
|
self.ele_length_map[eles] = Units.Quantity(mr_obj.CharacteristicLength).Value
|
||||||
|
else:
|
||||||
|
FreeCAD.Console.PrintError("The element " + eles + " of the meshregion " + mr_obj.Name + " has been added to another mesh region.\n")
|
||||||
|
else:
|
||||||
|
FreeCAD.Console.PrintError("The meshregion: " + mr_obj.Name + " is not used to create the mesh because the reference list is empty.\n")
|
||||||
|
else:
|
||||||
|
FreeCAD.Console.PrintError("The meshregion: " + mr_obj.Name + " is not used to create the mesh because the CharacteristicLength is 0.0 mm.\n")
|
||||||
for elel in self.ele_length_map:
|
for elel in self.ele_length_map:
|
||||||
ele_shape = FemMeshTools.get_element(self.part_obj, elel) # the method getElement(element) does not return Solid elements
|
ele_shape = FemMeshTools.get_element(self.part_obj, elel) # the method getElement(element) does not return Solid elements
|
||||||
ele_vertexes = FemMeshTools.get_vertexes_by_element(self.part_obj.Shape, ele_shape)
|
ele_vertexes = FemMeshTools.get_vertexes_by_element(self.part_obj.Shape, ele_shape)
|
||||||
|
|
|
@ -31,7 +31,7 @@ import FreeCAD
|
||||||
import _FemMeshRegion
|
import _FemMeshRegion
|
||||||
|
|
||||||
|
|
||||||
def makeFemMeshRegion(base_mesh, element_length=2.0, name="FEMMeshRegion"):
|
def makeFemMeshRegion(base_mesh, element_length=0.0, name="FEMMeshRegion"):
|
||||||
'''makeFemMeshRegion([length], [name]): creates a FEM mesh region object to define properties for a regon of a FEM mesh'''
|
'''makeFemMeshRegion([length], [name]): creates a FEM mesh region object to define properties for a regon of a FEM mesh'''
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Fem::FeaturePython", name)
|
obj = FreeCAD.ActiveDocument.addObject("Fem::FeaturePython", name)
|
||||||
_FemMeshRegion._FemMeshRegion(obj)
|
_FemMeshRegion._FemMeshRegion(obj)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user