Re: [Yade-users] [Question #703320]: Confusion about learning code in CohesiveFrictionalContactLaw.cpp

2022-09-29 Thread xuanshenyu
Question #703320 on Yade changed:
https://answers.launchpad.net/yade/+question/703320

Status: Answered => Solved

xuanshenyu confirmed that the question is solved:
Thanks for Jan's generous help, this is a great forum. My problem has
been solved!

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #703320]: Confusion about learning code in CohesiveFrictionalContactLaw.cpp

2022-09-28 Thread Jan Stránský
Question #703320 on Yade changed:
https://answers.launchpad.net/yade/+question/703320

Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

TLTR: inheritance

> I don't understand how ... 
> Law2_ScGeom6D_CohFrictPhys_CohesionMoment::go(...)' passes the updated 
> normalForce to Phys.
>  phys->normalForce = Fn * geom->normal;

yes, with this line [1].

I did not find a definition or declaration of normalForce in shared_ptr 
and CohFrictPhys*.
Probably my biggest confusion is not finding a definition or declaration of 
NormalForce.

What editor / IDE are you using?
I think an ordinary IDE should have capability of finding declaration / 
definition (although I do not have experience with C++ in IDE).

The key concept here is inheritance and polymorphism.
Type of "ip" variable is of type IGeom [2] which is then casted to "phys" 
variable of type CohFrictPhys [3].
CohFrictPhys is derived from RotStiffFrictPhys [4].
RotStiffFrictPhys is derived from FrictPhys [5].
FrictPhys is derived from NormShearPhys [6].
NormShearPhys is derived from NormPhys. [7]
(for completeness, NormPhys is derived from IPhys [8], so CohFrictPhys is 
derived from IPhys)
"normalForce" is declared in NormPhys as a Vector3r attribute [9].

You can also see documentation [10,11] and climb up the inheritance
until the origin of normalForce (present in NormPhys, not any more in
IPhys).

Cheers
Jan

[1] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/CohesiveFrictionalContactLaw.cpp#L133
[2] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/CohesiveFrictionalContactLaw.cpp#L109
[3] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/CohesiveFrictionalContactLaw.cpp#L115
[4] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/CohesiveFrictionalContactLaw.hpp#L49
[5] https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/FrictPhys.hpp#L43
[6] https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/FrictPhys.hpp#L17
[7] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/common/NormShearPhys.hpp#L23
[8] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/common/NormShearPhys.hpp#L9
[9] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/common/NormShearPhys.hpp#L15
[10] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.CohFrictPhys
[11] https://yade-dem.org/doc/yade.wrapper.html#iphys

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


[Yade-users] [Question #703320]: Confusion about learning code in CohesiveFrictionalContactLaw.cpp

2022-09-27 Thread xuanshenyu
New question #703320 on Yade:
https://answers.launchpad.net/yade/+question/703320

Hi, everyone

I don't understand how 'the bool 
Law2_ScGeom6D_CohFrictPhys_CohesionMoment::go(shared_ptr& ig, 
shared_ptr& ip, Interaction* contact)'  passes the updated normalForce 
to Phys.


Although the code has the following statement,  
   'go(shared_ptr& ig, shared_ptr& ip, Interaction* 
contact)'//line132
   ' CohFrictPhys* phys  = YADE_CAST(ip.get())//line138'
'phys->normalForce = Fn * geom->normal;// line 226'
I did not find a definition or declaration of normalForce in  shared_ptr 
and CohFrictPhys*.

Probably my biggest confusion is not finding a definition or declaration of 
NormalForce.

PS:Maybe it's just that I didn't learn C++ well :(.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp