Wrong time-step value read by precice.advance when using the "first-participant" method in seriel-explicit coupling for OpenFOAM

Hellow all. I am new to preCICE and found that this is definitly a wonderful tool.
I am trying to use it for a coupling between openFoam 8 and my own code of structure. I use the seriel-explicit coupling scheme and first-participant (Fluid part) for the time window size. My plan is to first calculate the fluid part and use the same time step for the structure part. I thought this should be done by using dt = precice.advanc() in my structure code. However, I found this commond does not give the correct time step that was used by the fluid, they are very close though. I am using adjustable time step in the openfoam.

<mesh name="Fluid-Mesh">
  <use-data name="Force" />
  <use-data name="Displacement" />
</mesh>

<mesh name="Cylinder-Mesh">
  <use-data name="Displacement" />
  <use-data name="Force" />
</mesh>

<participant name="Fluid">
  <use-mesh name="Fluid-Mesh" provide="yes" />
  <use-mesh name="Cylinder-Mesh" from="Cylinder" />
  <read-data name="Displacement" mesh="Fluid-Mesh" />
  <write-data name="Force" mesh="Fluid-Mesh" />
  <mapping:nearest-neighbor
    direction="read"
    from="Cylinder-Mesh"
    to="Fluid-Mesh"
    constraint="consistent" />
  <mapping:nearest-neighbor
    direction="write"
    from="Fluid-Mesh"
    to="Cylinder-Mesh"
    constraint="conservative" />
</participant>

<participant name="Cylinder">
  <use-mesh name="Cylinder-Mesh" provide="yes" />
  <read-data name="Force" mesh="Cylinder-Mesh" />
  <write-data name="Displacement" mesh="Cylinder-Mesh" />
  <watch-point mesh="Cylinder-Mesh" name="PointCylinder" coordinate="0.5;0.0" />
  <export:vtk directory="coupling-meshes" />
</participant>

<m2n:sockets from="Fluid" to="Cylinder" exchange-directory="../" />

<coupling-scheme:serial-explicit>
 
  <time-window-size method = "first-participant" />
  <max-time value="250" />
  <participants first="Fluid" second="Cylinder" />
  <exchange data="Force" mesh="Cylinder-Mesh" from="Fluid" to="Cylinder" />
  <exchange data="Displacement" mesh="Cylinder-Mesh" from="Cylinder" to="Fluid" />
</coupling-scheme:serial-explicit>

For example, the time step used by the foam is 0.00199414, but the one read and used by the structure through precice.advance is 0.00201513.
I would appriciate it if someone can help me with this.

Welcome, @Yang_Qu! :wave:

precice.advance() does not return the time step size used by the other participant. You could anyway have multiple coupling participants, so which one should this correspond to?

What it gives you is the maximum allowed time step size that this participant is allowed to execute, before reaching a synchronization/coupling time.

edit: I now re-read your post and I see that you are using the first-participant option.

I can imagine that this could be a bug in the OpenFOAM adapter. Feel free to open an issue, with any debugging information you think could be helpful: Issues Ā· precice/openfoam-adapter Ā· GitHub

The problem is solved. I thought that with the method of ā€œfirst-participantā€ the procedure is that the openfoam conducts calculation first and then pass the timestep that it used to the structure code. This assumption is wrong. The timestep is passed to the structure code before the openFoam actually making the calculation. Therefore, if the writecontrol is set as ā€œadjustableRunTimeā€, it will modify the timestep used by the openFoam to make sure that the output will be wrote at the excat time points. Then, the actual time step used by the openFoam is different from the one used by the structure code. So, after I change the writecontrol to ā€œRunTimeā€, the problem is solved.

1 Like

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