Configuration.xml file format for preCICE communication between python script and OpenFOAM

Hello,

I thought I had properly set up my configuration xml file for communication between two meshes, but I have run into a cryptic error when attempting to run a coupled analysis.

The first error I encountered was the following:

Participant “Fluid1” has to use and provide mesh “Solid1-Mesh” in order to read data from it. Please add a use-mesh node with name=“Solid1-Mesh” and provide=“true”.

After fixing this error by changing the * … * line below from precice-config-Py-OF.xml to the ** … ** line…

<participant name="Fluid1">	
    <use-mesh name="Fluid1-Mesh" provide="yes"/>
    * <use-mesh name="Solid1-Mesh" from="Solid1"/> *
  ** <use-mesh name="Solid1-Mesh" provide="true"/> **
    <write-data name="Pressure" mesh="Fluid1-Mesh"/>
    <read-data name="Displacement" mesh="Solid1-Mesh"/>
    <mapping:nearest-neighbor direction="read" from="Solid1-Mesh" to="Fluid1-Mesh" constraint="consistent" timing="initial"/>
</participant>

I then received the following error:

A read mapping of participant “Fluid1” needs to map FROM a received mesh. Mesh “Solid1-Mesh” is not received. Please add a from=“(participant)” attribute to the participant’s use-mesh tag.

I then added ‘from=“Solid1”’ to

  ** <use-mesh name="Solid1-Mesh" provide="true" from="Solid1"/> **

After trying to run the model again, this error appeared:

Participant “Fluid1” cannot receive and provide mesh “Solid1-Mesh” at the same time. Please remove all but one of the “from” and “provide” attributes in the node of Fluid1.

It seems that no matter what I do I encounter an issue with the mesh specification within the Fluid1 participant - by swapping the location of the Solid1 and Fluid1 participants in the xml file I receive similar errors, except for the Solid1 participant instead of Fluid1.

What is going on with this behavior? I feel like I have done something horribly wrong. Shouldn’t the xml file work as it is included in the attachments?

-Nicolette

Allrun.txt (2.1 KB)
Fluid1.log (4.2 KB)
precice-config-Py-OF.xml (2.4 KB)
slurm-1596248.out (5.1 KB)
Solid1.log (455 Bytes)
Solid1Solver.py.txt (4.5 KB)

@Makis, @ajaust - Tagging you here for continued discussion, if you are interested

Hey,

could you also post your OpenFOAM adapter configuration file, see Configure the OpenFOAM adapter | preCICE - The Coupling Library for more information. Maybe something is wrong there.

At least the error message

Participant “Fluid1” has to use and provide mesh “Solid1-Mesh” in order to read data from it. Please add a use-mesh node with name=“Solid1-Mesh” and provide=“true”.

sounds misleading to me. The fluid solver is not able to provide this mesh. I would revert to the XML file that you have provided. At the moment.

Just another tip for setting up/checking the XML file: There is a configuration visualizer on GitHub: GitHub - precice/config-visualizer: A small python tool for visualizing the preCICE xml configuration
It helps with checking the configuration and you can draw nice pictures to check whether preCICE is doing what you want it to do. :slight_smile:

1 Like

@ajaust,

Thanks for the response! I have attached the OpenFOAM preciceDict file as requested.
preciceDict.txt (425 Bytes)
Also, thank you for sharing the link to the visualizer, I will see what it can do :slight_smile:

Best regards,
-Nicolette

The config visualizer gives the following picture for the config you attached in your first post:

The problematic part here is the mapping (compare this picture with the ones in Config visualization | preCICE - The Coupling Library).

Normally, the data flow should be (with read mapping):

  1. Fluid1 writes pressure to Fluid1-Mesh
  2. Fluid1-Mesh is exchanged (sent to Solid1)
  3. Solid1 does a read-mapping from Fluid1-Mesh to Solid1-Mesh
  4. Solid1 reads data from Solid1-Mesh.

Trying to follow these steps, you will see that steps 3 and 4 are different in your graph: Solid1 tries to read directly from Fluid1-Mesh and the mapping does not really have any effect.

Try swapping the mapping from/to and exchanged data/meshes. It seems a bit spahetti right now, but if you observe the differences in the visualization, you will figure this out. Alternatively, pen and paper with a similar figure also helps. :slight_smile:

1 Like

Ok, the visualization tool helped a lot!!! Thank you so much @Makis and @ajaust.

After shuffling the xml file around a bit, I ended up with a flowchart that looks much more coherent, but am still running into the ‘empty’ mesh issue mentioned in my other post. I have included log files for reference.

—[precice] e[0m This is preCICE version 2.2.0
—[precice] e[0m Revision info: no-info [Git failed/Not a repository]
—[precice] e[0m Configuration: Release (Debug and Trace log unavailable)
—[precice] e[0m Configuring preCICE with configuration “./precice-config-Py-OF.xml”
—[precice] e[0m I am participant “Solid1”
—[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 empty. Please set the mesh using setMeshXXX() prior to calling initialize().

I think I am missing something WRT the solid mesh initialization, still.

Best,
-Nicolette

Solid1Solver.py.txt (4.5 KB)
Fluid1.log (5.3 KB) slurm-1599196.out (5.1 KB) Solid1.log (1.1 KB) precice-config-Py-OF.xml (2.4 KB)

Great that this helped already!

You have a typo in line 106

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

which should read

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

The subtle difference is id vs. ids. The command get_mesh_ids will give you all available mesh ids in the preCICE configuration and does not take any arguments. However, this error is only thrown if preCICE is built with debug flags. get_mesh_id takes a mesh name as argument and gives you the id of the mesh of the given name.

Edit I have to correct myself as the error is also thrown when using a release build.

I also realized something else. The call to interface.initialize() should happen after setting the meshes. So better move line 104 to line 129/130 or so.

1 Like

@ajaust Thank you so much, that did the trick!

I finally have precice outputting log files for iterations between the two solvers.

It hasn’t converged, but now that there is communication I think I am in good shape to move forward with trying to figure out what I can do with preCICE and python + OpenFOAM :slight_smile:

Fluid1.log (10.5 KB) Solid1.log (1.5 KB)
slurm-1599257.out (5.0 KB) precice-config-Py-OF.xml (2.4 KB)

Cheers,
-Nicolette

1 Like

Sounds great that you could fix it. :slight_smile:

Just one more two more remarks/tips:

  • Always check the log files of both solvers carefully. Most if my remarks were based on the output of the solid solver. The error message was very precise regarding what one had to do to fix the error.
  • The current setups seems to be fine, but there was not too much of coupling convergence going on. It looks like the OpenFOAM simulation explodes immediately (lots of nan in the logfile). I guess the simulation setup and/or the initial values exchanged are not yet correct.
1 Like

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