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

Post by Taufeeq2 »

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
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: non uniform distributed load

Post by chrisb »

Hi Taufeeq1, welcome to the FreeCAD forum.
I have moved your topic to the FEM forum.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: non uniform distributed load

Post by bernd »

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

Re: non uniform distributed load

Post by UR_ »

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 3054 times
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: non uniform distributed load

Post by Jee-Bee »

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
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: non uniform distributed load

Post by bernd »

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

Re: non uniform distributed load

Post by ulrich1a »

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

Re: non uniform distributed load

Post by Jee-Bee »

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
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: non uniform distributed load

Post by bernd »

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

Re: non uniform distributed load

Post by UR_ »

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 2862 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 2862 times

file:

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

macro:

ApplyNonUniformLoad.FCMacro
(3.86 KiB) Downloaded 109 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)
Post Reply