zhulianhua/dugksFoam

Better create a MPI compilation stuff??

sanguinariojoe opened this issue · 2 comments

In the user manual you suggest to override C++ OpenFOAM rules:

Change the compier from CXX to MPICXX, because we implemented
the velocity-space parallel feature which use the standard alone MPI
instead of the Pstream library of OpenFOAM.
cp $WM_DIR/rules/$WM_ARCH$WM_COMPILER/c++ \
$WM_DIR/rules/$WM_ARCH$WM_COMPILER/c++.bak
sed -i "s/$WM_CXX/mpicxx/" \
$WM_DIR/rules/$WM_ARCH$WM_COMPILER/c++

The obvious drawback is that you are editing OpenFOAM installed rules, which may affects future compilations (bad for rockies). Instead of that, you can create alternative compilation rules:

cp -r $WM_DIR/rules/$WM_ARCH$WM_COMPILER "$WM_DIR/rules/$WM_ARCH"MPI
export WM_COMPILER=MPI
sed -i "s/$WM_CXX/mpicxx/" $WM_DIR/rules/$WM_ARCH$WM_COMPILER/c++

It's a bit more complicated, but cleaner in my opinion, since you are actually not changing nothing in the OF installation.

Thanks for the good and clever suggestion.
As some users have no permission to write in the OpenFOAM installation path, so in the later version, I've changed the compilation method to :

cp `which wmake` .
sed -i '316s/makeType/makeType CC=mpicxx/' wmake
./Allwmake

Note, in the Allwmake, I used ./wmake just copied instead of the OpenFOAM system wmake.
But this works only for OpenFOAM 2.4.0 as later OpenFOAM release changed the wmake script.

I haven't found a better clean solution yet, but I've put your suggestion on the README page.

Found a better solution in commit 56dcadd