FEM: implement get_element since getElement does not return Solid elements
This commit is contained in:
parent
8b61027de2
commit
d64e2cfd5e
|
@ -29,6 +29,7 @@ __url__ = "http://www.freecadweb.org"
|
|||
|
||||
import FreeCAD
|
||||
import Fem
|
||||
import FemMeshTools
|
||||
import Units
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
@ -218,7 +219,6 @@ class FemGmshTools():
|
|||
def get_group_data(self):
|
||||
if self.analysis:
|
||||
print(' Group meshing.')
|
||||
import FemMeshTools
|
||||
self.group_elements = FemMeshTools.get_analysis_group_elements(self.analysis, self.part_obj)
|
||||
print(' {}'.format(self.group_elements))
|
||||
else:
|
||||
|
@ -240,11 +240,7 @@ class FemGmshTools():
|
|||
for eles in sub[1]:
|
||||
# print(eles) # element
|
||||
if search_ele_in_shape_to_mesh:
|
||||
if eles.startswith('Solid'):
|
||||
ele_shape = sub[0].Shape.Solids[int(eles.lstrip('Solid')) - 1] # Solid
|
||||
else:
|
||||
ele_shape = sub[0].Shape.getElement(eles) # Face, Edge, Vertex
|
||||
import FemMeshTools
|
||||
ele_shape = FemMeshTools.get_element(sub[0], eles) # the method getElement(element) does not return Solid elements
|
||||
found_element = FemMeshTools.find_element_in_shape(self.part_obj.Shape, ele_shape)
|
||||
if found_element:
|
||||
eles = found_element
|
||||
|
@ -258,10 +254,7 @@ class FemGmshTools():
|
|||
print(' {}'.format(self.ele_length_map))
|
||||
self.ele_node_map = {} # { 'ElementString' : [element nodes] }
|
||||
for elel in self.ele_length_map:
|
||||
if elel.startswith('Solid'):
|
||||
ele_shape = self.part_obj.Shape.Solids[int(elel.lstrip('Solid')) - 1] # Solid
|
||||
else:
|
||||
ele_shape = self.part_obj.Shape.getElement(elel) # Face, Edge, Vertex
|
||||
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)
|
||||
self.ele_node_map[elel] = ele_vertexes
|
||||
print(' {}'.format(self.ele_node_map))
|
||||
|
|
|
@ -72,10 +72,7 @@ def get_femnodes_by_references(femmesh, references):
|
|||
def get_femnodes_by_refshape(femmesh, ref):
|
||||
nodes = []
|
||||
for refelement in ref[1]:
|
||||
if refelement.startswith('Solid'):
|
||||
r = ref[0].Shape.Solids[int(refelement.lstrip('Solid')) - 1] # Solid
|
||||
else:
|
||||
r = ref[0].Shape.getElement(refelement) # Face, Edge, Vertex
|
||||
r = get_element(ref[0], refelement) # the method getElement(element) does not return Solid elements
|
||||
print(' ReferenceShape : ', r.ShapeType, ', ', ref[0].Name, ', ', ref[0].Label, ' --> ', refelement)
|
||||
if r.ShapeType == 'Vertex':
|
||||
nodes += femmesh.getNodesByVertex(r)
|
||||
|
@ -1018,12 +1015,7 @@ def get_analysis_group_elements(aAnalysis, aPart):
|
|||
# print(parent)
|
||||
# print(childs)
|
||||
for child in childs:
|
||||
if child:
|
||||
# Face, Edge, Vertex
|
||||
ref_shape = parent.Shape.getElement(child)
|
||||
else:
|
||||
# Solid
|
||||
ref_shape = parent.Shape
|
||||
ref_shape = get_element(parent, child) # the method getElement(element) does not return Solid elements
|
||||
if not stype:
|
||||
stype = ref_shape.ShapeType
|
||||
elif stype != ref_shape.ShapeType:
|
||||
|
@ -1240,6 +1232,13 @@ def is_same_geometry(shape1, shape2):
|
|||
return False
|
||||
|
||||
|
||||
def get_element(part, element):
|
||||
if element.startswith('Solid'):
|
||||
return part.Shape.Solids[int(element.lstrip('Solid')) - 1] # Solid
|
||||
else:
|
||||
return part.Shape.getElement(element) # Face, Edge, Vertex
|
||||
|
||||
|
||||
def femelements_count_ok(len_femelement_table, count_femelements):
|
||||
if count_femelements == len_femelement_table:
|
||||
print('Count FEM elements as sum of constraints: ', count_femelements)
|
||||
|
|
|
@ -123,13 +123,11 @@ class _TaskPanelMechanicalMaterial:
|
|||
self.references.append((ref[0], elem))
|
||||
|
||||
def has_equal_references_shape_types(self):
|
||||
import FemMeshTools
|
||||
if not self.references:
|
||||
self.references_shape_type = None
|
||||
for ref in self.references:
|
||||
if ref[1].startswith('Solid'):
|
||||
r = ref[0].Shape.Solids[int(ref[1].lstrip('Solid')) - 1] # Solid
|
||||
else:
|
||||
r = ref[0].Shape.getElement(ref[1]) # Face, Edge
|
||||
r = FemMeshTools.get_element(ref[0], ref[1]) # the method getElement(element) does not return Solid elements
|
||||
# print(' ReferenceShape : ', r.ShapeType, ', ', ref[0].Name, ', ', ref[0].Label, ' --> ', ref[1])
|
||||
if self.references_shape_type is None:
|
||||
self.references_shape_type = r.ShapeType
|
||||
|
|
Loading…
Reference in New Issue
Block a user