You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you do not configure any features in the preCICE configuration that require mesh connectivity, all these API functions are [no-ops](https://en.wikipedia.org/wiki/NOP_(code)). Thus, don't worry about performance. If you need a significant workload to already create this connectivity information in your adapter in the first place, you can also explicitly ask preCICE whether it is required:
The API function `isMeshConnectivityRequired` is only supported since v2.3.
40
47
{% endwarning %}
41
48
49
+
{% warning %}
50
+
The bulk API functions are only supported since v3.
51
+
{% endwarning %}
52
+
42
53
Maybe interesting to know: preCICE actually does internally not compute with quads, but creates two triangles. [Read more](https://precice.discourse.group/t/highlights-of-the-new-precice-release-v2-1/274#2-1-using-quads-for-projection).
43
54
44
55
{% warning %}
@@ -48,52 +59,45 @@ Quads are only supported since v2.1. For older version, the methods only exist a
48
59
The following code shows how mesh connectivity can be defined in our example. For sake of simplification, let's only define one triangle and let's assume that it consists of the first three vertices.
<!-- TODO: Section below should be the default on branch precice-v3 -->
70
-
## Changes in v3
71
-
72
-
Version 3 overhauls the definition of meshes.
73
-
74
-
Connectivity now consists of explicitly defined elements (elements created via calls to the API) and implicitly defined elements (elements additionally created by preCICE).
75
-
As an example, explicitly defining a triangle ABC via the API guarantees the existence of the implicit edges AB, AC, and BC.
76
-
77
-
Furthermore, all connectivity is defined only via vertex IDs. There are no more edge IDs to worry about.
78
-
The order of vertices also does not matter. Triangles BAC and CAB are considered duplicates and preCICE removes one of them during the deduplication step.
91
+
## Mesh pre-processing
79
92
80
-
The API for defining individual connectivity elements looks as follows:
93
+
preCICE pre-processes all provided meshes during initialization, removing duplicates and adding missing hierarchical elements.
81
94
82
-
```cpp
83
-
void setMeshEdge(precice::string_view meshName, int firstVertexID, int secondVertexID);
84
-
void setMeshTriangle(precice::string_view meshName, int firstVertexID, int secondVertexID, int thirdVertexID);
85
-
void setMeshQuad(precice::string_view meshName, int firstVertexID, int secondVertexID, int thirdVertexID, int fourthVertexID);
86
-
void setMeshTetrahredron(precice::string_view meshName, int firstVertexID, int secondVertexID, int thirdVertexID, int fourthVertexID);
87
-
```
88
-
89
-
Each of the above functions is accompanied by a bulk version, which allows to set multiple elements in a single call.
95
+
Some projection-based features require all hierarchical elements to be present.
96
+
Meaning, a triangle ABC requires edges AB, BC and AC to exist.
97
+
Manually defining such elements is not a pleasant experience, especially when dealing with tetrahedra whilst avoiding duplicates.
Copy file name to clipboardExpand all lines: pages/docs/couple-your-code/couple-your-code-direct-access.md
+28-21Lines changed: 28 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -14,41 +14,48 @@ These API functions are work in progress, experimental, and are not yet released
14
14
This concept is required if you want to access received meshes directly. It might be relevant in case you don't want to use the mapping schemes in preCICE, but rather want to use your own solver for data mapping. As opposed to the usual preCICE mapping, only a single mesh (from the other participant) is now involved in this situation since an 'own' mesh defined by the participant itself is not required any more. In order to re-partition the received mesh, the participant needs to define the mesh region it wants read data from and write data to. The complete concept on the receiving participant looks as follows:
15
15
16
16
```cpp
17
-
// Allocate a bounding-box vector containing lower and upper bounds per
18
-
// space dimension
19
-
std::vector<double> boundingBox(dim * 2);
20
-
21
-
// fill the allocated 'boundingBox' according to the interested region
22
-
// with the desired bounds...
23
-
// Get relevant IDs. Note that "ReceivedMeshname" is not a name of a
17
+
// Note that "ReceivedMeshname" is not a name of a
24
18
// provided mesh, but a mesh defined by another participant. Accessing
25
19
// a received mesh directly is disabled in a usual preCICE configuration.
26
-
const int otherMeshID = precice.getMeshID("ReceivedMeshName");
27
-
const int writeDataID = precice.getDataID("WriteDataName", otherMeshID);
summary: "preCICE uses MPI for communication between different participants (and also for communication between ranks of the same participant). So are there any problems if the solver that you intend to couple also already uses MPI (e.g. for parallelization)? Who should initialize MPI? Who should finalize MPI? This is what we discuss here."
6
6
---
7
7
8
-
It is not complicated. There are just three rules that preCICE follows:
8
+
It is not complicated. There are three rules that preCICE follows:
9
9
10
10
* preCICE only initializes MPI if it is not yet initialized (by e.g. the solver you want to couple).
11
11
* preCICE finalizes MPI if and only if it was also initialized by preCICE.
12
12
* preCICE only initializes MPI if it needs MPI.
13
+
* preCICE uses `MPI_COMM_WORLD` if no custom communicator is provided.
summary: "In previous steps, we only considered explicit coupling. We now move onto implicit coupling, so sub-iterating each time step multiple times until a convergence threshold is reached. This stabilzes strongly-coupled problems."
6
6
---
7
7
8
-
The main ingredient needed for implicit coupling is move backwards in time. For that, we need a [flux capacitor](https://www.youtube.com/watch?v=VcZe8_RZO8c). Just kidding :wink:. What we really need is that your solver can write and read iteration checkpoints. An iteration checkpoint should contain all the information necessary to reload a previous state of your solver. What exactly is needed depends solely on your solver. preCICE tells you when you need to write and read checkpoints. To this end, preCICE uses the following action interface:
8
+
The main ingredient needed for implicit coupling is move backwards in time. For that, we need a [flux capacitor](https://www.youtube.com/watch?v=VcZe8_RZO8c). Just kidding :wink:. What we really need is that your solver can write and read iteration checkpoints. An iteration checkpoint should contain all the information necessary to reload a previous state of your solver. What exactly is needed depends solely on your solver. preCICE tells you when you need to write and read checkpoints. To this end, preCICE uses the following interface:
* `isActionRequired` inquires the necessity of a certain action. It takes a string argument to reference the action.
18
-
* `markActionFulfilled` tells preCICE that the action is fulfilled. This is a simple safeguard. If a certain action is required and you did not mark it as fulfilled preCICE will complain.
19
-
* The Methods in the `precice::constants` namespace return strings to reference specific actions. For implicit coupling, we need `actionReadIterationCheckpoint` and `actionWriteIterationCheckpoint`.
15
+
These functions perform double duty:
16
+
17
+
1. They inform the adapter that writing or reading a checkpoint is required by the solver.
18
+
2. They let preCICE know that your adapter is capable of implicit coupling. preCICE will show an error if you configure implicit coupling without calling these functions.
20
19
21
20
Let's extend our example code to also handle implicit coupling.
22
21
@@ -25,17 +24,13 @@ turnOnSolver(); //e.g. setup and partition mesh
0 commit comments