|
2 | 2 | title: Global data |
3 | 3 | permalink: couple-your-code-global-data.html |
4 | 4 | keywords: api, adapter, data, global |
5 | | -summary: "Define and exchange global data (data not associated to a mesh) by using specific optional API functions." |
| 5 | +summary: "Define and exchange global data not accociated to a mesh." |
6 | 6 | --- |
7 | 7 |
|
8 | | -{% warning %} |
9 | | -These API functions are a work in progress, experimental, and are not yet released. The API might change during the ongoing development process. Use with care. |
10 | | -{% endwarning %} |
| 8 | +Global data is not natively supported, but there is a simple workaround. |
11 | 9 |
|
12 | | -{% note %} |
13 | | -This feature is only available for coupling between two participants, i.e. does not yet support [multi coupling](https://precice.org/configuration-coupling-multi.html). Further, it does not yet allow [convergence measures](https://precice.org/configuration-coupling.html#implicit-coupling-schemes) and [acceleration](https://precice.org/configuration-acceleration) to be defined for global data. An extension to these features is planned. |
14 | | -{% endnote %} |
15 | | - |
16 | | -preCICE allows participants to exchange data that is not associated with any mesh. Examples of such data are global background pressure (e.g. fluid-acoustic coupling) and angles between coordinate systems (e.g. fluid-structure coupling for rotor blades). |
17 | | - |
18 | | -## Configuration |
19 | | - |
20 | | -Configuration of global data objects is described below with examples. |
21 | | - |
22 | | -In order to use this feature, global data needs to be explicitly defined in the configuration file using the `global-data` tag. |
| 10 | +Every solver defines a mesh with a single vertex at `(0,0,0)` and uses it to read/write data. |
23 | 11 |
|
24 | 12 | ```xml |
25 | | -<precice-configuration dimensions="3" experimental="true"> |
26 | | - <global-data:vector name="angles" /> |
27 | | -... |
28 | | -``` |
29 | | - |
30 | | -Rest of the global data configuration steps are similar to the usual *mesh-associated* data as described in [introduction to configuration](https://precice.org/configuration-introduction.html). |
31 | | - |
32 | | -```xml |
33 | | -... |
34 | | -<participant name="SolverOne"> |
35 | | - <write-data name="angles" /> |
36 | | -... |
37 | | -<participant name="SolverTwo"> |
38 | | - <read-data name="angles"> |
39 | | -... |
40 | | -<coupling-scheme:serial-explicit> |
41 | | - <exchange data="angles" from="SolverOne" to="SolverTwo" /> |
42 | | -... |
43 | | -``` |
44 | | - |
45 | | -Since global data is not associated with any mesh, it should not be configured with the `use-data` tag under the `mesh` definition. Similarly, tags such as `read-data`, `write-data`, or `exchange` require no `mesh` attribute if used for global data. |
46 | | - |
47 | | -## API |
48 | | - |
49 | | -The API functions `writeGlobalData(...)` and `readGlobalData(...)` enable exchange of global data analogous to the `writeData(...)` and `readData(...)` functions for mesh-associated data. For the above example, the API calls would be as follows. |
50 | | - |
51 | | -For SolverOne: |
52 | | - |
53 | | -```C++ |
54 | | -... |
55 | | -participant.writeGlobalData("angles", writeAngles); |
56 | | -... |
| 13 | +<data:scalar name="GlobalData" /> |
| 14 | + |
| 15 | +<mesh name="GlobalA" dimensions="3"> |
| 16 | + <use-data name="GlobalData" /> |
| 17 | +</mesh> |
| 18 | + |
| 19 | +<mesh name="GlobalB" dimensions="3"> |
| 20 | + <use-data name="GlobalData" /> |
| 21 | +</mesh> |
| 22 | + |
| 23 | +<participant name="A" > |
| 24 | + <provide-mesh name="GlobalMeshA" /> |
| 25 | + <write-data mesh="GlobalMeshA" name="GlobalData" /> |
| 26 | +</participant> |
| 27 | + |
| 28 | +<participant name="B" > |
| 29 | + <provide-mesh name="GlobalMeshB" /> |
| 30 | + <receive-mesh name="GlobalMeshA" /> |
| 31 | + <read-data mesh="GlobalMeshB" name="GlobalData" /> |
| 32 | + <mapping:nearest-neighbor constraint="consistent" direction="read" from="GlobalMeshA" to="GlobalMeshB"/> |
| 33 | +</participant> |
57 | 34 | ``` |
58 | | - |
59 | | -For SolverTwo: |
60 | | - |
61 | | -```C++ |
62 | | -... |
63 | | -participant.readGlobalData("angles", dt, readAngles); |
64 | | -... |
65 | | - |
66 | | -``` |
67 | | - |
68 | | -## Supported functionality |
69 | | - |
70 | | -Global data exchange is supported in both explicit and implicit [coupling schemes](https://precice.org/configuration-coupling.html) with serial as well as parallel [coupling flow](https://precice.org/couple-your-code-coupling-flow.html#parallel-coupling-schemes). |
71 | | - |
72 | | -Within implicit coupling, convergence measures and acceleration are not yet supported. |
73 | | - |
74 | | -[Data initialization](https://precice.org/couple-your-code-initializing-coupling-data.html) and [time interpolation](https://precice.org/couple-your-code-waveform.html) are also supported for global data. |
0 commit comments