General

How to quickly export points for a timeVaryingFixedValue boundary in OpenFOAM

The timeVaryingFixedValue boundary in OpenFOAM allows data extracted from other simulations or experimental data to be mapped to be used as boundary condition. The boundary requires a directory structure containing the data to be set up as follows:

  • caseName
    • 0
    • constant
      • boundaryData/<boundaryName>
        • TimeFolder0
        • TimeFolder1
        • points
    • system

The points file contains the coordinates of the points used to perform the data mapping. If data originate from another boundary conditions (e.g., the outlet of another simulation), it is straightforward to automatically generate such file. 

Let us assume, for convenience, that the field p needs to be patched, and that the original simulation was executed with pimpleFoam. To extract the values of p and the points file, it suffices to define the following functionObject in the controlDict dictionary of the source simulation:

functions
{
    extractPoints  // Arbitrary name
    {
        type    surfaces;
        libs    (sampling);
        log     true;


        setFormat raw;
        surfaceFormat   foam;


        writeControl    writeTime;
        writeInterval   1;


        fields (p);


        surfaces
        {
            // Oversized sampling - for general testing
            patchSample
            {
                type      patch;
                patches   (massflowinlet);
            }
        }
    }
}

Note that the surface Format option is set to foam, to obtain the desired file.

Executing:

pimpleFoam -postProcess

will produce the following directory structure in the case folder:

  • postprocessing
    • extractPoints
      • timeFolder0
        • patchSample
          • scalarField
            • scalarField
              • p
          • faceCentres
          • faces
          • points

which contains the desired points file and scalar field file p (in bold above).

Note: change the name of the solver used to invoke the -postProcess option to be consistent with the one used for the specific simulation used as source of the data and points.

This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks. Alberto Passalacqua is not associated to OpenCFD Ltd.

4 Comments

  • FoamUser

    Hi,
    Thank you for this post.

    I have a question about the first listing (the tree structure of the case). Why are TimeFolder0 and TimeFolder1 under constant and not on the root level of the case with system and constant directories?

    Best regards
    Simo oueldelyamna

  • Ed

    Say you set up your boundary condition values for times 0 and 1, but you run your simulation from t=0 to t=4. This means that the boundary condition 0 is applied for t=0 and the boundary condition 1 applies to all the following timesteps (i.e., t=1 for t=1,2,3 and 4).

    Is there a way to make them alternate? So for the example, the boundary condition 0 applies again to t=2, the boundary condition 1 applies to t=3 and so on.

Leave a Reply

Your email address will not be published. Required fields are marked *

nine − 3 =

I accept the Privacy Policy