Participant reads zeros for mapped data

I am using a variant of the partitioned pipe tutorial to test the mesh connectivity setup for an adapter I am writing. On each coupling boundary, I have density and velocity stored at face centroids and pressure stored at mesh vertices. The idea is to use a nearest-projection mapping to map the pressures at vertices to the centroids of the other participant’s surface mesh, so that each participant receives all three quantities at cell centroids.

After some trial and error I arrived at this config file which does not produce any errors from preCICE:

precice-config.xml (5.0 KB)

The problem is that although both participants write the correct pressures on their vertex meshes, they read pressures of zero on their centroid meshes. I think this means they are trying to read a data set that was never written by the other, but I don’t see what in the config file could cause that. I also get the same behavior using a nearest-neighbor mapping which rules out a bug in my mesh connectivity setup. Any ideas what the problem might be?

Could you upload the solver output? Maybe the nodes were filtered out? I guess that is unlikely, but possible?

Did you also try some serial-explicit coupling for the start? In my experience serial-explicit is one of the simpler coupling types to debug.

I also put your configuration into the config visualizer and made a plot. I am not really able to interpret it at the moment, but maybe one of the preCICE experts will be able to do so by looking at the plot. :slight_smile:

@ajaust Serial explicit and serial implicit both produced the same behavior, and here is what preCICE writes to stdout for both participants. Nothing looks out of the ordinary to me.

precice-output-from-participants.txt (5.1 KB)

I’m not completely sure how to interpret config visualizations, but I see that Fluid1-Nodes from Fluid1 and Fluid2-Nodes from Fluid2 have no arrows emerging from them and maybe that is relevant.

From you output it looks like the coupling is not running/carried out. It seems that your code is halting after the (lack of) initialization of coupling data. Is your setup ever calling the preCICE functions writeXXXData (scalar or vector data) and advance?

Sorry, that was only the section of output where a message about filtering out nodes would have been seen. Here is all the output up to the point where the solvers crash due to trying to divide by the zero read pressure.

more-precice-output.txt (7.9 KB)

The “Reading x” and “Writing x” messages are from print statements I added for debugging, which are made just before the solver calls the preCICE read/write functions.

Is this the full log? It seems odd that it starts at iteration 2 directly. How did you verify that you read zeros?

I think that lack of outgoing arrows for Fluid1-Nodes from Fluid1 and Fluid2-Nodes from Fluid2 means that you could remove some lines from your configuration. The solver Fluid2 defines the Fluid1-Nodes mesh, but never uses it in any data mapping. Similar for the Fluid2-Nodes mesh on solver Fluid1.

Yes, it is the full log. The iteration 1 output appears immediately after “slaves are connected” and the output all looks normal to me. I see the zeros being read when running the two solvers in a debugger, i.e. after the calls to precicef_read_bsdata(pressure_id, npoints, point_ids, scalar_data) I see scalar_data is all zeros whereas it should definitely be nonzero (standard atmospheric pressure). I also see in the debugger the correct pressure being written and the correct density being read and written on both participants.

After removing <use-mesh name="Fluid2-Nodes" from="Fluid2> from the Fluid1 participant section and <use-mesh name="Fluid1-Nodes" from="Fluid1> from the Fluid2 section, and changing nothing else in the config file, I get an error:

(0) 11:10:04 [config::SolverInterfaceConfiguration]:84 in xmlEndTagCallback: ERROR: Participant “Fluid1” needs to use the mesh “Fluid2-Nodes” to be able to use it in the coupling scheme. Please either add a use-mesh tag in this participant’s configuration, or use a different mesh in the coupling scheme.

So I changed the exchange tags to exchange Pressure-f1 over Fluid1-Centroids instead of Fluid1-Nodes and similarly for Pressure-f2, and then got:

(0) 11:19:40 [cplscheme::CouplingSchemeConfiguration]:1027 in checkIfDataIsExchanged: ERROR: You need to exchange every data that you use for convergence measures and/or the iteration acceleration. Data “Pressure-f1” is currently not exchanged over the respective mesh on which it is used for convergence measures and/or iteration acceleration. Please check the <exchange … /> and <…-convergence-measure … /> tags in the <coupling-scheme:… /> of your precice-config.xml.

I think this error is because I have Fluid1 write Pressure-f1 on its node mesh Fluid1-Nodes, which is where it must be written.

Instead, starting from the original config file I can remove <use-data name="Pressure-f1" /> from <mesh name="Fluid2-Nodes"> and <use-data name="Pressure-f2" /> from <mesh name="Fluid1-Nodes"> and preCICE will not give an error about the config file. This makes sense because those meshes should not care about those data sets anyway. However, I still see zeros being read for both pressures in the debugger and the visualization output is equivalent.

You had your mapping directions (read/write) wrong. I guess this is what you want:

precice-config.xml (5.0 KB)

A good order of doing things for such complex configs is:

  1. Define “provided” meshes
  2. Define read-data and write-data
  3. Define over which meshes data is exchanged
  4. Define “received meshes”
  5. Define mappings
  6. Define convergence measures etc

@uekermann With that config file I get:

(0) 10:22:18 [config::ParticipantConfiguration]:658 in checkIllDefinedMappings: ERROR: There cannot be two mappings to mesh “Fluid1-Centroids” if the meshes from which is mapped contain duplicated data fields that are also actually mapped on this participant. Here, both from meshes contain data “Pressure-f2”. The mapping is not well defined. Which data “Pressure-f2” should be mapped to mesh “Fluid1-Centroids”?

In fact, I encountered this problem before which is why I switched one mapping in each participant from a read mapping to a write mapping. Trying to fix it a different way, starting from your config file I removed <use-data name="Pressure-f2" /> from <mesh name="Fluid2-Centroids"> and removed <use-data name="Pressure-f1" /> from <mesh name="Fluid1-Centroids"> and get:

(0) 10:29:07 [config::ParticipantConfiguration]:529 in finishParticipantConfiguration: ERROR: Mesh “Fluid2-Nodes” needs to use data “Density-f2” to allow a read mapping to it. Please add a use-data node with name=“Density-f2” to this mesh.

This is a strange error because neither node mesh has a read mapping to it; all the mappings are to the centroid meshes. Maybe this is a typo in the error message? Anyway, I added <use-data name="Density-f2" /> to <mesh name="Fluid2-Nodes"> as the message suggested and made the corresponding changes for velocity and the other node mesh to end up with this config file:

precice-config.xml (5.0 KB)

After which I get the same error about two mappings to a mesh:

(0) 10:37:10 [config::ParticipantConfiguration]:658 in checkIllDefinedMappings: ERROR: There cannot be two mappings to mesh “Fluid1-Centroids” if the meshes from which is mapped contain duplicated data fields that are also actually mapped on this participant. Here, both from meshes contain data “Density-f2”. The mapping is not well defined. Which data “Density-f2” should be mapped to mesh “Fluid1-Centroids”?

It seems as if the node meshes need to use and also not use the same data.

You have to remove more data fields such that Fluid2-Centroids and Fluid2-Nodes are disjoint. Could you please try this one?
precice-config.xml (4.8 KB)

It makes perfect sense to me that the data fields should be disjoint, yet with that config file I get an error:

(0) 10:09:48 [config::ParticipantConfiguration]:529 in finishParticipantConfiguration: ERROR: Mesh “Fluid2-Nodes” needs to use data “Density-f2” to allow a read mapping to it. Please add a use-data node with name=“Density-f2” to this mesh.

This is strange because:

  1. There are no read mappings to Fluid2-Nodes.
  2. Fluid2-Nodes has no reason to involve the density.
  3. Following the suggestion in the error message would make the data fields no longer disjoint.

Ah, ok, you actually wrote this above already, but I thought this error message makes absolutely no sense, so I better just ask again. Sorry for letting you describe the problem twice :grin:

Turns out, you discovered a bug :bug: :scream_cat:

I don’t see a quick workaround here. I guess we need a real fix.

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