CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Volume sampling on the run (https://www.cfd-online.com/Forums/openfoam/226476-volume-sampling-run.html)

Ryan. April 28, 2020 22:19

Volume sampling on the run
 
Hi,

is there any OpenFOAM function object similar to surfaceSampling but for the volume? I want to sample a volume region or the whole domain on the run. I don't want to do the reconstruction as it's time-consuming and I am only interested in a small region near the outlet.

thanks in advance,
Ryan

tomf April 30, 2020 10:34

Hi,

I am not sure what you exactly want to do, but maybe the volFieldValue functionObject is of help?

It uses a volRegion for doing some stuff.

This means you would need a cellSet or cellZone and then probably you need to specify whatever you need in the volFieldValue part.

I am not sure what the limitations are. Maybe you can make a small case to experiment on.

Good luck,
Tom

zhangyan May 4, 2020 02:44

Maybe you can try this:
https://github.com/StachuraMichal/Op...sampleCellZone

Ryan. May 6, 2020 19:02

Quote:

Originally Posted by zhangyan (Post 768567)

Thanks a lot. This is precisely what I was looking for. The only issue is that it only writes the points to the file but doesn't write the mesh. Do you know how to append the mesh to the samples?

lukasf January 31, 2022 10:39

Hi Ryan,


have you found a solution to sample volumes and to visualize those with paraview?


Happy for any help.


Lukas

al.csc January 31, 2022 18:02

Quote:

Originally Posted by lukasf (Post 821283)
Hi Ryan,


have you found a solution to sample volumes and to visualize those with paraview?


Happy for any help.


Lukas

Here an example for ESI version:

Code:


functions
{
    type    sets;
    libs    (sampling);
    log    on;
    enabled true;

    writeControl    timeStep;
    writeInterval  1;
    setFormat      raw; //or vtk for Paraview
    interpolationScheme cell;
    fields ( U );
    sets
    (
        centres
        {
            type    cellCentre;
          bounds  (0 0 0) (0.1 0.1 0.1);
        }
    );
}


Paste it at the end of your controlDict and adjust it for your case.

Cheers!

lukasf February 2, 2022 09:21

Quote:

Originally Posted by al.csc (Post 821298)
Here an example for ESI version:

Code:


functions
{
    type    sets;
    libs    (sampling);
    log    on;
    enabled true;

    writeControl    timeStep;
    writeInterval  1;
    setFormat      raw; //or vtk for Paraview
    interpolationScheme cell;
    fields ( U );
    sets
    (
        centres
        {
            type    cellCentre;
          bounds  (0 0 0) (0.1 0.1 0.1);
        }
    );
}

Paste it at the end of your controlDict and adjust it for your case.

Cheers!

Hi Ryan,


thank you.

I works. However, when I want to visualize the .vtk files with ParaView I do not like the way the file is displayed. Somehow, it only consists out of points.

Hence, I prefer this way:


Code:

    volFieldValue1
    {
        type                volFieldValue;
        libs                ("libfieldFunctionObjects.so");
        log                  false; //true;
        writeControl adjustableRunTime;
        writeFormat    ascii; //binary;
        writeInterval 1e-5;
        writeFields      true;//writes the fields of the volume
        //timeStart      0;
        //timeEnd        1000;
        regionType      cellSet; //cellZone;
        name              box; // box is the cellSet or cellZone defined by the topoSetDict
        operation        none;
        fields
        (
            U T p
        );
    }

However, this code did not work for the ESI version v1912. The fields where just empty. However, using version V2112 (same code) results in all values written into the files.

One receives a file in postProcessing/volFieldValue1 which is not important.
The volume field is directly written to the time directories or time directories of the processor0.

In this directory I run this command.

Code:

                        foamToVTK -cellSet box -useTimeName -excludePatches '(".*")' -noFaceZones
This way I get .vtk files which are visualized more nicely in ParaView.
Moreover, I source a non ESI openfoam Version for the foamToVTK command because this way the "-useTimeName" is available which I prefer.


All times are GMT -4. The time now is 19:47.