Skip to content

Commit 2ad527a

Browse files
committed
Assigned force correctly based on edge length
1 parent 1bde4e3 commit 2ad527a

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

src/Mod/Fem/TODO -CodeAster

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,54 @@ TODO:
22
- Che
33
- Fix add_femelemt_geometry for if no groups are selected
44
- allow multiple groups of materials and element types
5-
- Add elasticity as proper equation
65
- Add stress to med reader
76
- Make it possible to have materials as children of ElementGeometryLaminate
7+
- Run geodesics etc on Femmesh directly
8+
9+
force_objs = []
10+
for ref in obj.References:
11+
for r in ref[1]:
12+
o = getattr(ref[0].Shape, r)
13+
force_objs.append(o)
14+
15+
tot = 0
16+
for o in force_objs:
17+
if type(o) == Part.Vertex:
18+
tot += 1
19+
elif type(o) == Part.Edge:
20+
tot += o.Length
21+
elif type(o) == Part.Face:
22+
tot += o.Area
23+
24+
print(tot)
25+
26+
27+
for getting fibre directions:
28+
29+
thicknesses = []
30+
elements = []
31+
angles = []
32+
for i in range(1,len(geomesh_obj.TriangleFibreDirectionsIndex)):
33+
if geomesh_obj.TriangleFibreDirectionsIndex[i-1] != geomesh_obj.TriangleFibreDirectionsIndex[i]:
34+
ths = [lam_obj.Thicknesses[0]]
35+
angs = [lam_obj.Orientations[0]]
36+
elements.append(i)
37+
for j in range(geomesh_obj.TriangleFibreDirectionsIndex[i-1], geomesh_obj.TriangleFibreDirectionsIndex[i]):
38+
ths.append(geomesh_obj.TriangleThicknesses[i-1]/(geomesh_obj.TriangleFibreDirectionsIndex[i] - geomesh_obj.TriangleFibreDirectionsIndex[i-1]))
39+
ang = geomesh_obj.IndexedTriangleFibreDirections[j]
40+
if ang > 90:
41+
ang -= 180
42+
elif ang < -90:
43+
ang += 180
44+
angs.append(ang)
45+
thicknesses.append(ths)
46+
angles.append(angs)
47+
lam_obj.Windall = {'elements':elements, 'orientationlists':angles, 'thicknesslists':thicknesses}
48+
49+
obj.Windall = {'elements':[364], 'orientationlists':[[0]], 'thicknesslists':[[0.18]]}
50+
obj.Windall = {'elements':[], 'orientationlists':[], 'thicknesslists':[]}
51+
52+
853

954
Useful code snippets for med file reading:
1055
sys.path.append('/home/timbo/anaconda3/lib/python3.12/site-packages')

src/Mod/Fem/femsolver/codeaster/add_con_force.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
## \addtogroup FEM
2929
# @{
30-
30+
import FreeCAD
31+
import Part
3132

3233
def add_con_force(commtxt, ca_writer):
3334
commtxt += "# Adding force loads\n"
@@ -37,8 +38,26 @@ def add_con_force(commtxt, ca_writer):
3738
dirvec = femobj["Object"].DirectionVector
3839
F = force_obj.Force.getValueAs('N')
3940
dirvec.normalize()
40-
print('Force load: ',i, femobj, ' on: ', force_obj.Name, ' of: ', F, ' at: ', dirvec)
41+
#Need to divide force across length, number of points or area as appropriate
42+
force_entities = []
43+
for ref in force_obj.References:
44+
for r in ref[1]:
45+
o = getattr(ref[0].Shape, r)
46+
force_entities.append(o)
47+
tot = 0
48+
for o in force_entities:
49+
if type(o) == Part.Vertex:
50+
tot += 1
51+
elif type(o) == Part.Edge:
52+
tot += o.Length
53+
elif type(o) == Part.Face:
54+
tot += o.Area
55+
56+
txt = "Force load: {} on: {} of: {} at: {} spread across: {} Vertices, length or area\n".format(i,force_obj.Name, F,dirvec,tot)
57+
FreeCAD.Console.PrintMessage(txt)
58+
commtxt += '#'+txt
4159

60+
F /= tot
4261
for ref in force_obj.References:
4362
for geom in ref[1]:
4463
geoms.append(geom)

0 commit comments

Comments
 (0)