TotalKineticEnergy

From OpenFOAMWiki

1 Introduction

This is a very simple post processing tool to get the total kinetic energy of your domain. I think there are better workflows around to implement this (for example as a function lib) but non the less I want to share it with you. The reason for creating this tool are

  • getting more familiar with OpenFOAM code
  • getting more familiar with C++
  • self-interest

Valid versions: OF Version 23x.png

2 Description

This application is a post processing tool and calculates the total kinetic energy in your domain. You can use this tool for compressible and incompressible fluids. In order to use this tool you only have to download, compile and run it.

Incompressible fluids

If you wnat to calculate the total kinetic energy for a incompressible fluid the tool ask for a density. Therefor you have to insert the density (dimensioned) to the transportProperties.

Compressible fluids

For compressible fluids the density is looked up in each time step. Hence this, be sure that your solver is saving the density in each time step. If there is no density file the tool will not calculate the total kinetic energy and output that no density field is available:

~:$ totalKineticEnergy -compressible -latestTime

Create time

Create mesh for time = 10000

Time = 10000
Reading field U
    no rho field

End
Output

If everything is fine you will get the output of the total kinetic energy in Joule.

~:$ totalKineticEnergy -time 9001 -compressible
Create mesh for time = 9001

Time = 9001
Reading field U
Reading field rho

    Total kinetic energy: 9.90576e-12 [J]

End

3 Download

The tool is available on the bitbucket server. Just clone the repository and build the post-processing tool.

git clone https://shor-ty@bitbucket.org/shor-ty/totalkineticenergy.git
cd totalKineticEnergy
wmake

3.1 Other versions

For the next OpenFoam versions I try to keep that tool up to date