Fem constraint contact

About the development of the FEM module/workbench.

Moderator: bernd

UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Fem constraint contact

Post by UR_ »

JV_3D wrote: Tue Aug 29, 2017 2:49 am Why is this different results means?
This means, ccx is in trouble finding a convergent iteration sequence.

Unfortunately ccx builds for windows are less stable than native linux builds (so they say).
I've tested several builds against stability under iterative load, and there are differences!
Don't know which build is bundled with FreeCAD, but i can confirm your results.
If you are running into problems, please try this:
https://github.com/ddfem/ccx_mingw64/bl ... 2_MTNO.exe
most stable because of non optimized code
Much less faults on ccx's test suite!
In single thread mode it will finish.
Unfortunately we have no analytic result for this example, so we couldn't do any verification.

But at least a hint to get this work with bundled ccx.exe:

Change degree of elements from 2 to 1 (most important!!)
For better results refine mesh at least to max size 10,0

netgen params.png
netgen params.png (14.55 KiB) Viewed 4191 times
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Fem constraint contact

Post by UR_ »

JV_3D wrote: Tue Aug 29, 2017 2:49 am 2) I am using other example but ... how should I continue?
I think, there are several things gets mixed up.
Get your facts first, then you can distort them as you please. Mark Twain
ccx supports rougly spoken 3 types of contact:

1) surface/surface contact accessible by FreeCAD's GUI
This contact prevents from intrusion, but not from sliding and not from lifting
It's build from spring elements, which generates forces only on negative clearance (intrusion)

2) TIED surface/surface contact
You have to edit .inp file after generation and before starting ccx
See reddish parts
** Contact Constraints
** written by write_constraints_contact function
** FemConstraintContact
*CONTACT PAIR, INTERACTION=INT1,TYPE=SURFACE TO SURFACE
DEP1,IND1
*SURFACE INTERACTION, NAME=INT1
*SURFACE BEHAVIOR,PRESSURE-OVERCLOSURE=TIED
1000000.0
*FRICTION
0.1, 1000000.0
In this case spring elements are generated, which can produce push AND pull forces

3) *TIE, see this post for referencehttps://forum.freecadweb.org/viewtopic. ... IE#p180709
In this case rigid links are used for connecting faces.

Your example won't work, because there is no static equilibrium, if you use FreeCAD's standard type of contact (see #1)
I've tested your file with #2, which worked.
JV_3D
Posts: 41
Joined: Fri Dec 23, 2016 4:45 am

Re: Fem constraint contact

Post by JV_3D »

bernd wrote: Tue Aug 29, 2017 5:01 am what ccx version do you use?
I dont know what ccx stand for, for the other answers I suppose it means 'calculix', well I am using the one it come with FreeCAD, I don't know how to change this software or verify the version.
Ok, I do not know which ccx version the 0.17 FreeCAD has, but I download other ccx exe file and use them, the better results are given by 'ccx_2.10_MT' for Windows build, so don't know if it better or not, but know is showing only one result and not several has before (although the values are different from the example image 'abs displacement max' equal to '30.08mm' vs '46.2847mm'; P: 100MPa).

@UR_ I will check your answers, there are some topics I do not understand/manage, so I need to check the information with careful. I was understanding there was some formulation issues with the example, since the other file do work (despite the many result answers)

Thank you so much for the help
polymer
Posts: 278
Joined: Fri Sep 12, 2014 8:49 am

Re: Fem constraint contact

Post by polymer »

Hello, how is the current state of contact simulation in FreeCAD?
Does it work in the more recent versions with the calculix and elmer solver or is this function not implemented yet?
What is the best workflow for usage, for example when importing a step assembly or a multi-object?

Kind regards
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fem constraint contact

Post by bernd »

polymer wrote: Fri Dec 22, 2017 5:58 pm Hello, how is the current state of contact simulation in FreeCAD?
Does it work in the more recent versions with the calculix and elmer solver or is this function not implemented yet?
What is the best workflow for usage, for example when importing a step assembly or a multi-object?

Kind regards
Best work flow is start with a simple geometry and do some contact simulations with FreeCAD. Afterwards you will have a feeling and have may be a better own background to decide if it fits your needs.

Bernd
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: Fem constraint contact

Post by makkemal »

I have not used this in a while
Still works fine on latest master
contact.PNG
contact.PNG (191.29 KiB) Viewed 3924 times
I attache example based on latest master

Regards
Michael
Attachments
Beam_contact.FCStd
(71.42 KiB) Downloaded 192 times
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: Fem constraint contact

Post by makkemal »

I am working on auto contact feature

I get the following error when applying the Faces with command
App::Document::_RecomputeFeature(): Unknown exception in Feature "FemConstraintContact" thrown

I cant figure out what is going wrong ?

Code: Select all

 obj.References = [(geom,face1), (geom,face2)]    
Full script below

Code: Select all

import FreeCADGui, FreeCAD
import numpy as np
locations = []
#Variables
num=3 # Number of nearest neigbours to found 
Slope = 1000000.000000  # Contact stiffness
Friction = 0.300000     # Friction 
Scale = 1   # Scale


def find_index_of_nearest(array, idx,num ):
    xpoint=array[idx,0]
    ypoint=array[idx,1]
    zpoint=array[idx,2]
    distance = []
    for i in range(array.shape[0]):
        distance.append((array[i,0]-xpoint)**2 + (array[i,1]-ypoint)**2+ (array[i,2]-zpoint)**2)       
    idxmin = np.argpartition(np.array(distance), num)
    idxmin=np.array(idxmin[0:num])
    idxmin=np.delete(idxmin,np.where(idxmin==idx))  
    return idxmin

def get_all_close_surfaces(array, num):
    store = []
    for i in range(array.shape[0]):
        store.append(find_index_of_nearest(array,i,num))    
    return store


def addcontactobjects(array,geom):
    [col,row]=np.array(array.shape)
    for i in range(array.size):
        #print(i)
        FreeCAD.activeDocument().addObject("Fem::ConstraintContact","FemConstraintContact")
    idxc=0
    idxr=0
    for obj in FreeCAD.ActiveDocument.Objects:
        if (obj.isDerivedFrom('Fem::ConstraintContact')):
            objName = obj.Name
            #print(objName)
            obj.Slope = Slope
            obj.Friction = Friction
            obj.Scale = Scale
            face1='Face'+str(idxc)
            print(face1)
            face2='Face'+str(array[idxc,idxr])
            print(face2)
            obj.References = [(geom,face1), (geom,face2)]    
            print(idxc,array[idxc,idxr])
            idxr+=1
            if idxr > row-1:
                idxr = 0
                idxc+=1


try:
    for obj in FreeCAD.ActiveDocument.Objects:  # seach all objects in document
        objName = obj.Name
        objLabel = obj.Label
        try:
            if obj.Shape.Faces:  # is a face then
                print( objLabel, objName, len(obj.Shape.Faces), " face(s)")
                FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.getObject(obj.Name))  # select the object with face
                if 'Compound' in objName: 
                    print('Getting vector list for nearest neighbours contact \n ', objName)
                    for face in range(len(obj.Shape.Faces)):  # list the face(s) of object
#                         print(face)
                         surfaceloc=np.array(obj.Shape.Faces[face].CenterOfMass)  # center point
                         locations.append(surfaceloc)
#                         print(surfaceloc)                        
                    locations = np.array(locations)
                    #print(locations.shape)
                    results = np.array(get_all_close_surfaces(locations,num))
                    print(results)
                    addcontactobjects(results,obj)                                          
                else:
                   print("No object found to apply contact ",objName)
        except Exception:
            print("Not Shape")
except Exception:
    print("Not object")

Regards
Michael
Attachments
contact_test.FCStd
(8.94 KiB) Downloaded 87 times
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fem constraint contact

Post by bernd »

I have an idea, but I do not have access to FreeCAD atm. BTW do you know these links in the regard of contactFEM_ConstraintContact
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fem constraint contact

Post by bernd »

Could you give more informations what your problem is?

What I did:
- open your file
- run your code
- no error
- 36 Contact constraints are added to the document
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: Fem constraint contact

Post by makkemal »

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14893 (Git)
Build type: Release
Branch: master
Hash: b8c50dc0f93410d1a8009a162385b50107c301ec
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Locale: English/SouthAfrica (en_ZA)
Only faces are applied to first contact constraint if you open the contact and close it it gives the error even though the faces are valid ?
Post Reply