Field Name for multiple interfaces in preCICE and OpenFOAM

In the multiple-perpendicular-flaps case at tutorials/precice-config.xml at master · precice/tutorials (, there are two interfaces. The stress and force are named as Stress1, 2, and Force1, 2. How does preCICE know the user are required the force and stress? Does it infer the filed names in terms of some conventions? For example, if the string ‘Stress’ appears in the filed name, preCICE assume ‘Stress’ is desired. Is my understanding correct?

  <solver-interface dimensions="2">
    <data:vector name="Stress1" />
    <data:vector name="Displacement1" />
    <data:vector name="Stress2" />
    <data:vector name="Displacement2" />

Yes, this is correct. We infer the type of the data from the data name. It does not need to be identical, it just needs to contain start with the string Force, for example. Here is how we look up the names in the code. You can read more in the adapter configuration page.

While this assumption does not always work and can be a bit restrictive, separating the name from the type would complicate the adapter configuration file and the respective code (which is already quite large). I tried this already briefly, but this does not mean that we may not return back to this in the future. Contributions are very welcome!

1 Like

Thanks for confirming that. Just want to make it clearer.

In the adapter configuration page , it only mentions postfix. But looking at the [code] (openfoam-adapter/FSI.C at 49b62673e87fb0ca42267b4ac679e306ef1672b8 · precice/openfoam-adapter · GitHub) `dataName.find(“Force”) == 0’, it seems both prefix and postfix are allowed in a field name, right?

To be honest, I also wondered about this right now. I have tried it a long time ago, but I don’t remember what the conclusion was. It definitely works with postfixes (Displacements0), but I guess it should also work with prefixes (MyDisplacement).

Why don’t give it a quick try and document your findings here? If it works also with prefixes, feel free to directly edit and contribute to the documentation! :smiley:

A quick test shows the statement in the document is right. That means prefix is not allowed.

My understanding is ‘MyDisplacement’ contains “M”, “My”, “MyD”, …, “MyDisplacemet” but not “Displacement”. Whereas “Displacement0” contains “D”, “Di”, “Dis”, …, “Displacement”, and “Displacement”. Someone can confirm.

1 Like

This sounds correct. The find() method then just has a confusing name.

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