OpenFOAM tricks & tips: Debugging and VSCode intellisense

Bram De Jaegher

OpenFOAM tricks & tips:

Debugging and VSCode intellisense

Motivation

OpenFOAM is compiled for maximal performance (default)

Floating point error (e.g. division by zero):

             Foam::error::printStack(Foam::Ostream&) at ??:? 
             Foam::sigFpe::sigHandler(int) at ??:? 
             ? in "/lib/x86_64-linux-gnu/libc.so.6" 
		

OpenFOAM compiled with debug modus (poor performance):

             Program received signal SIGFPE, Arithmetic exception. 
             0x00007ffff6668e5f in Foam::divide <double> (res=..., f1=..., 
             at  /home/bram/openfoam4_debug/src/OpenFOAM/lnInclude/FieldFunctions.C:631/  
            631 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
		

Notice: specific error info, file location, # line, etc.

Without debug version:

With debug version:

Debugging in OpenFOAM

Warning: Live session incoming!

GDB is really useful when developing OpenFOAM applications, not only for debugging but also as sandbox.

References

VSCode

VSCode

I don't program in OpenFOAM, why is this useful?