May need independent MPI initialize/finalize
As discussed with @Mattijs, but also of interest for @sbna
When Pstream initializes MPI, it checks for a previous initialization of MPI and skips if not required. It then also skips attaching transfer buffers. On finalize, it does similar checks.
This means that MPI initialization outside of OpenFOAM will result in the buffers not being setup. Exiting OpenFOAM will finalize MPI, even if OpenFOAM was not the one who initialized it.
Need the following:
- if an external app initialized, still initialize our buffers
- only finalize if OpenFOAM was also the one initializing, but always clean up our buffers if we created then.
Open question: when MPI was initialized elsewhere, are there any potential conflict when calling freePstreamCommunicator?