22
It's the little things that matter: Improving Speed and Stability in OpenFOAM 4 th UK & Eire OpenFOAM User Meeting 19 th April 2016, Exeter, UK Dr. Aleksander J. Dubas, Research Engineer, TSL Technology Ltd. (& Visiting Academic @ University of Southampton)

It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

It's the little things that matter:Improving Speed and Stability in OpenFOAM

4th UK & Eire OpenFOAM User Meeting19th April 2016, Exeter, UK

Dr. Aleksander J. Dubas,Research Engineer,TSL Technology Ltd.

(& Visiting Academic @ University of Southampton)

Page 2: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

About Me

● First started using OpenFOAM to simulate flow through valves and other hydraulic flows in 2010

● Also (coincindentally) started to dabble with Linux at around the same time

Page 3: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

About Me

● PhD in Complex Systems Simulation, awarded 2014:

– “Robust Automated Computational Fluid Dynamics Analysis and Design Optimisation of Rim Driven Thrusters”

– Simulations all done in OpenFOAM (automation and optimisation using Python)

Page 4: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

About Me

● Innovate UK - Knowledge Transfer Partnership– Used OpenFOAM to design, prototype, test and put into production a

new thruster with world class performance

Page 5: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

About Me

Page 6: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

About This Presentation

Better

Cheaper Faster

Page 7: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

Pre-Solution with potentialFoam

● Initialises a velocity field● Pressure field can also be initialised with -writep flag

– This may be an unstable initialisation

– Method (and results) changed at version 2.4.0:http://www.openfoam.org/version2.4.0/

● Add -noFunctionObjects to stop Function Objects calculations (e.g. forces)

Page 8: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

Turbulence Model Selection

k-epsilon k-omega SST

Page 9: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

Field Cacheing

● In system/fvSolution add:

cache { grad(U); }

● Instant solving speed boost (slight increase in memory usage)

Page 10: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Double Glazing Problem

Hot (inside) Cold (outside)

Page 11: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Double Glazing Problem

Hot (inside) Cold (outside)

- 1100 K

NOT PHYSICALLY POSSIBLE!

Using buoyantBoussinesqPimpleFoam (transient solver)

Page 12: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Double Glazing Solution

● In system/fvSchemes change:

div(phi,T) Gauss upwind;

to

div(phi,T) bounded Gauss upwind;

● Moral of the story: boundedness is not just for steadyState

Page 13: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

● Compiling your own copy gives faster solutionsthan pre-packaged binaries

● However it does take a while to compile them (trade-off)● It is not as easy

– But the instructions at http://www.openfoam.org/download/source.php are very helpful

● Can add a little more edge with a few compiler flags

Page 14: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

Page 15: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

● -march=native

● N.B. only if you are compiling on the same machine you are running on

● Up to 20% faster!

Page 16: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

● Where? (your specific location may vary)– $HOME/OpenFOAM/OpenFOAM-3.0.x/wmake/rules/linuxGcc64

● Which files?– In c and c++

● What do I change?– cc = gcc -m64 -march=native

– CC = g++ -m64 -march=native

Page 17: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

● -mfpmath=sse

● -mfpmath=both and -mfpmath=sse,387 reduce performance

● Available SSE instructions are activated by -march=native

● An extra 3% faster

Page 18: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

● Where? (your specific location may vary)– $HOME/OpenFOAM/OpenFOAM-3.0.x/wmake/rules/linuxGcc64

● Which files?– In c and c++

● What do I change?– cc = gcc -m64 -march=native -mfpmath=sse

– CC = g++ -m64 -march=native -mfpmath=sse

Page 19: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

● -funroll-loops

● Noticeably increases compilation time

● An extra 1% faster (maybe)

● Worth it? Not sure.

Page 20: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

A Compilation of Improvements

● Where? (your specific location may vary)– $HOME/OpenFOAM/OpenFOAM-3.0.x/wmake/rules/linuxGcc64

● Which files?– In cOpt and c++Opt

● What do I change?– cOPT = -O3 -funroll-loops

– c++OPT = -O3 -funroll-loops

Page 21: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

Summary

● Five ways to speed up and/or stabilise your solutions:– Pre-solve with potentialFoam (with or without -writep)

– Choose an appropriate turbulence model

– cache{ grad(U); }

– div(phi,T) bounded Gauss upwind;

– Compile with a few extra flags

Page 22: It's the little things that matter: Improving Speed and ...ukri-openfoam.ex.ac.uk/docs/Tuesday/presentations/... · It's the little things that matter: Improving Speed and Stability

Thank You for Listening

● Any questions?

● Contact Details:– Email: [email protected]

– Skype: ajdubas

– Twitter: @ajdubas