CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > CFX

Scrypt for keyframe animation

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 6, 2013, 06:50
Default Scrypt for keyframe animation
  #1
New Member
 
Juanpa
Join Date: Aug 2013
Posts: 2
Rep Power: 0
dukitz is on a distinguished road
Hi everybody,

I have run a transient simulation of the flow in a compressor in CFX and I would like to create an animation. I have tried to create in CFD post via keyframe animations, but it takes ages. The thing is I need to create an animation of 500 frames and the program loads every timestep in the screen.

I have read in a forum that someone got a way to do it via scrypts, but it is an old thread and seems that nobody answers. I would try to do it myself, but the problem is that I don't know anything about it and I don't have time to experiment (thesis deadline next week).

I would really appreciate if someone could help me with that.

Regards

Juanpa

Last edited by dukitz; August 6, 2013 at 09:01.
dukitz is offline   Reply With Quote

Old   August 6, 2013, 10:08
Default
  #2
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 446
Rep Power: 11
mvoss is on a distinguished road
hello,

one possible approach:

Code:
COMMAND FILE:
  CFX Post Version = 12.0
END
!	@RESFILES=("YOUR_RESFILE.res");
!	foreach $res (@RESFILES) {
>load filename=E:/FULLPATH/$res
!	print "+----------------------------------------------------------------------------------------+\n";
!	print "|Loaded $res 										|\n";
>readstate filename=E:/FULLPATH/Ani.cst, mode = overwrite, load = true, keepexpressions = false
!	print "|Loaded state for $res 							|\n";
!	print "creating MPEG-Video from $res;/n";
> animate load, filename = E:/FULLPATH/Cam1.can
! 	print"|Animation loaded for $res 								|\n";
! 	print"|Starting to process MPEG-Video for $res 							|\n";
!	print "+----------------------------------------------------------------------------------------+\n";
>animate play=forward
! }
1. save your desired state as "Ani.cst" and
2. the animation setup as "Cam1.can"
3. adjust YOUR_RESFILE and FULLPATH
Save the above code as *.cse file and start via the ComanndLine from CFX-Launcher in the correct directory by doing a "cfd5post -batch YourScriptname.cst".

If it´s not running report back the error but in 9 of 10 times it is due to the paths and names to be typed correctly.


Matthias

Little Hint: when doing a wb-project just copy the script to the user-files section and set the paths according to this, so you can have multiple results when giving the FULL path in the @RESFILES and use it for other stuff such as grabbing data from trn-files
mvoss is offline   Reply With Quote

Old   August 6, 2013, 10:18
Default
  #3
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 446
Rep Power: 11
mvoss is on a distinguished road
me again,

found an even better one...this one grabbs data from the results and adjusts the total length of the animation in case of different total simulation times + you can adjust the animations settings in the script.
Adjust the paths and res-file-names and you are good to go.


Code:
! my $RESFOLDER =('V:\voss\3D_Mesh_Movement_CUBES\02_CFX_SETUP');
! my $STATEFOLDER = ('V:\voss\3D_Mesh_Movement_CUBES\03_CFX_POST');
! my $STATE = ('3D_Mesh_Movement_CUBES.cst');
! my $MOVIEFOLDER = ('V:\voss\3D_Mesh_Movement_CUBES\03_CFX_POST');


! my @RESFILES= ('3D-Mesh_Movement-CUBES_CnearBC5_001','3D-Mesh_Movement-CUBES_CnearBC3_001');

! foreach my $FILE(@RESFILES){

COMMAND FILE:
  CFX Post Version = 14.0
END

DATA READER:
  
  Clear All Objects = false
  Append Results = false
  Edit Case Names = false
  Open to Compare = false
  Multi Configuration File Load Option = Single Case
  Open in New View = true
  Keep Camera Position = true
  Load Particle Tracks = true
  Files to Compare =
END

DATA READER:
  Domains to Load=
END
> load filename=$RESFOLDER\$FILE.res, \
force_reload=true
! print "\n";
! print "----------------------------------------\n";
! print "LOADED results for $FILE \n";
>readstate filename=$STATEFOLDER\$STATE, mode = append, load = false, keepexpressions = true

! 	$timestepList = getValue("DATA READER","Timestep List");
!	@timestepList = split(/,/,$timestepList);
!	$lastFrame=$timestepList[$#timestepList];
!	print "found $lastFrame timesteps for $FILE \n";

!   $frameDiff = $lastFrame-2; # for creating the animation 

> load timestep=0

ANIMATION:ANIMATION
  Animate Camera = On
  Animation Hardcopy Filename = $MOVIEFOLDER\$FILE"_script".avi
  Save Hardcopy = Off
  Looping = Loop
  Looping Cycles = 1
  Video Format = wmv
  
END

ANIMATION:ANIMATION
  Animate Camera = On
Animation Hardcopy Filename = $MOVIEFOLDER\$FILE"_script".avi
  Save Hardcopy = On
  Looping = Loop
  Looping Cycles = 1
  Video Format = wmv
  
END
> animate new =

KEYFRAME:KeyframeNo1
  Number Of Frames = $frameDiff
END

> animate new = KeyframeNo1

> animate goto = $lastFrame

KEYFRAME:KeyframeNo2
  Number Of Frames = 1
END

> animate goto = 1

> animate modify = KeyframeNo1

> animate goto = $lastFrame


> load timestep=$lastFrame

> animate modify = KeyframeNo2

> animate goto = 1

ANIMATION:
  Animation Bit Rate = 5152000
  Animation Frame Rate = 24
  Animation Quality = Highest
  Animation Speed Factor = 2
  Antialiasing = On
  Drop Last MPEG Frame = Off
  Hardcopy Tolerance = 0.0001
  Intermediate File Format = jpg
  Keep Intermediate Files = Off
  MPEG Height = 1080 
  MPEG Scale = 100
  MPEG Size = Custom
  MPEG Width = 1920 
  Output Directory = .
  Output to User Directory = Off
  QAnim Override Symbol = On
  QAnim Symbol Size = 1.0
  QAnim Symbol Spacing = 0.6
  QAnim Symbol Type = Ball
  Screen Capture = Off
  Speed Adjustment Selection = Normal
  Speed Scaling Method = Distribute Frames Smoothly
  Timestep Interpolation Method = Timestep
  Variable Bit Rate = On
  White Background = Off
END
! print "STARTING MPEG for $FILE \n";
 > animate play=forward
! print "DONE MPEG for $FILE  \n";
! print "----------------------------------------\n";
! print "\n";
> close
!};
not quiet sure about the "Output Directory = ." line but since we set the HARDCOPY FILENAME it should work.

Matthias
mvoss is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Animation of Fluent transient data saisanthoshm88 CFX 14 May 12, 2015 19:29
Animation of Fluent transient data saisanthoshm88 FLUENT 2 December 18, 2012 10:51
Animation of Fluent transient data saisanthoshm88 Tecplot 0 December 16, 2012 10:04
Multiblock animation in Tecplot. Simon Tecplot 4 February 10, 2006 11:27
Animation query..newbie qn derick FLUENT 2 December 9, 2005 10:45


All times are GMT -4. The time now is 19:50.