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

Quick How-To: Sample like in sampleDict during runtime

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

Like Tree1Likes
  • 1 Post By HenningW

Reply
 
LinkBack Thread Tools Display Modes
Old   August 22, 2016, 04:29
Default Quick How-To: Sample like in sampleDict during runtime
  #1
Member
 
Join Date: Feb 2015
Posts: 37
Rep Power: 4
HenningW is on a distinguished road
Hi everyone,

I recently tried to sample various data during runtime. Since I never found a satisfying example on how to do it, here is my (commented) source code that I added at the end of my control dict. The example shows a surface and a line, but can be changed to almost anything that you can use in sampleDict as well.

Code:
libs (
    "libOpenFOAM.so"
);
functions
{

// ----------------- Samples a line with equidistant points ------------------

    pos_1250_300_test1 /* Any name you want - will be a subfolder in "postProcessing" */
    {
        functionObjectLibs ("libsampling.so"); /* Below this same structure as in sampleDict until the closing "}" - you have to define each sample for itself, if something differs (e.g. interpolation, otherwise you can use different values in sets*/
        type        sets;
        outputControl            timeStep;
        outputInterval            1;
        setFormat                raw;
        interpolationScheme cellPoint;
        fields
        (
            p U k omega
        );
        sets
        (
            line_plot_1250_300 /* Name of the first line */
            {
                type    uniform;
                axis    xyz;
                start   ( 1.25  0.3       -1.2);
                end     ( 1.25    0.3     1.2);
                nPoints 240;
            }
            line_plot_1250_200 /* Name of the second line */
            {
                type    uniform;
                axis    xyz;
                start   ( 1.25  0.2       -1.2);
                end     ( 1.25    0.2     1.2);
                nPoints 240;
            }
        )
    };


// ----------------- Sample for single point ------------------

    pos_1000_300_0 /* Example for a single point - hence in a new block you can change your properties */
    {
        type probes;
        functionObjectLibs ("libsampling.so");
        probeLocations
        (
            (1 0.3 0)
        );
        fields
        (
            p U
        );
        outputControl timeStep;
        outputInterval 100;
    }

// ----------------- Sample for a plane ------------------

    cuttingPlane
    {
        type            surfaces;
        functionObjectLibs
        (
            "libsampling.so"
        );
        outputControl     timeStep;
        outputInterval     4;
        surfaceFormat   foamFile;
        fields          
        ( 
            U
        );
        interpolationScheme cellPoint;
        surfaces
            (
                yNormal_OF /* First surface's name */
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    basePoint (0.5 0 0);
                    normalVector (1 0 0);
                }
                interpolate true;
                }
                someOtherSurface /* Second surface's name */
                {
                type cuttingPlane;
                planeType pointAndNormal;
                pointAndNormalDict
                {
                    basePoint (0.5 0 0);
                    normalVector (1 0 0);
                }
                interpolate true;
                }
            );
    }
}
I am not sure if its necessary to include libsampling.so everytime or if this is the most efficient way to do things, but it works for you.

I hope I was able to help you with this short code. Let me know if I messed something up, forgot something or if there is a better tutorial (case) somewhere out there =)

Henning
OlegSutyrin likes this.
HenningW is offline   Reply With Quote

Old   February 7, 2017, 05:29
Default
  #2
New Member
 
Oleg Sutyrin
Join Date: Feb 2016
Location: Russia
Posts: 21
Rep Power: 3
OlegSutyrin is on a distinguished road
Exactly what I need, thanks!
I've used only line sampling in OF4.0 so far. Small error in the code: there should be semicolon after "sets(...)" inside "pos_1250_300_test1" function.
OlegSutyrin 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
Sample utility bug? For many cloud points in the sampleDict, some are neglected! brandius OpenFOAM Post-Processing 7 July 15, 2016 08:13
sample on a plane during the runtime openfoammaofnepo OpenFOAM Post-Processing 2 April 4, 2015 00:27
runtime sample plan: how to get gradP Sylv OpenFOAM Programming & Development 5 September 17, 2013 03:35
sample error depending on the name of sampleDict element HakikiCanakkaleli OpenFOAM Post-Processing 0 March 24, 2013 07:45
How to sample (with interpolation) at runtime ole OpenFOAM Programming & Development 4 December 14, 2010 13:57


All times are GMT -4. The time now is 04:39.