CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] How to load all <case>/surfaces/*/*.vtk at once into Paraview

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By Nucleophobe
  • 2 Post By Flowkersma
  • 2 Post By AqeelAhmed168

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 30, 2011, 04:40
Default How to load all <case>/surfaces/*/*.vtk at once into Paraview
  #1
New Member
 
Stefan
Join Date: Jan 2011
Location: Bremen
Posts: 20
Rep Power: 15
holodeck10 is on a distinguished road
Dear Foamers,

I am still new to OpenFoam and did not discover full functionallities. So I hope the question is easy for you guys.

I am looking for a fast way to extract slices from interFoam results (total size: ~20-50GB) and calculate fluxes for these areas over time.

The slices are located vertically somwhere inside the domain. Their extend is smaller than the whole lengths or widths of the domain. Cells have various sizes (I used blockMesh with simpleGrading).

- A slow way would be using foamToVTK, loading the results into Paraview, cutting off all parts of the domain which are beside the length of the desired slice, apply the slice filter, use the mesh quality filter to caluclate areas, calculate area*u-component*alpha1, export it to csv and then plot/analyze it using whatever.

- I would still let Paraview do the area/flux calculation, because I don't know an alternative.

- I meanwhile discovered some openFoam tools such as "cellSet", "cellsToZones" and "sample", but I got stucked, when I want to load the aforementioned "slices" which are now surfaces. I have all data, which I want to load into paraview in vtk files, but they are lying in seperate files for each time step and I have no idea how to load them all at once. I also tried various formats using "sample", including foamFile, but don't succeeded.

After that I have 3 questions:

1) Is there a better way to get my fluxes at these slices/surfaces?
2) If not, how can I load all vtk files of the surfaces directory into Paraview?
3) Is there a way to extract directly cell sizes from interFoam results, which can be used for flux calculation?

Thanks for any suggestion!

Best regards
Stefan
holodeck10 is offline   Reply With Quote

Old   September 9, 2011, 02:11
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
I don't know if it answers all your questions or not, but I sample the desired slices during runtime with the sampling library. Inside the functions( ); you can put something like this:
Code:
    sliceCentre
    { 
        type            surfaces;
        functionObjectLibs
        (
            "libsampling.so"
        );
        outputControl  outputTime;
        outputInterval  1;
        surfaceFormat  vtk;
        fields
        (
            U
            alpha1
        );
        surfaces
        (
            sliceCentre
            {
                type            plane;
                basePoint       (0.0 0.0 0.0);
                normalVector    (0.0 0.0 1.0);
                interpolate     true;
            //    regularise      false;
            }
        );
        interpolationScheme cell;
    }
If you run paraview (in batch mode), you can easily loop over all this output with a python script.
Bernhard is offline   Reply With Quote

Old   September 9, 2011, 03:51
Default
  #3
New Member
 
Stefan
Join Date: Jan 2011
Location: Bremen
Posts: 20
Rep Power: 15
holodeck10 is on a distinguished road
Dear Bernhard,

thanks for your reply. It definitely rises my possibilities to treat this problem. So far, I arrived at the following stage:

- changed the source code in interFoam.C and createFields.H, so that it writes also cellsize. This prevents me from using Paraview, which is a bit slow for my purposes.

- used cellSet, setsToZone and sample in a shell script

That works quite well and I will probably change the source code further so that it calculates fluxes directly.

For all upcoming simulations I would have to extend your functions() section with cellSet and setsToZone. Do you know what is faster, doing cellSet, setsToZone and sample while simulation runs or during post-processing?

Cheers
Stefan
holodeck10 is offline   Reply With Quote

Old   September 9, 2011, 04:01
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
For your last question, I don't know which method is faster and whether it is a significant part compared to the total simulation time. However, if you sample during runtime, it may be sufficient to write less data, which also can be an advantage.
Bernhard is offline   Reply With Quote

Old   September 9, 2011, 04:40
Default
  #5
New Member
 
Stefan
Join Date: Jan 2011
Location: Bremen
Posts: 20
Rep Power: 15
holodeck10 is on a distinguished road
True. Thank you for the comment!

Have a good day!
Stefan
holodeck10 is offline   Reply With Quote

Old   June 3, 2015, 05:30
Default
  #6
Member
 
SM
Join Date: Dec 2010
Posts: 97
Rep Power: 15
canopus is on a distinguished road
Quote:
I have all data, which I want to load into paraview in vtk files, but they are lying in seperate files for each time step and I have no idea how to load them all at once.

How can I load all vtk files of the surfaces directory into Paraview?
canopus is offline   Reply With Quote

Old   August 22, 2015, 13:00
Default Script to make VTK series readable in Paraview
  #7
Member
 
Join Date: Aug 2012
Posts: 68
Blog Entries: 1
Rep Power: 13
Nucleophobe is on a distinguished road
Quote:
Originally Posted by canopus View Post

How can I load all vtk files of the surfaces directory into Paraview?
Canopus,

Paraview can read a sequence of VTK files, but the VTK filenames must end in an incrementing integer value (e.g., 1,2,3... or 1000,1001,1002...).
See:
http://www.paraview.org/Wiki/Animati...TK_file_series

I use a bash script to rename the VTK files. You'll need to tailor this to your application, but something like:
Code:
#!/bin/bash
count=0
for i in $(ls surfaces); do
    echo "Folder name:" $i
    echo "VTK number:" $count
    cp surfaces/$i/U_interpolatedPlane.vtk VTK_for_Paraview/U_$count.vtk
    let "count++"
done
Hope that helps.
-Nuc
Marpole likes this.
Nucleophobe is offline   Reply With Quote

Old   September 15, 2015, 07:18
Default
  #8
Senior Member
 
Mikko
Join Date: Jul 2014
Location: The Hague, The Netherlands
Posts: 243
Rep Power: 12
Flowkersma is on a distinguished road
Quote:
How can I load all vtk files of the surfaces directory into Paraview?
You can also load the files with Python. First open one of your surface files with Paraview then open the Python Shell inside Paraview and write

Code:
import os
directory = '/path/to/directory/'

reader = GetActiveSource()
files = [directory + file for file in os.listdir(directory)]

# sort here the files if the order is important
files = sorted(files)

reader.FileNames = files
Now try changing the timestep.

-Mikko
Nucleophobe and Marpole like this.
Flowkersma is offline   Reply With Quote

Old   November 22, 2019, 17:52
Default How can I load all vtk files of the surfaces directory into Paraview?
  #9
New Member
 
Aqeel Ahmed
Join Date: Feb 2017
Posts: 5
Rep Power: 9
AqeelAhmed168 is on a distinguished road
In version 5 and onwards run

foamSequenceVTKFiles

it will automatically put all the vtks from postProcessing directory in a new directory by default named "sequencedVTK"
nishant.kumar and Munki like this.
AqeelAhmed168 is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] Decomposed multiregion cases in Paraview with native reader Yann ParaView 2 January 16, 2019 05:48
[OpenFOAM] Load forces in ParaView kandelabr ParaView 1 December 16, 2017 09:00
[General] Error Message while trying to load ParaView Online Help akku ParaView 2 March 6, 2013 00:47
paraFoam reader for OpenFOAM 1.6 smart OpenFOAM Installation 13 November 16, 2009 21:41
[OpenFOAM] ParaView Crashes During OF-case Load brosemu ParaView 0 April 7, 2009 12:21


All times are GMT -4. The time now is 06:01.