Multiselect

About the development of the FEM module/workbench.

Moderator: bernd

Rei
Posts: 75
Joined: Fri May 27, 2016 3:00 pm

Multiselect

Postby Rei » Sat May 28, 2016 7:36 pm

Hi everyone. It was recommended that I post here and reference this thread:

viewtopic.php?f=3&t=15916

In terms of features, the ability to do multiselect would be greatly appreciated. With any sort of complex model, it could take ages to assign forces across a large section of it. Eg:

https://c2.staticflickr.com/8/7099/2669 ... 72a1_o.png

(Also, if anyone here could weigh in on some of the issues trying to get results out of FEA being discussed over there, that'd be great :) )
User avatar
bernd
Posts: 8216
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Multiselect

Postby bernd » Sun May 29, 2016 8:34 pm

I havn't read the thread, will do on Monday.

In the regard of multiselection. Do you mean something like this ...

# load FEM example
# copy code to console

Code: Select all

shape_obj = App.ActiveDocument.getObject("Box")
ref1 = [(shape_obj, ('Face3', 'Face6', 'Face2', 'Face4', 'Face5'))]
App.ActiveDocument.getObject("FemConstraintForce").References = ref1
or with multiple selection:
# load FEM example
# make Cube visible
# make Box_Mesh not visible
# select all the faces
# copy code

Code: Select all

sel = Gui.Selection.getSelectionEx()[0]
ref2 = [(sel.Object, sel.SubElementNames)]
App.ActiveDocument.getObject("FemConstraintForce").References = ref2
add force to lots of faces at once ...
screen.jpg
screen.jpg (38.5 KiB) Viewed 1861 times
User avatar
bernd
Posts: 8216
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Multiselect

Postby bernd » Mon May 30, 2016 11:03 am

A more sophisticated example ... Attached two files.

The constraint force is applied to one face only. Just click around and run the analysis … Nothing difficault. Let's start playing … We would like to apply the force to all (ALL) the triangles (2837 faces).

load constraint_force--1_face.FCStd
We gone make a compound of all faces we would like to use for the constraint …

Code: Select all

obj = App.ActiveDocument.getObjectsByLabel('terrain')[0]
faces = []
for f in obj.Shape.Faces:
    add_face = True
    for v in f.Vertexes:
        if v.Z < 100100:
             add_face = False
             print v.Z
    if add_face is True:
        if f not in faces:
            faces.append(f)

Part.show(Part.makeCompound(faces))

Add all faces of the compound to the constraint force

Code: Select all

fpart = App.ActiveDocument.getObjectsByLabel('Shape')[0]
cfaceslist = []
for fno in range(len(fpart.Shape.Faces)):
    cfaceslist.append('Face' + str(fno+1))

cfaces = tuple(cfaceslist)
ref = [(fpart, cfaces)]
cforce =  App.ActiveDocument.getObjectsByLabel('FemConstraintForce')[0]
cforce.References = ref
cforce.References
Run the analysis. Writing the file takes some time for me (ca 11 minutes). File constraint_force--2837_faces.FCStd is what I get.

constraint_force--1_face.FCStd
https://cloud.woelkli.com/index.php/s/f3JV2XmrgRaAHm5

constraint_force--2837_faces.FCStd
https://cloud.woelkli.com/index.php/s/iOy0DTkwZ6JORD9
screen.png
screen.png (458.08 KiB) Viewed 1833 times
Rei
Posts: 75
Joined: Fri May 27, 2016 3:00 pm

Re: Multiselect

Postby Rei » Mon May 30, 2016 10:25 pm

Thanks, I'll give that a try whenever I can get my actual model to a non-crashy state :)
User avatar
bernd
Posts: 8216
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Multiselect

Postby bernd » Tue May 31, 2016 5:21 pm

I encountered a problem with the FEM constraints and lot's of shapes. Attached a file wich has 109 faces addes. Double click on FemConstraintForce and click on ok. Attached the error screen. It is a GUI problem only. More reference shapes could be added by python without any problems. See above posts (2837 faces where added by python).

code to change the reference faces off the force constraint:

Code: Select all

fpart = App.ActiveDocument.getObjectsByLabel('Shape')[0]
count_faces = len(fpart.Shape.Faces)   # 121
# count_faces = 109  # 108 faces is still ok for the gui
cfaceslist = []
for fno in range(count_faces):
    cfaceslist.append('Face' + str(fno+1))

cfaces = tuple(cfaceslist)
ref = [(fpart, cfaces)]
cforce =  App.ActiveDocument.getObjectsByLabel('FemConstraintForce')[0]
# cforce.References = []
cforce.References = ref
cforce.References
OS: Debian GNU/Linux 8.4 (jessie)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7687 (Git)
Build type: Unknown
Branch: master
Hash: d6f31d5c4b673ae87df0e113724de9fa34cf4d63
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.7.0
constraint_force--max_faces_test.FCStd
(68.76 KiB) Downloaded 27 times
screen.jpg
screen.jpg (189.51 KiB) Viewed 1782 times
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: Multiselect

Postby makkemal » Wed Jun 01, 2016 2:56 am

I agree with this, look at how the prescribed displacement is setup which allows for multiple selections.
The new constraints we are adding works the same.
We have also modified pressure to do it in the same manner
User avatar
bernd
Posts: 8216
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Multiselect

Postby bernd » Wed Jun 01, 2016 4:32 am

makkemal wrote:I agree with this, look at how the prescribed displacement is setup which allows for multiple selections.
Same problem on prescribed displacement. If dozens of faces are added by python the gui gives errors.

Code: Select all

fpart = App.ActiveDocument.getObjectsByLabel('Shape')[0]
count_faces = len(fpart.Shape.Faces)  # 121
#count_faces = 109
cfaceslist = []
for fno in range(count_faces):
    cfaceslist.append('Face' + str(fno+1))

cfaces = tuple(cfaceslist)
ref = [(fpart, cfaces)]
cdisp =  App.ActiveDocument.getObjectsByLabel('FemConstraintDisplacement')[0]
cdisp.References = ref
cdisp.References
Attachments
screen.jpg
screen.jpg (196.45 KiB) Viewed 1755 times
wmayer
Site Admin
Posts: 14620
Joined: Thu Feb 19, 2009 10:32 am

Re: Multiselect

Postby wmayer » Sat Jun 04, 2016 7:44 am

The limiting factor is the function Command::doCommand. Internally it reserves memory buffer of a length of 4063. However, the passed string seems to be longer so that afterwards the created Python command is truncated, hence the "invalid syntax" error.

Since the you can pass an arbitrary number of arguments to doComand() it's not that easy to determine the requested size of the output string. I have to check if there is a good solution...
wmayer
Site Admin
Posts: 14620
Joined: Thu Feb 19, 2009 10:32 am

Re: Multiselect

Postby wmayer » Sat Jun 04, 2016 8:37 am

User avatar
bernd
Posts: 8216
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Multiselect

Postby bernd » Sun Jun 05, 2016 7:43 pm

wmayer wrote:git commit 3c269f4
Wow, even the file with the 2837 reference shapes works. :D It takes some time but it works.

Thanks werner for giving the description what the problem is, ähhm was !