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
Copy file name to clipboardExpand all lines: tutorial/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Tutorials for integrating the _CoSimIO_
2
2
3
-
This folder contains step-by-step instructions on how to integrate the _CoSimIO_ into a solver/software-tool. Since the _CoSimIO_ is independent of Kratos, this can be done completely standalone.
3
+
This folder contains step-by-step instructions on how to integrate the _CoSimIO_ into a solver/software-tool. Since the _CoSimIO_ is independent of Kratos, this is done completely standalone.
4
4
5
5
Each subfolder has the tutorial for an specific language:
6
6
***C++ Interface**: Is the natural interface of the _CoSimIO_ providing its full capabilities.
It is important to mention that the `CoSimIO_Info` is a pointer to the cpp info class which is allocated by the `CoSimIO_CreateInfo()`. So it is don't forget to free it when is not needed anymore using `CoSimIO_FreeInfo()` function. This container can be used to pass additional information about the solver/software-tool or connection settings to the CoSimIO:
97
97
98
98
```c
99
-
CoSimIO_Info_SetString(settings, "my_name", "the_name_of_this_solver"); // The name of this solver
100
-
CoSimIO_Info_SetString(settings, "connect_to", "the_other_solver_name"); // The name of the solver to connect to
99
+
CoSimIO_Info_SetString(settings, "my_name", "the_name_of_this_solver"); // my name
100
+
CoSimIO_Info_SetString(settings, "connect_to", "the_other_solver_name"); // to whom I want to connect toto
This function returns a `Info` object containing information about the connection which can be queried using `CoSimIO_Info_Get...` functions:
105
104
105
+
This method returns a `Info` object containing information about the connection which can be queried using `CoSimIO_Info_Get...` method. For further calls to `CoSimIO` it is necessary to get the `connection_name`:
106
106
```c
107
107
CoSimIO_Info_GetString(info, "connection_name");
108
108
CoSimIO_Info_GetInt(info, "connection_status");
@@ -117,10 +117,10 @@ Now putting together everything:
117
117
intmain()
118
118
{
119
119
CoSimIO_Info settings=CoSimIO_CreateInfo();
120
-
CoSimIO_Info_SetString(settings, "my_name", "the_name_of_this_solver"); // The name of this solver
121
-
CoSimIO_Info_SetString(settings, "connect_to", "the_other_solver_name"); // The name of the solver to connect to
This example can be found in [integration_tutorials/c/connect_disconnect.c](../../tests/integration_tutorials/c/connect_disconnect.c).
157
+
This example can be found in [integration_tutorials/c/connect_disconnect_a.c](../../tests/integration_tutorials/c/connect_disconnect_a.c) and [integration_tutorials/c/connect_disconnect_b.c](../../tests/integration_tutorials/c/connect_disconnect_b.c).
160
158
161
159
162
160
## Tutorial 4: Data Exchange
@@ -171,7 +169,7 @@ First we should create a setting which provides an identifier (like "velocity_of
CoSimIO_Info_SetString(import_settings, "connection_name", connection_name); // connection_name is obtained from calling "Connect"
199
197
```
200
198
201
199
In this case we just pass an empty pointer and specifying to the `ImportData()` that should allocate the data by itself. So, in order to ensure the memory coherance, the `CoSimIO_Free()` function should be used instead of standard `free()` function:
@@ -216,54 +214,50 @@ After seeing how we transfer raw data between solvers/software-tools, it is time
The argument `model_part` is a container for mesh, it contains nodes and elements. Check the [implementation](../../co_sim_io/c/co_sim_io_c_model_part.h) and the [tests](../../tests/co_sim_io/c/model_part/test_model_part.c) for details of `CoSimIO::ModelPart`.
226
222
227
-
* `number_of_nodes`: Number of Nodes (== size(`nodal_coordinates`)/3)
228
-
* `number_of_elements`: Number of Elements (== size(`elements_types`))
229
-
* `number_of_elements_connectivities`: Number of Elements connectivities (== size(`elements_connectivities`))
230
-
231
-
* `nodal_coordinates`: A vector of doubles of 3D coordinates of each node in x1,y1,z1,x2,y2,z2,... format:
223
+
Nodes can be created like this:
232
224
```c
233
-
double nodal_coordinates[] = {
234
-
0.0, 2.5, 1.0, /*0*/
235
-
2.0, 0.0, 1.5, /*1*/
236
-
2.0, 2.5, 1.5, /*2*/
237
-
4.0, 2.5, 1.7, /*3*/
238
-
4.0, 0.0, 1.7, /*4*/
239
-
6.0, 0.0, 1.8 /*5*/
240
-
};
241
-
```
242
-
*`elements_connectivities`: A vector of int containing the zero based index of each node in e1_1,e1_2,...,e2_1, e2_2,... format:
CoSimIO_Line2D2, // Type of element, see "co_sim_io/c/co_sim_io_c_model_part.h"
244
+
connectivity // Connectivity information, i.e. Ids of nodes that the element has
245
+
);
250
246
```
251
247
252
-
*`elements_types`: A vector of int containing the type of the elements. They are according to the vtk cell types, see [this link](https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf), page 9 & 10.
248
+
Don't forget to free the `CoSimIO_ModelPart` after using it with
253
249
```c
254
-
int elements_types[] = {5,5,5,5}; // VTK_TRIANGLE
250
+
CoSimIO_FreeModelPart(model_part);
255
251
```
256
252
257
253
On the other side one can use the `ImportMesh()` method to get the mesh sent by the export:
This example can be found in [integration_tutorials/c/export_mesh.c](../../tests/integration_tutorials/c/export_mesh.c) and [integration_tutorials/c/import_mesh.c](../../tests/integration_tutorials/c/import_mesh.c).
@@ -276,7 +270,8 @@ The overview of the Kratos CoSimulation Library can be found [here](../README.md
276
270
The building instructions for the Kratos CoSimulation Library can be found [here](../README.md#building-kratos-with-cosimulation).
For connecting to Kratos it is very important to have in mind that Kratos also uses *CoSimIO* for interprocess communication so its python interface reflects the CoSimIO. So we may create a python script for connecting and disconnecting in the same way described in the [python tutorial](https://github.com/KratosMultiphysics/CoSimIO/blob/master/tutorial/python/README.md):
273
+
coming soon!
274
+
<!-- For connecting to Kratos it is very important to have in mind that Kratos also uses *CoSimIO* for interprocess communication so its python interface reflects the CoSimIO. So we may create a python script for connecting and disconnecting in the same way described in the [python tutorial](https://github.com/KratosMultiphysics/CoSimIO/blob/master/tutorial/python/README.md):
280
275
281
276
```Python
282
277
from KratosMultiphysics.CoSimulationApplication import CoSimIO
@@ -302,10 +297,11 @@ Then you may run your executable with python script of Kratos from your working
Here we try to send some data to Kratos and get it back from it. Then we can check if both data are the same. Again the python file for Kratos side is very similar to the one descirbed in the [python tutorial](https://github.com/KratosMultiphysics/CoSimIO/blob/master/tutorial/python/README.md):
303
+
coming soon!
304
+
<!-- Here we try to send some data to Kratos and get it back from it. Then we can check if both data are the same. Again the python file forKratos side is very similar to the one descirbedin the [python tutorial](https://github.com/KratosMultiphysics/CoSimIO/blob/master/tutorial/python/README.md):
This tutorial shows how to map data between (non matching) meshes with Kratos. It is based on tutorials 9 & 10.
511
+
coming soon!
512
+
<!-- This tutorial shows how to map data between (non matching) meshes with Kratos. It is based on tutorials 9 & 10.
515
513
516
514
In this tutorial we first send two meshes based on the same geometry but with different discretizations to Kratos. Those meshes are used as basis for the mapping. In Kratos teminology those are the origin and the destination.
0 commit comments