CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Coupling Openfoam and PyTorch (https://www.cfd-online.com/Forums/openfoam-programming-development/218284-coupling-openfoam-pytorch.html)

scientium June 14, 2019 12:42

Coupling Openfoam and PyTorch
 
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/laplacianFoam.C.o:(.data.rel.ro._ZTVN4Foam8OPstrea 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
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);



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?

kont87 March 30, 2024 06:08

Hello,

Did you find a solution?

Kind regards


All times are GMT -4. The time now is 19:32.