CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Creating animations (http://www.cfd-online.com/Forums/openfoam/79029-creating-animations.html)

ThomasBE August 10, 2010 09:33

Creating animations
 
Hi,

I am running a transient LES simulation and am making an animation of the results. I was wondering if there is any way to save pictures of the results at timesteps during the run automatically. As of now I am only able to save the entire results files, and this takes vast amounts of storage. Anyone know of a solution to this problem?

Best regards,

Thomas

fgal August 10, 2010 10:20

Hi Thomas,

You don't need to save the results at each time step to make an annimation, 25 images per second is a maximum and even you don't need that much, do you ? If it is the case you can regulary use the save animation tool of paraFoam and delete the corresponding result directories once done while the computation is running.

Cheers

Francois.

akidess August 10, 2010 10:57

Francois, 25 frames per second of animation, yes. However one might wish to have 50 frames per second of simulation time to make the animation more clear, or even if you restrict yourself to 25 frames per second, for a long animation and large grids a lot of data can accumulate.

You could try to write a Python script to run paraview without graphical output and create your images alongside the simulation, but I don't really know how that works.

Luise August 10, 2010 12:12

Hi,
i haven't done this before, so I don't know if it works, but I thouht of including the sample library as a function object in controlDict. This way you could at least output the vtk-files.

something like this:
Code:

functions
(
    outputFolder
    {
        type sample;
        region region0;
        functionObjectLibs ("libsampling.so");
        outputControl timeStep;
        outputInterval 1;
        outputFormat vtk; // Dont know if this is the correct keyword...
        fields
        (
            U
            p
        );
        surfaces
        (
            domainSlice
            {
                // surface definition
            }
        );
    };
);

Luise

DVSoares August 10, 2010 16:01

Well, if the problem is memory, I believe that a python/bash/shell script would do well - store the results normally and then delete the ones you'll not use after taking a picture of.

I use the paraview create animation and then mencoder for the animations... Memory footprint is really small. Mencoder is awesome.

Cheers,

ThomasBE August 11, 2010 03:28

Hi,

The problem is harddisk space. 1 picture per second for 60 seconds took 20 GB. Preferably I'd run the simulation for 1200 seconds, which would mean 400 GB. And this is the coarse mesh. Creating pictures manually and deleting the files is an option, but it would be nice not having to babysit the simulation.

Luise, do you know where I could find information about your idea? Would be interesting to see if it is viable.

Luise August 11, 2010 04:16

Hi,

the syntax for outputFormat and surface definition etc. should be the same like in sampleDict.

Luise

ThomasBE August 11, 2010 06:50

Thanks Luise,

It worked like a charm. I now get 1.5 MB in .vtk files instead of 360 MB worth of results.

If any one is interested this is my final function. Basically just changed outputFormat to surfaceFormat.
Quote:

outputFolder
{
type surfaces;
region region0;
functionObjectLibs ("libsampling.so");
outputControl timeStep;
outputInterval 1;
surfaceFormat vtk;
fields
(
U
p
);
surfaces
(
domainSlice
{
type plane;
basePoint (-100 300 547.5);
normalVector (0 1 0);
interpolate true;
}
);
}
Now all I have to do is figure out how to load them as succesive timesteps in paraview...

DVSoares August 11, 2010 11:47

Couldn't we also consider using something like zlib for compression and on-the-fly reading of compressed files/folders?

akidess August 11, 2010 13:33

Daniel, you could, but if you don't care to keep most of the results anyways why not postprocess and discard them right away? Compressing would just add additional cost to compress and uncompress again for postprocessing.

fgal August 11, 2010 14:05

Thanks for sharing it, that is very useful.

tomf August 12, 2010 09:06

Hey,

I basically had the same problem, so I used the suggestions from this topic and it helps a lot. Unfortunately I do not get nice results for a planar slice through a polygonal mesh. I got nice slices for the simple cavity tutorial, also for a 3D version with a hybrid tetrahedral/prims mesh and a polygonal mesh, but not for this more challenging case. There are also warnings in the output of the case, which read like:

--> FOAM Warning :
From function Foam::cuttingPlane::walkCell
in file cuttingPlane/cuttingPlane.C at line 227
Did not find closed walk along surface of cell 900795 starting from edge 482246 in 1001 iterations.
Collected cutPoints so far:

And then a long list of cutPoints

The corresponding surface with holes is shown in the figure beneath.

http://i16.photobucket.com/albums/b3...Images0000.png

I wonder if it is possible to make sure the holes are not in the surface, so we get a nice closed surface. I also created the same slices from the full dataset in paraview, which then results in normal figures.

It seems like too many iterations are needed to find a "closed walk" around the surface of a cell? Or am I mistaken? I found the sourc of cuttingPlane.C, which has a limit of 1000 iterations. Modifying the source to increase the maximum number of iterations did not improve the situation.

Is there any way to improve the situation?

Thanks,
Tom

ThomasBE August 13, 2010 04:51

I'm sorry, but I don't know what happens there. The vtk files I get are give images of lower quality then the datasets, but I haven't experienced any holes or error messages.

NickG August 26, 2010 04:54

1 Attachment(s)
Hi

I don't take any samples just use the utility in paraview under files>save animation. This saves a sequence of images as you see them on screen.

I don't change any thing in the first box that comes up though you can change the number of frames per timestep etc.
If you save them as .png files then I understand that the resolution is better than jpeg.(?)

Then with gimp: file>open as layers : select all your images, enter.
(gimp is a free opensource image software package)

Save as gif - you may need to write this in the name box e.g. test.gif as changing it in the drop down file type box doesn't work for me.

In the next box that comes up you need to click on save as animation then Export.

In the final box you can choose to loop the animation to keep it restarting, also you can specify the gap between frames. So if a feature is moving too fast for you to watch properly you can increase this value to slow the animation down. I try to space my write directories such that I'm not wasting memory space but also not making the animation too jumpy.

Hope that helps too

Nick

The attached gif is of 46 frames with 100 ms between frames and represents ~0.2s real time and not looped

NickG August 26, 2010 05:00

1 Attachment(s)
looped hopefully :)

ziad October 10, 2010 12:16

Quote:

Originally Posted by NickG (Post 272834)
Hi

I don't take any samples just use the utility in paraview under files>save animation. This saves a sequence of images as you see them on screen.

I don't change any thing in the first box that comes up though you can change the number of frames per timestep etc.
If you save them as .png files then I understand that the resolution is better than jpeg.(?)

Then with gimp: file>open as layers : select all your images, enter.
(gimp is a free opensource image software package)

Save as gif - you may need to write this in the name box e.g. test.gif as changing it in the drop down file type box doesn't work for me.

In the next box that comes up you need to click on save as animation then Export.

In the final box you can choose to loop the animation to keep it restarting, also you can specify the gap between frames. So if a feature is moving too fast for you to watch properly you can increase this value to slow the animation down. I try to space my write directories such that I'm not wasting memory space but also not making the animation too jumpy.

Hope that helps too

Nick

The attached gif is of 46 frames with 100 ms between frames and represents ~0.2s real time and not looped

Thanks for the tip Nick. Works nicely and all opensource!

Ziad

kalle October 12, 2010 02:52

If you get 'low quality' in your animations when saving in vtk-format, it might be because you plot cell data instead of point data in paraview. You can convert from cell to point data by Filters -> Alphabetical -> Cell data to point data

I made a small python script some time ago to assist making animations:

http://openfoamwiki.net/index.php/VtkAnim

might be of help for someone...

K


All times are GMT -4. The time now is 13:22.