yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #28381
Re: [Question #703320]: Confusion about learning code in CohesiveFrictionalContactLaw.cpp
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<IPhys> 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.