Skip to content

Instantly share code, notes, and snippets.

@robinknowles
Last active February 25, 2022 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinknowles/022854daf258fa39e882bbe296fc9793 to your computer and use it in GitHub Desktop.
Save robinknowles/022854daf258fa39e882bbe296fc9793 to your computer and use it in GitHub Desktop.
An example of using sampledSurfaces to export patches from OpenFOAM
// OpenFOAM v2112 function using sampledSurfaces for patch/surface export
// Includes:
// - multiple file formats;
// - point-data export;
// - near-wall interpolation;
//
// Can be tested on motorBike tutorial data, using:
// postProcess -func sample -latestTime
sample
{
type surfaces;
libs (sampling);
fields ( p U );
writeControl writeTime;
// Set the default export format
surfaceFormat vtp;
// Tweak the cell-point interpolation to give near-wall values,
// especially useful for near-wall velocities.
interpolationScheme cellPointWallModified;
formatOptions
{
// Set VTP write format to binary to reduce on-disk size
vtp
{
format binary;
}
obj
{
// compression true; // uncomment to write gzipped OBJ files
}
}
surfaces
(
// Export motorBikeGroup patches as binary VTP
motorbike-surfs
{
type patch;
patches (motorBikeGroup);
// Export interpolated point-based data
interpolate true;
}
// Export motorBikeGroup patches in EnSight format
motorbike-surfs
{
type patch;
patches (motorBikeGroup);
// Override the default export format - use ascii Ensight
surfaceFormat ensight;
// Export cell/face-based data
interpolate false;
}
// Export motorBikeGroup patches in OBJ format
motorbike-surfs
{
type patch;
patches (motorBikeGroup);
// Override the default export format - use OBJ (no fields exported)
surfaceFormat obj;
}
);
}
// ************************************************************************* //
@robinknowles
Copy link
Author

Exporting patches with sampledSurfaces

An OpenFOAM v2112 function using sampledSurfaces for patch/surface export

Includes:

  • multiple file formats;
  • point-data export;
  • near-wall interpolation;

Try it out on the motorBike tutorial data (working in OpenFOAM v2112 & v2106).

Save the file above to system/sample then run:

postProcess -func sample -latestTime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment