Skip to main content

Post-processing tools 2025 R1

test_dvs_client_cxx

Last update: 16.07.2025
Go to the documentation of this file.
1/* *************************************************************
2 * Copyright 2017-2023 ANSYS, Inc.
3 * All Rights Reserved.
4 *
5 * Restricted Rights Legend
6 *
7 * Use, duplication, or disclosure of this
8 * software and its documentation by the
9 * Government is subject to restrictions as
10 * set forth in subdivision [(b)(3)(ii)] of
11 * the Rights in Technical Data and Computer
12 * Software clause at 52.227-7013.
13 * *************************************************************
14 */
15
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <stdint.h>
28#include <stdarg.h>
29
33#include "logger.h"
34#include "test_dynamic_data.h"
35
36#include <vector>
37
38#ifdef _WIN32
39#include <Windows.h>
40#else
41#include <unistd.h>
42#endif
43
44static void logging_function(void* user_data, const char* message)
45{
46 fprintf(stderr, message);
47}
48
56int main(int argc, char** argv)
57{
58 uint32_t port = 50055;
59 uint32_t msec_delay = 0;
60 char host[512] = {0};
61 strcpy(host, "127.0.0.1");
62 char protocol[10] = {0};
63 strcpy(protocol, "grpc");
64 uint32_t width = 50;
65 uint32_t height = 50;
66 uint32_t depth = 50;
67 uint32_t max_timesteps = 10;
68 uint32_t current_rank = 0;
69 uint32_t total_ranks = 1;
70 uint8_t create_ghosts = 1;
71 uint8_t block_for_server = 1;
72 uint32_t starting_timestep = 0;
73 uint32_t dedup = 1;
74 bool send_structured_parts = false;
75 char dataset_id[255] = {0};
76 strcpy(dataset_id, "Test-C++-API");
77 char secret[255] = {0};
78 uint32_t plot_rank = 0;
79 uint32_t server_number = 0;
80 uint32_t server_verbosity = 0;
81 uint32_t local_ranks = 0;
82 uint32_t all_defs = false;
83 char cache_uri[512] = {0};
84 bool log_all = false;
85 uint32_t debug_wait = 0;
86 bool start_server = false;
87 bool test_delete = false;
88
89 uint32_t i = 1;
90 while (i < argc)
91 {
92 if ((strcmp(argv[i], "-p") == 0 ) && (i < argc - 1))
93 {
94 i++;
95 port = atoi(argv[i]);
96 }
97 else if ((strcmp(argv[i], "-h") == 0) && (i < argc - 1))
98 {
99 i++;
100 strncpy(host, argv[i], 255);
101 }
102 else if ((strcmp(argv[i], "-protocol") == 0) && (i < argc - 1))
103 {
104 i++;
105 strncpy(protocol, argv[i], 10);
106 if (strcmp(protocol, "grpc") != 0 && strcmp(protocol, "null") != 0 )
107 {
108 fprintf(stderr, "protocol: %s invalid\n", protocol);
109 exit(1);
110 }
111 }
112 else if ((strcmp(argv[i], "-d") == 0) && (i < argc - 1))
113 {
114 i++;
115 msec_delay = atoi(argv[i]);
116 }
117 else if ((strcmp(argv[i], "-s") == 0) && (i < argc - 3))
118 {
119 i++;
120 width = atoi(argv[i++]);
121 height = atoi(argv[i++]);
122 depth = atoi(argv[i]);
123 }
124 else if ((strcmp(argv[i], "-t") == 0) && (i < argc - 1))
125 {
126 i++;
127 max_timesteps = atoi(argv[i]);
128 }
129 else if ((strcmp(argv[i], "-r") == 0) && (i < argc - 2))
130 {
131 i++;
132 current_rank = atoi(argv[i++]);
133 total_ranks = atoi(argv[i]);
134 }
135 else if (strcmp(argv[i], "-noghost") == 0)
136 {
137 create_ghosts = 0;
138 }
139 else if (strcmp(argv[i], "-nowait") == 0)
140 {
141 block_for_server = 0;
142 }
143 else if ((strcmp(argv[i], "-start") == 0) && (i < argc - 1))
144 {
145 i++;
146 starting_timestep = atoi(argv[i]);
147 }
148 else if (strcmp(argv[i], "-nodedup") == 0)
149 {
150 dedup = 0;
151 }
152 else if (strcmp(argv[i], "-id") == 0)
153 {
154 i++;
155 memset(dataset_id, 0, 255);
156 strncpy(dataset_id, argv[i], 255);
157 }
158 else if (strcmp(argv[i], "-secret") == 0)
159 {
160 i++;
161 strncpy(secret, argv[i], 255);
162 }
163 else if (strcmp(argv[i], "-structured") == 0)
164 {
165 send_structured_parts = true;
166 }
167 else if (strcmp(argv[i], "-plot_rank") == 0)
168 {
169 i++;
170 plot_rank = atoi(argv[i]);
171 }
172 else if (strcmp(argv[i], "-server") == 0 && (i < argc - 3))
173 {
174 i++;
175 start_server = true;
176 server_number = atoi(argv[i++]);
177 local_ranks = atoi(argv[i++]);
178 server_verbosity = atoi(argv[i]);
179 }
180 else if (strcmp(argv[i], "-cache_uri") == 0)
181 {
182 i++;
183 strncpy(cache_uri, argv[i], 512);
184 }
185 else if (strcmp(argv[i], "-all_defs") == 0)
186 {
187 all_defs = true;
188 }
189 else if (strcmp(argv[i], "-log_all") == 0)
190 {
191 log_all = true;
192 }
193 else if (strcmp(argv[i], "-debug_wait") == 0)
194 {
195 i++;
196 debug_wait = atoi(argv[i]);
197 }
198 else if (strcmp(argv[i], "-test_delete") == 0)
199 {
200 test_delete = true;
201 }
202 else
203 {
204 fprintf(stderr, "Unknown option: %s\n", argv[i]);
205 fprintf(stderr, "Usage: %s [-p port] [-h host] [-d msec_delay] [-t num_timesteps] [-s dx dy dz] [-noghost] [-nowait] [-start t]\n", argv[0]);
206 fprintf(stderr, "Options:\n");
207 fprintf(stderr, " -t timesteps Number of timesteps to generate. Default: %u\n", max_timesteps);
208 fprintf(stderr, " -p port Server port to connect to. Default: %u\n", port);
209 fprintf(stderr, " -h host Server hostname to connect to. Default: %s\n", host);
210 fprintf(stderr, " -protocol str Server protocol. I.E. grpc or null. Default: grpc");
211 fprintf(stderr, " -d delay Number of milliseconds to delay between timestep pushes. Default: %u\n", msec_delay);
212 fprintf(stderr, " -s dx dy dz Size of 3D hex grid (width height depth) Default: %u %u %u\n", width, height, depth);
213 fprintf(stderr, " -r x y Rank information x=current rank (0 based), y=total number of ranks. Default: %u %u\n", current_rank, total_ranks);
214 fprintf(stderr, " -noghost Do not create ghost elements\n");
215 fprintf(stderr, " -nowait Do not wait for server to be available\n");
216 fprintf(stderr, " -start t Begin timesteps with timestep Default: %u\n", starting_timestep);
217 fprintf(stderr, " -nodedup Do not de-duplicate data on the client side Default: deduplicate\n");
218 fprintf(stderr, " -id string Set an id/name for the dataset Default: TestID\n");
219 fprintf(stderr, " -secret string Shared secret to use when talking with server Default: no shared secret\n");
220 fprintf(stderr, " -structured Turn on sending structured part data Default: Don't send structured part data\n");
221 fprintf(stderr, " -plot_rank Set the rank which should send plot data to EnSight (zero based) Default: %u\n", plot_rank);
222 fprintf(stderr, " -server n r v Start a server using server number [n], expecting [r] local ranks for DVS connections to connect to with verbosity [v]. Local Rank Min/Max: 1/1000\n");
223 fprintf(stderr, " -cache_uri str The URI for the server to use for the cache. Default: No cache\n");
224 fprintf(stderr, " -all_defs Send all part/var definitions no matter the current rank. Default: No\n");
225 fprintf(stderr, " -log_all Print out all client logging information\n. Default: No client logs");
226 fprintf(stderr, " -debug_wait ms Wait for [ms] for debugging\n");
227 fprintf(stderr, " -test_delete Test deleting all timesteps before each update Default: Do not test\n");
228 exit(1);
229 }
230 i++;
231 }
232
233 if (debug_wait > 0)
234 {
235 #ifdef _WIN32
236 Sleep(debug_wait);
237 #else
238 usleep(debug_wait*1000);
239 #endif
240 }
241
242 char uri[512] = {0};
243 sprintf(uri, "%s://%s:%u", protocol, host, port);
244 fprintf(stderr, "Connecting to: %s\n", uri);
245 fprintf(stderr, "Timestep delay: %u\n", msec_delay);
246
247 uint32_t send_vars = 1;
248 uint32_t send_elems = 1;
249 uint32_t send_hex_elems = 1;
250 uint32_t send_nfaced_elems = 1;
251 uint32_t send_pnt_elems = 1;
252 uint32_t send_tri_quad_elems = 1;
253 uint32_t send_nsided_elems = 0;
254 uint32_t send_plots = 1;
255
256 dvs_client_flags flags;
257 if (block_for_server) flags = static_cast<dvs_client_flags>(flags | dvs_client_flags::BLOCK_FOR_SERVER);
258 if (dedup) flags = static_cast<dvs_client_flags>(flags | dvs_client_flags::DEDUP);
259
260 fprintf(stderr, "Client Flags: Blocking: %d, Dedup: %u\n", (BLOCK_FOR_SERVER & flags) > 0, (DEDUP & flags) > 0);
261
262 DVS::IServer* server = DVS::CREATE_SERVER_INSTANCE(uri);
263 if (server == nullptr)
264 {
265 fprintf(stderr, "Failed to create server\n");
266 exit(1);
267 }
268 if (start_server)
269 {
270 char temp[10];
271 snprintf(temp, 10, "%u", server_verbosity);
272 server->set_option("VERBOSE",temp);
273 if (strlen(cache_uri) > 0) server->set_option("CACHE_URI",cache_uri);
274 server->startup(server_number, local_ranks);
275 auto uri = server->get_uri();
276 if (uri){
277 fprintf(stderr, "The final uri is: %s\n", uri);
278 }
279 }
280
281 DVS::IClient* client = nullptr;
282 client = DVS::CREATE_CLIENT_INSTANCE(server, flags, secret);
283 fprintf(stderr, "Current Client Version: %s\n", client->get_version());
284 if (client == nullptr)
285 {
286 fprintf(stderr, "Failed to create client\n");
287 exit(1);
288 }
290 client->set_logger(new DVS::Logger(nullptr, log_flags, logging_function));
291 {
292 if (part_info_num != 7 || var_info_num != 9)
293 {
294 fprintf(stderr, "This pseudo client code relies on part infos == 7 and var infos == 7, needs modified otherwise\n");
295 exit(1);
296 }
297
298 struct TestDynamicData test;
299 test_dynamic_data_init(&test, 0, current_rank, total_ranks);
300 client->begin_init(dataset_id, test.current_rank, test.total_ranks, test.num_chunks);
301 client->set_unit_system(test.unit_system);
302 client->add_metadata(test.metadata_keys, test.metadata_vals, test.metadata_num_pairs);
303 //TODO: Have this done in only the 0th rank once merging definitions is finished
304 if (send_plots && current_rank == plot_rank) client->add_plot_info(test.plots, plot_info_num);
305
306 if ((total_ranks == 1) || (total_ranks == 2) || all_defs)
307 {
308 //If one rank or two ranks and first rank send everything (tests second rank having no definitions)
309 if (current_rank == 0 || all_defs)
310 {
311 client->add_part_info(test.parts, part_info_num);
312 client->add_var_info(test.vars, var_info_num);
313 }
314 }
315 else if (total_ranks == 3)
316 {
317 //If 3 ranks splitup definition data between first 2 ranks
318 //the last rank will not have any (will receive data from others)
319 if (current_rank == 0)
320 {
321 //Send part 0
322 client->add_part_info(test.parts, 1);
323 //Send vars 0->1
324 client->add_var_info(test.vars, 2);
325 }
326 else if (current_rank == 1)
327 {
328 //Send parts 1->2
329 client->add_part_info(&test.parts[1], part_info_num-1);
330 //Send vars 2->5
331 client->add_var_info(&test.vars[2], var_info_num - 2);
332 }
333 //Third rank will have empty definitions which should be filled in
334 }
335 else if (total_ranks > 3)
336 {
337 //If more than 3 ranks splitup data between first 3 ranks
338 //other 3 ranks will not have any (will receive data from others)
339 if (current_rank == 0)
340 {
341 //Send part 0
342 client->add_part_info(test.parts, 1);
343 //Send vars 0->1
344 client->add_var_info(test.vars, 2);
345 }
346 else if (current_rank == 1)
347 {
348 //Send part 1
349 client->add_part_info(&test.parts[1], 1);
350 //Send parts 2->3
351 client->add_var_info(&test.vars[2], 2);
352 }
353 else if (current_rank == 2)
354 {
355 //Send part 2
356 client->add_part_info(&test.parts[2], part_info_num-2);
357 //Send parts 4->5
358 client->add_var_info(&test.vars[4], var_info_num - 4);
359 }
360 }
361 else
362 {
363 //Situation not currently handled exit out
364 fprintf(stderr, "Bad Initialization of Ranks\n");
365 exit(1);
366 }
367
368 client->end_init();
369 }
370
371 uint32_t update_num = 0; // Keep a running update number for this session
372 for (uint32_t i = starting_timestep; i < max_timesteps; i++)
373 {
374 if (i > 1 + starting_timestep && msec_delay)
375 {
376 #ifdef _WIN32
377 Sleep(msec_delay);
378 #else
379 usleep(msec_delay*1000);
380 #endif
381 }
382 if (test_delete && i != starting_timestep) {
383 fprintf(stderr, "Rank: %i of %i Deleting Item\n", (current_rank+1), total_ranks);
384 client->delete_item(update_num++, current_rank, "/timestep.time/gte/0.0");
385 }
386 fprintf(stderr, "Rank: %i of %i Sending Timestep: %i of %i\n", (current_rank+1), total_ranks, (i+1), max_timesteps);
387
388 struct TestDynamicData test;
389 test_dynamic_data_init(&test, i, current_rank, total_ranks);
390 test.ghosts = create_ghosts;
391 test_dynamic_data_create_mesh_and_elements(&test, width, height, depth);
392
393 client->begin_update(update_num++, current_rank, test.current_chunk, test.time);
394
395 if (send_structured_parts)
396 {
398 (
399 test.parts[5]._id,
400 test.pp_global_ijk_max,
401 test.pp_local_ijk_min,
402 test.pp_local_ijk_max,
403 test.pp_origin,
404 test.pp_unit_vec_i,
405 test.pp_unit_vec_j,
406 test.pp_unit_vec_k,
407 test.pp_i_vals,
408 test.pp_j_vals,
409 test.pp_k_vals
410 );
411
413 (
414 test.parts[6]._id,
415 test.curv_global_ijk_max,
416 test.curv_local_ijk_min,
417 test.curv_local_ijk_max,
418 test.curv_x_vals,
419 test.curv_y_vals,
420 test.curv_z_vals
421 );
422 }
423
424 if (send_hex_elems) client->update_nodes(test.parts[0]._id, test.mesh_x_coords, test.mesh_y_coords, test.mesh_z_coords, test.mesh_coords_size);
425 if (send_pnt_elems) client->update_nodes(test.parts[1]._id, test.mesh_x_coords, test.mesh_y_coords, test.mesh_z_coords, test.mesh_coords_size);
426 if (send_nfaced_elems) client->update_nodes(test.parts[2]._id, test.mesh_x_coords, test.mesh_y_coords, test.mesh_z_coords, test.mesh_coords_size);
427 if (send_tri_quad_elems) client->update_nodes(test.parts[3]._id, test.mesh_x_coords, test.mesh_y_coords, test.mesh_z_coords, test.mesh_coords_size);
428 if (send_nsided_elems) client->update_nodes(test.parts[4]._id, test.polymesh_x_coords, test.polymesh_y_coords, test.polymesh_z_coords, test.polymesh_coords_size);
429
430 if (send_elems)
431 {
432 if (send_hex_elems)
433 {
434 client->update_elements(test.parts[0]._id, HEXAHEDRON, test.mesh_hex_elem_coords, test.mesh_hex_elem_coords_size);
435 if (test.mesh_hex_ghost_elem_coords_size > 0)
436 {
437 client->update_elements(test.parts[0]._id, HEXAHEDRON_GHOST, test.mesh_hex_ghost_elem_coords, test.mesh_hex_ghost_elem_coords_size);
438 }
439 }
440
441 if (send_nfaced_elems)
442 {
444 (
445 test.parts[2]._id,
446 CONVEX_POLYHEDRON,
447 test.mesh_nfaced_hex_elem_faces_per_elem,
448 test.mesh_nfaced_hex_elem_faces_per_elem_size,
449 test.mesh_nfaced_hex_elem_nodes_per_face,
450 test.mesh_nfaced_hex_elem_nodes_per_face_size,
451 test.mesh_nfaced_hex_elem_coords,
452 test.mesh_nfaced_hex_elem_coords_size
453 );
454 if (test.mesh_nfaced_hex_ghost_elem_coords_size > 0)
455 {
457 (
458 test.parts[2]._id,
459 CONVEX_POLYHEDRON_GHOST,
460 test.mesh_nfaced_hex_ghost_elem_faces_per_elem,
461 test.mesh_nfaced_hex_ghost_elem_faces_per_elem_size,
462 test.mesh_nfaced_hex_ghost_elem_nodes_per_face,
463 test.mesh_nfaced_hex_ghost_elem_nodes_per_face_size,
464 test.mesh_nfaced_hex_ghost_elem_coords,
465 test.mesh_nfaced_hex_ghost_elem_coords_size
466 );
467 }
468 }
469
470 if (send_nsided_elems && current_rank == 0)
471 {
472 //Only send if current rank is 0 as we aren't
473 //splitting this part up based on rank
475 (
476 test.parts[4]._id,
477 N_SIDED_POLYGON,
478 test.polymesh_elem_nodes_per_face,
479 test.polymesh_elem_nodes_per_face_size,
480 test.polymesh_elem_nodes,
481 test.polymesh_elem_nodes_size
482 );
483 }
484
485 if (send_pnt_elems) client->update_elements(test.parts[1]._id, PNT, test.mesh_point_elem_coords, test.mesh_point_elem_coords_size);
486
487 if (send_tri_quad_elems)
488 {
489 client->update_elements(test.parts[3]._id, QUADRANGLE, test.mesh_quad_elem_coords, test.mesh_quad_elem_coords_size);
490 client->update_elements(test.parts[3]._id, TRIANGLE, test.mesh_tri_elem_coords, test.mesh_tri_elem_coords_size);
491 }
492 }
493
494 if (send_vars)
495 {
496 //Case vars not working correctly with DVS
497 client->update_var_case(dvs_var_type::SCALAR, test.vars[6]._id, &test.case_var_value, 1);
498 client->update_var_part(dvs_var_type::SCALAR, test.vars[4]._id, test.parts[0]._id, &test.part_scalar[0], 1);
499 client->update_var_part(dvs_var_type::SCALAR, test.vars[4]._id, test.parts[1]._id, &test.part_scalar[1], 1);
500 if (send_hex_elems) client->update_var_element(HEXAHEDRON, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[0]._id, test.mesh_hex_elem_var_scalar, test.mesh_hex_elem_var_scalar_size);
501 if (send_hex_elems) client->update_var_element(HEXAHEDRON, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[0]._id, test.mesh_hex_elem_var_rank_scalar, test.mesh_hex_elem_var_rank_scalar_size);
502
503 //N-FACED Elements use the same elemental vars for now as hex elements
504 if (send_nfaced_elems) client->update_var_element(CONVEX_POLYHEDRON, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[2]._id, test.mesh_hex_elem_var_scalar, test.mesh_hex_elem_var_scalar_size);
505 if (send_nfaced_elems) client->update_var_element(CONVEX_POLYHEDRON, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[2]._id, test.mesh_hex_elem_var_rank_scalar, test.mesh_hex_elem_var_rank_scalar_size);
506
507 if (send_structured_parts)
508 {
509 client->update_var_element(STRUCTURED, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[5]._id, test.structured_elem_var_scalar, test.structured_elem_var_scalar_size);
510 client->update_var_element(STRUCTURED, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[5]._id, test.structured_elem_var_scalar_rank, test.structured_elem_var_scalar_rank_size);
511
512 client->update_var_element(STRUCTURED, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[6]._id, test.structured_elem_var_scalar, test.structured_elem_var_scalar_size);
513 client->update_var_element(STRUCTURED, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[6]._id, test.structured_elem_var_scalar_rank, test.structured_elem_var_scalar_rank_size);
514 }
515
516 if (test.mesh_hex_ghost_elem_var_scalar_size > 0)
517 {
518 if (send_hex_elems) client->update_var_element(HEXAHEDRON_GHOST, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[0]._id, test.mesh_hex_ghost_elem_var_scalar, test.mesh_hex_ghost_elem_var_scalar_size);
519 //N-FACED Elements use the same elemental vars for now as hex elements
520 if (send_nfaced_elems) client->update_var_element(CONVEX_POLYHEDRON_GHOST, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[2]._id, test.mesh_hex_ghost_elem_var_scalar, test.mesh_hex_ghost_elem_var_scalar_size);
521 }
522 if (test.mesh_hex_ghost_elem_var_rank_scalar_size > 0)
523 {
524 if (send_hex_elems) client->update_var_element(HEXAHEDRON_GHOST, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[0]._id, test.mesh_hex_ghost_elem_var_rank_scalar, test.mesh_hex_ghost_elem_var_rank_scalar_size);
525 //N-FACED Elements use the same elemental vars for now as hex elements
526 if (send_nfaced_elems) client->update_var_element(CONVEX_POLYHEDRON_GHOST, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[2]._id, test.mesh_hex_ghost_elem_var_rank_scalar, test.mesh_hex_ghost_elem_var_rank_scalar_size);
527 }
528
529 if (send_pnt_elems) client->update_var_element(PNT, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[1]._id, test.mesh_point_elem_var_rank_scalar, test.mesh_point_elem_var_rank_scalar_size);
530
531 if (send_nfaced_elems) client->update_var_element(HEXAHEDRON, dvs_var_type::VECTOR, test.vars[3]._id, test.parts[0]._id, test.mesh_hex_elem_var_vector, test.mesh_hex_elem_var_vector_size);
532 if (test.mesh_hex_ghost_elem_var_vector_size > 0)
533 {
534 if (send_nfaced_elems) client->update_var_element(HEXAHEDRON_GHOST, dvs_var_type::VECTOR, test.vars[3]._id, test.parts[0]._id, test.mesh_hex_ghost_elem_var_vector, test.mesh_hex_ghost_elem_var_vector_size);
535 }
536
537 if (send_tri_quad_elems)
538 {
539 client->update_var_element(QUADRANGLE, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[3]._id, test.mesh_quad_elem_var_scalar, test.mesh_quad_elem_var_scalar_size);
540 client->update_var_element(QUADRANGLE, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[3]._id, test.mesh_quad_elem_var_rank_scalar, test.mesh_quad_elem_var_rank_scalar_size);
541 client->update_var_element(TRIANGLE, dvs_var_type::SCALAR, test.vars[2]._id, test.parts[3]._id, test.mesh_tri_elem_var_scalar, test.mesh_tri_elem_var_scalar_size);
542 client->update_var_element(TRIANGLE, dvs_var_type::SCALAR, test.vars[5]._id, test.parts[3]._id, test.mesh_tri_elem_var_rank_scalar, test.mesh_tri_elem_var_rank_scalar_size);
543 }
544
545 client->update_var_node(dvs_var_type::SCALAR, test.vars[0]._id, test.parts[0]._id, test.mesh_node_var_scalar, test.mesh_node_var_scalar_size);
546 client->update_var_node(dvs_var_type::VECTOR, test.vars[1]._id, test.parts[0]._id, test.mesh_node_var_vector, test.mesh_node_var_vector_size);
547 client->update_var_node(dvs_var_type::SCALAR, test.vars[0]._id, test.parts[2]._id, test.mesh_node_var_scalar, test.mesh_node_var_scalar_size);
548 client->update_var_node(dvs_var_type::VECTOR, test.vars[1]._id, test.parts[2]._id, test.mesh_node_var_vector, test.mesh_node_var_vector_size);
549
550 if (send_structured_parts)
551 {
552 client->update_var_node(dvs_var_type::SCALAR, test.vars[0]._id, test.parts[5]._id, test.structured_nodal_scalar, test.structured_nodal_scalar_size);
553 client->update_var_node(dvs_var_type::SCALAR, test.vars[0]._id, test.parts[6]._id, test.structured_nodal_scalar, test.structured_nodal_scalar_size);
554 }
555 }
556
557 if (send_plots && current_rank == plot_rank)
558 {
559 client->update_plot(test.plots[0]._id, test.plot_x_values[0], test.plot_y_values[0], test.plot_num_values);
560 client->update_plot(test.plots[1]._id, test.plot_x_values[1], test.plot_y_values[1], test.plot_num_values);
561 client->update_plot(test.plots[2]._id, test.plot_x_values[2], test.plot_y_values[2], test.plot_num_values);
562 }
563 client->end_update();
564
565 test_dynamic_data_free(&test);
566 }
567 DVS::DESTROY_CLIENT_INSTANCE(client);
568
569 if (start_server)
570 {
571 //If we started our own server wait for the pending timesteps to clear before tearing everything down
572 //in case it was writing stuff.
573
574 //Not waiting isn't a problem but if we had another process connecting to this
575 //process' server and sending data we might lose the last timestep since it won't be
576 //fully complete and we would not have written it yet.
577 uint32_t num_pending = 1;
578 uint32_t num_complete = 0;
579 while (num_pending > 0) {
580 dvs_ret error = server->get_timestep_count(num_pending, num_complete);
581 if (error != DVS_NONE) break;
582 // Avoid burning up a CPU waiting for the I/O to complete
583 const uint32_t temp_delay_ms = 50;
584#ifdef _WIN32
585 Sleep(temp_delay_ms);
586#else
587 usleep(temp_delay_ms * 1000);
588#endif
589 }
590 }
591 DVS::DESTROY_SERVER_INSTANCE(server);
592
593 return 0;
594}
API for solvers to use to send data to EnSight servers.
virtual void set_logger(ILogger *logger)=0
Set the logger interface to use.
virtual dvs_ret update_nodes_structured(uint32_t part_id, const uint32_t global_ijk_max[3], const uint32_t local_ijk_min[3], const uint32_t local_ijk_max[3], const float origin[3], const float dir_i[3], const float dir_j[3], const float dir_k[3], const float *i_vals, const float *j_vals, const float *k_vals)=0
Update the nodes for a parallelepiped structured part.
virtual dvs_ret add_plot_info(const dvs_plot_info *plot_info, uint32_t num_plots)=0
Add plot information for session.
virtual dvs_ret set_unit_system(const char *system)=0
Set the unit system we are using for this session (optional)
virtual dvs_ret update_elements(uint32_t part_id, dvs_element_type type, const uint32_t *indices, uint32_t num_indices)=0
Update elements for a specific part and element type.
virtual dvs_ret delete_item(uint32_t update_num, uint32_t rank, const char *filter)=0
Delete an item.
virtual dvs_ret add_part_info(const dvs_part_info *part_info, uint32_t num_parts)=0
Add part information for session.
virtual dvs_ret end_update()=0
Call to end the update for this timestep/rank/chunk.
virtual dvs_ret update_elements_polyhedral(uint32_t part_id, dvs_element_type type, const uint32_t *faces_per_element, uint32_t faces_per_element_size, const uint32_t *nodes_per_face, uint32_t nodes_per_face_size, const uint32_t *indices, uint32_t indices_size)=0
Update N-FACED Elements.
virtual dvs_ret add_var_info(const dvs_var_info *var_info, uint32_t num_vars)=0
Add variable information for session.
virtual dvs_ret update_nodes(uint32_t part_id, const float *x, const float *y, const float *z, uint32_t num_values)=0
Update nodes for a specific part.
virtual dvs_ret update_var_case(dvs_var_type var_type, uint32_t var_id, const float *values, uint32_t num_values)=0
Update case variable.
virtual const char * get_version()=0
Get the version of the client API.
virtual dvs_ret end_init()=0
Finish initialization for this rank.
virtual dvs_ret update_var_part(dvs_var_type var_type, uint32_t var_id, uint32_t part_id, const float *values, uint32_t num_values)=0
Update part vector variable.
virtual dvs_ret add_metadata(const char *const keys[], const char *const vals[], uint32_t num_metadata_pairs)=0
Add metadata for the current dataset.
virtual dvs_ret begin_update(uint32_t update_num, uint32_t rank, uint32_t chunk, float time)=0
Method to begin an update.
virtual dvs_ret update_elements_polygon(uint32_t part_id, dvs_element_type type, const uint32_t *nodes_per_polygon, uint32_t nodes_per_polygon_size, const uint32_t *indices, uint32_t indices_size)=0
Update N-SIDED elements.
virtual dvs_ret update_var_node(dvs_var_type var_type, uint32_t var_id, uint32_t part_id, const float *values, uint32_t num_values)=0
Update nodal variable values.
virtual dvs_ret update_var_element(dvs_element_type elem_type, dvs_var_type var_type, uint32_t var_id, uint32_t part_id, const float *values, uint32_t num_values)=0
Update elemental scalar variable values.
virtual dvs_ret update_plot(uint32_t plot_id, const float *x_values, const float *y_values, uint32_t num_values)=0
Update plot data for plot.
virtual dvs_ret begin_init(const char *dataset_name, uint32_t current_rank, uint32_t total_ranks, uint32_t num_chunks)=0
Begins initialization for this rank.
Interface class used to run a dynamic data server in a thread accepting incoming client connections.
virtual const char * get_uri()=0
Get URI of this server.
virtual void set_option(const char *key, const char *value)=0
Set a specific option on the server, these are used during startup See See Server Options.
virtual dvs_ret startup(uint32_t server_number, uint32_t local_ranks)=0
Start the server.
virtual dvs_ret get_timestep_count(uint32_t &num_pending, uint32_t &num_complete) const =0
return the current number of pending and complete timesteps in the server
C++ Client API for using the Dynamic Visualization Store.
C++ Server API for using Dynamic Visualization Store Server.
Contains enums used in C/C++ API.
dvs_log_flags
Flags to control logging filters.
@ LOG_UPDATE_BEG_END
Log messages related to begin and end of updates.
@ LOG_ALL
Log all messages.
dvs_client_flags
Flags for specific server setup.
@ DEDUP
Do not send duplicate data to server.
@ BLOCK_FOR_SERVER
Clients should block for servers to be initialized before sending data.
@ VECTOR
XYZ Coordinates.
int32_t dvs_ret
Return value of methods, TODO.
#define DVS_NONE
No detected error has occurred.
int main(int argc, char **argv)
Main method of test client application.

Connect with Ansys