Pyprecice on Python 3.8: undefined symbol when importing cyprecice

Hello,

I was able to install the preCICE library by means of spack (works like a charm coupling two instances of OpenFOAM) but I have run into some errors when attempting to use python with preCICE.

I am trying to install the python bindings for preCICE via pip3 for Python 3.8, which was easy enough, however when I test the bindings with the solverdummy.py scripts included in the github repository I encounter the following error.

python3 solverdummy.py precice-config.xml SolverOne MeshOne
Traceback (most recent call last):
> File “solverdummy.py”, line 5, in
> import precice
> File “/gscratch/sw/contrib/OpenFOAM7-CESG/ThirdParty-7/Anaconda3/lib/python3.8/site-packages/precice/init.py”, line 3, in
> from cyprecice import Interface, action_read_iteration_checkpoint, action_write_iteration_checkpoint, action_write_initial_data, get_version_information
> ImportError: /gscratch/sw/contrib/OpenFOAM7-CESG/ThirdParty-7/Anaconda3/lib/python3.8/site-packages/cyprecice.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZNK7precice15SolverInterface9getMeshIDERKSs

Seems that it stops from reading an ‘undefined symbol’ when importing the precice module within python. I tried to install pyprecice by means of the other methods listed here but haven’t had any success.

Is there someone here who could provide some insight into how I can resolve this?

Best regards,
-Nikki

Nevermind, issue was resolved. I figured out how to install the pyprecice package and was able to run the test case successfully. Sorry to spam the forum with my non-issue.

I downloaded the source code from a previous version (v2.1.1.2) of pyprecice and compiled using the command ‘python3 setup.py install’ within the unzipped folder.

v2.1.1.2

Output from test case

preCICE: This is preCICE version 2.0.2
preCICE: Revision info: no-info [Git failed/Not a repository]
preCICE: Configuring preCICE with configuration: “precice-config.xml”
preCICE: Setting up master communication to coupling partner/s
preCICE: Masters are connected
preCICE: Setting up preliminary slaves communication to coupling partner/s
preCICE: Receive global mesh MeshOne
preCICE: Prepare partition for mesh MeshTwo
preCICE: Setting up slaves communication to coupling partner/s
preCICE: Slaves are connected
preCICE: Compute read mapping from mesh “MeshOne” to mesh “MeshTwo”.
preCICE: Mapping distance min:0 max:0 avg: 0 var: 0 cnt: 3
preCICE: it 1 of 2 | dt# 1 of 2 | t 0 | dt 1 | max dt 1 | ongoing yes | dt complete no | write-iteration-checkpoint |
DUMMY: Writing iteration checkpoint
DUMMY: Advancing in time
preCICE: Compute write mapping from mesh “MeshTwo” to mesh “MeshOne”.
preCICE: Mapping distance min:0 max:0 avg: 0 var: 0 cnt: 3
preCICE: min iteration convergence measure: #it = 1 of 5, conv = false
preCICE: it 2 of 2 | dt# 1 of 2 | t 0 | dt 1 | max dt 1 | ongoing yes | dt complete no | read-iteration-checkpoint |
DUMMY: Reading iteration checkpoint
DUMMY: Advancing in time
preCICE: min iteration convergence measure: #it = 2 of 5, conv = false
preCICE: Time window completed
preCICE: it 1 of 2 | dt# 2 of 2 | t 1 | dt 1 | max dt 1 | ongoing yes | dt complete yes | write-iteration-checkpoint |
DUMMY: Writing iteration checkpoint
DUMMY: Advancing in time
preCICE: min iteration convergence measure: #it = 1 of 5, conv = false
preCICE: it 2 of 2 | dt# 2 of 2 | t 1 | dt 1 | max dt 1 | ongoing yes | dt complete no | read-iteration-checkpoint |
DUMMY: Reading iteration checkpoint
DUMMY: Advancing in time
preCICE: min iteration convergence measure: #it = 2 of 5, conv = false
preCICE: Time window completed
preCICE: it 1 of 2 | dt# 3 of 2 | t 2 | dt 1 | max dt 1 | ongoing no | dt complete yes |
Run finished at Fri Feb 26 14:34:04 2021
Global runtime = 149ms / 0.149s
Number of processors = 1

Rank: 0

                                                                Event |      Count |  Total[ms] |    Max[ms] |    Min[ms] |    Avg[ms] | Time Ratio |

                                                              _GLOBAL |          1 |        149 |        149 |        149 |        149 |          1 |
                                                              advance |          4 |         44 |         41 |          0 |         11 |      0.295 |
                                              advance/m2n.receiveData |          3 |         42 |         40 |          0 |         14 |      0.282 |
                                                 advance/m2n.sendData |          4 |          0 |          0 |          0 |          0 |          0 |
                   advance/map.nn.computeMapping.FromMeshTwoToMeshOne |          1 |          0 |          0 |          0 |          0 |          0 |
advance/map.nn.computeMapping.FromMeshTwoToMeshOne.getIndexOnVertices |          1 |          0 |          0 |          0 |          0 |          0 |
                          advance/map.nn.mapData.FromMeshOneToMeshTwo |          3 |          0 |          0 |          0 |          0 |          0 |
                          advance/map.nn.mapData.FromMeshTwoToMeshOne |          4 |          0 |          0 |          0 |          0 |          0 |
                                                            configure |          1 |          0 |          0 |          0 |          0 |          0 |
                                                             finalize |          1 |          0 |          0 |          0 |          0 |          0 |
                                                           initialize |          1 |        103 |        103 |        103 |        103 |      0.691 |
                                initialize/m2n.acceptMasterConnection |          1 |          6 |          6 |          6 |          6 |     0.0403 |
                                initialize/m2n.acceptSlavesConnection |          1 |         52 |         52 |         52 |         52 |      0.349 |
                          initialize/m2n.broadcastVertexDistributions |          1 |          0 |          0 |          0 |          0 |          0 |
                                 initialize/m2n.buildCommunicationMap |          1 |          0 |          0 |          0 |          0 |          0 |
                                  initialize/m2n.createCommunications |          1 |          4 |          4 |          4 |          4 |     0.0268 |
                            initialize/m2n.exchangeVertexDistribution |          1 |         48 |         48 |         48 |         48 |      0.322 |
                                           initialize/m2n.receiveData |          1 |          0 |          0 |          0 |          0 |          0 |
                initialize/map.nn.computeMapping.FromMeshOneToMeshTwo |          1 |          0 |          0 |          0 |          0 |          0 |

initialize/map.nn.computeMapping.FromMeshOneToMeshTwo.getIndexOnVertices | 1 | 0 | 0 | 0 | 0 | 0 |
initialize/map.nn.mapData.FromMeshOneToMeshTwo | 1 | 0 | 0 | 0 | 0 | 0 |
initialize/partition.prepareMesh.MeshTwo | 1 | 0 | 0 | 0 | 0 | 0 |
initialize/partition.receiveGlobalMesh.MeshOne | 1 | 39 | 39 | 39 | 39 | 0.262 |
solver.advance | 4 | 0 | 0 | 0 | 0 | 0 |
solver.initialize | 1 | 1 | 1 | 1 | 1 | 0.00671 |

                                                                 Name |        Max |  MaxOnRank |        Min |  MinOnRank |    Min/Max |

                                                              _GLOBAL |        149 |          0 |        149 |          0 |          1 |
                                                              advance |         41 |          0 |          0 |          0 |          0 |
                                              advance/m2n.receiveData |         40 |          0 |          0 |          0 |          0 |
                                                 advance/m2n.sendData |          0 |          0 |          0 |          0 |          0 |
                   advance/map.nn.computeMapping.FromMeshTwoToMeshOne |          0 |          0 |          0 |          0 |          0 |
advance/map.nn.computeMapping.FromMeshTwoToMeshOne.getIndexOnVertices |          0 |          0 |          0 |          0 |          0 |
                          advance/map.nn.mapData.FromMeshOneToMeshTwo |          0 |          0 |          0 |          0 |          0 |
                          advance/map.nn.mapData.FromMeshTwoToMeshOne |          0 |          0 |          0 |          0 |          0 |
                                                            configure |          0 |          0 |          0 |          0 |          0 |
                                                             finalize |          0 |          0 |          0 |          0 |          0 |
                                                           initialize |        103 |          0 |        103 |          0 |          1 |
                                initialize/m2n.acceptMasterConnection |          6 |          0 |          6 |          0 |          1 |
                                initialize/m2n.acceptSlavesConnection |         52 |          0 |         52 |          0 |          1 |
                          initialize/m2n.broadcastVertexDistributions |          0 |          0 |          0 |          0 |          0 |
                                 initialize/m2n.buildCommunicationMap |          0 |          0 |          0 |          0 |          0 |
                                  initialize/m2n.createCommunications |          4 |          0 |          4 |          0 |          1 |
                            initialize/m2n.exchangeVertexDistribution |         48 |          0 |         48 |          0 |          1 |
                                           initialize/m2n.receiveData |          0 |          0 |          0 |          0 |          0 |
                initialize/map.nn.computeMapping.FromMeshOneToMeshTwo |          0 |          0 |          0 |          0 |          0 |

initialize/map.nn.computeMapping.FromMeshOneToMeshTwo.getIndexOnVertices | 0 | 0 | 0 | 0 | 0 |
initialize/map.nn.mapData.FromMeshOneToMeshTwo | 0 | 0 | 0 | 0 | 0 |
initialize/partition.prepareMesh.MeshTwo | 0 | 0 | 0 | 0 | 0 |
initialize/partition.receiveGlobalMesh.MeshOne | 39 | 0 | 39 | 0 | 1 |
solver.advance | 0 | 0 | 0 | 0 | 0 |
solver.initialize | 1 | 0 | 1 | 0 | 1 |
DUMMY: Closing python solver dummy…

2 Likes

Great to hear that you could fix it. Since you have installed everything via Spack I wanted to add that there is a package for the Python bindings in Spack. It is called py-pyprecice. We are currently updating the Spack recipe of the bindings for the most recent versions of preCICE, but up to version 2.1.1 there should be suitable bindings integrated in the current Spack.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.