# Different behaviour of setMeshQuads() between v3.1.2 and v3.2.0 in setting 2D mesh connectivity

**URL:** https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451
**Category:** Using preCICE
**Tags:** data-mapping
**Created:** [April 19, 2025, 6:32am UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451 "2025-04-19T06:32:56Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Ya\_Squall](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ya_squall/32/2265_2.png) [@Ya\_Squall](https://precice.discourse.group/u/Ya_Squall)
#### Post date: [April 19, 2025, 6:32am UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/1 "2025-04-19T06:32:56Z")

</div>

```c++
  <mesh name="A-Mesh" dimensions="2">
    <use-data name="etaHOS" />
    <use-data name="UHOS" />
  </mesh>

  <mesh name="B-Mesh" dimensions="2">
    <use-data name="etaHOS" />
    <use-data name="UHOS" />
  </mesh>

  <participant name="A">
    <provide-mesh name="A-Mesh" />
    <receive-mesh name="B-Mesh" from="B" />
    <read-data name="etaHOS" mesh="A-Mesh" />
    <read-data name="UHOS" mesh="A-Mesh" />
    <mapping:linear-cell-interpolation direction="read" from="B-Mesh" to="A-Mesh" constraint="consistent" />
  </participant>

  <participant name="B">
    <provide-mesh name="B-Mesh" />
    <write-data name="etaHOS" mesh="B-Mesh" />
    <write-data name="UHOS" mesh="B-Mesh" />
  </participant>

```

As shown above, pure 2D coupling ({x0, y0,x1, y1,x2, y2,… …, xn, yn} passed to precicef\_set\_vertices()), to satisfy mapping:linear-cell-interpolation, precicef\_set\_mesh\_quads() is called to build connectivities for Mesh-B. But got the following error in v3.2.0. It works fine in v3.1.2. Wondering if there’s any un-documented change in behavious of the precicef\_set\_mesh\_quads() function. How can I get around this? Many thanks.

```c++
ASSERTION FAILED
Location: precice::math::geometry::ConvexityResult precice::math::geometry::isConvexQuad(std::array<Eigen::Matrix<double, -1, 1>, 4>)
File: /scratcha-fdgs/lux/OpenFOAM/lux-v2106/platforms/precice-3.2.0/src/math/geometry.cpp:149
Expression: std::all_of(coords.cbegin(), coords.cend(), [](const auto &v) { return v.size() == 3; })
Rank: 0
Arguments:
  0: "This only works in 3D." == This only works in 3D.

Stacktrace:
 0# 0x00007FC652F4458C in /scratcha-fdgs/lux/OpenFOAM/lux-v2106/platforms/precice-3.2.0/platforms/lib64/libprecice.so.3
 1# 0x00007FC65272779B in /scratcha-fdgs/lux/OpenFOAM/lux-v2106/platforms/precice-3.2.0/platforms/lib64/libprecice.so.3
 2# 0x00007FC652E8DADA in /scratcha-fdgs/lux/OpenFOAM/lux-v2106/platforms/precice-3.2.0/platforms/lib64/libprecice.so.3
 3# precice::Participant::setMeshQuads(precice::span<char const, 18446744073709551615ul>, precice::span<int const, 18446744073709551615ul>) in /scratcha-fdgs/lux/OpenFOAM/lux-v2106/platforms/precice-3.2.0/platforms/lib64/libprecice.so.3
 4# precicef_set_mesh_quads_ in /scratcha-fdgs/lux/OpenFOAM/lux-v2106/platforms/precice-3.2.0/platforms/lib64/libprecice.so.3

```

---

<div class="post-metadata">

### Author: ![Ya\_Squall](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ya_squall/32/2265_2.png) [@Ya\_Squall](https://precice.discourse.group/u/Ya_Squall)
#### Post date: [April 19, 2025, 7:19am UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/2 "2025-04-19T07:19:22Z")

</div>

For 3D cases, where precicef\_set\_mesh\_tetrahedra() is called, the code works fine both in v3.1.2 and v3.2.0.

---

<div class="post-metadata">

### Author: ![Ya\_Squall](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ya_squall/32/2265_2.png) [@Ya\_Squall](https://precice.discourse.group/u/Ya_Squall)
#### Post date: [April 19, 2025, 2:51pm UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/3 "2025-04-19T14:51:32Z")

</div>

@Makis After digging into the source code, found that in setMeshQuads(), there’s a line:

```
    auto convexity = math::geometry::isConvexQuad(coords);

```

at beginning of which is:

```
  PRECICE_ASSERT(std::all_of(coords.cbegin(), coords.cend(),
                             [](const auto &v) { return v.size() == 3; }),
                 "This only works in 3D.");

```

Guess this assert will call std::abort() if dim != 3 in Degub mode, which is unfortunate my case. And previously in v3.1.2 I am only running in Release mode, that is why I didn’t get error.

My question is, my earlier runs in v3.1.2 showed me that precice works fine when I call setMeshQuads() for pure 2D cases, why in the above PRECICE\_ASSERT it is said “This only works in 3D”? My use case is 2D volume coupling, and I quote your document “For volume coupling in 2D, mesh connectivity boils down to defining triangles and / or quads between vertices”.

---

<div class="post-metadata">

### Author: ![Ya\_Squall](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ya_squall/32/2265_2.png) [@Ya\_Squall](https://precice.discourse.group/u/Ya_Squall)
#### Post date: [April 20, 2025, 12:33am UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/4 "2025-04-20T00:33:17Z")

</div>

Rebuild with Release mode, got another error from same function call (`math::geometry::isConvexQuad(coords)`):

```
---[precice] ERROR: Non-planar quads are not supported. The vertex coordinates are: [312.5,2.55, 375,2.55, 375,3.825, 312.5,3.825].

```

This is not happening in v3.1.2. The difference in configuring v3.1.2 and v3.2.0 is just replaced boost 1.82.0 to 1.86.0. same eigen lib.

---

<div class="post-metadata">

### Author: ![Ya\_Squall](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ya_squall/32/2265_2.png) [@Ya\_Squall](https://precice.discourse.group/u/Ya_Squall)
#### Post date: [April 20, 2025, 1:23am UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/5 "2025-04-20T01:23:11Z")

</div>

made following change to the precice code, now it works. Hope this will not break the precice internal logic.

```
ConvexityResult isConvexQuad(std::array<Eigen::VectorXd, 4> coords)
{
  // Ensure all points have at least 2 or 3 dimensions
  PRECICE_ASSERT(std::all_of(coords.cbegin(), coords.cend(),
                             [](const auto& v) {
                               return v.size() == 2 || v.size() == 3;
                             }),
                 "All coordinates must be 2D or 3D.");

  // If coords are 2D, extend them to 3D by adding a zero z-component
  if (coords[0].size() == 2) {
    for (auto& v : coords) {
      Eigen::VectorXd extended(3);
      extended << v[0], v[1], 0.0;
      v = extended;
    }
  }

  // Now ensure all vectors are 3D
  PRECICE_ASSERT(std::all_of(coords.cbegin(), coords.cend(),
                             [](const auto& v) { return v.size() == 3; }),
                 "This only works in 3D.");

  // ...The rest remains the same...
}

```

---

<div class="post-metadata">

### Author: ![Ya\_Squall](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ya_squall/32/2265_2.png) [@Ya\_Squall](https://precice.discourse.group/u/Ya_Squall)
#### Post date: [April 20, 2025, 4:04am UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/6 "2025-04-20T04:04:46Z")

</div>

so far the tests are normal.

---

<div class="post-metadata">

### Author: ![fsimonis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fsimonis/32/6_2.png) [@fsimonis](https://precice.discourse.group/u/fsimonis)
#### Post date: [May 15, 2025, 10:37am UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/7 "2025-05-15T10:37:08Z")

</div>

Hi,  
This definitely a bug in preCICE.  
Quads were never designed to be used in 2D, which changed with the introduction of the linear cell interpolation mapping.

Thanks for doing the research! I opened an issue:

> <https://github.com/precice/precice/issues/2296>
>
> \*\*Describe your setup\*\*
> 
> Operating system (e.g. Linux distribution and version):… all
> preCICE Version: 3.2.0 and before
> 
> \*\*Describe the problem\*\*
> 
> When using LCI in 2D, the user needs to define triangles or quads.
> The latter has an internal check for convexity, which only supports 3D coordinates.
> This leads to an error and triangles need to be used as a fall-back.
> 
> \*\*Step To Reproduce\*\*
> Based on https://precice.discourse.group/t/different-behaviou-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451
>  
> 1. Define 2d meshes and a linear-cell-interpolation mapping between them. 
> 2. Define quads using \`setMeshQuad\`
> 3. Observe the assertion \`This only works in 3D.\` in Debug.
>  
> \*\*Expected behaviour\*\*
> The Quads should be set correctly for 2D meshes.
> 
> \*\*Additional context\*\*
> 
> \[Reported on discourse\](https://precice.discourse.group/t/different-behaviou-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451)

Best  
Frédéric

---

<div class="post-metadata">

### Author: ![fsimonis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fsimonis/32/6_2.png) [@fsimonis](https://precice.discourse.group/u/fsimonis)
#### Post date: [September 24, 2025, 3:54pm UTC](https://precice.discourse.group/t/different-behaviour-of-setmeshquads-between-v3-1-2-and-v3-2-0-in-setting-2d-mesh-connectivity/2451/8 "2025-09-24T15:54:57Z")

</div>

@Ya_Squall The 2D for Quads will be part of the upcoming 3.3.0 release.
