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

From: [email protected] <[email protected]> On Behalf 
Of Alberto Fernández
Sent: Wednesday, March 29, 2023 6:23 AM
To: ProjectChrono <[email protected]>
Subject: [chrono] Problem using ChBuilderBeamIGA from python

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.
--
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 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/5ee0329f-fda0-4087-9454-fbfc8ef19707n%40googlegroups.com<https://groups.google.com/d/msgid/projectchrono/5ee0329f-fda0-4087-9454-fbfc8ef19707n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/PH0PR06MB823742ACE97B0E3E911A7DA7A7899%40PH0PR06MB8237.namprd06.prod.outlook.com.

Reply via email to