pychrono error creating ChElasticityCosseratAdvancedGenericFPM

24 views
Skip to first unread message

Alberto Fernández

unread,
Apr 12, 2023, 6:24:38 AM4/12/23
to ProjectChrono
I'm trying to create a Cosserat beam in python using the full matrix with coupling terms. I think the call to the constructor is correct, but I get a type error

Call (Klaw is a  pychrono.ChMatrixDynamicD 6x6):
melasticity = fea.ChElasticityCosseratAdvancedGenericFPM(Klaw, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)

Error:
TypeError: Wrong number or type of arguments for overloaded function 'new_ChElasticityCosseratAdvancedGenericFPM'.
  Possible C/C++ prototypes are:
    chrono::fea::ChElasticityCosseratAdvancedGenericFPM::ChElasticityCosseratAdvancedGenericFPM()
    chrono::fea::ChElasticityCosseratAdvancedGenericFPM::ChElasticityCosseratAdvancedGenericFPM(chrono::ChMatrixNM< double,6,6 > const,double const,double const,double const,double const,double const,double const)

I assume this is a problem with the call not being correctly defined in the python wrapper, but I don't know how to fix it. Is there other route that may work?
I also tried instantiating  ChElasticityCosseratAdvancedGenericFPMand then using SetEMatrix but no luck that way either.
Thank you for your time

alessand...@unipr.it

unread,
Apr 13, 2023, 3:40:30 AM4/13/23
to Alberto Fernández, ProjectChrono

hi Alberto,

the problem is that chrono::fea::ChElasticityCosseratAdvancedGenericFPM::ChElasticityCosseratAdvancedGenericFPM( ... ) requires a ChMatrixNM, that is a fixed size 6x6 matrix built on stack, but most likely you are passing ChMatrixDynamicD , that is a dynamically-sized matrix on the heap. Even if this is a 6x6 matrix too, both are not interchangeable. At the moment there is no way to generate a ChMatrixNM< double,6,6 > in Python because Python does not support templating, sorry.

Alessandro

--
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/61be7629-c3cc-4bff-a2e0-595e67cff81cn%40googlegroups.com.
Message has been deleted

Radu Serban

unread,
Apr 14, 2023, 5:50:21 PM4/14/23
to ProjectChrono

Alessandro, you may want to look into changing the signature of ChElasticityCosseratAdvancedGenericFPM to take a ChMatrixRef. I implemented ChMatrixRef precisely so that one can write non-template functions that can accept either a ChMatrixDynamic or a ChMatrixNM. I used this approach in other parts of Chrono (and there are others that I need to change along these lines to make them available to PyChrono).

--Radu

 

 

From: projec...@googlegroups.com <projec...@googlegroups.com> On Behalf Of Alberto Fernández
Sent: Thursday, April 13, 2023 10:08 AM
To: ProjectChrono <projec...@googlegroups.com>
Subject: Re: [chrono] pychrono error creating ChElasticityCosseratAdvancedGenericFPM

 

Thanks for the answer Alessandro.

I'm in fact using ChMatrixDynamicD. I tried first with  ChMatrixNMD since the reference documentation shows:

"""

chrono.ChVectorD # as ChVector<double> in c++

chrono.ChQuaternionD # as ChQuaternion<double> in c++

chrono.ChMatrix33D # as ChMatrix33<double> in c++

chrono.ChMatrixNMD # as ChMatrixNM<double> in c++

chrono.ChMatrixDynamicD # as ChMatrixDynamic<double> in c++

chrono.ChMatrixD # as ChMatrix<double> in c++

chrono.ChFrameD # as ChFrame<double> in c++

chrono.ChFrameMovingD # as ChFrameMoving<double> in c++

chrono.ChCoordsysD # as ChCoordsys<double> in c++

"""

However, it looks like it was not implemented. Then I saw in the changelog that `ChMatrixNM`, `ChMatrixDynamic`, `ChVectorDynamic` are aliases to Eigen type. Without going deeper I gave it a try just in case. I think I understand why it does not work now. Thanks

Reply all
Reply to author
Forward
0 new messages