# Initialize data when using direct access to received mesh?

**URL:** <https://precice.discourse.group/t/initialize-data-when-using-direct-access-to-received-mesh/2102>\
**Category:** Using preCICE\
**Created:** [September 4, 2024, 4:43pm UTC](https://precice.discourse.group/t/initialize-data-when-using-direct-access-to-received-mesh/2102 "2024-09-04T16:43:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![j-signorelli](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/j-signorelli/32/1912_2.png) [@j-signorelli](https://precice.discourse.group/u/j-signorelli)\
**Post date:** [September 4, 2024, 4:43pm UTC](https://precice.discourse.group/t/initialize-data-when-using-direct-access-to-received-mesh/2102/1 "2024-09-04T16:43:13Z")

</div>

Hi,

I am interested in having Participant B not provide any mesh but instead just have direct access to Participant A’s mesh, but I also want Participant B to write initial data to Participant A. Is this possible?

The documentation states that, in the context of coupling data:

> All data is initialized to 0 by default. If you configure preCICE to provide custom initial data, then participants need to provide this data before calling [initialize()](https://precice.org/doxygen/main/classprecice_1_1Participant.html#a6192be916f9fd9fa9f9f2d2d5faf7169). After you defined the meshes, use [requiresInitialData()](https://precice.org/doxygen/main/classprecice_1_1Participant.html#a316297f6af74a53d5d9943e619906a70) to check if initial data is required. Then use [writeData()](https://precice.org/doxygen/main/classprecice_1_1Participant.html#a72d563346e6670bce80e2319717dfc24) to specify your initial data and continue to [initialize()](https://precice.org/doxygen/main/classprecice_1_1Participant.html#a6192be916f9fd9fa9f9f2d2d5faf7169).

However, in order to use `writeData()` prior to `initialize()`, Participant B needs the vertex IDs and coordinates of Participant A’s mesh, which it seems that it cannot have access to until _after_ calling `initialize()`, as stated [here](https://precice.org/doxygen/main/classprecice_1_1Participant.html#a34edf198c52da36048dab3afa60a0b46).

Is this possible at all presently? Thank you for any assistance.

---

<div class="post-metadata">

**Author:** ![DavidSCN](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DavidSCN](https://precice.discourse.group/u/DavidSCN)\
**Post date:** [September 5, 2024, 6:58am UTC](https://precice.discourse.group/t/initialize-data-when-using-direct-access-to-received-mesh/2102/2 "2024-09-05T06:58:08Z")

</div>

The problem you describe is exactly the reasons why this is not possible anymore. This was a direct consequence of the API simplification between preCICE v2 and preCICE v3.

> <https://github.com/precice/precice/issues/1583>
>
> \*\*Describe the problem\*\*
> 
> To provide initial data, we have to call a write dat…a function before calling \`initialize()\`. If we use direct access, we can only write to a mesh that we access via direct access \*after\* \`initialize\`. Therefore, initializing data via direct access is not possible. 
> 
> \*\*Step To Reproduce\*\*
> 
> I added a test to illustrate the problem via https://github.com/BenjaminRodenberg/precice/commit/1a50d473454d7796ae52b267c4dc1387529353db
> 
> \*\*Expected behaviour\*\*
> 
> See test mentioned above.
> 
> \*\*Additional context\*\*
> 
> This is basically a consequence of #1350.

If possible, the initial shape of the coupling data should be encoded by participant A. For serial coupling schemes, you could also let participant B start, then participant A will read the data from the first time step when executed for the first time.  
If that’s still not sufficient or zero data is a problem, you could consider having the first solver time-step with zero data or skip the first solve execution in your solver.

---

<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:** [September 8, 2024, 6:58am UTC](https://precice.discourse.group/t/initialize-data-when-using-direct-access-to-received-mesh/2102/3 "2024-09-08T06:58:59Z")

</div>

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