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

Quick How-To: Sample like in sampleDict during runtime

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

Like Tree6Likes
  • 5 Post By HenningW
  • 1 Post By pvpnrao

Reply
 
LinkBack Thread Tools Search this Thread 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: 39
Rep Power: 11
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
HenningW is offline   Reply With Quote

Old   February 7, 2017, 04:29
Default
  #2
Member
 
Oleg Sutyrin
Join Date: Feb 2016
Location: Russia
Posts: 41
Rep Power: 10
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

Old   June 26, 2017, 19:12
Default
  #3
Member
 
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10
pvpnrao is on a distinguished road
does it run in parallel?
pvpnrao is offline   Reply With Quote

Old   July 10, 2017, 08:04
Default
  #4
Member
 
Join Date: Feb 2015
Posts: 39
Rep Power: 11
HenningW is on a distinguished road
Yes, it should run in parallel as well
HenningW is offline   Reply With Quote

Old   May 28, 2018, 07:55
Default Point cloud
  #5
Member
 
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10
pvpnrao is on a distinguished road
Here is one more sampling function. It provides a point cloud where the points are arranged along Cartesian axes. The fields can be interpolated on these points. I found this function somewhere on OpenFOAMWiki.

I used it to generate data files which I can use in order average the flow-fields along a particular coordinate axes.

//-----3D array of points along Cartesian axes----------------------
my_point_cloud
{
functionObjectLibs ("libsampling.so");
type sets;
outputControl timeStep;
outputInterval 1;
setFormat raw;
interpolationScheme cellPoint;
fields
(
U D
);

sets
(
arrayA1
{
type array;
axis xyz;
coordinateSystem
{
e1 (1 0 0);
e2 (0 1 0);
origin (0 0 0);
}

pointsDensity (2500 200 100);
spanBox (3.5 0.1 0.25);
}
);

}
manuc likes this.
pvpnrao is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
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 10 August 22, 2022 09:56
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 06:45
How to sample (with interpolation) at runtime ole OpenFOAM Programming & Development 4 December 14, 2010 12:57


All times are GMT -4. The time now is 21:41.