You are on page 1of 20

Supplement

Qualitative postprocessing – Coprocessing


Coprocessing
• CFD simulations have the potential to overwhelm any computer with the output
obtained from simulations.
• The traditional approach is to run a simulation and save the solution at given time-
steps or intervals for post processing at a later time.
• An alternative way to do post processing, is to extract results (or pretty pictures) while
the simulation is running (on-the-fly), this is coprocessing.

GEOMETRY

MESH

SOLVER CO-PROCESSING

POST-PROCESSING
Coprocessing
• For unsteady and big simulations, coprocessing is an alternative if we do not
want to overflow the system with tons of data.
• By doing coprocessing, we can do visualization on-the-fly.
• In principle, coprocessing is similar to doing sampling using
functionObjects, but when we do coprocessing we output pretty pictures
(e.g., streamlines, iso-surfaces, cut-planes).
• Instead, when we do sampling using functionObject we save data for
plotting (we save a quantity of interest).
• An added benefit of coprocessing is that results can be immediately
reviewed, and problems can be immediately addressed.
• Coprocessing requires that you identify what you want to see before running
the simulation. You need to plan everything in advanced.
• In OpenFOAM®, you can output on-the-fly streamlines, cutting planes, iso-
surfaces, near surface fields, forces and force coefficients (they can be
written into data bins).
Coprocessing

• Let us do some coprocessing. Go to the directory:

$PTOFC/postprocessing/vespacoarse/

• In the case directory, you will find the README.FIRST file. In this file, you will find the general instructions of
how to run the case. In this file, you might also find some additional comments.
• You will also find a few additional files (or scripts) with the extension .sh, namely, run_all.sh,
run_mesh.sh, run_sampling.sh, run_solver.sh, and so on. These files can be used to run the case
automatically by typing in the terminal, for example, sh run_solver.
• We highly recommend to open the README.FIRST file and type the commands in the terminal, in this way
you will get used with the command line interface and OpenFOAM® commands.
• If you are already comfortable with OpenFOAM®, use the automatic scripts to run the cases.
Coprocessing

Geometry and computational domain


Coprocessing
What are we going to do?

• We will use this case to do coprocessing using functionObjects.


• We do not need to generate the mesh or run the simulation for a long time.
However, all the dictionaries are included.
• The dictionaries to initialize the solution using potentialFoam are also
included
• We will run the simulation for 20 iterations and then we will visualize the
solution.
• In this case, we will use the solver simpleFoam with turbulence modeling,
and we will run in serial, but feel free to run in parallel.
Coprocessing
Running the case

• In the terminal window type:

1. $> foamCleanTutorials
3. $> rm –f 0
4. $> cp –r 0_org 0
5. $> tar –xzvf constant.tar.gz
6. $> cp system/simplefoam/* system/
7. $> simpleFoam > log | tail –f log
8. $> paraFoam

• In step 5 we uncompress the pre-generated mesh


• In step 6 we copy the dictionaries for the solver simpleFoam.
• In step 7 we run the solver simpleFoam.
Coprocessing
The controlDict dictionary
49 functions • Let us take a look at the bottom of the controlDict
50 (
51 dictionary file.
53 #include "readFields"
54 #include "streamLines" • We define the functionObjects in the sub-dictionary
55 #include "cuttingPlane"
56 #include "wallBoundedStreamLines" functions (lines 49-89).
57 #include "./system/files/isoSurface"
58 #include "forceCoeffs" • In this case, instead of defining inline the
88
89 ); functionObject, we are using the directive include.
• In the directory system you will find the dictionaries files
readFields, streamLines, cuttingPlane,
wallBoundedStreamLines, and forceCoeffs.
• In the directory system/files you will find the
dictionary file isoSurface.
• If you use the include directive, you will need to update
the controlDict dictionary in order to read any
modification done in the included dictionary files.
• By the way, you can give any name to the input files
defined in lines 53-58.
Coprocessing
The cuttingPlane dictionary
• In this dictionary we define the cutting planes.
• Remember, we need to know the location of the cutting
planes a-priori.

1 cuttingPlane Name of the functionObject


2 {
3 type surfaces;
4 functionObjectLibs ("libsampling.so");
5
6 //writeControl outputTime;
7
9 writeControl timeStep; Saving frequency. Can be different from
10 writeInterval 5;
11
the saving frequency of the solution
12
13 surfaceFormat vtk; Fields to sample and sample format.
14 fields ( p U k omega);
15
VTK format can be visualize in paraFoam/paraview
16 interpolationScheme cellPoint;
17
18 surfaces
19 (
20 xNormal Name of the plane
21 {
22 type cuttingPlane;
23 planeType pointAndNormal;
24 pointAndNormalDict
25 {
26 basePoint (0 0 0); Plane type and plane location
27 normalVector (1 0 0);
28 }
29 interpolate true;
30 }
Coprocessing
The cuttingPlane dictionary
31
32 yNormal Name of the plane
33 {
34 type cuttingPlane;
35 planeType pointAndNormal;
36 pointAndNormalDict
37 {
38 basePoint (0 0 0);
39 normalVector (0 1 0); Plane type and plane location
40 }
41 interpolate true;
42 }
43
44 zNormal Name of the plane
45 {
46 type cuttingPlane;
47 planeType pointAndNormal;
48 pointAndNormalDict
49 {
50 basePoint (0 0 1);
51 normalVector (0 0 1); Plane type and plane location
52 }
53 interpolate true;
54 }
55
56
57
);
• The output of this functionObject is saved in the
58 } directory postProcessing/cuttingPlane
• In this directory, you will find many time directories
with the sampled data.
• Inside each directory you will find a series of files
with the VTK extension, you can open these files
in paraFoam/paraview
Coprocessing
The cuttingPlane dictionary output
• Planes sampled using functionObjects.
• Each plane contains the information of the fields sampled (U, p, k and omega).
Coprocessing
The streamLines dictionary
• In this dictionary we define the streamlines.
• Remember, we need to know the location from where to
release the streamlines a priori.

1 streamLines Name of the functionObject


2 {
3 type streamLine;
4
5 //writeControl outputTime;
6
7
8 writeControl timeStep; Saving frequency. Can be different from
9 writeInterval 5;
10
the saving frequency of the solution
11
12 setFormat vtk;
13
14 // Velocity field to use for tracking.
15 UName U; Velocity field used to compute the streamlines
16
17 // Tracked forwards (+U) or backwards (-U)
18 trackForward true;
19
20 //Names of fields to sample. Mustcontain velocity field!
21 fields (U p); Fields to sample
22
23 // Steps particles can travel before being removed
24 lifeTime 10000;
25
Coprocessing
The streamLines dictionary
38
39 // Seeding method. See the sampleSets in sampleDict.
40 seedSampleSet uniform; Seed type
41
42 uniformCoeffs
43 {
44 type uniform; Options related to the seeding of the streamlines
45 axis x; //distance;
46
48 start (-1 0 0);
49 end (-1 0 1.6);
50 nPoints 20;
51 }
52 }

• The output of this functionObject is saved in the


directory
postProcessing/sets/streamLines
• In this directory, you will find many time directories
with the sampled data.
• Inside each directory you will find a series of files
with the VTK extension, you can open these files
in paraFoam/paraview
Coprocessing
The streamLines dictionary output
• Streamlines sampled using functionObjects.
• Each streamlines contains the information of the fields sampled (U and p).
Coprocessing
The system/files/isoSurface dictionary
• In this dictionary we define the iso-surfaces.
• Remember, we need to know the value of the iso-
surface a priori.

2 isoSurface Name of the functionObject


3 {
4 type surfaces;
5 functionObjectLibs ("libsampling.so");
6
10 writeControl timeStep; Saving frequency. Can be different from
11 writeInterval 10;
12
the saving frequency of the solution
13 surfaceFormat vtk;
14 fields ( p U k omega); Fields to sample
15
16 interpolationScheme cellPoint;
17
19 surfaces
20 (
21
22 constantIso Name of the iso-surface
23 {
24 // Iso surface for constant values.
25 // Triangles guaranteed not to cross cells.
26 type isoSurfaceCell;
27 isoField p; Field used to create the iso-surface
28 isoValue 30;
29 interpolate false;
and its value
30 regularise false;
33 }
34
Coprocessing
The system/files/isoSurface dictionary
35 interpolatedIso Name of the iso-surface
36 {
37 // Iso surface for interpolated values only
38 type isoSurface;
39 isoField p; Field used to create the iso-surface
40 isoValue 80;
41 interpolate true;
and its value
48
49 }
50
62
63 );
64
65
66 }

• The output of this functionObject is saved in the


directory postProcessing/isoSurface
• In this directory, you will find many time directories
with the sampled data.
• Inside each directory you will find a series of files
with the VTK extension, you can open these files
in paraFoam/paraview
Coprocessing
The system/files/isoSurface dictionary output
• Iso-surfaces sampled using functionObjects.
• Each iso-surface contains the information of the fields sampled (U, p, k and omega).
Coprocessing
The wallBoundedStreamLines dictionary
• In this dictionary we define the wall bounded
streamlines.
• The streamlines are released from a surface close to the
motorBike patch using the field Unear.
1
2 // Interpolate U to create near-wall UNear
3 near Create the near field
4 {
5 functionObjectLibs ("libfieldFunctionObjects.so");
6
7 type nearWallFields;
8
9 writeControl outputTime; Saving frequency. Can be different from
14 the saving frequency of the solution
18 fields
19 (
20 (U UNear) Use U to create the Unear field
21 );
22
23 // Patches/groups to sample (regular expressions)
24 patches (motorBike); Interpolate the near fields to this patch
25
26 // Distance to sample
27 distance 0.01; //0.001 Distance from the patch to the near field
28 }
29
30
31
Coprocessing
The wallBoundedStreamLines dictionary
33 wallBoundedStreamLines Name of the functionObject
34 {
35 // Where to load it from (if not already in solver)
36 functionObjectLibs ("libfieldFunctionObjects.so");
37 type wallBoundedStreamLine;
38
39 writeControl outputTime;
40
45 setFormat vtk;
46
47 // Velocity field to use for tracking.
48 U UNear; Velocity field used to compute the streamlines
49
50 // Tracked forwards (+U) or backwards (-U)
51 trackForward true; Fields to sample
52
53 interpolationScheme cellPoint;
54
64 fields (U UNear p k); Options related to the seeding of the wall bounded streamlines
65
66 // Steps particles can travel before being removed
67 lifeTime 100;
68
69 // Cloud name to use • The output of this functionObject is saved in the
70
71
cloudName wallBoundedParticleTracks; directory
72 // Seeding method. See the sampleSets in sampleDict. postProcessing/sets/wallBoundedStream
73
74
seedSampleSet patchSeed;
Lines
75 patchSeedCoeffs
76 { • In this directory, you will find many time directories
77 type patchSeed;
78 patches (motorBike); with the sampled data.
79 axis xyz; //x, y, z, xyz, distance;
80 maxPoints 20000; • Inside each directory you will find a series of files
81 }
82 } with the VTK extension, you can open these files
in paraFoam/paraview
Coprocessing
The cuttingPlane dictionary output
• Wall bounded streamlines sampled using functionObjects.
• Each streamlines contains the information of the fields sampled (U, Unear, p and k).

You might also like