# Adapters for distributed meshes with possible connectivity

**URL:** <https://precice.discourse.group/t/adapters-for-distributed-meshes-with-possible-connectivity/798>\
**Category:** Using preCICE\
**Tags:** adapters, parallel\
**Created:** [November 19, 2021, 4:11pm UTC](https://precice.discourse.group/t/adapters-for-distributed-meshes-with-possible-connectivity/798 "2021-11-19T16:11:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ray\_Scarr](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ray_scarr/32/980_2.png) [@Ray\_Scarr](https://precice.discourse.group/u/Ray_Scarr)\
**Post date:** [November 19, 2021, 4:11pm UTC](https://precice.discourse.group/t/adapters-for-distributed-meshes-with-possible-connectivity/798/1 "2021-11-19T16:11:41Z")

</div>

I am writing an adapter that needs to handle distributed meshes. The [coupling roadmap](https://precice.org/couple-your-code-distributed-meshes.html) talks about three approaches, two of which do not allow edges to be defined between vertices owned by different ranks. Obviously that only matters if mesh connectivity is required, but it is unclear to me when connectivity is required and what the cost of not having these cross-rank edges would be for a simulation that requires connectivity. Without understanding that, one can’t decide which of the three methods is best for the expected use cases. So I have several related questions:

1. My reading of [the Uekermann dissertation](https://mediatum.ub.tum.de/doc/1320661/document.pdf) suggests that preCICE requires mesh connectivity if and only if a nearest projection mapping is used. Is that correct?

2. Why might a user want or need to use nearest projection instead of nearest neighbor?

3. Suppose a user runs a simulation that requires connectivity and no cross-rank edges are defined. Would the user notice any negative consequences, such as slower convergence or obvious errors in the solution, due to these missing edges?

4. Does the preCICE ID assigned to a vertex on a given rank have any meaning on different ranks?

5. If one implements [the second method](https://precice.org/couple-your-code-distributed-meshes.html#use-a-single-mesh-and-duplicate-copied-vertices), the adapter has to know whether the mapping is conservative or consistent. I don’t see a way to determine that using the API. Is there one?

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [November 21, 2021, 4:25pm UTC](https://precice.discourse.group/t/adapters-for-distributed-meshes-with-possible-connectivity/798/2 "2021-11-21T16:25:15Z")

</div>

Hi @Ray_Scarr 👋

> [@Ray\_Scarr](#):
>
> My reading of [the Uekermann dissertation](https://mediatum.ub.tum.de/doc/1320661/document.pdf) suggests that preCICE requires mesh connectivity if and only if a nearest projection mapping is used. Is that correct?

This is pretty much correct. There are some details, like watchpoints or certain actions that also benefit from mesh connectivity, but it’s mostly about the NP mapping.

> [@Ray\_Scarr](#):
>
> Why might a user want or need to use nearest projection instead of nearest neighbor?

If the distance between both meshes is much lower than the mesh width, the error of NP is O(h^2) while the error of NN is only O(h). (RBF mapping needs no connectivity and has a O(h^2) error, but is more expensive to compute)

> [@Ray\_Scarr](#):
>
> Suppose a user runs a simulation that requires connectivity and no cross-rank edges are defined. Would the user notice any negative consequences, such as slower convergence or obvious errors in the solution, due to these missing edges?

NP falls back to NN if a vertex of the other mesh would be projected to the missing edge. So, you get there a higher local mapping error. There are certainly situation where you can live with this.

> [@Ray\_Scarr](#):
>
> Does the preCICE ID assigned to a vertex on a given rank have any meaning on different ranks?

No. The ID is unique per rank, but two different vertices on two different ranks can have the same ID.

> [@Ray\_Scarr](#):
>
> If one implements [the second method](https://precice.org/couple-your-code-distributed-meshes.html#use-a-single-mesh-and-duplicate-copied-vertices), the adapter has to know whether the mapping is conservative or consistent. I don’t see a way to determine that using the API. Is there one?

No, there is none through the API. But the adapter typically knows which data should be written and whether this data needs a consistent mapping (e.g. temperature, velocity, …) or a conservative mapping (e.g. nodal force).

---

<div class="post-metadata">

**Author:** ![Ray\_Scarr](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ray_scarr/32/980_2.png) [@Ray\_Scarr](https://precice.discourse.group/u/Ray_Scarr)\
**Post date:** [November 22, 2021, 5:43pm UTC](https://precice.discourse.group/t/adapters-for-distributed-meshes-with-possible-connectivity/798/3 "2021-11-22T17:43:10Z")

</div>

@uekerman Thank you, that’s what I needed to know. Your answer raises another point that is unclear to me:

> But the adapter typically knows which data should be written and whether this data needs a consistent mapping (e.g. temperature, velocity, …) or a conservative mapping (e.g. nodal force).

It makes perfect sense that the mapping type should depend on the nature of the physical quantity, but in preCICE config files I see mappings defined by _meshes_. not _quantities_. For instance, the [heat exchanger example](https://github.com/precice/tutorials/blob/master/heat-exchanger/precice-config.xml) has:

```xml
<participant name="Solid">
  <use-mesh name="Solid-to-Fluid-Inner" provide="yes" />
  <use-mesh name="Fluid-Inner-to-Solid" from="Fluid-Inner" />
  <write-data mesh="Solid-to-Fluid-Inner" name="Sink-Temperature-Solid" />
  <write-data mesh="Solid-to-Fluid-Inner" name="Heat-Transfer-Coefficient-Solid" />
  <read-data mesh="Solid-to-Fluid-Inner" name="Sink-Temperature-Fluid-Inner" />
  <read-data mesh="Solid-to-Fluid-Inner" name="Heat-Transfer-Coefficient-Fluid-Inner" />
  <mapping:nearest-neighbor
    constraint="consistent"
    direction="read"
    to="Solid-to-Fluid-Inner"
    from="Fluid-Inner-to-Solid" />
...
</participant>

```

I suppose this works because both the temperature and heat transfer coefficient should use a consistent mapping for physical reasons. But if instead I had two quantities defined at the same locations, one to be mapped consistently and the other conservatively, it seems that preCICE would need two meshes defined from the same point cloud so that the two different mappings can be defined independently. Is that correct?

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [November 22, 2021, 6:23pm UTC](https://precice.discourse.group/t/adapters-for-distributed-meshes-with-possible-connectivity/798/4 "2021-11-22T18:23:56Z")

</div>

Exactly, completely correct.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/67d2a5fa6f80e597e2267ff17fa8c1673cd11caa.svg) [@system](https://precice.discourse.group/u/system)\
**Post date:** [November 25, 2021, 6:23pm UTC](https://precice.discourse.group/t/adapters-for-distributed-meshes-with-possible-connectivity/798/5 "2021-11-25T18:23:56Z")

</div>

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