Problem using ChBuilderBeamIGA from python

26 views
Skip to first unread message

Alberto Fernández

unread,
Mar 29, 2023, 7:22:53 AM3/29/23
to ProjectChrono
Hello all,

First of all, congratulations on this project. I’m trying to do a small check model of a curved beam. I’d like to use ChBuilderBeamIGA() from python, but it throws an error.

"""

sys = chrono.ChSystemSMC()
mesh = fea.ChMesh()
mesh.SetAutomaticGravity(True,2)
sys.Add(mesh)
sys.Set_G_acc(chrono.ChVectorD(0,-9.81, 0))

beam_ro = 0.050
beam_ri = 0.045
CH_C_PI = 3.1456

minertia = fea.ChInertiaCosseratSimple()
minertia.SetDensity(7800)
minertia.SetArea(CH_C_PI * (pow(beam_ro, 2)- pow(beam_ri, 2)))
minertia.SetIyy( (CH_C_PI / 4.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)) )
minertia.SetIzz( (CH_C_PI / 4.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)) )
   
melasticity = fea.ChElasticityCosseratSimple()
melasticity.SetYoungModulus(210e9)
melasticity.SetGwithPoissonRatio(0.3)
melasticity.SetIyy( (CH_C_PI / 4.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)) )
melasticity.SetIzz( (CH_C_PI / 4.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)) )
melasticity.SetJ  ( (CH_C_PI / 2.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)) )

msection = fea.ChBeamSectionCosserat(minertia, melasticity)

msection.SetCircular(True)
msection.SetDrawCircularRadius(beam_ro)

gen_cpoints = np.genfromtxt("./Control Points.csv", delimiter=',')
points = []
for _p in gen_cpoints:
    points.append(chrono.ChVectorD(*_p))
pos = chrono.ChVectorD(0, 0.0, 0.0)
splinepoints = chrono.vector_ChVectorD(points)
mspline = chrono.ChLineBspline(3, splinepoints)

builder = fea.ChBuilderBeamIGA()
beam = builder.BuildBeam(mesh, msection, mspline, chrono.VECT_X)

"""

This code gives a type error:

"""

TypeError: Wrong number or type of arguments for overloaded function 'ChBuilderBeamIGA_BuildBeam'.
  Possible C/C++ prototypes are:
    chrono::fea::ChBuilderBeamIGA::BuildBeam(std::shared_ptr< chrono::fea::ChMesh >,std::shared_ptr< chrono::fea::ChBeamSectionCosserat >,int const,chrono::ChVector< > const,chrono::ChVector< > const,chrono::ChVector< > const,int const)
    chrono::fea::ChBuilderBeamIGA::BuildBeam(std::shared_ptr< chrono::fea::ChMesh >,std::shared_ptr< chrono::fea::ChBeamSectionCosserat >,int const,chrono::ChVector< > const,chrono::ChVector< > const,chrono::ChVector< > const)
    chrono::fea::ChBuilderBeamIGA::BuildBeam(std::shared_ptr< chrono::fea::ChMesh >,std::shared_ptr< chrono::fea::ChBeamSectionCosserat >,geometry::ChLineBspline &,chrono::ChVector< > const)

"""

I may be missing something, but if I do print(type(mesh), type(msection), type(mspline)) I get:

<class 'pychrono.fea.ChMesh'> <class 'pychrono.fea.ChBeamSectionCosserat'> <class 'pychrono.core.ChLineBspline'>

The call looks correct to me. I've been looking into the code and with my very limited knowledge of swig it seems like this particular function is exported to python.
I have also tried two other approaches, first I tried to reproduce the process in BuilderBeamIGA in python, but it came a point (elem.SetNodesGenericOrder) where I needed to pass a std::vector< double,std::allocator< double > >. I thought this should work with a list of doubles but it does not.
I also tried using BuilderBeamIGA call with start point and end point. My idea (kind of a hack really) was to move afterward the nodes into position (the beam is curved). I’m not finding an easy way to do that from pyhton.
Am I trying to do something impossible from python?
Thank you for your time.

Radu Serban

unread,
Mar 29, 2023, 10:02:08 AM3/29/23
to ProjectChrono

Hi Alberto,

 

This seems to be an issue with the SWIG interface files (which is how we generate the PyChrono wrappers to Chrono).  We’ll look into this, but I cannot give you a date when this will be fixed.

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/5ee0329f-fda0-4087-9454-fbfc8ef19707n%40googlegroups.com.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages