non uniform distributed load

About the development of the FEM module/workbench.

Moderator: bernd

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

non uniform distributed load

Postby Taufeeq2 » Fri Mar 30, 2018 12:47 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: 19043
Joined: Tue Mar 17, 2015 9:14 am

Re: non uniform distributed load

Postby chrisb » Fri Mar 30, 2018 12:56 pm

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

Re: non uniform distributed load

Postby bernd » Sat Mar 31, 2018 6:54 am

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

Re: non uniform distributed load

Postby UR_ » Sat Mar 31, 2018 10:09 am

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

Re: non uniform distributed load

Postby Jee-Bee » Sat Mar 31, 2018 12:29 pm

Worst case you can make it you're self with a CLOAD or DLOAD just add on every node or face another load.
Not nice but i wasn't able to see all the examples... http://www.feacluster.com/CalculiX/ccx_ ... ode403.php
User avatar
bernd
Posts: 8442
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: non uniform distributed load

Postby bernd » Sun Apr 01, 2018 9:40 am

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: 1883
Joined: Sun Jul 07, 2013 12:08 pm

Re: non uniform distributed load

Postby ulrich1a » Sun Apr 01, 2018 10:11 am

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: 1962
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: non uniform distributed load

Postby Jee-Bee » Tue Apr 03, 2018 9:28 am

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

Re: non uniform distributed load

Postby bernd » Tue Apr 03, 2018 2:59 pm

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

Re: non uniform distributed load

Postby UR_ » Wed Apr 18, 2018 5:40 pm

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
cosine shaped pressure distribution.gif (367.89 KiB) Viewed 885 times

workflow:
- ensure Edit->Preferences->FEM->Calculix->InputFileSplitting is checked
- load "cosine shaped pressure load.FCStd"
- delete object "NonUniformLoad"
- 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
deflection.gif (603.03 KiB) Viewed 885 times

file:

cosine shaped pressure load.FCStd
(960.21 KiB) Downloaded 46 times

macro:

ApplyNonUniformLoad.FCMacro
(3.86 KiB) Downloaded 38 times

Code: Select all

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

# pressure load distribution p = f(x,y,z)  [MPa]
def UniformLoad(x, y, z):
    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 ##
LoadFace = doc.getObject("CompoundFilter").Shape.Face3          # face to apply pressure load 
LoadDisplayScale = 20.                                           # scaling of vectors for pressure visualization [mm/MPa}
##



ElementFaces = mesh.getFacesByFace(LoadFace)
print ("No of Element Faces: " + str(len(ElementFaces)))
print ("Element Faces: " + str(ElementFaces))



# get WorkingDir
WorkingDir = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/Mod/Fem/General').GetString("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")
    f.write ("*DLOAD\n") 
    f.write ("** FemConstraintPressure: face load\n")
    
    
    VGroup = Draft.makeVisGroup()
    VGroup.Label = "NonUniformLoad"
    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)
        VGroup.addObject(Face)
        
        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))
        
        ElementFaceLoad = UniformLoad(Xm, Ym, Zm)
        print ("ElementFaceLoad: " + str(ElementFaceLoad))
        
        normal = Face.Shape.normalAt(0,0)
        print ("Face normal: " + str(normal))
        
        # visualize pressure vector
        Load = Draft.makeLine(Face.Shape.CenterOfMass, LoadDisplayScale * ElementFaceLoad * normal + Face.Shape.CenterOfMass)
        VGroup.addObject(Load)
        
        # write to INP file
        f.write (str(n) + ",P," + str(ElementFaceLoad)+ "\n")
        
        print ("==============================")

print "ready"

done with:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13516 (Git)
Build type: Release
Branch: master
Hash: 7101d9a89d49ed718d42611a81f1097b723e5ad2
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: German/Germany (de_DE)