• No results found

Post Processing and Advanced Running Options

N/A
N/A
Protected

Academic year: 2021

Share "Post Processing and Advanced Running Options"

Copied!
49
0
0

Loading.... (view fulltext now)

Full text

(1)

OpenFOAM postprocessing and advanced

running options

Gianluca Montenegro

Department of Energy Politecnico di Milano

(2)

The post processing tool: paraFoam

The main post-processing tool provided with OpenFOAM is the reader module to run with ParaView, an open-source, visualization application

The module is compiled into 2 libraries, PVFoamReader and vtkFoam, using version 2.4.4 of ParaView supplied with the OpenFOAM release

ParaView uses the Visualization Toolkit (VTK) as its data processing and rendering engine and can therefore read any data in VTK format

OpenFOAM includes the foamToVTK utility to convert data from its native format to VTK format, which means that any VTK-based graphics tools can be used to post-process OpenFOAM cases. This provides an alternative means for using ParaView with OpenFOAM

paraFoamis strictly a script that launches ParaView using the reader module supplied with OpenFOAM

It is executed like any of the OpenFOAM utilities with the root directory path and the case directory name as arguments:

(3)

Before starting

Before starting with the user should copy two tutorials in his own run folder: cp -r $FOAM_TUTORIALS/simpleFoam/pitzDaily/ $FOAM_RUN/ cp -r $FOAM_TUTORIALS/dieselFoam/aachenBomb $FOAM_RUN/ SimpleFoam is an incompressible steady-state flow solver, while dieselFoam is dedicated to combustion process with spray injection

The two cases should also be executed run

blockMesh . pitzDaily simpleFoam . pitzDaily blockMesh . aachenBomb dieselFoam . aachenBomb

The user should care about reducing the endTime and the writeInterval to have immediately some calculations to post process for the pitzDaily case

For the aachenBomb case the user should switch off the chemistry to reduce the computational time

(4)

Viewing the mesh

The mesh can be viewed only in paraFoam since there is no pre-processing tool to view the mesh

We shall start with the pitzDaily case of the simpleFoam tutorial: paraFoam $FOAM RUN/ pitzDaily

Click the Accept button which will bring up an image of the case geometry in the image display window.

In the parameters panel it is possible to choose what you can visualize: the time step

the region the vol field

the point field if exists

(5)

The post processing tool: paraFoam

WhenparaViewis launched the case is controlled from the left panel, which contains the following:

Selection Window lists the modules opened in ParaView, where the selected

modules are highlighted in yellow and the graphics for the given module can be enabled/disabled by clicking the eye button alongside

Parameters panel contains the input selections for the case, such as times,

regions and fields

Display panel controls the visual representation of the selected module, e.g.

colors

Information panel gives case statistics such as mesh geometry and size

ParaView operates a tree-based structure in which data can be filtered from the top-level case module to create sets of sub-modules

(6)

Viewing the mesh

Selectpropertyandwireframe of surfaceto visualize the mesh. Play wit the actor colormenu to select the color you prefer

(7)

Viewing the mesh

To improve the quality of the mesh Visualization it is possible to overlap the surface of your mesh

Select theextract partsfrom the filter menu and then selectsurface visualization of the mesh. Play with the color option to create the desired contrast

(8)

Viewing fields: display panel

The Display panel contains the settings for visualizing the data/fields for a given case module. The following points are particularly important:

the data range is not automatically updated to the max/min limits of a field, so the user should take care to select Edit Color Map and Reset range at appropriate intervals, in particular after loading the initial case module

the style of legend, e.g. font, for the color bar is controlled by in the Scalar Bar panel of the Edit Color Map window

the underlying mesh can be represented by selecting Wireframe in the Representation menu

the geometry, e.g. a mesh (if Wireframe is selected), can be visualized as a single color by selecting Property from the Color by menu and specifying the Actor color the image can be made translucent by editing the value in Opacity (1 = solid, 0 = invisible)

the activated field can be translated, scaled, rotated with respect the other ones In the color windows it is possible to select the field that the user wants to plot

(9)

Viewing fields: vectorFields (U)

Selecting the velocity field from the color window in the display panel, two options are available:

point volPointInterpolate, the velocity field is defined on the grid vertex and

interpolated from the cell centers

cell U the velocity field is displayed in the cell center

It is possible to visualize only the magnitude of velocity, without any information about the direction of the velocity vector:

magU . pitzDaily Time = 50

Reading U

Calculating magU

mag(U): max: 10.619 min: 0.12244 Then select the magU filed in the color window

If you run themagUutility after having launched paraFoam you will need to change the time step or to update the GUI to visualize the new field

Alternatively the user may use the calculator filter. Keep in mind that it works only for the selected time step

(10)

Viewing fields: vectorFields (U)

To visualize the velocity filed as a field of vectors you must act on filters once again:

(11)

Viewing fields: vectorFields (U)

Starting from the cell center filtered field, the user must select theGlyphsfilter and then accept

The vector field will be displayed in the window on the right

(12)

Viewing fields: glyphs (U)

The filter reads an Input and offers a range of Glyphs for which the Arrow0 provides a clear vector plot images

In the Orient/Scale window, the most common options for Scale Mode are: Vector Magnitude, where the glyph length is proportional to the vector magnitude, whereas selectingData Scaling Offeach glyph is the same length

An additionalScale Factorparameter controls the base length of the glyphs It is possible to select the maximum number of Glyphs to be displayed. Putting a number lower than the cell number can speed up the visualization

Other option rather than arrows are available: cones, cubes, lines, spheres and arrow2d

It is possible to select the glyphs filter directly from the ParaView toolbar:

(13)

Viewing fields: contour plots

A contour plot is created by selecting Contour from the Filter menu at the top menu bar

Iso−surface button

The filter acts on a given module so that, if the module is the 3D case module itself, the contours will be a set of 2D surfaces that represent a constant value, i.e. isosurfaces The Parameters panel for contours contains the list of constant values, that the user can edit, most conveniently by the Generate range of values window. The Input and Scalars menus present the module and fields, respectively, that are read by the filter

(14)

Viewing fields: streamlines

Streamlines are created by first creating anappend attributesfilter

Streamlines are created selecting thetracer linesusing the Stream Tracer filter The tracer Seed window specifies a distribution of tracer points over a Line or Point Cloud

The distance the tracer travels and the length of steps the tracer takes are specified in the text boxes below

(15)

Viewing fields: probes

To plot a graph in ParaView, the users must first extract the internal mesh using the Extract Partsfilter

The user can then plot a graph by selectingProbefrom the Filter menu

In the Probe Object window, the user should select Line and position the line vertically up the center of the domain with a resolution of 50

The fields that are plotted are selected in the Point scalars window of the Probe panel

(16)

Viewing fields: probes

The user can select theprobefilter directly by clicking onto theprobesbutton on the toolbar

Sample button

It is possible to write the selected sampled fields onto a csv file. The output will be a comma separated file as follows:

volPointInterpolate(p),0.200097,5.12835,8.24178,10.3533,... volPointInterpolate(magU),8.63369,8.13691,7.70859,7.37819,.... volPointInterpolate(epsilon),48.1914,52.6348,59.0361,67.6491,7,... volPointInterpolate(k),1.08187,1.13229,1.19894,1.28333,1.3918,...

(17)

Viewing fields: Data analysis

To plot field values in a certain point (cell, vertex, line) as a function of time (plotted time steps) the user can select the filterData analysisform the filter menu or by clicking onto theData Analysisbutton on the toolbar:

Data analysis

(18)

Viewing fields: probes

Pick the cell you want to select by positioning the pointer onto it and pressing the p key (pick)

The user can pick the cell by means of different query methods: cell, point (interpolated), line, cell ID, point ID

Plotted fields can be activated or deactivated

The time period can be selected by acting on the slide bar in the temporal parameterswindow

Once again the plotted fields can be written onto a csv file by clicking the save as CSVbutton

(19)

Cut planes

To create a contour plot across a plane rather than producing isosurfaces, the user must first use theCutfilter to create the cutting plane, on which the contours can be plotted

TheCutfilter allows the user to specify a cutting Plane or Sphere in the Cut Func-tion menu by a center and normal/radius respectively

The user can then run the Contour fil-ter on the cut plane to generate contour lines

Multiple cut planes can be generated using the Add value or the Generate

range of values sub panel

(20)

Clip filter

TheClipfilter works similarly to theCutone, but keeps the mesh and field information on one side of the cutting plane

TheClipfilter allows the user to specify a cutting Plane, Sphere, Box or on the basis of a value for a scalar field

The clip selection can be inverted by activating the Inside out option The visibility option allows the user to activate or deactivate the visibility of the cutting plane, sphere or box

(21)

Threshold

TheThresholdfilter allows to visualize only the cells having the values of the selected field within a specified range

The range can be specified by means of moving the Upper threshold and lower

threshold bars

(22)

Visualizing Lagrangian

To visualize the Lagrangian particle tracking the case must be converted into paraview format

The user should run the applicationfoamToVTKon the case containing the Lagrangian particle tracking (in our case the aachenBomb tutorial for thedieselFoamapplication) foamToVTK . aachenBomb

This command will generate an additional folder namedVTKinside the case directory The user must start paraview typing the following command:

paraview

The case can be opened clicking on the file menu, open, and selecting the VTK directory. By clicking on the*.vtkfile the case will be opened

The user may load all the time steps by clicking on the timesteps button and selecting the Add all choice on the new window

The use must then open the files contained in the lagrangian directory inside the VTK folder

(23)

Visualizing Lagrangian

To display the particles the user must filter the lagrangian field with theGlyphsfilter Then the scalar option must be selected in the scale mode window along with the spheres as glyphs

(24)

The 3D view button

There are settings controlling the 3D view Properties, selected from the View menu, or alternatively by clicking the small 3D View toggle button at the top left of the image display window

The General panel includes the following items which are often worth setting at startup the background color, where white is often a preferred choice for printed material Use parallel projection which is the usual choice for CFD, especially for 2D cases the level of detail (LOD) which controls the rendering of the image while it is being manipulated, e.g. translated, resized, rotated; lowering the levels set by the sliders, allows cases with large numbers of cells to be re-rendered quickly during manipulation

The Annotate panel includes options for including annotations in the image The Display Orientation Axes feature is particularly useful.

The Camera panel includes buttons of Standard Views, settings for Camera Controls and the options for detailed Camera Orientation

The user can store up to 6 camera positions by clicking on a given button using the right mouse button, for subsequent retrieval using the left mouse button

(25)

Viewing sets with paraview

The user may create sets (pintSet, faceSet and cellSet) to perform certain additional operation over the fields, i.e. moving certain points or applying a source term only in a certain area

A set, i.e. a cellSet, can be created in OpenFOAM using the commandcellSet $FOAM_APP/utilities/mesh/manipulation/cellSet

This application creates a list of cells on the base of data read from thecellSetDict file

The user shall try to create a new cellSet in the pitzDaily tutorial case run

cp -r $FOAM_TUTORIAL/simpleFoam/pitzDaily cd pitzDaily/system

cp $FOAM_UTILITIES/mesh/manipulation/cellSet/cellSetDict .

(26)

Viewing sets with paraview

The user must modify the cellSetDict file in the following way: // Name of set to operate on

name myCellSet;

// One of clear/new/invert/add/delete|subset/list action new;

topoSetSources (

// Cells with cell centre within box boxToCell

{

box (-0.05 -0.25 -0.001) (0.1 0.25 0.001); }

);

To create the cell set the user must run the cellSet application cellSet . pitzDaily

(27)

Viewing sets with paraview

Once the cellSet has been created run thefoamToVTKcommand on the pitzDaily case using thecellSetoption:

foamToVTK . pitzDaily -cellSet myCellSet

To know all the available option of thefoamToVTKapplication typefoamToVTKand press enter. It will be displayed the usage of that application

Usage: foamToVTK <root> <case> [-surfaceFields] [-ascii] [-faceSet faceSet name] [-mesh mesh name] [-nearCellValue] [-pointSet pointSet name] [-excludePatches patches to exclude] [-allPatches] [-cellSet cellSet name] [-parallel] [-fields fields] [-constant] [-noPointValues] [-latestTime] [-noInternal] [-time time] To visualize the cellSet the user must open the VTK folder (it works also form a already opened paraFoam windows) in the pitzDaily directory and select the file with the name of the cellSet:myCellSet_*.*

(28)

Data manipulation

It possible to rely on data manipulation utilities which OpanFOAM provides inside its utilities folder

OpenFOAM utilities can also be copied and customized to create user defined utilities An example could be theptotutilities which calculates the total pressure starting from the velocity and pressure field

$FOAM_UTILITIES/postProcessing/miscellaneous/ptot

It is also possible to export data to be visualized with other post-processing tools >cd $FOAM_UTILITIES/postProcessing/dataConversion

>ls

foamDataToFluent foamToFieldview9 foamToVTK foamToEnsight foamToGMV smapToFoam

(29)

Running in parallel

The method of parallel computing used by OpenFOAM is known as domain

decomposition, in which the geometry and associated fields are broken into pieces and allocated to separate processors for solution

The first step is to decompose the domain using thedecomposeParutility The user must edit the dictionary associated with decomposePar named decomposeParDictwhich is located in the system directory of the case

The first entry isnumberOfSubdomainswhich specifies the number of sub-domains into which the case will be decomposed, usually corresponding to the number of processors available for the case

The parallel running uses the public domain openMPI implementation of the standard message passing interface (MPI)

The process of parallel computation involves: decomposition of mesh and fields; running the application in parallel; and, post-processing the decomposed case

(30)

Running in parallel

We shall use the pitzDaily case for the simpleFoam application tutorial tut

cd simpleFoam cd pitzDaily

We can copy the pitzDaily case to the pitzDailyParallel cp -r pitzDaily pitzDailyParallel

And copy into the system directory the directory the decomposeParDict file available in the pitzdailtExptInlet case

(31)

Running in parallel: domain decomposition

The mesh and fields are decomposed using thedecomposeParutility

The underlying aim is to break up the domain with minimal effort but in such a way to guarantee a fairly economic solution

The geometry and fields are broken up according to a set of parameters specified in a dictionary nameddecomposeParDictthat must be located in thesystemdirectory of the case of interest

In thedecomposeParDictfile the user must set the number of domains which the case should be decomposed into: usually it corresponds to the number of cores available for the calculation

numberOfSubdomains 2;

(32)

Running in parallel: domain decomposition

The user has a choice of four methods of decomposition, specified by the method keyword

For each method there are a set of coefficients specified in a sub-dictionary of decompositionDict, named<method>Coeffs, used to instruct the decomposition process

method simple/hierarchical/metis/manual;

simple: simple geometric decomposition in which the domain is split into pieces

by direction, e.g. 2 pieces in the x direction, 1 in y etc.

hierarchical: Hierarchical geometric decomposition which is the same as simple

except the user specifies the order in which the directional split is done, e.g. first in the y-direction, then the x-direction etc

metis: METIS decomposition which requires no geometric input from the user and

attempts to minimize the number of processor boundaries. The user can specify a weighting for the decomposition between processors which can be useful on machines with differing performance between processors

manual: Manual decomposition, where the user directly specifies the allocation of

(33)

Running in parallel: domain decomposition

The coefficients sub-dictionary for thesimplemethod are set as follows: simpleCoeffs

{

n (2 1 1); delta 0.001; }

Where n is the number of sub-domains in the x, y, z directions (nx ny nz) and delta is the cell skew factor, typically 10−3

The coefficients sub-dictionary for thehierarchicalmethod are set as follows: hierarchicalCoeffs { n (2 2 1); delta 0.001; order xyz; }

Where n is the number of sub-domains in the x, y, z directions, delta is the cell skew factor and order is the order of decomposition xyz/xzy/yxz...

(34)

Running in parallel: domain decomposition

The coefficients sub-dictionary for themetismethod are set as follows: metisCoeffs { processorWeights ( 1 ... 1 ); }

It is the list of weighting factors for allocation of cells to processors:<wt1>is the weighting factor for processor 1, etc.

The coefficients sub-dictionary for themanualmethod contains the reference to a file manualCoeffs

{

dataFile "<fileName>"; }

(35)

Running in parallel: domain decomposition

Data files may need to be distributed if only local disks are used in order to improve performance

The root path to the case directory may differ between machines. The paths must then be specified in the decomposeParDict dictionary usingdistributedandroots keywords

The distributed entry should read distributed yes;

and the roots entry is a list of root paths,<root0>,<root1>, . . . , for each node roots <nRoots> ( "<root0>" "<root1>" ... );

where<nRoots>is the number of roots

Each of the processorN directories should be placed in the case directory at each of the root paths specified in the decomposeParDict dictionary

(36)

Running in parallel: domain decomposition

The decomposePar utility is executed in the normal manner by typing decomposePar <root> <case>

The output will look like:

Calculating distribution of cells Selecting decompositionMethod metis ...

Processor 0

Number of cells = 6199

Number of faces shared with processor 1 = 71 Number of processor patches = 1

Number of processor faces = 71 Number of boundary faces = 12667 Processor 1

Number of cells = 6026

Number of faces shared with processor 0 = 71 Number of processor patches = 1

Number of processor faces = 71 Number of boundary faces = 12343

(37)

Running in parallel: domain decomposition

On completion, a set of subdirectories will have been created, one for each processor, in the case directory

The directories are named processorN where N = 0, 1, ... represents a processor number and contains a time directory, containing the decomposed field descriptions, and a constant/polyMesh directory containing the decomposed mesh description. pitzDailyParallel |---> 0 |---> constant |---> processor0 |---> processor1 |---> system

openMPI can be run on a local multiprocessor machine very simply but when running on machines across a network, a file must be created that contains the host names of the machines. The file can be given any name and located at any path

(38)

Running in parallel: execution

An application is run in parallel using thempiruncommand:

mpirun --hostfile <machines> -np <nProcs> <foamExec> <root> <case> <otherArgs> -parallel > log

where:<nProcs>is the number of processors;<foamExec>is the executable, e.g. simpleFoam; and, the output is redirected to a file named log.

The<machines>file contains the names of the machines listed, one machine per line The names must correspond to a fully resolved hostname in the /etc/hosts file of the machine on which the openMPI is run. The<machines>file would contain: hostname1

hostname2 cpu=2 hostname3

In our case it becomes:

(39)

Running in parallel: post-processing

When post-processing cases that have been run in parallel the user has two options: reconstruction of the mesh and field data to recreate the complete domain and fields, which can be post-processed as normal;

post-processing each segment of decomposed domain individually

(40)

Running in parallel: post-processing

After a case has been run in parallel, it can be reconstructed for post-processing by merging the sets of time directories from each processorN directory into a single set of time directories

The reconstructPar utility performs such a reconstruction by executing the command: reconstructPar <root> <case>

In our case it will become:

reconstructPar . pitzDailyParallel Time = 0 Reconstructing FV fields Reconstructing volScalarFields p ... Reconstructing volVectorFields U Reconstructing volTensorFields R No point fields No lagrangian fields

(41)

The sample utility

OpenFOAM provides the sample utility to sample field data for plotting on graphs

The sampling locations are specified for a case through asampleDictdictionary located in the casesystemdirectory

The data can be written in a range of formats including well-known graphing packages such as Grace/xmgr, gnuplot and jPlot

The sampling can be executed by running the utility applicationsampleaccording to the application syntax

sample . pitzDaily

The sampleDict dictionary can be generated with the standard set of keyword entries using FoamX, or by copying a detailedsampleDictfrom a the sample utility folder: $FOAM_UTILITIES/postProcessing/miscellaneous/sample

(42)

The sampleDict file

The sampleDict contains entries to be set according to the user needs interpolationScheme cellPoint;

The choice for the interpolationScheme can be one of the following:

cell : use cell-centre value only, constant over cells, no interpolation at all cellPoint : use cell-centre and vertex values

cellPointFace : use cell-centre, vertex and face values

Vertex values are determined from neighboring cell-centre values whereas face values determined using the current face interpolation scheme for the field (linear, gamma, etc.)

writeFormat raw;

The choice for the write format depends on the application used to plot the series. The user can choose one of the following:

xmgr jplot gnuplot

(43)

The sampleDict file

ThesampleDictfile contains asampleSetsubdictionary which defines where the fields should be sampled

sampleSets ( uniform { name data; axis x; start (-0.0206 0 0); end (0.29 0 0); nPoints 1000; } )

In this subdictionary the user can specify the type of sampling method, the name of samples and how to write point coordinate plus other parameters depending on the method chosen

(44)

The sampleDict file

The user may choose one of the following sampling methods:

uniform: evenly distributed points on line face: one point per face intersection

midPoint: one point per cell, in between two face intersections midPointAndFace: combination of face and midPoint curve: specified points, not necessary on line, uses tracking cloud: specified points, uses findCell

name lineX1;

Thenameentry is typically a filename. After running thesampleapplication the user will find a new folder in the case directory namedsample

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

axis distance;

Specifies how to write point coordinates, options are: x/y/z: x/y/z coordinate only

xyz: three columns

(45)

The sampleDict file

There are also some type specific options:

startandendcoordinate for uniform, face, midPoint and midPointAndFace nPointsnumber of sampling points for uniform

list of coordinates for curve and cloud

The fields list contains the fields that the user wishes to sample fields ( p mag(U) U.component(1) R.component(0) );

The sample utility can parse the following restricted set of functions to enable the user to manipulate vector and tensor fields

U.component(n) writes the nth component of the vector/tensor mag(U) writes the magnitude of the vector/tensor

(46)

Probes

To plot values of fields as functions of the time the user can rely on the new functionObject class

This is a modular plugin that evaluates at every time step the specified field at the specified location

Function objects are created adding them to a function subdict in the controlDict file The user may find an example of how to modify the controlDict file in

$FOAM_TUTORIAL/oodles/pitzDaily/case

This function cannot parse the set of functions as the sample utility does, however in the case of the Ux component extraction the user can easily do that for the U probed field

(47)

Probes

functions (

probes1 {

type probes; // Type of functionObject

// Where to load it from (if not already in solver) functionObjectLibs ("libsampling.so");

probeLocations // Locations to be probed. runTime modifiable! (

(0.1778 0.0253 0.0) );

// Fields to be probed. runTime modifiable! fields ( p ); } );

During the job run it will be created, inside the case directory, a folder named probes containing the probed values

(48)

foamLog

There are limitations to monitoring a job by reading the log file, in particular it is difficult to extract trends over a long period of time

The foamLog script is therefore provided to extract data of residuals, iterations, Courant number etc. from a log file and present it in a set of files that can be plotted graphically The user must run the application in the following manner:

simpleFoam . pitzDaily > log Where the log file can be named arbitrarily The script is executed by

foamLog <root> <case> <logFile>

(49)

foamLog

Once thelogfile has been created thefoamLogmust be executed to generate the required statistics

foamLog <root> <case> <logFile>

The files are stored in a subdirectory of the case directory named logs

Each file has the name<var> <subIter>where<var>is the name of the variable specified in the log file and<subIter>is the iteration number within the time step Those variables that are solved for, the initial residual takes the variable name<var> and final residual takes ¡var¿FinalRes. By default, the files are presented in

two-column format of time and the extracted values >cd pitzDaily

>ls

contCumulative_0 epsilonIters_0 kIters_0 Time_0 UyFinalRes_0 contGlobal_0 executionTime_0 p_0 Ux_0 UyIters_0 contLocal_0 foamLog.awk pFinalRes_0 UxFinalRes_0

epsilon_0 k_0 pIters_0 UxIters_0 epsilonFinalRes_0 kFinalRes_0 Separator_0 Uy_0

References

Related documents