Skip to content

Commit

Permalink
FEM: implement get_element since getElement does not return Solid ele…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
berndhahnebach authored and yorikvanhavre committed Dec 21, 2016
1 parent 8b61027 commit d64e2cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
13 changes: 3 additions & 10 deletions src/Mod/Fem/FemGmshTools.py
Expand Up @@ -29,6 +29,7 @@

import FreeCAD
import Fem
import FemMeshTools
import Units
import subprocess
import tempfile
Expand Down Expand Up @@ -218,7 +219,6 @@ def get_gmsh_command(self):
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:
Expand All @@ -240,11 +240,7 @@ def get_group_data(self):
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
Expand All @@ -258,10 +254,7 @@ def get_group_data(self):
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))
Expand Down
19 changes: 9 additions & 10 deletions src/Mod/Fem/FemMeshTools.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/Mod/Fem/_TaskPanelMechanicalMaterial.py
Expand Up @@ -123,13 +123,11 @@ def get_references(self):
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
Expand Down

0 comments on commit d64e2cf

Please sign in to comment.