Hello preCICE community,
I am opening this topic in the hopes of following:
- It works as guidance for future developers working on OF adapters
- Getting help on debugging OpenFOAM adapter or OF related things
Kubuntu 20.04 LTS
preCICE v2.3.0, compiled in Debug mode
OpenFOAM v7 (Optimised version),
OpenFOAM v7 adapter compiled in Debug mode
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
As only a common user of OpenFOAM, I am not very well versed in debugging OpenFOAM or OpenFOAM libraries. But following some general tips, I am able to make do.
- Here is a good post on CFD online forum with the banana trick. Good when you are only dealing with the OpenFOAM case files
Info << "Does this print in the terminal way" << endl;, where we put print statements. Good if you are messing with solvers
DEBUG(adapterInfo("message goes here"));, in case of preCICE OpenFOAM adapters (I think this needs
ADAPTER_PREP_FLAGS = -DADAPTER_DEBUG_MODE).
- Coupled OF simulation: I only run the Fluid participant and wait before I run the other participant. Open the
openfoam-adapterproject in QT, Debug > Start Debugging > Attach to Running application > Choose the solver running for Fluid participant. After this, I run the 2nd participant, and usually, I can get the debugger to stop on
Interface.C. (I have not been able to enter into modules).
- After sourcing OpenFOAM environment set
WM_COMPILE_OPTION=Debug(this gives some extra terminal info), but will help with QT debug option above.
- When modifying solver or adapter, we can get same result as previous point by modifying first line in
EXE_INC = \to
EXE_INC = -O0 -fdefault-inline -ggdb3 -DFULLDEBUG \
With the methods mentioned above, most user-related issues are solved.
I am hoping to get some thoughts/hints/opinions on the following issue I personally face. In my particular case, I have added extra modules to the OpenFOAM adapter and I want to debug the modules.
- With the methods mentioned above, I am not able to start debugging the OpenFOAM adapter, before it starts running, as I am merely attaching the debugger to a running application. So I am only able to debug from the point I attach to the application.
- How can we access data values (fields values) that are exchanged by the OpenFOAM adapter? Currently, I see what fields are exchanged but data values are inaccessible. Do we need to compile OpenFOAM with Debug mode?
With this post, I am hoping to hear from OpenFOAM adapter developers how they handle debugging the OpenFOAM adapter and their experience with debugging.