Display time in animations

Post processing utility for Elmer
mzenker
Posts: 1955
Joined: 07 Dec 2009, 11:49
Location: Germany

Display time in animations

Post by mzenker » 26 Oct 2010, 12:34

Hi,

is there a way to display the time (in seconds) on the picture of an animation generated from a transient simulation?

Thank you,

Matthias

petroo
Posts: 148
Joined: 13 Jan 2010, 19:07
Location: Aachen, Germany

Re: Display time in animations

Post by petroo » 26 Oct 2010, 15:25

Hello Matthias,

if there is no intrinsic solution you might take a detour via ImageMagick: If you save the individual images for the later animation with a sensible time-dependent file name (I can send you an example upon request) you can put filename-extracted pieces of text by some simple ImageMagick command into each image and combine them to the desired animation afterwards.

Regards,

Peter

mzenker
Posts: 1955
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Display time in animations

Post by mzenker » 26 Oct 2010, 15:53

Hi Peter,

thank you for the hint. But as I save the animation directly from ElmerPost, I would by far prefer a solution within Elmer .

Would it be possible to do it with the VTK postprocessor?

BTW, the VTK Postprocessor is still veeery unstable for me, it frequently crashes right at startup. Is this a known behaviour?

Matthias

Juha
Site Admin
Posts: 357
Joined: 21 Aug 2009, 15:11

Re: Display time in animations

Post by Juha » 27 Oct 2010, 10:44

Hi,

If your system has had freetype installed at the time of compiling & installing
ElmerPost you might have the commands

ffttext x y string
ftfont font [size r g b]

in your Elmerpost. If so, you might have some luck with the following

o save the script below to a file, say "file.txt"

Code: Select all

proc time_disp { x y t } {
  math t=$t-1
  math x=$x
  math y=$y
  math { tstr=sprintf( "fttext %g %g \"Simulation time: %g (s)\"",x y times(2,t) ); }
  math tcl(tstr);
}
o in the ElmerPost main windows command line enter

Code: Select all

source "file.txt"
o in the "Timestep Control" panels "after timestep" input field enter

Code: Select all

time_disp x y $t
(replace the x & y by screen coordinates of your choice.) You can enter
several command there separated by semicolon, if need be...

Regards, Juha

mzenker
Posts: 1955
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Display time in animations

Post by mzenker » 27 Oct 2010, 12:50

Hi Juha,

thank you for your help.

I have tried on the ElmerPost command line

math {tstr=sprintf("fttext 0 0 \"test\"")}
math tcl(tstr)

and I get the error message

invalid command name "fttext"

So I am afraid my system does not support this command, unless I have made another trivial error.
I use the binary distribution 4671 (Elmersolver says it's 4649) under Windoze XP.

Is there anything else I can do?

Thank you,

Matthias

Juha
Site Admin
Posts: 357
Joined: 21 Aug 2009, 15:11

Re: Display time in animations

Post by Juha » 27 Oct 2010, 14:23

Hi,

no i'm sorry, not that i know.

Regards, Juha

PS. You don't have to take the detour from matc to tcl to use the fttext-command,
if such existed. You should be able to just do:

Code: Select all

fftext x y string
from the ElmerPost command line.

mzenker
Posts: 1955
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Display time in animations

Post by mzenker » 27 Oct 2010, 14:34

If I do

fttext 0 0 "test"

from the command line, I get again the "invalid command name" error.

Do I have to compile ElmerPost myself in order to get freetype support, or are there binaries with this functionality?

Thank you,

Matthias

petroo
Posts: 148
Joined: 13 Jan 2010, 19:07
Location: Aachen, Germany

Re: Display time in animations

Post by petroo » 27 Oct 2010, 16:14

Hi Matthias,
mzenker wrote:fttext 0 0 "test"

from the command line, I get again the "invalid command name" error.
Maybe there is a typo? Is it ffttext ..., i.e. with an additional f in the command?

(Didn't test myself as I am quite sure not to have had it installed at compilation time.)

Regards,

Peter

mzenker
Posts: 1955
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Display time in animations

Post by mzenker » 27 Oct 2010, 16:18

Hi Peter,

neither

fttext

nor

ffttext

works, unfortunately...

Matthias

Juha
Site Admin
Posts: 357
Joined: 21 Aug 2009, 15:11

Re: Display time in animations

Post by Juha » 28 Oct 2010, 13:43

Hi,

Mikko kindly made a new windows installer, with freetype stuff included. The
installer is found here:

http://www.nic.funet.fi/pub/sci/physics ... n/windows/

Examples:

fttext hello
fttext hello 0.1 0.2

note the argument order "string x y", change the script accordingly & x ja y are in range -1...1

Setting fonts:

ftfont FreeSerif

ftfont FreeSerif 20
font size given in pixels

ftfont FreeSerif 20 1.0 0.0 0.0
r, g, b in range 0...1

Fonts are to be found $ELMER_POST_HOME/fonts/TrueType.

Freetype installer provided fonts are:

FreeMono
FreeMonoBold
FreeMonoBoldOblique
FreeMonoOblique
FreeSans
FreeSansBold
FreeSansBoldOblique
FreeSansOblique
FreeSerif
FreeSerifBold
FreeSerifBoldItalic
FreeSerifItalic

Juha

Post Reply