Compilation problem with the OpenFOAM adapter for OpenFOAM 7

Hello,

I am trying to couple OpenFOAM 7 and CalculiX. preCICE is installed correctly like the CalculiX adapter. The openfoam adapter seems to fail. Running a tutorial case gives “Unknown function type preciceAdapterFunctionObject”. The ldd.log of the openfoam adapter installation presents no mistake. The only problem in the wmake.log is "could not open file MeshHandle.hpp " (but I have “Building completed successfully!”).

Thank you for your help.

Please note that the previous message corresponds to the “standard” version of the adapter and not the special one for OF7 (my bad).

However, I have exactly the same error with the good one at https://github.com/precice/openfoam-adapter/tree/OpenFOAM7

Thank you for your help

Hi, @fsalmon!

We have created this Allwmake script to make building easier, but it still cannot handle all the corner cases. Furthermore, OpenFOAM (.org) often introduces breaking changes in every release, which we try to handle by maintaining different branches of the adapter. See our Notes on OpenFOAM for more compatibility details (you already found it while I was writing this). We are also looking for a better way to support multiple OpenFOAM versions at the same time.

The reason ldd.log shows no errors (in runtime linking) is because the previous step (wmake) has failed with the error you describe: could not open file MeshHandle.hpp. However, the error you get is actually a known warning and I always get the same. This simply says that wmake does not know at this point which other files MeshHandle.hpp depends upon and may need more time.

Click to see the beginning of the logfile I get
wmake libso .
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file preciceAdapterFunctionObject.C
could not open file MeshHandle.hpp for source file preciceAdapterFunctionObject.C due to No such file or directory
Making dependency list for source file Adapter.C
could not open file MeshHandle.hpp for source file Adapter.C due to No such file or directory
Making dependency list for source file DisplacementDelta.C
Making dependency list for source file Displacement.C
Making dependency list for source file Force.C
Making dependency list for source file FSI.C
could not open file MeshHandle.hpp for source file FSI/FSI.C due to No such file or directory
Making dependency list for source file CHT.C
could not open file MeshHandle.hpp for source file CHT/CHT.C due to No such file or directory
Making dependency list for source file SinkTemperature.C
Making dependency list for source file HeatTransferCoefficient.C
Making dependency list for source file HeatFlux.C
Making dependency list for source file KappaEffective.C
Making dependency list for source file Temperature.C
Making dependency list for source file CouplingDataUser.C
Making dependency list for source file Interface.C
could not open file MeshHandle.hpp for source file Interface.C due to No such file or directory
Making dependency list for source file Utilities.C

Note: The error Unknown function type preciceAdapterFunctionObject also means that something went wrong during building, which you correctly discovered in the wmake.log.

Thank you for the detailed answer. I have the same logfile.

I understand the difficulties, no problem. I will try to install an older version of OpenFOAM, it is not an inconvenient way for what I want to do.

Have a nice day

I will try to install an older version of OpenFOAM, it is not an inconvenient way for what I want to do.

This is not what I meant. You can still use OpenFOAM 7!

Please upload your complete wmake.log file, so that I can get more information about the problem and help you debug this. It should be very easy.

Ok.

Actually, I think I made a mistake. With the adapter dedicated to OpenFOAM 7, the compilation does not succeed. Here is the wmake.log with the adapter for OF7:
wmake.log (25.6 KB)

and with the standard adapter:
wmake.log (29.3 KB)

Thank you for your help

I assume that you mixed up the two files? In the first file I see:

Adapter.C: In member function ‘void preciceAdapter::Adapter::execute()’:
Adapter.C:515:53: error: ‘DIRECTORY’ is not a member of ‘Foam::fileName’
         if (runTime_.timePath().type() == fileName::DIRECTORY)
                                                     ^~~~~~~~~

This is a breaking change introduced in OpenFOAM 7. Here is the respective diff for the adapter.

I also see:

Adapter.C: In member function ‘void preciceAdapter::Adapter::adjustSolverTimeStep()’:
Adapter.C:755:65: error: no matching function for call to ‘Foam::Time::setDeltaT(double&, bool)’
     const_cast<Time&>(runTime_).setDeltaT(timestepSolver_, false);
                                                                 ^
In file included from /home/fsalmo01/OpenFOAM/OpenFOAM-7/src/finiteVolume/lnInclude/fvCFD.H:6:0,
                 from Interface.H:6,
                 from Adapter.H:4,
                 from Adapter.C:1:
/home/fsalmo01/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/Time.H:516:26: note: candidate: virtual void Foam::Time::setDeltaT(const dimensionedScalar&)
             virtual void setDeltaT(const dimensionedScalar&);
                          ^~~~~~~~~
/home/fsalmo01/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/Time.H:516:26: note:   candidate expects 1 argument, 2 provided
/home/fsalmo01/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/Time.H:519:26: note: candidate: virtual void Foam::Time::setDeltaT(Foam::scalar)
             virtual void setDeltaT(const scalar);
                          ^~~~~~~~~

This is a breaking chane introduced in OpenFOAM 6. Here is the diff for the adapter.


In the second file I see:

Interface.C: In member function ‘void preciceAdapter::Interface::configureMesh(const Foam::fvMesh&)’:
Interface.C:95:49: warning: ‘*((void*)&<anonymous> +8)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             for (int i = 0; i < faceCenters.size(); i++)
                                 ~~~~~~~~~~~~~~~~^~
Interface.C:97:58: warning: ‘*((void*)&<anonymous> +16)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                 vertices[verticesIndex++] = faceCenters[i].x();
                                                          ^

This is a known warning, which we only get with some compiler versions. There is currently an open issue for this: https://github.com/precice/openfoam-adapter/issues/28

Do you now have a working code? Was it enough to use the adapter version for OpenFOAM 7?

Yes you are right, I mixed both repositories and then gave to you the wrong indications. The first file is for the standard adapter and the second one is for the modified adapter. Sorry.

I will try to change the compiler as you recommend. Thank you

I will try to change the compiler as you recommend.

I don’t actually recommend changing the compiler. This is just a warning that you can ignore. Installing a different compiler can be quite painful, so if it works, just keep it like this.

Does the included tutorial run?

No they do not work. Both fluid and solid are not linked. I have:

--> FOAM FATAL ERROR:
Unknown function type preciceAdapterFunctionObject

I also tried other versions of OpenFOAM (4 and 5) with the adapter for “old” versions and I have exactly the same error: “could not open file MeshHandle.hpp for source file …”

I also tried other versions of OpenFOAM (4 and 5) with the adapter for “old” versions and I have exactly the same error: “could not open file MeshHandle.hpp for source file …”

But, as I explained above, this is not an error. If your wmake.log does not show any errors later on, please look into your ldd.log and upload it here.

Note: In wmake.log you can check for compilation and linking at build time errors. In ldd.log you can check for linking at runtime errors. It can be that the adapter is built successfully, but then at runtime it cannot link to preCICE.

Hello,

Ok, thank you for the reply. In the wiki, it is clearly written that the error “Unknown function type preciceAdapterFunctionObject” should stem from the building of the adapter.

Here is the ldd.log:

ldd.log (5.8 KB)

Here is the ldd.log

But this also does not show any errors, everything looks good.

I sometimes get the Unknown function type preciceAdapterFunctionObject error because I build the adapter for one OpenFOAM version, but then open a new terminal and accidentally load another OpenFOAM version, for which I have not built the adapter. Do you maybe have the same problem here?

In the wiki, it is clearly written that the error “Unknown function type preciceAdapterFunctionObject” should stem from the building of the adapter.

This is the most common case, yes. Thank you for pointing this out, I added a note for other cases.

Please check that you have the adapter installed in your current OpenFOAM environment and then that it links correctly:

ls $FOAM_USER_LIBBIN
ldd $FOAM_USER_LIBBIN/libpreciceAdapterFunctionObject.so

Thank you for your help ! You are right, the problem stems from $FOAM_USER_LIBBIN. Actually, I do not know why, $FOAM_USER_LIBBIN gives a wrong path which does not exist. However, using $FOAM_LIBBIN works perfectly for me, the library is written in the good folder.

Perhaps, others would have a look in this repository but I did not think to do that. It might be a good thing to add a sentence in the wiki to check the path given by OpenFOAM. In particular, writing what should be the path with imaginary $HOME name ? It is not the first time for me that the paths provided by OpenFOAM are not good. It is just a suggestion.

Thank you again for your great help

I added another hint in the wiki, but I cannot write something very specific: this path depends also on your OpenFOAM version and platform. Checking if it exists should be enough to find out the source of the problem. Also, just relying on $FOAM_USER_LIBBIN is the standard OpenFOAM practice, so I don’t know if we could prevent this corner case in any other way.

Is the adapter now working for you?

I assume the topic as solved. For your problem with $FOAM_USER_LIBBIN, I recommend that you try to find the reason starting from your $FOAM_ETC/config.sh/settings, line 164. You may then submit a bug report to OpenFOAM, or ask on CFD Online for help.

Hi,

Yes it is now working so the issue is solved.

As regards the environment variables, I think the problem stems from: WM_PROJECT_USER_DIR=$HOME/OpenFOAM/$USER-7
because the definition of $FOAM_USER_LIBBIN uses this path.

I do not understand the $USER, in the directory OpenFOAM, I have OpenFOAM-7 and ThirdParty-7. In the installation wiki https://openfoamwiki.net/index.php/Installation/Linux/OpenFOAM-7/Ubuntu/18.04 they do not add a directory $USER-7 in OpenFOAM. I do not know if I miss something but I do not understand how it is possible to have a correct path for $WM_PROJECT_USER_DIR.

Have a good day