CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Post processing an internal plane/surface

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By tomf

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 22, 2021, 05:18
Default Post processing an internal plane/surface
  #1
Member
 
Callum Guy
Join Date: Dec 2019
Location: Scotland
Posts: 44
Rep Power: 6
CallumG is on a distinguished road
Hi Foamers,

I know there are a few threads on this but I am incredibly confused with them all and I know some of the information is outdated so I'm going to ask again.

I'm generating very large case files on our server and I want to postProcess single planes of data for export.

I have a very simple rectangular domain and I would like to "slice/cut plane/internal surface" (whatever you want to call it!) so I am taking the field data from central y-normal and x-normal planes and later view them in ParaView.

Could anyone clarify (for dummies!) how to do this?

I should mention I'm on v1912.

Cheers,
Callum
CallumG is offline   Reply With Quote

Old   November 24, 2021, 05:15
Default
  #2
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi Callum,

There is a tutorial that uses the surfaces functionObject for this.

Please have a look at:

$FOAM_TUTORIALS/incompressible/pimpleFoam/RAS/propeller/

The relevant files are the controlDict and the surfaces files in the system folder. As you see, the surfaces file is read in the functions subDict of the controlDict. The example usage of the surfaces functionObject is described in the surfaces file.

You would need to modify it towards your needs, but I think you should get it from there.

Cheers,
Tom

Last edited by tomf; November 24, 2021 at 05:16. Reason: grammar
tomf is offline   Reply With Quote

Old   December 14, 2021, 04:22
Default
  #3
Member
 
Callum Guy
Join Date: Dec 2019
Location: Scotland
Posts: 44
Rep Power: 6
CallumG is on a distinguished road
Hi Tom,

thanks very much for your reply and the advice!

For the benefit of others I ended up adding the following to my controlDict:

Code:
functions
{    
    cuttingPlanes
    {
        type              surfaces;
        outputControl     timeStep;
        outputInterval     1;
        surfaceFormat    vtk;
        fields   (U alpha.water);
        interpolationScheme          cellPoint;
        surfaces
            (
                yplane
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    point (0 -5.5 0);
                    normal (0 -1 0);
                }
                interpolate true;
                }
                xplane
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    point (5 0 0);
                    normal (1 0 0);
                }
                interpolate true;
                }
            );
    }
}
This made vtk's for each plane I created (xplane and yplane) in my postProcessing directory for each timestep. After that I needed to make a series file to view the vtk's continuosly in Paraview. I did this in python and the code looked something like this:

Code:
import os

def main():
    cutPlanesDir = "postProcessing/cuttingPlanes/"

    directories = os.listdir(cutPlanesDir)
    directories.sort()
    directories = [d for d in directories if "series" not in d]

    with open(cutPlanesDir+"yplane.vtp.series", 'w') as yf:
        yf.write("{\n")
        yf.write("  \"file-series-version\" : \"1.0\",\n")
        yf.write("  \"files\" : [\n")
    with open(cutPlanesDir+"yplane.vtp.series", 'a') as yf:
        for time in directories:
            if time != directories[-1]:
                yf.write("    { \"name\" : \""+time+"/yplane.vtp\", \"time\" : "+time+" },\n")
            else:
                yf.write("    { \"name\" : \""+time+"/yplane.vtp\", \"time\" : "+time+" }\n")
        yf.write("  ]\n")
        yf.write("}")

    with open(cutPlanesDir+"xplane.vtp.series", 'w') as yf:
        yf.write("{\n")
        yf.write("  \"file-series-version\" : \"1.0\",\n")
        yf.write("  \"files\" : [\n")
    with open(cutPlanesDir+"xplane.vtp.series", 'a') as yf:
        for time in directories:
            if time != directories[-1]:
                yf.write("    { \"name\" : \""+time+"/xplane.vtp\", \"time\" : "+time+" },\n")
            else:
                yf.write("    { \"name\" : \""+time+"/xplane.vtp\", \"time\" : "+time+" }\n")
        yf.write("  ]\n")
        yf.write("}")
    return

if __name__ == "__main__":
    main()
Thanks again community, hope this is useful for others!

Callum
CallumG is offline   Reply With Quote

Old   December 14, 2021, 04:29
Default
  #4
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi Callum,

Glad you got it working.

Just a final hint (also for others) as there is a utility in OpenFOAM that can do the 'series' for you. It is called foamSequenceVTKFiles. If you have the .vtp extension it is invoked as:

Code:
foamSequenceVTKFiles -vtp
This will create a folder sequencedVTK with links inside that folder to the original files and the naming is sequential, such that ParaView can interpret this as a series of files. May safe some additional disk space/time.

Cheers,
Tom
Teresa Sun likes this.
tomf is offline   Reply With Quote

Old   December 14, 2021, 05:29
Default
  #5
Member
 
Callum Guy
Join Date: Dec 2019
Location: Scotland
Posts: 44
Rep Power: 6
CallumG is on a distinguished road
Excellent Tom!

I only wrote my own script because when I tried the command foamSequenceVTKFiles it didn't work, which I'm assuming is because I didn't use the flag '-vtp'.

Brilliant! Merry Christmas Foamers!!
CallumG is offline   Reply With Quote

Old   December 16, 2021, 03:49
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by CallumG View Post
Hi Tom,

thanks very much for your reply and the advice!

For the benefit of others I ended up adding the following to my controlDict:

Code:
functions
{    
    cuttingPlanes
    {
        type              surfaces;
        outputControl     timeStep;
        outputInterval     1;
        surfaceFormat    vtk;
        fields   (U alpha.water);
        interpolationScheme          cellPoint;
        surfaces
            (
                yplane
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    point (0 -5.5 0);
                    normal (0 -1 0);
                }
                interpolate true;
                }
                xplane
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    point (5 0 0);
                    normal (1 0 0);
                }
                interpolate true;
                }
            );
    }
}
This made vtk's for each plane I created (xplane and yplane) in my postProcessing directory for each timestep. After that I needed to make a series file to view the vtk's continuosly in Paraview.
....
I am a bit surprised at your result. I know that the Ensight and VTK surface writers both add time-collation to their output, but the VTK writers should ideally also be creating the series file. This is either an oversight, or not feasible for some other reason - it could be worthwhile adding an issue on develop.openfoam.com - if nothing else, at least to document why it is that way.

BTW: all of the machinery for generating vtk.series files is already in there (src/fileFormats) and it is most certainly being used for foamToVTK, for example.
olesen is offline   Reply With Quote

Old   September 24, 2023, 14:57
Default
  #7
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 204
Rep Power: 7
farzadmech is on a distinguished road
Thanks a lot for your explanation, it was helpful.

Farzad
Quote:
Originally Posted by CallumG View Post
Hi Tom,

thanks very much for your reply and the advice!

For the benefit of others I ended up adding the following to my controlDict:

Code:
functions
{    
    cuttingPlanes
    {
        type              surfaces;
        outputControl     timeStep;
        outputInterval     1;
        surfaceFormat    vtk;
        fields   (U alpha.water);
        interpolationScheme          cellPoint;
        surfaces
            (
                yplane
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    point (0 -5.5 0);
                    normal (0 -1 0);
                }
                interpolate true;
                }
                xplane
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    point (5 0 0);
                    normal (1 0 0);
                }
                interpolate true;
                }
            );
    }
}
This made vtk's for each plane I created (xplane and yplane) in my postProcessing directory for each timestep. After that I needed to make a series file to view the vtk's continuosly in Paraview. I did this in python and the code looked something like this:

Code:
import os

def main():
    cutPlanesDir = "postProcessing/cuttingPlanes/"

    directories = os.listdir(cutPlanesDir)
    directories.sort()
    directories = [d for d in directories if "series" not in d]

    with open(cutPlanesDir+"yplane.vtp.series", 'w') as yf:
        yf.write("{\n")
        yf.write("  \"file-series-version\" : \"1.0\",\n")
        yf.write("  \"files\" : [\n")
    with open(cutPlanesDir+"yplane.vtp.series", 'a') as yf:
        for time in directories:
            if time != directories[-1]:
                yf.write("    { \"name\" : \""+time+"/yplane.vtp\", \"time\" : "+time+" },\n")
            else:
                yf.write("    { \"name\" : \""+time+"/yplane.vtp\", \"time\" : "+time+" }\n")
        yf.write("  ]\n")
        yf.write("}")

    with open(cutPlanesDir+"xplane.vtp.series", 'w') as yf:
        yf.write("{\n")
        yf.write("  \"file-series-version\" : \"1.0\",\n")
        yf.write("  \"files\" : [\n")
    with open(cutPlanesDir+"xplane.vtp.series", 'a') as yf:
        for time in directories:
            if time != directories[-1]:
                yf.write("    { \"name\" : \""+time+"/xplane.vtp\", \"time\" : "+time+" },\n")
            else:
                yf.write("    { \"name\" : \""+time+"/xplane.vtp\", \"time\" : "+time+" }\n")
        yf.write("  ]\n")
        yf.write("}")
    return

if __name__ == "__main__":
    main()
Thanks again community, hope this is useful for others!

Callum
farzadmech 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
wind turbine - post processing er_ijaz FLUENT 0 September 30, 2013 05:28
post processing for CEL expressions Niru CFX 0 May 10, 2013 13:13
Automated post processing using CFD Post shreyasr ANSYS 0 January 28, 2013 06:21
post processing in CFX11.0 u k jha CFX 1 September 17, 2010 05:53
post processing in CFD MANISH BHARGAVA Main CFD Forum 0 October 17, 1998 20:51


All times are GMT -4. The time now is 18:23.