CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   sampleDict and controlDict (http://www.cfd-online.com/Forums/openfoam-post-processing/116371-sampledict-controldict.html)

musahossein April 17, 2013 19:00

sampleDict and controlDict
 
Dear all: I am trying to understand the difference between the functionality of sampleDict and ControlDict. If, for example, I need pressure output in OpenFoam and use the following commands in controlDict, I find that putting them in sampleDict does the same thing. So why not put all the commands in controlDict and not use sampleDict at all -- or are there more differences between the two than what meets the eye?:

wallPressure
{
type surfaces;
functionObjectLibs ("libsampling.so");
outputControl outputTime;
surfaceFormat raw;
interpolationScheme cell;

fields ( alpha1
p
);
surfaces
(
leftwalls
{
type patch;
patches (leftWall);
interpolate true;
triangulate false;
}
rightwalls
{
type patch;
patches (rightWall);
interpolate true;
triangulate false;
}
);
}

wyldckat April 18, 2013 17:55

Greetings Musaddeque,

The difference is that:
  • utility sample (the one that uses "sampleDict") is used after the solver has finished executing things.
  • The sampling function objects on the other hand (the ones in "controlDict"), can be used while the solver is still running.
Both exist because it all depends on how much sampling one really wants to perform :)


For example:
  • sampling every time iteration might be quick for monitoring a couple of points;
  • but if you want 10 section cuts for only the last iteration, then you use sample.
Best regards,
Bruno

musahossein April 18, 2013 21:49

Many thanks for your explanation. Now I get the picture.

Sujatha September 27, 2013 12:43

Some one please help,

I am a newbie to OpenFOAM and have a doubt related to the above posts.
I need to find the pressure at a point in all the time steps, so what is the procedure that I need to follow.
I will be grateful to get some hint.
Thanks in advance.
Regards,

wyldckat September 27, 2013 19:31

Greetings Sujatha and welcome to the forum!

There are at least 2 ways you can do this:
  • You can use sample application, along with a "sampleDict". You can find examples by running:
    Code:

    find $FOAM_TUTORIALS $FOAM_UTILITIES -name sampleDict
  • You can use probeLocations application, along with a "probesDict". You can find examples by running:
    Code:

    find $FOAM_TUTORIALS $FOAM_UTILITIES -name probesDict
Best regards,
Bruno

musahossein September 27, 2013 23:34

Ms Sujatha: Yes please do follow suggestion by Mr Bruno - he is one of the many geniuses on the forum who has helped many a lost foamers find the way -- I speak from experience. So best wishes. Now I have a question for Mr Bruno: Bruno, I tried to run the point probe in OpenFoam. I am running sloshingtank 2d (interdymfoam solver) and when I put the point probe very close to the wall, the solver will give error messages during the run. Also, if I am using moving mesh, then does the probe move with the mesh so that it is probing the same point each time? If not then dont you think it is a major error in OpenFoam? I look forward to your comments.

wyldckat September 28, 2013 06:12

Hi Musaddeque,
Quote:

Originally Posted by musahossein (Post 453957)
Now I have a question for Mr Bruno: Bruno, I tried to run the point probe in OpenFoam. I am running sloshingtank 2d (interdymfoam solver) and when I put the point probe very close to the wall, the solver will give error messages during the run. Also, if I am using moving mesh, then does the probe move with the mesh so that it is probing the same point each time? If not then dont you think it is a major error in OpenFoam? I look forward to your comments.

Mmm... good question. OpenFOAM does have the ability to transform coordinates for sampling, but I can't remember if I ever saw such transformation of probes and section cuts for dynamic mesh solvers...

I've done a quick search and found this bug report: http://www.openfoam.org/mantisbt/view.php?id=744 - I had looked into this back then and I never managed to use this myself.
In addition, I found this old thread: http://www.cfd-online.com/Forums/ope...-problems.html

:eek: I think I've figured it! At least in theory. You need to create a "pointSet" first for the initial mesh and use that point set for the sampling.
Please share the dictionary you've used for sampling, as well as instructions on how you've used it, so that I can test and create a variant for moving meshes.

Best regards,
Bruno

Sujatha September 28, 2013 09:41

Thanks a lot Mr. Bruno for your timely and quick reply. That hint helped me , I could do it with the probesDict and the pressure is obtained.
As Mr.Musahossein has quoted you helped me find the way.
I am grateful.
Regards,

musahossein September 29, 2013 17:31

Point probe close to wall gives errors
 
Bruno:

Here is the sampleDict file that I am using to look at pressures very close to the tank wall. The tank is 1mX1mX0.1. The solver is interDymFOam and the problem is sloshingtank2D. The water depth is 0.5. The centroid (0,0,0) is at mid point along the tanks just at the transition between the water and air. The point probe is at 0.49m and 0.3m below the water level at rest. When I run the sample file, I get error mesages that the probe location is out outside the tank or something to that effect. However, when I place the proble at 0.45m, there are no errors. If you require, I can sent you the tank mesh file, but I dont thin the tank has anything to do with it.

Any help advice will be appreciated, thanks.

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  1.6                                  |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      sampleDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
interpolationScheme cell;
graphFormat gnuplot;

//surfaceFormat    raw;
surfaceFormat raw;


//setFormat    ASCII;
setFormat    raw;

sets
(
// evaluate phase and pressure close to tank rightwall using line probe
  right
  {
        type    uniform;
        axis    xyz;
        start  ( 0  0.45  0.60);
        end    ( 0  0.45  -0.40);
        nPoints 100;
  }

);

fields (alpha1
    p);

surfaceFormat raw;
surfaces
(
//    compute wallPressure at left and rightwalls
            leftwall
        {
        type        patch;
        patches        (leftWall);
        rhoName rhoInf;
        rhoInf 998.2; //Reference density for fluid
        outputInterval: 1.0
        interpolate    true;
        triangulate    false;
        }
            rightwalls
                {
                type        patch;
                patches        (rightWall);
        rhoName rhoInf;
        rhoInf 998.2; //Reference density for fluid
        outputInterval: 1.0
        interpolate    true;
                triangulate    false;
                }
);

fields (alpha1
    p);

functions
{
probes1
{

type probes;
functionObjectLibs ("libsampling.so");
region region1;
probeLocations
(
(0 0.49 -0.3)
);

fields (p);

}
}


musahossein September 29, 2013 17:39

Bruno:

I asked the same question a while back.At that time I reproduced the error message that came on the scree. Here is the URL to that post:

http://www.cfd-online.com/Forums/ope...ct-issues.html

I hope this will clarify the situation better.

Thankyou
Musa

wyldckat October 6, 2013 13:29

Hi Musa,

OK, since you've split your question into two separate threads, I'll address the usage of "sampleDict" here.
The example file provided for this utility: https://github.com/OpenFOAM/OpenFOAM...ple/sampleDict - indicates that it can use a cloud of points, which acts similarly to the probe.

But neither the probes nor the cloud of points will move along with your geometry. These points are fixed in space.

Now, based on your other thread, it seems that you want to sample a point in a patch, not a point strictly inside the domain. For this, you can use the "faceSource" function object: http://foam.sourceforge.net/docs/cpp/a00608.html - if you search here on the forum, I think there is already a couple of examples on how to use this.

I'm going to answer on the other thread now, namely this one: http://www.cfd-online.com/Forums/ope...ct-issues.html

Best regards,
Bruno

kingjewel1 April 1, 2014 16:51

Sorry i have to ask this here: can i use sampleDict on a decomposed case? Ie one that has just been run in parallel?

musahossein April 1, 2014 19:03

Quote:

Originally Posted by kingjewel1 (Post 483313)
Sorry i have to ask this here: can i use sampleDict on a decomposed case? Ie one that has just been run in parallel?

Yes you can. Howver make sure to "gather" all the parallel output by typing 'reconstructPar' in the case directory once the parallel case is complete. Depending on the size of your data it make take a little while. The run 'sample' in the case directory. That will run the sampleDict file on the parallel processing results.

I hope that answers your question.

kingjewel1 April 2, 2014 03:04

Quote:

Originally Posted by musahossein (Post 483331)
Yes you can. Howver make sure to "gather" all the parallel output by typing 'reconstructPar' in the case directory once the parallel case is complete. Depending on the size of your data it make take a little while. The run 'sample' in the case directory. That will run the sampleDict file on the parallel processing results.

I hope that answers your question.

Thank you, ive been looking for that information all over, especially the reconstructpar bit.

wyldckat April 5, 2014 16:13

Greetings to all!

@kingjewel1:
Quote:

Originally Posted by kingjewel1 (Post 483313)
Sorry i have to ask this here: can i use sampleDict on a decomposed case? Ie one that has just been run in parallel?

I don't have much experience with sample, but according to whatever this command gives you:
Code:

sample -help
it should state whether it works in parallel or not. Example from OpenFOAM 2.3.x:
Code:

Usage: sample [OPTIONS]
options:
  -case <dir>      specify alternate case directory, default is the cwd
  -constant        include the 'constant/' dir in the times list
  -dict <file>      read control dictionary from specified location
  -latestTime      select the latest time
  -noFunctionObjects
                    do not execute functionObjects
  -noZero          exclude the '0/' dir from the times list, has precedence
                    over the -zeroTime option
  -parallel        run in parallel
  -region <name>    specify alternative mesh region
  -roots <(dir1 .. dirN)>
                    slave root directories for distributed running
  -time <ranges>    comma-separated time ranges - eg, ':10,20,40:70,1000:'
  -srcDoc          display source code in browser
  -doc              display application documentation in browser
  -help            print the usage

Using: OpenFOAM-2.3.x (see www.OpenFOAM.org)
Build: 2.3.x-9d0ee4591849

It does state that you can use it in parallel, the same way you run solvers in parallel as well!

Best regards,
Bruno

kingjewel1 April 6, 2014 10:56

Quote:

Originally Posted by wyldckat (Post 484055)
Greetings to all!

@kingjewel1:

I don't have much experience with sample, but according to whatever this command gives you:
Code:

sample -help
it should state whether it works in parallel or not. Example from OpenFOAM 2.3.x:
Code:

Usage: sample [OPTIONS]
options:
  -case <dir>      specify alternate case directory, default is the cwd
  -constant        include the 'constant/' dir in the times list
  -dict <file>      read control dictionary from specified location
  -latestTime      select the latest time
  -noFunctionObjects
                    do not execute functionObjects
  -noZero          exclude the '0/' dir from the times list, has precedence
                    over the -zeroTime option
  -parallel        run in parallel
  -region <name>    specify alternative mesh region
  -roots <(dir1 .. dirN)>
                    slave root directories for distributed running
  -time <ranges>    comma-separated time ranges - eg, ':10,20,40:70,1000:'
  -srcDoc          display source code in browser
  -doc              display application documentation in browser
  -help            print the usage

Using: OpenFOAM-2.3.x (see www.OpenFOAM.org)
Build: 2.3.x-9d0ee4591849

It does state that you can use it in parallel, the same way you run solvers in parallel as well!

Best regards,
Bruno

Hi @Bruno,

Thank you for that. My question was not whether
Code:

sample
could be executed IN parallel but whether it could be executed ON a parallel decomposed case. It seems not and that
Code:

reconstructPar
must be run first.:)

Tasos May 10, 2014 20:37

Hi everyone,

I am a very new openFoam user and i am trying a lot! All the discussion with Mr Bruno helped me a lot, but i have some extra questions. I use this sampleDict:

Code:

interpolationScheme cellPoint;

setFormat      gnuplot;

sets
(
    Tasos
    {
        type    face;
        axis    y;
        start  ( 4.018 0 0 );
        end    ( 4.018 0.7 0 );
        nPoints 100;
    }
);

fields          ( U );

and i have a graph for each time step (graph y-U for each specific time step)
now i want to make a graph of U - time.

Can you help me, please, because i am in confusion :/

Thanks a lot,
Tasos.

wyldckat May 11, 2014 05:30

Greetings Tasos,

If you can provide an example case with instructions on how to get to the point you are right now, it'll be easier to help you, because it takes considerable time to set-up a similar case and to do some trial-and-error to figure out the best solution.

On the other hand, why not use ParaView to do the plot of U over time? If you want to plot with gnuplot, you can export the data to CSV after plotting.

Best regards,
Bruno

rcarmi August 26, 2014 14:11

Sampling data in a window and save backup every other time steps
 
Hi all,

Here is my question and I guess I can do that with the controlDict.

I want to simulate something kind of big and cannot save all the data (too much space and saving data slow down the simulation) yet I want backup just in case I need to crash the simulation for a bit and restart later from latest time step (example I need to run another simulation quickly and I don't need the big one for now so I can resume it later).

So here is what I would like to do :

at every 0.05s sample the data in a box (where do I define this box) for all the flow field parameters

then at every 1s I want to back up the entire simulation (domain larger than the area of interest).

I am doing that with IHFOAM by the way.

Best

Remi

musahossein August 29, 2014 08:33

backing up data
 
I dont know whether you can back up data every 1s or at any time interval. Openfoam does not give you the option. Also, why backup results data? It will take a huge amount of space and may not be efficient to restore. Why cant you just back up the input data and the associated files (system, constant etc) so that in the event of a crash, you can rerun your case.


All times are GMT -4. The time now is 09:32.