precice / openfoam-adapter

OpenFOAM-preCICE adapter
https://precice.org/adapter-openfoam-overview.html
GNU General Public License v3.0
135 stars 80 forks source link

Cannot run fluid-fluid tutorials with preCICE develop #303

Closed MakisH closed 11 months ago

MakisH commented 1 year ago

Describe your setup

Operating system (e.g. Linux distribution and version): Ubuntu 22.04 preCICE Version: f7289a67

Describe the problem

Trying to merge develop into ff-develop, and while running some tutorials, I noticed the following output:

---[preciceAdapter] Loaded the OpenFOAM-preCICE adapter - v1.2.3 + unreleased changes.
---[preciceAdapter] Reading preciceDict...
---[precice]  This is preCICE version 3.0.0
---[precice]  Revision info: v2.5.0-413-gf7289a67
---[precice]  Build type: Debug
---[precice]  Configuring preCICE with configuration "../precice-config.xml"
---[precice]  I am participant "Fluid2"
---[precice] ERROR:  Input sizes are inconsistent attempting to write 1D data "Pressure" to mesh "Fluid2-Mesh". You passed 41 vertices and 82 data components, but we expected 41 data components (1 x 41).

This comes from tutorials/flow-over-heated-plate-partitioned-flow/fluid2-openfoam.

Similarly from tutorials/partitioned-backwards-facing-step/fluid1-openfoam:

---[precice] ERROR:  Input/Output sizes are inconsistent attempting to read 1D data "Pressure" from mesh "Fluid1-Mesh". You passed 32 vertices and 96 data components, but we expected 32 data components (1 x 32).

Affected tutorials:

Potentially affected:

Not affected:

Additional context

The tutorial partitioned-pipe does not throw this error, but instead runs into an assertion:

---[preciceAdapter] Loaded the OpenFOAM-preCICE adapter - v1.2.3 + unreleased changes.
---[preciceAdapter] Reading preciceDict...
---[precice]  This is preCICE version 3.0.0
---[precice]  Revision info: v2.5.0-413-gf7289a67
---[precice]  Build type: Debug
---[precice]  Configuring preCICE with configuration "../precice-config.xml"
---[precice]  I am participant "Fluid1"
---[precice]  Setting up primary communication to coupling partner/s
---[precice]  Primary ranks are connected
---[precice]  Setting up preliminary secondary communication to coupling partner/s
---[precice]  Prepare partition for mesh Fluid1-Mesh
---[precice]  Gather mesh Fluid1-Mesh
---[precice]  Send global mesh Fluid1-Mesh
---[precice]  Receive global mesh Fluid2-Mesh
---[precice]  Setting up secondary communication to coupling partner/s
---[precice]  Secondary ranks are connected
---[precice]  Computing "nearest-neighbor" mapping from mesh "Fluid2-Mesh" to mesh "Fluid1-Mesh" in "read" direction.
---[precice]  Mapping distance min:0 max:7.17448e-15 avg: 2.20885e-15 var: 4.2847e-30 cnt: 500
---[precice]  Mapping "Pressure" for t=0 from "Fluid2-Mesh" to "Fluid1-Mesh"
---[precice]  Mapping "Pressure" for t=1 from "Fluid2-Mesh" to "Fluid1-Mesh"
ASSERTION FAILED
Location:   void precice::impl::DataContext::mapData()
File:       /home/gc/repos/precice/precice/src/precice/impl/DataContext.cpp:95
Expression: context.fromData->stamples().size() > 0
Rank:       0
Arguments:  none

Maybe related to https://github.com/precice/openfoam-adapter/pull/297, to #255, or to https://github.com/precice/precice/pull/1742. I guess that somewhere in the code we are mixing up some data and mesh dimensions, or that in the Interface.C we are giving the wrong number of locations.

cc @thesamriel

davidscn commented 1 year ago

I think what's triggering this assertion is that we have multiple data sets living on the same interface and writing to the same buffer. We need to split the buffer reading/writing in the adapter according to the data sets

https://github.com/precice/openfoam-adapter/blob/3e660e10901f8d6758f5484dad565dc8b41681d3/Interface.C#L548-L554

I can take a closer look later.

MakisH commented 1 year ago

Makes sense, we are reusing the dataBuffer_, and previously we were specifying the number of locations separately. But now, it is extracted from the size of dataBuffer_.

Essentially, this means we need a separate buffer for each mesh (already the case) and for scalars vs vectors.

I guess we get this issue in the FF tutorials because in these tutorials we have both scalars and vectors on the same mesh. In the flow-over-heated-plate we only have scalars, while in the perpendicular-flap we only have vectors.

Edit: I can confirm that I get the same behavior with preCICE commit 39429b4, i.e., before the dimensions PR.

davidscn commented 1 year ago

I guess we get this issue in the FF tutorials because in these tutorials we have both scalars and vectors on the same mesh. In the flow-over-heated-plate we only have scalars, while in the perpendicular-flap we only have vectors.

It's not so much about the mixture of scalars/vectors, but more about the various data fields on the same interface. In the fluid-fluid module, we have for example pressure and velocity gradients on the same read side. One could easily reproduce this issue by splitting one of single-data interfaces in the perpendicular-flap tutorial into two separate fields, e.g., Stress1 and Stress2

davidscn commented 1 year ago

I guess we get this issue in the FF tutorials because in these tutorials we have both scalars and vectors on the same mesh. In the flow-over-heated-plate we only have scalars, while in the perpendicular-flap we only have vectors.

Actually, that's exactly the issue, I had something slightly different in mind.

https://github.com/precice/openfoam-adapter/blob/b0f4d1ffe99c93db2deaf2bd041ee707766e1337/Interface.C#L530-L534