@@ -401,6 +401,7 @@ cdef class Participant:
401
401
positions : array_like
402
402
The coordinates of the vertices in a numpy array [N x D] where
403
403
N = number of vertices and D = dimensions of geometry.
404
+ A list of the same shape is also accepted.
404
405
405
406
Returns
406
407
-------
@@ -435,6 +436,16 @@ cdef class Participant:
435
436
>>> vertex_ids = participant.set_mesh_vertices(mesh_name, positions)
436
437
>>> vertex_ids.shape
437
438
(5,)
439
+
440
+ Set mesh vertices for a 3D problem with 5 mesh vertices, where the positions are a list of tuples.
441
+
442
+ >>> positions = [(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5)]
443
+ >>> positions.shape
444
+ (5, 3)
445
+ >>> mesh_name = "MeshOne"
446
+ >>> vertex_ids = participant.set_mesh_vertices(mesh_name, positions)
447
+ >>> vertex_ids.shape
448
+ (5,)
438
449
"""
439
450
check_array_like(positions, " positions" , " set_mesh_vertices" )
440
451
@@ -496,6 +507,7 @@ cdef class Participant:
496
507
vertices : array_like
497
508
The IDs of the vertices in a numpy array [N x 2] where
498
509
N = number of edges and D = dimensions of geometry.
510
+ A list of the same shape is also accepted.
499
511
500
512
Examples
501
513
--------
@@ -557,6 +569,7 @@ cdef class Participant:
557
569
vertices : array_like
558
570
The IDs of the vertices in a numpy array [N x 3] where
559
571
N = number of triangles and D = dimensions of geometry.
572
+ A list of the same shape is also accepted.
560
573
561
574
Examples
562
575
--------
@@ -621,6 +634,7 @@ cdef class Participant:
621
634
vertices : array_like
622
635
The IDs of the vertices in a numpy array [N x 4] where
623
636
N = number of quads and D = dimensions of geometry.
637
+ A list of the same shape is also accepted.
624
638
625
639
Examples
626
640
--------
@@ -685,6 +699,7 @@ cdef class Participant:
685
699
vertices : array_like
686
700
The IDs of the vertices in a numpy array [N x 4] where
687
701
N = number of quads and D = dimensions of geometry.
702
+ A list of the same shape is also accepted.
688
703
689
704
Examples
690
705
--------
@@ -794,6 +809,13 @@ cdef class Participant:
794
809
>>> vertex_ids = [1, 2, 3, 4, 5]
795
810
>>> values = np.array([[v1_x, v1_y, v1_z], [v2_x, v2_y, v2_z], [v3_x, v3_y, v3_z], [v4_x, v4_y, v4_z], [v5_x, v5_y, v5_z]])
796
811
>>> participant.write_data(mesh_name, data_name, vertex_ids, values)
812
+
813
+ Write vector data for a 3D (D=3) problem with 5 (N=5) vertices, where the values are provided as a list of tuples:
814
+ >>> mesh_name = "MeshOne"
815
+ >>> data_name = "DataOne"
816
+ >>> vertex_ids = [1, 2, 3, 4, 5]
817
+ >>> values = [(v1_x, v1_y, v1_z), (v2_x, v2_y, v2_z), (v3_x, v3_y, v3_z), (v4_x, v4_y, v4_z), (v5_x, v5_y, v5_z)]
818
+ >>> participant.write_data(mesh_name, data_name, vertex_ids, values)
797
819
"""
798
820
check_array_like(vertex_ids, " vertex_ids" , " write_data" )
799
821
check_array_like(values, " values" , " write_data" )
@@ -934,8 +956,14 @@ cdef class Participant:
934
956
>>> coordinates = np.array([[c1_x, c1_y], [c2_x, c2_y], [c3_x, c3_y], [c4_x, c4_y], [c5_x, c5_y]])
935
957
>>> values = np.array([v1, v2, v3, v4, v5])
936
958
>>> participant.write_and_map_data(mesh_name, data_name, coordinates, values)
937
- """
938
959
960
+ Write scalar data for a 2D problem with 5 vertices, where the coordinates are provided as a list of tuples, and the values are provided as a list of scalars:
961
+ >>> mesh_name = "MeshOne"
962
+ >>> data_name = "DataOne"
963
+ >>> coordinates = [(c1_x, c1_y), (c2_x, c2_y), (c3_x, c3_y), (c4_x, c4_y), (c5_x, c5_y)]
964
+ >>> values = [v1, v2, v3, v4, v5]
965
+ >>> participant.write_and_map_data(mesh_name, data_name, coordinates, values)
966
+ """
939
967
check_array_like(coordinates, " coordinates" , " write_and_map_data" )
940
968
check_array_like(values, " values" , " write_and_map_data" )
941
969
@@ -982,13 +1010,21 @@ cdef class Participant:
982
1010
Read scalar data for a 2D problem with 2 vertices:
983
1011
>>> mesh_name = "MeshOne"
984
1012
>>> data_name = "DataOne"
1013
+ >>> coordinates = np.array([[1.0, 1.0], [2.0, 2.0]])
1014
+ >>> dt = 1.0
1015
+ >>> values = map_and_read_data(mesh_name, data_name, coordinates, dt)
1016
+ >>> values.shape
1017
+ >>> (2, )
1018
+
1019
+ Read scalar data for a 2D problem with 2 vertices, where the coordinates are provided as a list of tuples:
1020
+ >>> mesh_name = "MeshOne"
1021
+ >>> data_name = "DataOne"
985
1022
>>> coordinates = [(1.0, 1.0), (2.0, 2.0)]
986
1023
>>> dt = 1.0
987
1024
>>> values = map_and_read_data(mesh_name, data_name, coordinates, dt)
988
1025
>>> values.shape
989
1026
>>> (2, )
990
1027
"""
991
-
992
1028
check_array_like(coordinates, " coordinates" , " map_and_read_data" )
993
1029
994
1030
if not isinstance (coordinates, np.ndarray):
@@ -997,7 +1033,7 @@ cdef class Participant:
997
1033
size = coordinates.shape[0 ]
998
1034
dimensions = self .get_data_dimensions(mesh_name, data_name)
999
1035
1000
- cdef vector[double ] cpp_coordinates = coordinates
1036
+ cdef vector[double ] cpp_coordinates = coordinates.flatten()
1001
1037
cdef vector[double ] cpp_values = [- 1 for _ in range (size * dimensions)]
1002
1038
1003
1039
self .thisptr.mapAndReadData (convert(mesh_name), convert(data_name), cpp_coordinates, relative_read_time, cpp_values)
@@ -1045,6 +1081,13 @@ cdef class Participant:
1045
1081
>>> gradients = np.array([[v1x_dx, v1y_dx, v1x_dy, v1y_dy], [v2x_dx, v2y_dx, v2x_dy, v2y_dy]])
1046
1082
>>> participant.write_gradient_data(mesh_name, data_name, vertex_ids, gradients)
1047
1083
1084
+ Write gradient vector data for a 2D problem with 2 vertices, where the gradients are provided as a list of tuples:
1085
+ >>> mesh_name = "MeshOne"
1086
+ >>> data_name = "DataOne"
1087
+ >>> vertex_ids = [1, 2]
1088
+ >>> gradients = [(v1x_dx, v1y_dx, v1x_dy, v1y_dy), (v2x_dx, v2y_dx, v2x_dy, v2y_dy)]
1089
+ >>> participant.write_gradient_data(mesh_name, data_name, vertex_ids, gradients)
1090
+
1048
1091
Write vector data for a 3D problem with 2 vertices:
1049
1092
>>> mesh_name = "MeshOne"
1050
1093
>>> data_name = "DataOne"
@@ -1072,7 +1115,6 @@ cdef class Participant:
1072
1115
1073
1116
self .thisptr.writeGradientData (convert(mesh_name), convert(data_name), cpp_vertex_ids, cpp_gradients)
1074
1117
1075
-
1076
1118
def requires_gradient_data_for (self , mesh_name , data_name ):
1077
1119
"""
1078
1120
Checks if the given data set requires gradient data. We check if the data object has been intialized with the gradient flag.
@@ -1096,11 +1138,9 @@ cdef class Participant:
1096
1138
>>> data_name = "DataOne"
1097
1139
>>> participant.is_gradient_data_required(mesh_name, data_name)
1098
1140
"""
1099
-
1100
1141
return self .thisptr.requiresGradientDataFor(convert(mesh_name), convert(data_name))
1101
1142
1102
-
1103
- def set_mesh_access_region (self , mesh_name , bounding_box ):
1143
+ def set_mesh_access_region (self , mesh_name , bounding_box ):
1104
1144
"""
1105
1145
This function is required if you don't want to use the mapping schemes in preCICE, but rather
1106
1146
want to use your own solver for data mapping. As opposed to the usual preCICE mapping, only a
@@ -1156,8 +1196,7 @@ cdef class Participant:
1156
1196
1157
1197
self .thisptr.setMeshAccessRegion(convert(mesh_name), cpp_bounding_box)
1158
1198
1159
-
1160
- def get_mesh_vertex_ids_and_coordinates (self , mesh_name ):
1199
+ def get_mesh_vertex_ids_and_coordinates (self , mesh_name ):
1161
1200
"""
1162
1201
Iterating over the region of interest defined by bounding boxes and reading the corresponding
1163
1202
coordinates omitting the mapping. This function is still experimental.
0 commit comments