[Gmsh] animate structural mode shapes

Christophe Geuzaine geuzaine at acm.caltech.edu
Mon May 31 07:31:46 CEST 2004


Al Danial wrote:
> 
> Is there a way to bind the "play" icon so that it executes
> a user-defined function (namely an animation loop such
> as the one above) instead of going through time steps?

No... But what you could do is delete the view at the end of your 
script, i.e.,

View "ten_segment_bar" {
VL(0.0,0.0,0.0,0.1,0.0,0.0){0,0.00,0, 0,0.31,0};
VL(0.1,0.0,0.0,0.2,0.0,0.0){0,0.31,0, 0,0.59,0};
VL(0.2,0.0,0.0,0.3,0.0,0.0){0,0.59,0, 0,0.81,0};
VL(0.3,0.0,0.0,0.4,0.0,0.0){0,0.81,0, 0,0.95,0};
VL(0.4,0.0,0.0,0.5,0.0,0.0){0,0.95,0, 0,0.99,0};
VL(0.5,0.0,0.0,0.6,0.0,0.0){0,0.99,0, 0,0.95,0};
VL(0.6,0.0,0.0,0.7,0.0,0.0){0,0.95,0, 0,0.81,0};
VL(0.7,0.0,0.0,0.8,0.0,0.0){0,0.81,0, 0,0.59,0};
VL(0.8,0.0,0.0,0.9,0.0,0.0){0,0.59,0, 0,0.31,0};
VL(0.9,0.0,0.0,1.0,0.0,0.0){0,0.31,0, 0,0.00,0};
};

// The scene's bounding box is only computed when a new point is added, 
// or after a file is merged. Neither happened here, so we need to force
// it:
BoundingBox; // warning: this is new in Gmsh 1.53

nFrames = 100;
nIter   = 2 ;
For iter In {1:nIter}
     For frame In {1:nFrames}
         View[0].DisplacementFactor = Sin(2*Pi*frame/nFrames);
         View[0].VectorType = 5;
         Sleep 0.01;
         Draw;
     EndFor
EndFor

Delete View[0];

And then you can just hit "reload" (or "0") to restart the animation. 
Not perfect, but maybe good enough ;-)

Cheers,

Christophe

-- 
Christophe Geuzaine
Applied and Computational Mathematics, Caltech
geuzaine at acm.caltech.edu - http://geuz.org