Import OpenFOAM sampled pressure into PrePoMax

Hi Everyone,

I am trying to import pressure loads on a structure which was calculated in OpenFOAM. However, the CFD model is very large and I can’t writing the entire field frequently, instead only the pressure on the structure is written to files using OF libsampling.so (type surface).

There are several output options available including “VTK” and “foamFile”, is this currently an option to read this surface value rather than reading/mapping the entire mesh?

Thanks
Sha

Can’t you write the pressure in OpenFOAM only in elements adjacent to the surface of the solid object?

Thanks for the response, Assuming it is possible (I could perhaps write a small function object), how can I then read it into Prepomax?

Alternatively, how difficult would it be to add the functionality to Prepomax? Any recommandation where to start?

If you can reduce the amount of data in OpenFOAM results files (by including only part of the mesh or storinf pressure results only in the selected layer of elements) then it should be possible to import it to PrePoMax for use in imported pressure load as shown here: https://www.youtube.com/watch?v=76gqtkEhFwg

I am not an OpenFOAM user, but I added the supported functionality to read OpenFOAM results as a whole. So now I am wondering if it is the best way to do it or if people usually export the pressure in some other way, as you wrote. What kind of data output is the most common for the pressure output? Is it similar to the temperature output where, as I was told, most programs enable the user to output the temperatures in X, Y, Z, T format?

Thank you for your response. For small simulations reading the entire field is fine. But for large simulations normally you would only write the loads on specific required patches, e.g. a specific wall boundary. As writing the entire internal field with very high frequency in transient simulations is not an option really.

In OF this can be done using libsampling. The data will be written in variety of formats in a separate directory “postProcessing/correspondingTimeLable”

Variety of file format options are available including VTK, VTP raw (x,y,z,fieldName), nastran and native foam format.

If you provide some pointers about where to start I am happy to help / do it myself as I will somewhat urgently need this.

One more thing, is it possible to chose several times for dynamic analysis?

Thanks
Sha

Without the user interface, the important classes are located in:

CaeModel/Steps/Loads/ImportedPressure.cs
CeaResults/FileInOut/Input/OpenFoam/OpenFoamFileReader.cs
CeaResults/Interpolator/ResultsInterpolator.cs

The ImportedPressure defines the OpenFoal results file to be read. The main function that prepares the data is:

public void ImportPressure(UnitSystem unitSystem)

Then the OpenFoamFileReader reads the file data and forwards it to the _inerpolator variable, which is of a ResultsInterpolator class. The interpolator is used in functions:

public void GetPressureAndDistanceForPoint(double[] point, out double[] distance, out double value)
public override double GetPressureForPoint(double[] point)

which are called by other classes. The interpolator function that does the interpolation is:

public void InterpolateAt(double[] point, InterpolatorEnum interpolator, out double[] distance, out double value)

The interpolator can only use data prepared as triangular meshes. So point clouds currently cannot be used. It splits the space into a fixed number of equal boxes (I know, it is far from perfect) to speed up the search when doing the interpolation.

the function:

public ResultsInterpolator(PartExchangeData source)

should be changed to add data from a different source.

I can help if we define the best/most used data file format.

Thanks for this. I will start looking into it as well.
The data format for normal OpenFOAM output is standard. It can also be converted to VTK but still you get the entire internal field and usually we can’t write all that data with high frequency due to disk space limitations.

Normally we only need the pressure fields on a specific structure (defined as a patch in OF). This can then be directly extracted during a run by defining it as a sampling surface using libsampling.so. For example

nameOfTheFuntionObject
{
type surfaces;
libs (“libsampling.so”);
enabled true;
writeControl runTime;
timeStart 10;
writeInterval 0.5;
surfaceFormat vtk;
formatOptions
{
vtk
{
legacy true;
format ascii;
}
}
fields (p);
interpolationScheme cellPoint;
surfaces
( a_patch_name {type patch; patches (patch_name); interpolate true;} );

}

OF support writing the surface data with the following formats (see surfaceFormat above): foam or foamFile depending on version, VTK, raw, stl, ensight, starcd, nastran

I think probably makes sense to start with “foam” and “VTK”,

foam format writes: points, faces, values files
VTK: VTK ASCII format this will write the newer VTP files by default but can be converted to VTK using formatOptions {
vtk {
legacy true.;
format ascii; }

In the corresponding function object dictionary.

These however, won’t be written to the case directory. The VTK format files will be saved under

CaseDirectory/postProcessing/nameOfTheFuntionObject/time_lable

So probably need some input from the user to find the correct files rather than just reading an empty .foam file.

I tried writing a sample dataset with “foam” format but could not load them in PrePoMax so probably some small changed would still be required but I imagine the available OpenFoamFileReader could be used.

The “VTK” format extracted from a simulation can be downloaded here. Foam format is available here. Note that the directory structure is a bit different and the data is stored with the following structure:

CaseDirectory/postProcessing/nameOfTheFuntionObject/time_lable/a_patch_name/

under a_patch_name there are faceCentres, faces, points files and a directory called scalarField which contains a file names “p” as defined by “fields (p)” in the function object dictionary (see the example).

Thanks
Sha

You can upload them to some hosting website like OneDrive, Google Drive, Dropbox or WeTransfer and paste the link here.

1 Like

Thanks, added a vtk/foam samples to the previous post

If you provide sample files I can look into it.

They are in my previous post (Post 8), here again:

The “VTK” format extracted from a simulation can be downloaded here. Foam format is available here .

Let me know if you can’t download

Although addition of the feature to directly load the extracted surface is probably the most efficient approach for this problem as explained above, it is also possible to use mapFields in OF and sample the CFD domain on a smaller mesh around the surfaces of interest using fieldFunctionObject during a run.
This could be setup efficiently to save storage and will be written to files with the same format of a normal OF mesh which can then be imported directly to PrePoMax using the currently available features.

Thought to share this for anyone who might be interested.