src/OpenFOAM logo
The Open Source CFD Toolbox
  Search
  
  Back to OpenFOAM Home
 
  OpenCFD®
  Company profile
  OpenFOAM support
  OpenFOAM development
  OpenFOAM training
  Solutions
  Contact OpenCFD
  Recruitment
  Recommended links
 
  OpenFOAM®
  Features
  Download
  Documentation
  * User Guide
  * C++ Source Guide
  * README file
  * Release notes
  * Upgrading to 1.5
 
  Our trade mark policy
 
  © 2000-2008 OpenCFD Ltd
SourceForge.net Logo
OpenCFD® Solutions Contact OpenFOAM®
OpenFOAM 1.5 User Guide © 2000-2008 OpenCFD Ltd

6.5 Sampling data

OpenFOAM provides the sample utility to sample field data, either through a 1D line for plotting on graphs or a 2D plane for displaying as isosurface images. The sampling locations are specified for a case through a sampleDict dictionary in the case system directory. The data can be written in a range of formats including well-known graphing packages such as Grace/xmgr, gnuplot and jPlot.

The sampleDict dictionary can be generated by copying an example sampleDict from the sample source code directory at $FOAM_UTILITIES/postProcessing/sampling/sample. The plateHole tutorial case in the $FOAM_TUTORIALS/solidDisplacementFoam directory also contains an example for 1D line sampling:


17  interpolationScheme cellPoint;
18  
19  setFormat     raw;
20  
21  sets
22  (
23      leftPatch
24      {
25          type            uniform;
26          axis            y;
27          start           (0 0.5 0.25);
28          end             (0 2 0.25);
29          nPoints         100;
30      }
31  );
32  
33  surfaces
34  ();
35  
36  fields
37  (
38      sigmaxx
39  );
40  
41  // ************************************************************************* //


Keyword

Options Description



interpolationScheme

cell
cellPoint
cellPointFace
Cell-centre value assumed constant over cell
Linear weighted interpolation using cell values
Mixed linear weighted / cell-face interpolation

setFormat

raw
gnuplot
xmgr
jplot
Raw ASCII data in columns
Data in gnuplot format
Data in Grace/xmgr format
Data in jPlot format

surfaceFormat

null
foamFile
dx
vtk
raw
stl
Suppresses output
points, faces, values file
DX scalar or vector format
VTK ASCII format
    xyz  \special {t4ht= values for use with e.g.gnuplotsplot
ASCII STL; just surface, no values

fields

List of fields to be sampled, e.g. for velocity U:

U Writes all components of                            U  \special {t4ht=

U.component(0) Writes component 0, i.e.                            Ux  \special {t4ht=

U.component(1) Writes component 1, i.e.                            Uy  \special {t4ht=

mag(U) Writes magnitude, i.e.                          |U | \special {t4ht=

sets

List of 1D sets subdictionaries -- see 6.4

surfaces

List of 2D surfaces subdictionaries -- see 6.5 and 6.6




Table 6.3: keyword entries for sampleDict.

The dictionary contains the following entries:

interpolationScheme
the scheme of data interpolation;
sets
the locations within the domain that the fields are line-sampled (1D).
surfaces
the locations within the domain that the fields are surface-sampled (2D).
setFormat
the format of line data output;
surfaceFormat
the format of surface data output;
fields
the fields to be sampled;

The interpolationScheme includes cellPoint and cellPointFace options in which each polyhedral cell is decomposed into tetrahedra and the sample values are interpolated from values at the tetrahedra vertices. With cellPoint, the tetrahedra vertices include the polyhedron cell centre and 3 face vertices. The vertex coincident with the cell centre inherits the cell centre field value and the other vertices take values interpolated from cell centres. With cellPointFace, one of the tetrahedra vertices is also coincident with a face centre, which inherits field values by conventional interpolation schemes using values at the centres of cells that the face intersects.

The setFormat entry for line sampling includes a raw data format and formats for gnuplot, Grace/xmgr and jPlot graph drawing packages. The data are written into a sets directory within the case directory. The directory is split into a set of time directories and the data files are contained therein. Each data file is given a name containing the field name, the sample set name, and an extension relating to the output format, including .xy for raw data, .agr for Grace/xmgr and .dat for jPlot. The gnuplot format has the data in raw form with an additional commands file, with .gplt extension, for generating the graph. Note that any existing sets directory is deleted when sample is run.

The surfaceFormat entry for surface sampling includes a raw data format and formats for gnuplot, Grace/xmgr and jPlot graph drawing packages. The data are written into a surfaces directory within the case directory. The directory is split into time directories and files are written much as with line sampling.

The fields list contains the fields that the user wishes to sample. The sample utility can parse the following restricted set of functions to enable the user to manipulate vector and tensor fields, e.g. for U:

U.component(n   \special {t4ht=)
writes the n  \special {t4ht=th component of the vector/tensor, n = 0,1 ...  \special {t4ht=;
mag(U)
writes the magnitude of the vector/tensor.

The sets list contains sub-dictionaries of locations where the data is to be sampled. The sub-dictionary is named according to the name of the set and contains a set of entries, also listed in 6.4, that describes the locations where the data is to be sampled. For example, a uniform sampling provides a uniform distribution of nPoints sample locations along a line specified by a start and end point. All sample sets are also given: a type; and, means of specifying the length ordinate on a graph by the axis keyword.


Required entries
Sampling type Sample locations name axis start end nPoints points








uniform Uniformly distributed points on a line • \special {t4ht= • \special {t4ht= • \special {t4ht= • \special {t4ht= • \special {t4ht=
face Intersection of specified line and cell faces • \special {t4ht= • \special {t4ht= • \special {t4ht= • \special {t4ht=
midPoint Midpoint between line-face intersections • \special {t4ht= • \special {t4ht= • \special {t4ht= • \special {t4ht=
midPointAndFace Combination of midPoint and face • \special {t4ht= • \special {t4ht= • \special {t4ht= • \special {t4ht=
curve Specified points, tracked along a curve • \special {t4ht= • \special {t4ht=        • \special {t4ht=
cloud Specified points • \special {t4ht= • \special {t4ht=        • \special {t4ht=








Entries Description
Options




type Sampling type
see list above
axis Output of sample location x x  \special {t4ht= ordinate
y y  \special {t4ht= ordinate
z z  \special {t4ht= ordinate
xyz xyz  \special {t4ht= coordinates
distance distance from point 0
start Start point of sample line
e.g.(0.0 0.0 0.0)
end End point of sample line
e.g.(0.0 2.0 0.0)
nPoints Number of sampling points
e.g.200
points List of sampling points





Table 6.4: Entries within sets sub-dictionaries.

The surfaces list contains sub-dictionaries of locations where the data is to be sampled. The sub-dictionary is named according to the name of the surface and contains a set of entries beginning with the type: either a plane, defined by point and normal direction, with additional sub-dictionary entries a specified in 6.5; or, a patch, coinciding with an existing boundary patch, with additional sub-dictionary entries a specified in 6.6.


Keyword Description Options



basePoint Point on plane e.g.(0 0 0)
normalVector Normal vector to plane e.g.(1 0 0)
interpolate Interpolate data? true/false
triangulate Triangulate surface? (optional) true/false




Table 6.5: Entries for a plane in surfaces sub-dictionaries.


Keyword Description Options



patchName Name of patch e.g.movingWall
interpolate Interpolate data? true/false
triangulate Triangulate surface? (optional) true/false




Table 6.6: Entries for a patch in surfaces sub-dictionaries.