Python sover: multiple MPI initializations

Hello,

I have successfully installed the preCICE adapter for coupling OpenFOAM models to each other, as well as the Python bindings to connect two Python solvers to one another, but have run into issues when attempting to couple an OpenFOAM model with a ‘Pythonic’ solver.

After initializing an OpenFOAM model and a Python model using the attached Allrun script, the following error is output by the Python model (Solid1.log) and the OpenFOAM model waits at the first timestep for initialization of the preCICE coupling to begin.


Open MPI has detected that this process has attempted to initialize
MPI (via MPI_INIT or MPI_INIT_THREAD) more than once. This is
erroneous.

[n2554:72834] *** An error occurred in MPI_Init
[n2554:72834] *** reported by process [4192272385,0]
[n2554:72834] *** on a NULL communicator
[n2554:72834] *** Unknown error
[n2554:72834] *** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
[n2554:72834] *** and potentially your MPI job)

Seems as though there is a problem with the initialization of MPI by the Python script, but I do not know enough about how the Python bindings initialize their connection to the preCICE driven MPI to understand where the issue is arising from.

Can anyone offer assistance or guidance?

Best,
-Nicolette

p.s. I have attached all files relevant to the issue to this post.

Allrun.sh.txt (2.3 KB)
Fluid1.log (4.8 KB)
precice-config-Py-OF.xml (2.4 KB) slurm-1592394.out (5.0 KB) Solid1.log (864 Bytes) Solid1Solver.py.txt (4.1 KB)

Hi @nikki,

preCICE-wise, your code looks correct. In Solid1Solver.py you are also using some additional libraries, such as OpenSees. Does this also initialize MPI? I could imagine that OpenSees and preCICE could conflict in this aspect, but normally they should not.

What happens if you replace Sees with some dummy values and not call OpenSees anymore? This could help understand what is going on.

Hello @Makis,

Thank you for your response. I wasn’t aware that OpenSeesPy was initializing MPI, but it seems as though it was.
I commented out all lines referencing anything OpenSees, and have encountered a new issue. I have attached log files for reference.

—[precice] e[0m This is preCICE version 2.0.2
—[precice] e[0m Revision info: no-info [Git failed/Not a repository]
—[precice] e[0m Configuring preCICE with configuration: “./precice-config-Py-OF.xml”
—[precice] e[0m Setting up master communication to coupling partner/s
—[precice] e[0m Masters are connected
—[precice] e[0m Setting up preliminary slaves communication to coupling partner/s
—[precice] e[0m Receive global mesh Fluid1-Mesh
—[precice] e[0m Prepare partition for mesh Solid1-Mesh
—[precice] e[0m Gather mesh Solid1-Mesh
—[precice] e[0m Send global mesh Solid1-Mesh
> —[precice] e[31mERROR: e[0m The provided mesh Solid1-Mesh is invalid (possibly empty).

It seems that the Solid1_Mesh is not being assigned properly, and thus preCICE cannot complete the coupling. I assumed that the calls to

meshID = interface.get_mesh_id(“Solid1_Mesh”)
vertexIDs = interface.set_mesh_vertices(meshID, grid)

in Solid1Solver.py would be sufficient to achieve this.
Is there a command I am missing?

Regards,
-Nicolette

Fluid1.log (5.2 KB)
slurm-1593374.out (5.1 KB)
Solid1.log (947 Bytes)

That’s nice to see! Then we can further investigate why the Python code triggers the original error:

Open MPI has detected that this process has attempted to initialize
MPI (via MPI_INIT or MPI_INIT_THREAD) more than once. This is
erroneous.

@BenjaminRodenberg @IshaanDesai have you seen such problems with python codes before?

@nikki could you please open a new thread for the The provided mesh Solid1-Mesh is invalid (possibly empty) error? Before that:

  • Check that you actually give values to grid (and that it is “array-like”, but it looks correct to me). Check also that the name Solid1-Mesh is used correctly everywhere (code & config).
  • Upgrade to at least preCICE v2.1.x (current latest: v2.2.0): the error messages were rewritten in v2.1.0 and are now much more useful. Also upgrade to the latest Python bindings, then.

The mesh you set in your Python script is called Structure_Nodes

meshID = interface.get_mesh_id("Structure_Nodes")

but there is no such mesh in your precice configuration. There it is called Solid1-Mesh. Changing line 88 to

meshID = interface.get_mesh_id("Solid1-Mesh")

should fix the error. With newer preCICE versions (I tested with preCICE 2.1.0) there is a more descriptive error message and additional checks telling you what is wrong. :wink:

Hi again @Makis,

I upgraded preCICE to v2.2.0, and reinstalled the Python bindings (v2.2.0.1) as well as the OpenFOAM adapter. I am now encountering a new error! I will start a new thread for it and @ you so you are in the loop.

@ajaust,

Thanks for your help - I made changes so the python script no longer is referencing the improper mesh name, but I am still having problems with the xml configuration file, even after doing so. I will include you in the new thread as well.

Best,
-Nicolette

2 Likes

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