About the development of the FEM module/workbench.

Moderator: bernd

Taufeeq2
Posts: 18
Joined: Fri Mar 30, 2018 12:39 pm

Does anyone know of a way of applying a non uniform distributed load on a face using freecad?
I have tried reading the calculix manual but couldnt get my head around the way calculix code is written.
Any help would be greatly appreciated
chrisb
Posts: 28152
Joined: Tue Mar 17, 2015 9:14 am

### Re: non uniform distributed load

Hi Taufeeq1, welcome to the FreeCAD forum.
I have moved your topic to the FEM forum.
bernd
Posts: 10828
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: non uniform distributed load

what exactly do you mean by a nonuniform face load?
UR_
Posts: 1196
Joined: Tue Jan 03, 2017 8:42 pm

### Re: non uniform distributed load

bernd wrote:
Sat Mar 31, 2018 6:54 am
what exactly do you mean by a nonuniform face load?
beam load q(x).png (10.49 KiB) Viewed 1581 times
Jee-Bee
Posts: 2130
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: non uniform distributed load

Not nice but i wasn't able to see all the examples... http://www.feacluster.com/CalculiX/ccx_ ... ode403.php
bernd
Posts: 10828
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: non uniform distributed load

what could be don as work around:

- split the face into new faces, by sketcher and boolean fragments
- use uniform face load on each face
ulrich1a
Posts: 1958
Joined: Sun Jul 07, 2013 12:08 pm

### Re: non uniform distributed load

An approach to program this, would be something similar like the mesh settings for GMSH. So one can set values at the edges of a face and an interpolation routine would be needed, that sets the intermediate values for all mesh-faces or nodes of this face.

Openfoam allows to define a field, for example a flow field for the inlet of some tube that has the velocity distribution of a laminar flow. Such a field is than used to set the boundary conditions at an cross section of that tube.

This looks like a feature request with a lot of programming work required.

Ulrich
Jee-Bee
Posts: 2130
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: non uniform distributed load

I would aasume u need this: http://www.feacluster.com/CalculiX/ccx_ ... de241.html
But there is no uniformal distributed option in it....
bernd
Posts: 10828
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: non uniform distributed load

we would not need it, we could calculate the dload for every element face.
UR_
Posts: 1196
Joined: Tue Jan 03, 2017 8:42 pm

### Re: non uniform distributed load

bernd wrote:
Tue Apr 03, 2018 2:59 pm
we could calculate the dload for every element face
Attached one can find a small example, howto apply a nonuniform pressure load.

There is plate from shell elements with a circluar shaped face.

The face at the center should get a cosine shaped pressure distribution.

cosine shaped pressure distribution.gif (367.89 KiB) Viewed 1389 times

workflow:
- ensure Edit->Preferences->FEM->Calculix->InputFileSplitting is checked
- activate Analysis
- "Write inp file" in CalculiXccxTools task view
- execute macro "ApplyNonUniformLoad.FCMacro" and wait for finishing (see report view)
- "Run Calculix" in CalculiXccxTools task view

result:

deflection.gif (603.03 KiB) Viewed 1389 times

file:

macro:

Code: Select all

``````import Draft
import Part
import os
import sys
import tempfile
import math

# pressure load distribution p = f(x,y,z)  [MPa]
p = math.cos (math.sqrt (x*x + y*y) / 20 * math.pi / 2)
return p

doc = App.ActiveDocument

mesh =  doc.getObjectsByLabel("FEMMeshGmsh")[0].FemMesh

## hardcoded user input ##
LoadDisplayScale = 20.                                           # scaling of vectors for pressure visualization [mm/MPa}
##

print ("No of Element Faces: " + str(len(ElementFaces)))
print ("Element Faces: " + str(ElementFaces))

# get WorkingDir

if not WorkingDir:
WorkingDir = doc.getObject("CalculiXccxTools").WorkingDir

if not WorkingDir:
WorkingDir =  tempfile.gettempdir()

print ("WorkingDir: " + WorkingDir)

if not WorkingDir:
raise SystemExit

# create INP file pressure section
# has to be included into master INP file
with open (WorkingDir + "/FemMeshGmsh_Pressure.inp", "w") as f:

f.write ("***********************************************************\n")
f.write ("** Element + CalculiX face + load in [MPa]\n")
f.write ("** written by " + (os.path.basename(__file__)) + "\n")
f.write ("** FemConstraintPressure\n")

VGroup = Draft.makeVisGroup()
VGroup.ViewObject.LineColor = (0.000,1.000,0.000)
VGroup.ViewObject.ShapeColor = (1.000,0.000,0.000)
VGroup.ViewObject.Transparency = 80

for n in ElementFaces:

Gui.updateGui()

Nodes = mesh.getElementNodes(n)
print ("Nodes of Elem (" + str(n) + "): " + str(Nodes))

Points = []

if len(Nodes) == 3:

# for 1st order faces
Points.append(mesh.getNodeById(Nodes[0]))
Points.append(mesh.getNodeById(Nodes[1]))
Points.append(mesh.getNodeById(Nodes[2]))

elif len(Nodes) == 6:

# for 2nd order faces
Points.append(mesh.getNodeById(Nodes[0]))
Points.append(mesh.getNodeById(Nodes[3]))
Points.append(mesh.getNodeById(Nodes[1]))
Points.append(mesh.getNodeById(Nodes[4]))
Points.append(mesh.getNodeById(Nodes[2]))
Points.append(mesh.getNodeById(Nodes[5]))

else:
print ("Error: ElementFace: " + str(n) + " NodeCount: " + str(len(Nodes)) + " Hint: Only 3 or 6 nodes per face allowed")
break

print (Points)

Face = Draft.makeWire (Points, closed = True, face = True)

Xm = Face.Shape.CenterOfMass.x
Ym = Face.Shape.CenterOfMass.y
Zm = Face.Shape.CenterOfMass.z

print ("CenterOfMass: X" + str(Xm) + " Y" + str(Ym) + " Z" + str(Zm))

normal = Face.Shape.normalAt(0,0)
print ("Face normal: " + str(normal))

# visualize pressure vector

# write to INP file
f.write (str(n) + ",P," + str(ElementFaceLoad)+ "\n")

print ("==============================")

``````

done with:
OS: Windows 10
Word size of OS: 64-bit