fbpx

OpenFOAM function object

Published by rupole1185 on

CloudHPC is able to provide a number of real-time information when running OpenFOAM simulations. In particular it gets useful to add some OpenFOAM function object which are able to plot some variables calculated by OpenFOAM. Thanks to these, you can monitor your analysis and it is possible to make a quick post-processing of the results.

These function objects work in two ways:

  • they generate .dat file in a new postProcessing folder where you can find the calculation you required OpenFOAM to make
  • they generate new variables located in the time-step folders, like U, p or other independent variables

Let’s have a look at the most important function objects then!

controlDict and OpenFOAM function object

The first question is mostly direct: how can I set a function object? Easy is the reply. At the bottom of your controlDict file just add the following:

functions
{
   // Add here your function object
}

It’s just a simple tag at the end of your controlDict that specifies them. Now that you know where you can add them, let’s have a look at them!

Simulation monitoring

Even though all OpenFOAM function object allows to quickly monitor your analysis, there are some specific objects usefull to have a view of the way the analysis is proceeding with a simple glance. The first is cellMax, which returns the max all over the domain of the variables specified in fields (U and p in this example):

        cellMax
        {
              type            volFieldValue;
              libs            ("libfieldFunctionObjects.so");
              writeControl    timeStep;
              writeInterval   1;                //write max at every iteration
              writeFields     false;
              log             false;
              operation       max;
              fields          (U p);
        }

Another very important way to monitor your analysis is by getting the residuals. To do that, there are two possibilities, depending on which OpenFOAM version you are currently using as specified in the example below:

        //Valid for OpenFOAM.com [i.e. OpenFOAM-v2112]
        #includeFunc solverInfo;

        //Valid for OpenFOAM.org [i.e. OpenFOAM-of9]
        residuals
        {
                type   residuals;
                functionObjectLibs   ("libutilityFunctionObjects.so");
                enabled   true;
                writeControl   timeStep;
                writeInterval   1;
                fields   (p U);
        }

Despite the difference between the two OpenFOAM branches, the result is pretty much similar: the residual information in a .dat file inside the postProcessing directory. CloudHPC automatically detects the presence of this file and generates a graph for each of them.

Add more variables to your analysis

By default, most of the OpenFOAM solver just compute velocity, pressure, temperature and turbulence. This is often not sufficient: users wants to compute wallShearStress, wallHeatFlux, yPlus, totalPressure, Mach number, etc. Let’s see how we can tell OpenFOAM to compute these peculiar variables:

        yPlus
        {
              type            yPlus;
              libs            ("libfieldFunctionObjects.so");
              writeControl    writeTime;
        }

        wallHeatFlux
        {
              type            wallHeatFlux;
              libs            ("libfieldFunctionObjects.so");
              writeControl    writeTime;
        }

        wallShearStress
        {
              type            wallShearStress;
              libs            ("libfieldFunctionObjects.so");
              writeControl    writeTime;
        }

        MachNo
        {
              type            MachNo;
              libs            ("libfieldFunctionObjects.so");
              writeControl    writeTime;
        }

        #includeFunc    totalPressureIncompressible(rhoInf=1.20);

        #includeFunc    totalPressureCompressible;

Most of this type of OpenFOAM function object are similar. Only the totalPressure one: in this case one needs to remember the peculiarity of OpenFOAM for incompressible flows. Density Rho is never really computed and for this reason we can notice a specific command for this type of flows.

Computing patch quantities

Other fundamental OpenFOAM function object to use are those which compute patch quantities such a flows or averages.

        //OpenFOAM.com version [i.e. OpenFOAM-v2112]
        #includeFunc    flowRatePatch(name=patch_name);

        //OpenFOAM.org version [i.e. OpenFOAM-of9]
        #includeFunc  patchFlowRate(patch=patch_name);
        #includeFunc  patchAverage( patch=patch_name, fields=( p ) )

        //Both OpenFOAM versions
        forces
        {
           type          forces;
           libs          ("libforces.so");
           writeControl  timeStep;
           timeInterval  1;
           rho           rhoInf;  // Density -> only for incompressible
           rhoInf        1.2;     // Density -> only for incompressible
           log           yes;
           patches       ( patch_name );
           CofR          ( 0 0 0 );
        }

Also in this case, results are in a .dat file in the postProcessing folder and CloudHPC automatically detects their presence and generates a graph for each of them.

Find your own function object

Now that you know them, you can test if you can monitor your analysis on our cloudHPC system for free up to 300 vCPU Hours by registering here.

The ones reported here are just the most useful function object but there are many others. To see which ones you can use just look in the following OpenFOAM folder:

OPENFOAM_INSTALLATION_DIRECTORY/etc/caseDicts/postProcessing/


CloudHPC is a HPC provider to run engineering simulations on the cloud. CloudHPC provides from 1 to 224 vCPUs for each process in several configuration of HPC infrastructure - both multi-thread and multi-core. Current software ranges includes several CAE, CFD, FEA, FEM software among which OpenFOAM, FDS, Blender and several others.

New users benefit of a FREE trial of 300 vCPU/Hours to be used on the platform in order to test the platform, all each features and verify if it is suitable for their needs


Categories: cloudHPCOpenFOAM

2 Comments

Update OpenFOAM numerical settings automatically - Cloud HPC · 16 January 2024 at 5:23 pm

[…] the past posts about simulation schemes and function object, we talked about the possibility of setting a first or second order analysis and the possibility of […]

Leave a Reply

Avatar placeholder

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