← Back to team overview

yade-dev team mailing list archive

Re: Engine crash

 

Thanks, Vaclav, for good advices. r1819.

>PPS You can also use the plotting framework to get this kind of data at
>runtime, without writing to file. It is much more flexible. You can e.g.
>write a function in _utils.cpp that will do it and call it every time
>you need.
Ok, thanks, will use it. But now I need such file.
Actually, what functions includes _utils.cpp? Is it wrapped C++ functions,
accessible from python to get higher productivity?
______________________________
[ENG] Best Regards
[GER] Mit freundlichen Grüßen
[RUS] С наилучшими пожеланиями
[UKR] З найкращими побажаннями

Anton Gladkyy


2009/11/27 Václav Šmilauer <eudoxos@xxxxxxxx>

>
> >     InteractionContainer::iterator ii =
> > rootBody->interactions->begin();
> >     InteractionContainer::iterator iiEnd =
> > rootBody->interactions->end();
> >     numberCohesiveContacts=0;
> >     for(; ii!=iiEnd; ++ii ) {
> >         const shared_ptr<Interaction>& interaction = *ii;
> >         RpmPhys* contPhys =
> > static_cast<RpmPhys*>(interaction->interactionPhysics.get());
> >         if (contPhys->isCohesive==true) {
> >             numberCohesiveContacts++;
> >         }
> >     }
> Do it like this:
>
>  FOREACH(const shared_ptr<Interaction>& i, *rootBody->interactions){
>   if(!i->isReal()) continue;
>   /* handle interactions */
>  }
>
> 1. use FOREACH, it is easier to read, write and equally fast.
>
> 2. Check isReal, otherwise you get also "potential" interactions, which
> have NULL interactionGeometry and interactionsPhysics, hence the crash.
>
> 3. I suggest you use
> YADE_PTR_CAST<RpmPhys>(interaction->interactionPhysics) /* I think
> speedwise there is no difference between const ref to shared_ptr or
> const ptr */ instead of static_cast. It allows you to trap bad types in
> the debug build (nice assertion failure dereferencing NULL shared_ptr)
> instead of doing weird things, and it has no performance penaly in the
> optimized build.
>
> HTH, Vaclav
>
>
> > #4  <signal handler called>
> > #5  0x00007f22dc46452e in CohesiveStateRPMRecorder::action
> > (this=0x4490c50, rootBody=0xf3d400)
> > at
> /home/gladk/dem/yade/currentMono/yade/pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp:30
>
> (Huh, not very useful as we don't know what is line 30...)
>
> PS. I will create Recorder class deriving from PeriodicEngine. It will
> handle opening the file for you; there is many classes that need it...
>
> PPS You can also use the plotting framework to get this kind of data at
> runtime, without writing to file. It is much more flexible. You can e.g.
> write a function in _utils.cpp that will do it and call it every time
> you need.
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-dev<https://launchpad.net/%7Eyade-dev>
> Post to     : yade-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-dev<https://launchpad.net/%7Eyade-dev>
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References