← Back to team overview

yade-users team mailing list archive

Re: [Question #684115]: Some basic concepts in FrictPhys.cpp

 

Question #684115 on Yade changed:
https://answers.launchpad.net/yade/+question/684115

    Status: Open => Answered

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

1.1

> Is the shared_ptr<FrictMat> a template class

yes. But as C++ newcomer, you can consider shared_ptr<SomeClass> as
normal pointer SomeClass* with "automatic destruction"

> will instantiate a pointer to FricMat?

no, the pointer already exists. It just change (cast) it  for C++ from
const shared_ptr<Material>&
to
const shared_ptr<FrictMat>&

> I have checked the definition of shared_ptr but it is too complicated
for a c++ newer to understand.

apart from definitions, try to google some simple examples.

1.2

> The YADE_PTR_CAST will do change the b1 type to FrictMat?

yes, see above

> But if b1 is not a pointer to FrictMat, like a CohFrictMat, will it
cause a material type mismatch between the particle material and the
IPhysFunctor?

if b1 is not FrictMat, than mat1 will be nullptr, causing segmentation
fault. But this function is called from Yade internals, specifically
IPhysDispatcher, who sends there only correct types.

CohFrictMat is not a good example, because CohFrictMat **IS** FrictMat
(it is derived from it) and the code would work OK.

2
> Why these two values could be negative?

who not? :-)
This condition is there from (at least, was too lazy to search more) 2009, probably its meaning was Sphere-Facet interaction or something like that

3
const shared_ptr<FrictPhys>& contactPhysics
means that the pointer is constant (the FrictPhys instance), not its content. You can change its content, but you cannot change, where the pointer points.

4
kn is MatchMaker [1]

cheers
Jan

[1] https://gitlab.com/yade-dev/trunk/commit/56597aa634e5f5a7684210dd4c8a858be5116cae#b34548f45a5a6c26d6a5293e702d6ccb1cbd5bbf_44_50
[2] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.MatchMaker

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