CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Coupling Openfoam and PyTorch

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   June 14, 2019, 13:42
Default Coupling Openfoam and PyTorch
New Member
Join Date: Feb 2019
Posts: 3
Rep Power: 6
scientium is on a distinguished road
Hello Foamers,

I am trying to couple OpenFOAM and PyTorch (C++ API). I am almost done except one final bit.

I am using cmake to compile the libraries together. I am trying to build the laplacianFOAM with PyTorch. In the CMakeLists.txt file, I must include

find_package(Torch REQUIRED)

to include torch (of course!!).

This works well if I do not have any IOobject in my source. I am consistently getting the following error during compilation.

CMakeFiles/mylaplacianFoam.dir/ mE[_ZTVN4Foam8OPstreamE]+0x80): undefined reference to `Foam::UOPstream::writeQuoted(std::string const&, bool)'
collect2: error: ld returned 1 exit status
CMakeFiles/mylaplacianFoam.dir/build.make:97: recipe for target 'mylaplacianFoam' failed
make[2]: *** [mylaplacianFoam] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mylaplacianFoam.dir/all' failed
make[1]: *** [CMakeFiles/mylaplacianFoam.dir/all] Error 2
Makefile:83: recipe for target 'all' failed

More specifically, while compiling the solver, the following declaration

volScalarField T

gives me the said error. If I comment out the IOobject declaration, I do not face any compilation error. I also do not get any compilation error if I use wmake (without torch library, haven't tried that route yet).

So, I have two questions.

1. Why is this error cropping up when I include the PyTorch libraries?
2. Is there another way in which I can read the T data without using IOobject?

EDIT:: Found the cause of the problem. It seems that the flag -D_GLIBCXX_USE_CXX11_ABI needs updating from 0 to 1. However, it still does not solve the problem. It still gives compilation error. I looked up the internet and it seems that either I have to recompile my openfoam or compile mylaplacianFoam with both the flags. Anyone knows how to do either of these things?

Last edited by scientium; June 15, 2019 at 02:05. Reason: Made progress on debugging
scientium is offline   Reply With Quote


c++, compiling, pytorch

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

All times are GMT -4. The time now is 18:16.