CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Save data only from a plane (http://www.cfd-online.com/Forums/openfoam-solving/118163-save-data-only-plane.html)

Pj. May 22, 2013 01:58

Save data only from a plane
 
I need to run a 2M cells simulation and i need to save the pressure and the speed on a surface for about 9000 time steps.

The way I proceed right now is to save all the cells value for the 9000 time steps and THEN sample the value on the surface I need.

The problem is that, this way, I create an huge amount of datas (about 1TB) to extract from it 5GB of datas that i actually need.

Moreover the sample utility is slower than pisoFoam (both are running on parallel on 60 cores).


Is there a more efficient way to do this operation?


I thought I could delete the time-steps folders with the purgeWrite option, but to do so I need to sample the surface during the pisoFoam execution. Is this possible?

fredo490 May 22, 2013 04:52

When you say a "plane", is it a patch ?

If yes, you can edit your solver, create a new field where you copy only the data of the desired patch.

1) create the field
Code:

    volScalarField ExportPressure
    (
        IOobject
        (
            "ExportPressure",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

2) Find the patch (let's say it is named "wall")
Code:

    label patchWallID = mesh.boundaryMesh().findPatchID("wall");
    const fvPatch& patchWallFaces = mesh.boundary()[patchWallID];

so we get the ID of the wall and also the patch faces

3) Loop over the cells of your patch to save the data
Code:

    forAll(patchWallFaces, facei)
    {
      ExportPressure.boundaryField()[patchWallID][facei] = P.boundaryField()[patchWallID][facei] ;
    }

Or even simplier (need to check if it works in parallel)
Code:

      ExportPressure.boundaryField()[patchWallID] = P.boundaryField()[patchWallID];
4) Your new field ExportPressure will be written with the other variables.
However, if you want to export it at each time step (no matter what), just add the following code after "calculating" the step 3:
Code:

ExportPressure.write();
I wrote this quickly so you might have to debug my code

Pj. May 22, 2013 05:40

Thank you very much Fredo.

Actually my "plane" is not a patch, but it's a plane I define in sampleDict with a point and a normal inside my domain.

Code:

surfaces
(
    constantPlane
    {
        type plane;
        name in;
        basePoint ( 0 0 25 );
        normalVector ( 1 0 0 );
    }
);

(My domain is a box from (-1,-3,0) to (26,3,3). So the plane is parallel to the outlet patch but 1m before it)

Moreover (I'm sorry i forgot to say it before), I need this data to be read by the BC timeVaryingMappedFixedValue. To obtain so I set the output format in sampleDict to foamFile and then i need to do some minor manipulation.
What kind of format are the data written with your method?

Moreover I'm sorry, but I'm not an expert with OF. So, the commands you wrote me where have to be written? Inside pisoFoam.C or something like that?

Anyway, even if it's not "perfect" it's a good solution. I will give it a deep look and maybe a try. Thank you very much.

fredo490 May 22, 2013 06:21

1 Attachment(s)
yeah, the code needs to be included in the solver code.
1) in the createField.H
2) / 3) and 4) can be included inside the C file (pisoFoam.C I guess).

The output file looks like the one enclosed. I have exported the temperature only on the wall patch from the Temperature Field T.


All times are GMT -4. The time now is 16:55.