CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   How Coorectly Run sampleDict (https://www.cfd-online.com/Forums/openfoam-post-processing/191618-how-coorectly-run-sampledict.html)

FlyBob91 August 14, 2017 06:20

How Coorectly Run sampleDict
 
Hello to all,
i have to run a post-processing extration of the U and P value. I decided to use for the first time the sampleDict.
I put it in the system folrder, run the simulation and finally type the command "sample" which gives me this message

Code:

sample has been superceded by the postProcess utility:
    postProcess -func sample

To re-use existing 'sampleDict' files simply add the following entries:
    type sets;
    libs ("libsampling.so");
and run
    postProcess -func sampleDict

I added the line the message suggested to the sampleDict file. Then i run the command

Code:

postProcess -func sampleDict
Here the message

Code:

Create time

Create mesh for time = 0

Time = 0

Reading fields:
    volVectorFields: U

Executing functionObjects

Time = 0.001

Reading fields:
    volVectorFields: U

Executing functionObjects

End

Unfortunately no new files are generated. What's wrong?
Here my sampleDict file.

Code:

type sets;
libs ("libsampling.so");

setFormat raw;


// Surface output format. Choice of
//      null        : suppress output
//      foamFile    : separate points, faces and values file
//      dx          : DX scalar or vector format
//      vtk        : VTK ascii format
//      raw        : x y z value format for use with e.g. gnuplot 'splot'.
//
// Note:
// other formats such as obj, stl, etc can also be written (by proxy)
// but without any values!
// surfaceFormat vtk;

// interpolationScheme. choice of
//      cell          : use cell-centre value only; constant over cells (default)
//      cellPoint    : use cell-centre and vertex values
//      cellPointFace : use cell-centre, vertex and face values.
// 1] vertex values determined from neighbouring cell-centre values
// 2] face values determined using the current face interpolation scheme
//    for the field (linear, gamma, etc.)
interpolationScheme cellPointFace;

// Fields to sample.
fields
(
        U
);

// Set sampling definition: choice of
//      uniform            evenly distributed points on line
//      face                one point per face intersection
//      midPoint            one point per cell, inbetween two face intersections
//      midPointAndFace    combination of face and midPoint
//
//      curve              specified points, not nessecary on line, uses
//                          tracking
//      cloud              specified points, uses findCell
//
// axis: how to write point coordinate. Choice of
// - x/y/z: x/y/z coordinate only
// - xyz: three columns
//  (probably does not make sense for anything but raw)
// - distance: distance from start of sampling line (if uses line) or
//            distance from first specified sampling point
//
// type specific:
//      uniform, face, midPoint, midPointAndFace : start and end coordinate
//      uniform: extra number of sampling points
//      curve, cloud: list of coordinates
sets
(

);

// Surface sampling definition: choice of
//      plane : values on plane defined by point, normal.
//      patch : values on patch.
//
// 1] patches are not triangulated by default
// 2] planes are always triangulated
// 3] iso-surfaces are always triangulated
surfaces
(
    hello
    {
        type            patch;    // always triangulated
        // make plane relative to the coordinateSystem (Cartesian)
        // coordinateSystem
        // {
        //    origin      (0.05 0 0);
        // }
                patches        ("outlet");
        interpolate    false;
                triangulate    false;
    }

);

Thanks for help

tetra-eder September 13, 2017 00:54

I have the same problem. Did you find a solution?

KTG September 13, 2017 01:31

Re
 
I think you are missing the name of your sample, and some curly braces. Try this:

my_sample {
<your previously posed dict here>
}

It when you post process, it should put a folder called "my_sample" in the postProcessing folder.

If that doesn't work, try the template below (just change the point (1 1 1) to something in your domain).

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  plus                                  |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


volume_sample {

type sets;
libs            ("libsampling.so");

interpolationScheme cellPoint;

setFormat      csv;

sets
(
    data
    {
        type    cloud;
        axis    xyz;
        points    (

(  1 1 1 )

);       
    }
);

fields          ( U p );

}


// ************************************************************************* //


tetra-eder September 13, 2017 01:56

Thanks for your help. Unfortunately, when I do this, I get the error
Code:

--> FOAM FATAL IO ERROR:
keyword type is undefined in dictionary ".functions.sampleDict"

file: .functions.sampleDict from line 20 to line 324.

    From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 566."

In my case, I would like to get the iso surface of a scalar field. Using your suggestion I have now
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  plus                                  |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


my_sample {

type surfaces;
libs            ("libsampling.so");

interpolationScheme cellPoint;

setFormat      csv;

surfaces
(
    interface
    {
        type            isoSurface;
        isoField        gamma_L;
        isoValue        0.5;
        interpolate    true;
    }
);

fields          ( gamma_L );

}


// ************************************************************************* //


KTG September 13, 2017 02:44

Try running the solver. For example:

simpleFoam -postProcess

Some of the function objects don't work if the required fields are not loaded (works with the -parallel option and mpi too).

Check out the motorbike tutorial in tutorials/incompressible/simpleFoam/motorbike for an example of how to use some of the simple function objects. If you paste your function object in place of one of the ones used there and it doesn't run properly, the problem is in your function object. If you just run the motorbike tutorial, the function objects execute at run time because they are #include at the bottom of the controlDict.

tetra-eder September 13, 2017 04:01

Thanks. It works!
Here is what I did:
1) created a file in the system folder named surfaces
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  5                                    |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/

surfaces
{
    type            surfaces;
    libs            ("libsampling.so");
    writeControl    writeTime;

    surfaceFormat  raw;
    fields          (gamma_L);

    interpolationScheme cellPoint;

    surfaces
    (
        interface
        {
            type            isoSurface;
            isoField        gamma_L;
            isoValue        0.5;
            interpolate    true;
        }
    );
}


// ************************************************************************* //

2) run
Code:

postProcess -func surfaces


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