← Back to team overview

yade-users team mailing list archive

Re: Gravity Triaxial

 

chiara modenese a écrit :
I tried to modify the value of gravity accessing the engine in the TriaxialCompressionEngine, but still it does nothing..
How did you try to do this ? Normally with following lines in TCEngine, I guess it should work. They allow you to pass through all the engines of the simulation, and to change the "gravity" attribute of the "GravityEngine", once you found it.


vector<shared_ptr<Engine> >::iterator itFirst = ncb->engines.begin(); // ncb is the Scene vector<shared_ptr<Engine> >::iterator itLast = ncb->engines.end(); for ( ;itFirst!=itLast; ++itFirst ) // you check all the engines of the simulation
           {
if ( ( *itFirst )->getClassName() == "GravityEngine" ) // that's the ClassName of this Engine, as it is defined in the first argument of YADE_CLASS_BASE_DOC_ATTRS of the .hpp (I guess ? I'm more used to other syntax, with REGISTER_CLASS_NAME(...))
               {
PtrGravityEngine = YADE_PTR_CAST<GravityEngine> ( *itFirst ); // PtrGravityEngine should before be declared as a shared_ptr<GravityEngine>....
                   PtrGravityEngine ->gravity = "the value you want"
               }
           }



Jerome



Follow ups

References