Skip to main content

Post-processing tools 2025 R1

test_dvs_reader

Last update: 16.07.2025
Go to the documentation of this file.
1/**************************************************************
2*
3* (C) 2024 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.
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*/
16
24#include <string.h>
25
26#include "logger_verbose.h"
28#include <array>
29#include <chrono>
30#include <functional>
31#include <memory>
32#include <string>
33#include <thread>
34#include <vector>
35#include <cfloat>
36#include <iostream>
37
38static void logging_function(void* user_data, const char* message)
39{
40 fprintf(stdout, message);
41}
42
43static void print(const DVS::IObject* object)
44{
45 if (object)
46 {
47 std::string object_name = "Unknown:";
48 if (object->get_type() == DVS::IObject::PART) {
49 object_name = "Part";
50 }
51 else if (object->get_type() == DVS::IObject::PLOT) {
52 object_name = "Plot";
53 }
54
55 fprintf( stdout, "%s: Name: %s Type: %i\n", object_name.c_str(), object->get_name(), object->get_type() );
56 fprintf( stdout, "Dataset Name: %s\n", object->get_dataset()->get_name());
57 fprintf( stdout, "Metadata Size: %u\n", object->get_num_metadata());
58 if (object->get_num_metadata()) {
59 for (uint32_t metadata_idx = 0; metadata_idx < object->get_num_metadata(); metadata_idx++) {
60 fprintf(stdout, "Key: %s, Val:%s ", object->get_metadata_key(metadata_idx), object->get_metadata_value(metadata_idx));
61 }
62 fprintf(stdout, "\n");
63 }
64 fprintf(stdout, "\n");
65 }
66}
67
68static void print(const DVS::IVar* var)
69{
70 if (var)
71 {
72 fprintf( stdout, "Var: Name: %s, Type: %i, Location: %i, Unit Dim: %s, Unit Label: %s\n",
73 var->get_name(), var->get_var_type(), var->get_var_location(), var->get_unit_dimension(), var->get_unit_label());
74 fprintf(stdout, "Dataset Name: %s\n", var->get_dataset()->get_name());
75 fprintf( stdout, "Metadata Size: %u\n", var->get_num_metadata());
76 if (var->get_num_metadata()) {
77 for (uint32_t metadata_idx = 0; metadata_idx < var->get_num_metadata(); metadata_idx++) {
78 fprintf(stdout, "Key: %s, Val:%s ", var->get_metadata_key(metadata_idx), var->get_metadata_value(metadata_idx));
79 }
80 fprintf(stdout, "\n");
81 }
82 fprintf(stdout, "\n");
83 }
84}
85
93int main(int argc, char** argv)
94{
95 DVS::IServer* server = nullptr;
96 char server_uri[512] = {0};
97 char server_filter[512] = {0};
98 char cache_uri[512] = {0};
99 uint32_t debug_wait = 0;
100 uint32_t timestep_wait = 0;
101 bool all_coords = false;
102 bool all_connectivity = false;
103 bool all_variable_data = false;
104 uint32_t server_number = 0;
105 uint32_t local_ranks = 1;
106 uint32_t server_verbosity = 0;
107
108 uint32_t i = 1;
109 while (i < argc)
110 {
111 if ((strcmp(argv[i], "-cache_uri") == 0) && (i < argc - 1))
112 {
113 i++;
114 strncpy(cache_uri, argv[i], 512);
115 }
116 else if ((strcmp(argv[i], "-server_uri") == 0) && (i < argc - 1))
117 {
118 i++;
119 strncpy(server_uri, argv[i], 512);
120 }
121 else if ((strcmp(argv[i], "-server_filter") == 0))
122 {
123 i++;
124 strncpy(server_filter, argv[i], 512);
125 }
126 else if ((strcmp(argv[i], "-all_coords") == 0))
127 {
128 all_coords = true;
129 }
130 else if ((strcmp(argv[i], "-all_conn") == 0))
131 {
132 all_connectivity = true;
133 }
134 else if ((strcmp(argv[i], "-all_vars") == 0))
135 {
136 all_variable_data = true;
137 }
138 else if (strcmp(argv[i], "-server") == 0 && (i < argc - 3))
139 {
140 i++;
141 server_number = atoi(argv[i++]);
142 local_ranks = atoi(argv[i++]);
143 server_verbosity = atoi(argv[i]);
144 }
145 else if ((strcmp(argv[i], "-all_vars") == 0))
146 {
147 all_variable_data = true;
148 }
149 else if ((strcmp(argv[i], "-debug_wait") == 0) && (i < argc - 1))
150 {
151 i++;
152 debug_wait = atoi(argv[i]);
153 }
154 else if ((strcmp(argv[i], "-timestep_wait") == 0) && (i < argc - 1))
155 {
156 i++;
157 timestep_wait = atoi(argv[i]);
158 }
159 else
160 {
161 fprintf(stderr, "Unknown option: %s\n", argv[i]);
162 fprintf(stderr, "Usage: %s [-uri str] [-debug_wait ms] \n", argv[0]);
163 fprintf(stderr, "Options:\n");
164 fprintf(stderr, " -cache_uri str The URI for the reader to use for the cache. Default: No cache\n");
165 fprintf(stderr, " -server_uri str The URI for the reader to connect to a running DVS server. Default: no server\n");
166 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. Defaults to 0 1 0\n");
167 fprintf(stderr, " -server_filter A filter to apply to the query generated from the DVS server");
168 fprintf(stderr, " -all_coords Print the full coordinates for the mesh chunks iterated over (not a good idea for large datasets)\n");
169 fprintf(stderr, " -all_conn Print the full connectivity for the element blocks iterated over (not a good idea for large datasets)\n");
170 fprintf(stderr, " -all_vars Print the full variable values for mesh chunks and element blocks (not a good idea for large datasets)\n");
171 fprintf(stderr, " -debug_wait s Wait for [s] for debugging\n");
172 fprintf(stderr, " -timestep_wait s Wait for [s] for eventual new timesteps\n");
173 exit(1);
174 }
175 i++;
176 }
177
178 if (debug_wait > 0) {
179 std::this_thread::sleep_for(std::chrono::seconds(debug_wait));
180 }
181
182 std::unique_ptr<DVS::IQuery, std::function<void(DVS::IQuery*)>> dataset_query(DVS::CREATE_QUERY_INSTANCE(),
183 [](DVS::IQuery* p){p->release();});
184 if (strlen(server_uri) > 0){
185 server = DVS::CREATE_SERVER_INSTANCE(server_uri);
186 server->startup_unthreaded(server_number, local_ranks);
187 server->update();
188 char temp[10];
189 snprintf(temp, 10, "%u", server_verbosity);
190 server->set_option("VERBOSE",temp);
191 DVS::IQuery* server_query;
192 server_query = server->create_query(std::string(server_filter));
193 dataset_query.reset(server_query);
194 }
195 dataset_query->set_logger(new DVS::LoggerVerbose(nullptr, dvs_verbosity::DVS_VERBOSE, &logging_function));
196 dvs_ret err;
197 if (!server){
198 err = dataset_query->add_uri(cache_uri);
199 if (DVS_NONE != err) {
200 return err;
201 }
202 }
203
204
205 fprintf(stdout, "---------------------------\n");
206 fprintf(stdout, "Listing All Timesteps for Query\n");
207 fprintf(stdout, "---------------------------\n");
208 uint32_t num_timesteps = 0;
209 if (server){
210 bool flag = true;
211 uint32_t pending, complete;
212 while (flag){
213 std::this_thread::sleep_for(std::chrono::seconds(timestep_wait));
214 server->get_timestep_count(pending, complete);
215 if (pending > 0){
216 server->update();
217 dataset_query->clear_data();
218 auto server_query = server->create_query(std::string(server_filter));
219 dataset_query.reset(server_query);
220 }
221 else{
222 flag = false;
223 }
224 }
225 }
226
227 err = dataset_query->get_num_timesteps(num_timesteps);
228 if (DVS_NONE != err) {
229 fprintf(stdout, "Error getting number of timesteps\n");
230 return err;
231 }
232
233
234 std::vector<float> timesteps(num_timesteps, 0.f);
235 dataset_query->get_timesteps(timesteps.data());
236
237 fprintf(stdout, "Timesteps: ");
238 for (auto time : timesteps) {
239 fprintf (stdout, " %f", time);
240 }
241 fprintf(stdout, "\n");
242
243 fprintf(stdout, "---------------------------\n");
244 fprintf(stdout, "Listing All Ranks for Query\n");
245 fprintf(stdout, "---------------------------\n");
246 uint32_t num_ranks = 0;
247 err = dataset_query->get_num_ranks(num_ranks);
248 if (DVS_NONE != err) {
249 fprintf(stdout, "Error getting number of ranks\n");
250 return err;
251 }
252 std::vector<uint32_t> global_ranks(num_ranks, 0);
253 dataset_query->get_ranks(global_ranks.data());
254 for (auto rank : global_ranks) {
255 fprintf(stdout, "%u ", rank);
256 }
257 fprintf(stdout, "\n");
258
259 fprintf(stdout, "---------------------------\n");
260 fprintf(stdout, "Listing Max Chunks for Query\n");
261 fprintf(stdout, "---------------------------\n");
262
263 uint32_t num_chunks_per_rank = 0;
264 err = dataset_query->get_num_chunks_per_rank(num_chunks_per_rank);
265 if (DVS_NONE != err) {
266 fprintf(stdout, "Error getting number of chunks per rank\n");
267 return err;
268 }
269 std::vector<uint32_t> global_chunk_max(num_chunks_per_rank, 0);
270 dataset_query->get_chunks_per_rank(global_chunk_max.data());
271 for (auto chunk : global_chunk_max) {
272 fprintf(stdout, "%u ", chunk);
273 }
274 fprintf(stdout, "\n");
275
276 fprintf(stdout, "---------------------------\n");
277 fprintf(stdout, "Listing All Parts for Query\n");
278 fprintf(stdout, "---------------------------\n");
279 uint32_t num_parts = 0;
280 err = dataset_query->get_num_parts(num_parts);
281 if (DVS_NONE != err) {
282 fprintf(stdout, "Error getting number of parts\n");
283 return err;
284 }
285 for (uint32_t part_index = 0; part_index < num_parts; part_index++)
286 {
287 auto part = dataset_query->get_part(part_index);
288 if (!part) continue;
289 print(part);
290 }
291 fprintf(stdout, "---------------------------\n");
292 fprintf(stdout, "Listing All Plots for Query\n");
293 fprintf(stdout, "---------------------------\n");
294 uint32_t num_plots = 0;
295 err = dataset_query->get_num_plots(num_plots);
296 if (DVS_NONE != err) {
297 fprintf(stdout, "Error getting number of plots\n");
298 return err;
299 }
300 for (uint32_t plot_index = 0; plot_index < num_plots; plot_index++)
301 {
302 auto plot = dataset_query->get_plot(plot_index);
303 if (!plot) continue;
304 print(plot);
305 }
306 fprintf(stdout, "---------------------------\n");
307 fprintf(stdout, "Listing All Vars for Query\n");
308 fprintf(stdout, "---------------------------\n");
309 uint32_t num_vars = 0;
310 err = dataset_query->get_num_variables(num_vars);
311 if (DVS_NONE != err) {
312 fprintf(stdout, "Error getting number of vars\n");
313 return err;
314 }
315 for (uint32_t var_index = 0; var_index < num_vars; var_index++)
316 {
317 auto var = dataset_query->get_variable(var_index);
318 if (!var) continue;
319 print(var);
320 }
321 fprintf(stdout, "---------------------------\n");
322 fprintf(stdout, "Listing All Case Variables for Query\n\n");
323 num_vars = 0;
324 err = dataset_query->get_num_variables(num_vars);
325 if (DVS_NONE != err) {
326 fprintf(stdout, "Error getting number of vars for case vars\n");
327 return err;
328 }
329 for (uint32_t var_index = 0; var_index < num_vars; var_index++)
330 {
331 auto var = dataset_query->get_variable(var_index);
332 if (var && var->get_var_location() == dvs_var_location::CASE) {
333 const DVS::IDataset* dataset = var->get_dataset();
334 std::vector<float> var_value(var->get_float_count_per_value());
335 for (float timestep : timesteps) {
336 if (DVS_NONE == dataset_query->get_variable_data(dataset, var, timestep, var_value.data())) {
337 //Only scalars are supported for case/part variables right now so we
338 //can just look at the first value
339 fprintf(stdout, "Dataset: %s, Var: %s, Time: %f, Value: %f\n",
340 dataset->get_name(), var->get_name(), timestep, var_value[0]);
341 }
342 else {
343 fprintf(stdout, "Dataset: %s, Var: %s, Time: %f, No Value Found\n",
344 dataset->get_name(), var->get_name(), timestep);
345 }
346 }
347 }
348 }
349 fprintf(stdout, "---------------------------\n");
350 fprintf(stdout, "Listing All Part Variables for Query\n\n");
351 num_vars = 0;
352 err = dataset_query->get_num_variables(num_vars);
353 if (DVS_NONE != err) {
354 fprintf(stdout, "Error getting number of vars for part vars\n");
355 return err;
356 }
357 for (uint32_t var_index = 0; var_index < num_vars; var_index++)
358 {
359 auto var = dataset_query->get_variable(var_index);
360 if (var && var->get_var_location() == dvs_var_location::PART) {
361 auto dataset = var->get_dataset();
362 std::vector<float> var_value(var->get_float_count_per_value());
363 for (float timestep : timesteps) {
364 for (uint32_t part_index = 0; part_index < dataset->get_num_parts(); part_index++) {
365 const DVS::IObject* part = dataset->get_part(part_index);
366 if (!part) {
367 continue;
368 }
369 if (DVS_NONE == dataset_query->get_variable_data(part, var, timestep, var_value.data())) {
370 //Only scalars are supported for case/part variables right now so we
371 //can just look at the first value
372 fprintf(stdout, "Dataset: %s, Part: %s, Var: %s, Time: %f, Value: %f\n",
373 dataset->get_name(), part->get_name(), var->get_name(), timestep, var_value[0]);
374 }
375 else {
376 fprintf(stdout, "Dataset: %s, Part: %s, Var: %s, Time: %f, No Value Found\n",
377 dataset->get_name(), part->get_name(), var->get_name(), timestep);
378 }
379 }
380 }
381 }
382 }
383 fprintf(stdout, "---------------------------\n");
384 fprintf(stdout, "Listing All Datasets for Query\n");
385 uint32_t num_datasets = 0;
386 err = dataset_query->get_num_datasets(num_datasets);
387 if (DVS_NONE != err) {
388 fprintf (stdout, "Error getting number of datasets\n");
389 return err;
390 }
391 for (uint32_t dataset_idx = 0; dataset_idx < num_datasets; dataset_idx++)
392 {
393 DVS::IDataset* dataset = dataset_query->get_dataset(dataset_idx);
394 if (dataset)
395 {
396 fprintf(stdout, "---------------------------\n");
397 fprintf(stdout, "Dataset: %s Units System: %s\n",
398 dataset->get_name(), dataset->get_unit_system() );
399 for (uint32_t cur_pair = 0; cur_pair < dataset->get_num_metadata(); cur_pair++) {
400 fprintf(stdout, "Key: %s, Val: %s\n", dataset->get_metadata_key(cur_pair), dataset->get_metadata_value(cur_pair));
401 }
402 fprintf(stdout, "\n");
403
404 std::vector<uint32_t> ranks(dataset->get_num_ranks(), 0);
405 dataset->get_ranks(ranks.data());
406
407 fprintf(stdout, "Ranks: ");
408 for (auto rank : ranks) {
409 fprintf(stdout, " %u", rank);
410 }
411 fprintf(stdout, "\n");
412
413 std::vector<uint32_t> chunks(dataset->get_num_chunks_per_rank(), 0);
414 dataset->get_chunks_per_rank(chunks.data());
415 fprintf(stdout, "Chunks: ");
416 for (auto chunk : chunks) {
417 fprintf(stdout, " %u", chunk);
418 }
419 fprintf(stdout, "\n");
420
421 for (uint32_t part_idx = 0; part_idx < dataset->get_num_parts(); part_idx++) {
422 const DVS::IObject* part = dataset->get_part(part_idx);
423 if (!part) continue;
424 print(part);
425 }
426
427 for (uint32_t plot_idx = 0; plot_idx < dataset->get_num_plots(); plot_idx++) {
428 const DVS::IObject* plot = dataset->get_plot(plot_idx);
429 if (!plot) continue;
430 print(plot);
431 }
432
433 for (uint32_t var_idx = 0; var_idx < dataset->get_num_variables(); var_idx++) {
434 const DVS::IVar* var = dataset->get_var(var_idx);
435 if (!var) continue;
436 print(var);
437 }
438 }
439 }
440
441 fprintf(stdout, "---------------------------\n");
442 fprintf(stdout, "Listing All Mesh Chunks for Query\n");
443 fprintf(stdout, "---------------------------\n");
444 uint32_t num_mesh_chunks = 0;
445 err = dataset_query->get_num_mesh_chunks(num_mesh_chunks);
446 if (DVS_NONE != err) {
447 fprintf(stdout, "Error getting number of mesh chunks\n");
448 return err;
449 }
450 for (uint32_t index = 0; index < num_mesh_chunks; index++) {
451 DVS::IMeshChunk* mesh_chunk = dataset_query->get_mesh_chunk(index);
452 if (mesh_chunk) {
453 DVS::IMeshChunk::MeshType type = mesh_chunk->get_type();
454 const DVS::IObject* part = mesh_chunk->get_object();
455 float time = mesh_chunk->get_time();
456 uint32_t rank = mesh_chunk->get_rank();
457 uint32_t chunk = mesh_chunk->get_chunk();
458
459 std::string coords_hash(mesh_chunk->get_hash_size(), 0);
460 if (coords_hash.empty() || DVS_NONE != mesh_chunk->get_hash(&(coords_hash[0]))) {
461 fprintf(stdout, "ERROR: Could not load coordinates hash\n");
462 }
463
464 fprintf(stdout, "Mesh Chunk %u Type: %i Part: %s Rank: %u Chunk: %u Time: %f Hash: %s\n",
465 index, type, part->get_name(), rank, chunk, time, coords_hash.c_str());
466
467 std::array<uint32_t,3> num_coords;
468
469 dvs_ret coord_ret = DVS_NONE;
470
472 coord_ret = mesh_chunk->get_coords_size(num_coords[0]);
473 //Coords of all axis match for unstructured
474 num_coords[1] = num_coords[2] = num_coords[0];
475 }
477 coord_ret = mesh_chunk->get_coords_curv_size(num_coords[0]);
478 //Coords of all axis match for curvilinear
479 num_coords[1] = num_coords[2] = num_coords[0];
480 }
482 coord_ret = mesh_chunk->get_coords_parallele_size(num_coords[0], num_coords[1], num_coords[2]);
483 }
484 if (coord_ret != DVS_NONE) {
485 fprintf(stdout, "ERROR: %d Loading Coords Size\n", coord_ret);
486 }
487 else {
488 fprintf(stdout, "Size of coords arrays: X(I): %d Y(J): %d Z(K): %d\n", num_coords[0], num_coords[1], num_coords[2]);
489 }
490 if (coord_ret == DVS_NONE && all_coords) {
491
492 std::vector<float> x_coords(num_coords[0]);
493 std::vector<float> y_coords(num_coords[1]);
494 std::vector<float> z_coords(num_coords[2]);
495
496 //The vars are for structured data if needed
497 std::array<float,3> origin;
498 std::array<float,3> dir_vec_i, dir_vec_j, dir_vec_k;
499 std::array<float,3> local_ijk_min, local_ijk_max, global_ijk_max;
500
502 coord_ret = mesh_chunk->get_coords(x_coords.data(), y_coords.data(), z_coords.data());
503
504 //Validating the coords match if interleaved
505 std::vector<float> interleaved(num_coords[0]+num_coords[1]+num_coords[2]);
506 auto interleaved_ret = mesh_chunk->get_coords_interleaved(interleaved.data());
507 if (coord_ret == DVS_NONE && interleaved_ret == DVS_NONE) {
508 bool good_values = x_coords[0] == interleaved[0];
509 good_values &= y_coords[0] == interleaved[1];
510 good_values &= z_coords[0] == interleaved[2];
511 for (uint32_t i = 1; i < num_coords[0] && good_values; i++) {
512 good_values &= x_coords[i] == interleaved[i*3];
513 good_values &= y_coords[i] == interleaved[i*3+1];
514 good_values &= z_coords[i] == interleaved[i*3+2];
515 }
516 if (!good_values) {
517 fprintf(stdout, "ERROR: Interleaved coords don't match non-interleaved\n");
518 }
519 }
520 else if (interleaved_ret != DVS_NONE) {
521 //Error message for coord_ret handled later
522 fprintf(stdout, "ERROR: %d, Getting interleaved coords\n", interleaved_ret);
523 }
524 }
526 coord_ret = mesh_chunk->get_coords_curv(local_ijk_min.data(),
527 local_ijk_max.data(),
528 global_ijk_max.data(),
529 x_coords.data(),
530 y_coords.data(),
531 z_coords.data());
532 if (coord_ret == DVS_NONE) {
533 //Error message for coord_ret handled later
534 fprintf(stdout, "LocalIJKMin: %f %f %f\n", local_ijk_min[0], local_ijk_min[1], local_ijk_min[2]);
535 fprintf(stdout, "LocalIJKMax: %f %f %f\n", local_ijk_max[0], local_ijk_max[1], local_ijk_max[2]);
536 fprintf(stdout, "GlobalIJKMax: %f %f %f\n", global_ijk_max[0], global_ijk_max[1], global_ijk_max[2]);
537 }
538
539 //Validating the coords match if interleaved
540 std::vector<float> interleaved(num_coords[0]+num_coords[1]+num_coords[2]);
541 std::array<float,3> local_ijk_min_2, local_ijk_max_2, global_ijk_max_2;
542 auto interleaved_ret = mesh_chunk->get_coords_curv_interleaved(local_ijk_min_2.data(),
543 local_ijk_max_2.data(),
544 global_ijk_max_2.data(),
545 interleaved.data());
546 if (coord_ret == DVS_NONE && interleaved_ret == DVS_NONE) {
547 bool good_values = x_coords[0] == interleaved[0];
548 good_values &= y_coords[0] == interleaved[1];
549 good_values &= z_coords[0] == interleaved[2];
550 for (uint32_t i = 1; i < num_coords[0] && good_values; i++) {
551 good_values &= x_coords[i] == interleaved[i*3];
552 good_values &= y_coords[i] == interleaved[i*3+1];
553 good_values &= z_coords[i] == interleaved[i*3+2];
554 }
555 for (uint32_t i = 0; i < 3 && good_values; i++) {
556 good_values &= local_ijk_min[i] == local_ijk_min_2[i];
557 good_values &= local_ijk_max[i] == local_ijk_max_2[i];
558 good_values &= global_ijk_max[i] == global_ijk_max_2[i];
559 }
560 if (!good_values) {
561 fprintf(stdout, "ERROR: Interleaved curv coords don't match non-interleaved\n");
562 }
563 }
564 else if (interleaved_ret != DVS_NONE) {
565 //Error message for coord_ret handled later
566 fprintf(stdout, "ERROR: %d, Getting interleaved curv coords\n", interleaved_ret);
567 }
568 }
570 coord_ret = mesh_chunk->get_coords_parallele(origin.data(),
571 dir_vec_i.data(),
572 dir_vec_j.data(),
573 dir_vec_k.data(),
574 local_ijk_min.data(),
575 local_ijk_max.data(),
576 global_ijk_max.data(),
577 x_coords.data(),
578 y_coords.data(),
579 z_coords.data());
580 if (coord_ret == DVS_NONE) {
581 fprintf(stdout, "Origin: %f %f %f\n", origin[0], origin[1], origin[2]);
582 fprintf(stdout, "DirVecI: %f, %f, %f\n", dir_vec_i[0], dir_vec_i[1], dir_vec_i[2]);
583 fprintf(stdout, "DirVecJ: %f, %f, %f\n", dir_vec_j[0], dir_vec_j[1], dir_vec_j[2]);
584 fprintf(stdout, "DirVecK: %f, %f, %f\n", dir_vec_k[0], dir_vec_k[1], dir_vec_k[2]);
585 fprintf(stdout, "LocalIJKMin: %f %f %f\n", local_ijk_min[0], local_ijk_min[1], local_ijk_min[2]);
586 fprintf(stdout, "LocalIJKMax: %f %f %f\n", local_ijk_max[0], local_ijk_max[1], local_ijk_max[2]);
587 fprintf(stdout, "GlobalIJKMax: %f %f %f\n", global_ijk_max[0], global_ijk_max[1], global_ijk_max[2]);
588 }
589 }
590
591 if (coord_ret == DVS_NONE) {
592 fprintf(stdout, "X:");
593 for (uint32_t i = 0; i < num_coords[0]; i++) {
594 fprintf(stdout, " %f", x_coords[i]);
595 }
596 fprintf(stdout, "\n");
597
598 fprintf(stdout, "Y:");
599 for (uint32_t i = 0; i < num_coords[1]; i++) {
600 fprintf(stdout, " %f", y_coords[i]);
601 }
602 fprintf(stdout, "\n");
603
604 fprintf(stdout, "Z:");
605 for (uint32_t i = 0; i < num_coords[2]; i++) {
606 fprintf(stdout, " %f", z_coords[i]);
607 }
608 fprintf(stdout, "\n");
609 }
610 else {
611 fprintf(stdout, "ERROR: %d, Getting coords\n", coord_ret);
612 }
613 }
614
615 uint32_t num_nodal_vars = 0;
616 if (DVS_NONE != mesh_chunk->get_num_variables(num_nodal_vars)) {
617 fprintf(stdout, "ERROR: Could not get num nodal vars\n");
618 }
619 for (uint32_t var_index = 0; var_index < num_nodal_vars; var_index++) {
620 auto var = mesh_chunk->get_variable(var_index);
622 fprintf(stdout, "ERROR: Var is not nodal and should be\n");
623 }
624
625 uint32_t num_var_values = 0;
626 if (DVS_NONE != mesh_chunk->get_variable_size(var_index, num_var_values)) {
627 fprintf(stdout, "ERROR: Could not get nodal var data\n");
628 }
629
630 std::string nodal_var_hash_1(mesh_chunk->get_var_hash_size(var_index), 0);
631 std::string nodal_var_hash_2(mesh_chunk->get_var_hash_size(var), 0);
632 if (nodal_var_hash_1.empty() || DVS_NONE != mesh_chunk->get_var_hash(var_index, &(nodal_var_hash_1[0]))) {
633 fprintf(stdout, "ERROR: Could not get nodal var hash 1\n");
634 }
635 if (nodal_var_hash_2.empty() || DVS_NONE != mesh_chunk->get_var_hash(var, &(nodal_var_hash_2[0]))) {
636 fprintf(stdout, "ERROR: Could not get nodal var hash 2\n");
637 }
638 if (nodal_var_hash_1 != nodal_var_hash_2) {
639 fprintf(stdout, "ERROR: Nodal var hashes do not match\n");
640 }
641
642 fprintf(stdout, "Nodal Var: %s, Num Values: %u, Hash: %s\n", var->get_name(), num_var_values, nodal_var_hash_1.c_str());
643 if (all_variable_data) {
644 float min = FLT_MAX-1;
645 float max = -1*min;
646 std::vector<float> var_data(num_var_values);
647 if (DVS_NONE != mesh_chunk->get_variable_data(var_index, var_data.data())) {
648 fprintf(stdout, "ERROR: Could not get nodal var data\n");
649 }
650 fprintf(stdout, "VarData:");
651 for (const auto& val : var_data) {
652 fprintf(stdout, " %f", val);
653 if (val < min) {
654 min = val;
655 }
656 if (val > max) {
657 max = val;
658 }
659 }
660 fprintf(stdout, "\n");
661 fprintf(stdout, "Min: %f, Max: %f\n", min, max);
662 }
663 }
664
665 fprintf(stdout, "*******************************\n"
666 "Mesh Chunk: Test New Interfaces for Floats\n"
667 "*******************************\n");
668 uint32_t num_nodal_vars_floats = 0;
669 if (DVS_NONE != mesh_chunk->get_num_variables(num_nodal_vars_floats, DVS::VAR_TYPE::FLOAT)) {
670 fprintf(stdout, "ERROR: Could not get num nodal vars\n");
671 }
672 for (uint32_t var_index = 0; var_index < num_nodal_vars_floats; ++var_index) {
673 auto var = mesh_chunk->get_variable(var_index, DVS::VAR_TYPE::FLOAT);
675 fprintf(stdout, "ERROR: Var is not nodal and should be\n");
676 }
677
678 uint32_t num_var_values = 0;
679 if (DVS_NONE != mesh_chunk->get_variable_size(var_index, num_var_values, DVS::VAR_TYPE::FLOAT)) {
680 fprintf(stdout, "ERROR: Could not get nodal var data\n");
681 }
682
683 std::string nodal_var_hash_1(mesh_chunk->get_var_hash_size(var_index, DVS::VAR_TYPE::FLOAT), 0);
684 std::string nodal_var_hash_2(mesh_chunk->get_var_hash_size(var), 0);
685 if (nodal_var_hash_1.empty() || DVS_NONE != mesh_chunk->get_var_hash(var_index, &(nodal_var_hash_1[0]), DVS::VAR_TYPE::FLOAT)) {
686 fprintf(stdout, "ERROR: Could not get nodal var hash 1\n");
687 }
688 if (nodal_var_hash_2.empty() || DVS_NONE != mesh_chunk->get_var_hash(var, &(nodal_var_hash_2[0]))) {
689 fprintf(stdout, "ERROR: Could not get nodal var hash 2\n");
690 }
691 if (nodal_var_hash_1 != nodal_var_hash_2) {
692 fprintf(stdout, "ERROR: Nodal var hashes do not match\n");
693 }
694
695 fprintf(stdout, "Nodal Var: %s, Num Values: %u, Hash: %s\n", var->get_name(), num_var_values, nodal_var_hash_1.c_str());
696 if (all_variable_data) {
697 float min = FLT_MAX-1;
698 float max = -1*min;
699 std::vector<float> var_data(num_var_values);
700 if (DVS_NONE != mesh_chunk->get_variable_data(var_index, var_data.data())) {
701 fprintf(stdout, "ERROR: Could not get nodal var data\n");
702 }
703 fprintf(stdout, "VarData:");
704 for (const auto& val : var_data) {
705 std::cout << " " << val;
706 if (val < min) {
707 min = val;
708 }
709 if (val > max) {
710 max = val;
711 }
712 }
713 fprintf(stdout, "\n");
714 std::cout << "Min: " << min << ", Max: " << max << std::endl;
715 }
716 }
717
718 fprintf(stdout, "*******************************\n"
719 "Mesh Chunk: Test New Interfaces for Int64s\n"
720 "*******************************\n");
721 uint32_t num_nodal_vars_int64s = 0;
722 if (DVS_NONE != mesh_chunk->get_num_variables(num_nodal_vars_int64s, DVS::VAR_TYPE::INT64)) {
723 fprintf(stdout, "ERROR: Could not get num nodal vars\n");
724 }
725 for (uint32_t var_index = 0; var_index < num_nodal_vars_int64s; ++var_index) {
726 auto var = mesh_chunk->get_variable(var_index, DVS::VAR_TYPE::INT64);
728 fprintf(stdout, "ERROR: Var is not nodal and should be\n");
729 }
730
731 uint32_t num_var_values = 0;
732 if (DVS_NONE != mesh_chunk->get_variable_size(var_index, num_var_values, DVS::VAR_TYPE::INT64)) {
733 fprintf(stdout, "ERROR: Could not get nodal var data\n");
734 }
735
736 std::string nodal_var_hash_1(mesh_chunk->get_var_hash_size(var_index, DVS::VAR_TYPE::INT64), 0);
737 std::string nodal_var_hash_2(mesh_chunk->get_var_hash_size(var), 0);
738 if (nodal_var_hash_1.empty() || DVS_NONE != mesh_chunk->get_var_hash(var_index, &(nodal_var_hash_1[0]), DVS::VAR_TYPE::INT64)) {
739 fprintf(stdout, "ERROR: Could not get nodal var hash 1\n");
740 }
741 if (nodal_var_hash_2.empty() || DVS_NONE != mesh_chunk->get_var_hash(var, &(nodal_var_hash_2[0]))) {
742 fprintf(stdout, "ERROR: Could not get nodal var hash 2\n");
743 }
744 if (nodal_var_hash_1 != nodal_var_hash_2) {
745 fprintf(stdout, "ERROR: Nodal var hashes do not match\n");
746 }
747
748 fprintf(stdout, "Nodal Var: %s, Num Values: %u, Hash: %s\n", var->get_name(), num_var_values, nodal_var_hash_1.c_str());
749 if (all_variable_data) {
750 int64_t min = INT64_MAX-1;
751 int64_t max = -1*min;
752 std::vector<int64_t> var_data(num_var_values);
753 if (DVS_NONE != mesh_chunk->get_variable_data(var_index, var_data.data())) {
754 fprintf(stdout, "ERROR: Could not get nodal var data\n");
755 }
756 fprintf(stdout, "VarData:");
757 for (const auto& val : var_data) {
758 std::cout << " " << val;
759 if (val < min) {
760 min = val;
761 }
762 if (val > max) {
763 max = val;
764 }
765 }
766 fprintf(stdout, "\n");
767 std::cout << "Min: " << min << ", Max: " << max << std::endl;
768 }
769 }
770
771
772
773
774
775
776
777 uint32_t num_element_blocks = 0;
778 if (DVS_NONE != mesh_chunk->get_num_element_blocks(num_element_blocks)) {
779 fprintf(stdout, "ERROR: Could not get number of element blocks\n");
780 }
781 std::vector<dvs_element_type> element_block_types(num_element_blocks);
782 mesh_chunk->get_element_block_types(element_block_types.data());
783 for (const auto& elem_type : element_block_types) {
784 auto elem_block = mesh_chunk->get_element_block_by_type(elem_type);
785 if (elem_block) {
786 switch(elem_block->get_element_type())
787 {
788 case N_SIDED_POLYGON:
789 case N_SIDED_POLYGON_GHOST:
790 {
791 uint32_t dummy = 0;
792 uint32_t num_elements = 0;
793 uint32_t nodes_per_polygon_size = 0;
794 uint32_t indices_size = 0;
795 if (DVS_NONE != elem_block->get_num_elements(num_elements)) {
796 fprintf(stdout, "ERROR getting number of elements\n");
797 }
798 if (DVS_NONE == elem_block->get_nodes_per_element(dummy)) {
799 fprintf(stdout, "ERROR get_nodes_per_element should be invalid for this type\n");
800 }
801 if (DVS_NONE == elem_block->get_connectivity_size(dummy)) {
802 fprintf(stdout, "ERROR get_connectivity_size should be invalid for this type\n");
803 }
804 if (DVS_NONE == elem_block->get_connectivity(nullptr)) {
805 fprintf(stdout, "ERROR get_connectivity should be invalid for this type\n");
806 }
807 if (DVS_NONE == elem_block->get_connectivity_polyhedral_size(dummy, dummy, dummy)) {
808 fprintf(stdout, "ERROR get_connectivity_polyhedral_size should be invalid for this type\n");
809 }
810 if (DVS_NONE == elem_block->get_connectivity_polyhedral(nullptr,nullptr,nullptr)) {
811 fprintf(stdout, "ERROR get_connectivity_polyhedral should be invalid for this type\n");
812 }
813
814 if (DVS_NONE != elem_block->get_connectivity_polygon_size(nodes_per_polygon_size, indices_size)) {
815 fprintf(stdout, "ERROR with get_connectivity_polygon_size()\n");
816 }
817
818 std::string conn_hash(elem_block->get_hash_size(), 0);
819 if (conn_hash.empty() || elem_block->get_hash(&(conn_hash[0]))) {
820 fprintf(stdout, "ERROR: Could not load connectivity hash\n");
821 }
822 fprintf(stdout, "- Unstructured Polygon Element: Type: %i, Ghost: %u, Number of Elements: %u, Nodes Per Poly: %u, Indices Size: %u, Hash: %s\n",
823 elem_type, elem_block->get_is_ghost(), num_elements, nodes_per_polygon_size, indices_size, conn_hash.c_str());
824
825
826 if (DVS_NONE != elem_block->get_connectivity_polygon(nullptr, nullptr)) {
827 fprintf(stdout, "ERROR get_connectivity_polygon\n");
828 }
829
830 if (all_connectivity) {
831 std::vector<uint32_t> nodes_per_polygon(nodes_per_polygon_size);
832 std::vector<uint32_t> indices(indices_size);
833
834 if (DVS_NONE != elem_block->get_connectivity_polygon(nodes_per_polygon.data(),
835 indices.data())) {
836 fprintf(stdout, "ERROR get_connectivity_polygon\n");
837 }
838 else {
839 fprintf(stdout, "NPP:");
840 for (const auto& nodes : nodes_per_polygon) {
841 fprintf(stdout, " %u", nodes);
842 }
843 fprintf(stdout, "\n");
844 fprintf(stdout, "Indices:");
845 for (const auto& index : indices) {
846 fprintf(stdout, " %u", index);
847 }
848 fprintf(stdout, "\n");
849 }
850 }
851 break;
852 }
853 case CONVEX_POLYHEDRON:
854 case CONVEX_POLYHEDRON_GHOST:
855 {
856 uint32_t dummy = 0;
857 uint32_t num_elements = 0;
858 uint32_t faces_per_elem_size = 0;
859 uint32_t nodes_per_face_size = 0;
860 uint32_t indices_size = 0;
861 if (DVS_NONE != elem_block->get_num_elements(num_elements)) {
862 fprintf(stdout, "ERROR getting number of elements\n");
863 }
864 if (DVS_NONE == elem_block->get_nodes_per_element(dummy)) {
865 fprintf(stdout, "ERROR get_nodes_per_element should be invalid for this type\n");
866 }
867 if (DVS_NONE == elem_block->get_connectivity_size(dummy)) {
868 fprintf(stdout, "ERROR get_connectivity_size should be invalid for this type\n");
869 }
870 if (DVS_NONE == elem_block->get_connectivity_polygon_size(dummy, dummy)) {
871 fprintf(stdout, "ERROR get_connectivity_polygon_size should be invalid for this type\n");
872 }
873
874 if (DVS_NONE != elem_block->get_connectivity_polyhedral_size(faces_per_elem_size, nodes_per_face_size, indices_size)) {
875 fprintf(stdout, "ERROR with get_connectivity_polyhedral_size\n");
876 }
877
878 std::string conn_hash(elem_block->get_hash_size(), 0);
879 if (conn_hash.empty() || elem_block->get_hash(&(conn_hash[0]))) {
880 fprintf(stdout, "ERROR: Could not load connectivity hash\n");
881 }
882
883 fprintf(stdout, "- Unstructured Polyhedral Element: Type: %i, Ghost: %u, Number of Elements: %u, FPE: %u NPF: %u Indices: %u, Hash: %s\n",
884 elem_type, elem_block->get_is_ghost(), num_elements, faces_per_elem_size, nodes_per_face_size, indices_size, conn_hash.c_str());
885
886 if (DVS_NONE != elem_block->get_connectivity_polyhedral(nullptr, nullptr, nullptr)) {
887 fprintf(stdout, "ERROR get_connectivity_polyhedral\n");
888 }
889
890 if (all_connectivity) {
891 std::vector<uint32_t> faces_per_element(faces_per_elem_size);
892 std::vector<uint32_t> nodes_per_face(nodes_per_face_size);
893 std::vector<uint32_t> indices(indices_size);
894
895 if (DVS_NONE != elem_block->get_connectivity_polyhedral(faces_per_element.data(),
896 nodes_per_face.data(),
897 indices.data())) {
898 fprintf(stdout, "ERROR get_connectivity_polyhedral\n");
899 }
900 else {
901 fprintf(stdout, "FPE:");
902 for (const auto& faces : faces_per_element) {
903 fprintf(stdout, " %u", faces);
904 }
905 fprintf(stdout, "\n");
906 fprintf(stdout, "NPF:");
907 for (const auto& nodes : nodes_per_face) {
908 fprintf(stdout, " %u", nodes);
909 }
910 fprintf(stdout, "\n");
911 fprintf(stdout, "Indices:");
912 for (const auto& index : indices) {
913 fprintf(stdout, " %u", index);
914 }
915 fprintf(stdout, "\n");
916 }
917 }
918 break;
919 }
920 case STRUCTURED:
921 {
922 uint32_t dummy = 0;
923 uint32_t num_elements = 0;
924 uint32_t nodes_per_element = 0;
925 if (DVS_NONE != elem_block->get_num_elements(num_elements)) {
926 fprintf(stdout, "ERROR get_num_elements\n");
927 }
928 if (DVS_NONE != elem_block->get_nodes_per_element(nodes_per_element)) {
929 fprintf(stdout, "Error get_nodes_per_element\n");
930 }
931 if (DVS_NONE == elem_block->get_connectivity_size(dummy)) {
932 fprintf(stdout, "Error get_connectivity_size should be invalid for this type\n");
933 }
934 if (DVS_NONE == elem_block->get_connectivity(nullptr)) {
935 fprintf(stdout, "Error get_connectivity should be invalid for this type\n");
936 }
937 if (DVS_NONE == elem_block->get_connectivity_polygon_size(dummy,dummy)) {
938 fprintf(stdout, "Error get_connectivity_polygon_size should be invalid for this type\n");
939 }
940 if (DVS_NONE == elem_block->get_connectivity_polygon(nullptr,nullptr)) {
941 fprintf(stdout, "Error get_connectivity_polygon should be invalid for this type\n");
942 }
943 if (DVS_NONE == elem_block->get_connectivity_polyhedral_size(dummy,dummy,dummy)) {
944 fprintf(stdout, "Error get_connectivity_polyhedral_size should be invalid for this type\n");
945 }
946 std::string conn_hash(elem_block->get_hash_size(), 0);
947 if (conn_hash.empty() || elem_block->get_hash(&(conn_hash[0]))) {
948 fprintf(stdout, "ERROR: Could not load connectivity hash\n");
949 }
950 fprintf(stdout, "- Structured Element: Type: %i NPE: %u Hash: %s\n", elem_type, nodes_per_element, conn_hash.c_str());
951 break;
952 }
953 case UNDEFINED:
954 case UNDEFINED_PARALLELEPIPED:
955 case UNDEFINED_CURVILINEAR:
956 fprintf(stdout, "ERROR, undefined element type found\n");
957 break;
958
959 default:
960 {
961 uint32_t dummy = 0;
962 uint32_t num_elements = 0;
963 uint32_t nodes_per_elem = 0;
964 uint32_t indices_size = 0;
965 if (DVS_NONE != elem_block->get_num_elements(num_elements)) {
966 fprintf(stdout, "ERROR getting number of elements\n");
967 }
968 if (DVS_NONE != elem_block->get_nodes_per_element(nodes_per_elem)) {
969 fprintf(stdout, "ERROR getting nodes per element\n");
970 }
971
972 if (DVS_NONE == elem_block->get_connectivity_polygon_size(dummy, dummy)) {
973 fprintf(stdout, "ERROR get_connectivity_polygon_size should be invalid for this type\n");
974 }
975 if (DVS_NONE == elem_block->get_connectivity_polygon(nullptr, nullptr)) {
976 fprintf(stdout, "ERROR get_connectivity_polygon should be invalid for this type\n");
977 }
978 if (DVS_NONE == elem_block->get_connectivity_polyhedral_size(dummy, dummy, dummy)) {
979 fprintf(stdout, "ERROR get_connectivity_polyhedral_size should be invalid for this type\n");
980 }
981 if (DVS_NONE == elem_block->get_connectivity_polyhedral(nullptr, nullptr, nullptr)) {
982 fprintf(stdout, "ERROR get_connectivity_polyhedral should be invalid for this type\n");
983 }
984
985 if (DVS_NONE != elem_block->get_connectivity_size(indices_size)) {
986 fprintf(stdout, "ERROR get_connectivity_size\n");
987 }
988
989 std::string conn_hash(elem_block->get_hash_size(), 0);
990 if (conn_hash.empty() || elem_block->get_hash(&(conn_hash[0]))) {
991 fprintf(stdout, "ERROR: Could not load connectivity hash\n");
992 }
993
994 fprintf(stdout, "- Unstructured Basic Element: Type: %i, Ghost: %u, Number of Elements: %u, Nodes Per Elem: %u, Indices Size: %u, Hash: %s\n",
995 elem_type, elem_block->get_is_ghost(), num_elements, nodes_per_elem, indices_size, conn_hash.c_str());
996
997 if (DVS_NONE != elem_block->get_connectivity(nullptr)) {
998 fprintf(stdout, "ERROR get_connectivity\n");
999 }
1000
1001 if (all_connectivity) {
1002 std::vector<uint32_t> indices(indices_size);
1003 if (DVS_NONE != elem_block->get_connectivity(indices.data())) {
1004 fprintf(stdout, "ERROR get_connectivity\n");
1005 }
1006 else {
1007 fprintf(stdout, "Indices:");
1008 for (const auto& index : indices) {
1009 fprintf(stdout, " %u", index);
1010 }
1011 fprintf(stdout, "\n");
1012 }
1013 }
1014 break;
1015 }
1016 }
1017
1018 uint32_t num_elemental_vars = 0;
1019 if (DVS_NONE != elem_block->get_num_variables(num_elemental_vars)) {
1020 fprintf(stdout, "ERROR: Could not get num elemental vars\n");
1021 }
1022
1023 for (uint32_t var_index = 0; var_index < num_elemental_vars; var_index++) {
1024 auto var = elem_block->get_variable(var_index);
1026 fprintf(stdout, "ERROR: Var is not elemental and should be\n");
1027 }
1028
1029 uint32_t num_elem_var_values = 0;
1030 if (DVS_NONE != elem_block->get_variable_data(var_index, &num_elem_var_values, nullptr)) {
1031 fprintf(stdout, "ERROR: Could not get elemental var data\n");
1032 }
1033 std::string elem_var_hash_1(elem_block->get_var_hash_size(var_index), 0);
1034 std::string elem_var_hash_2(elem_block->get_var_hash_size(var), 0);
1035 if (elem_var_hash_1.empty() || DVS_NONE != elem_block->get_var_hash(var_index, &(elem_var_hash_1[0]))) {
1036 fprintf(stdout, "ERROR: Could not get elem var hash 1\n");
1037 }
1038 if (elem_var_hash_2.empty() || DVS_NONE != elem_block->get_var_hash(var, &(elem_var_hash_2[0]))) {
1039 fprintf(stdout, "ERROR: Could not get elem var hash 2\n");
1040 }
1041 if (elem_var_hash_1 != elem_var_hash_2) {
1042 fprintf(stdout, "ERROR: Elem var hashes do not match\n");
1043 }
1044 fprintf(stdout, "Elemental Var: %s, Num Values: %u, Hash: %s\n", var->get_name(), num_elem_var_values, elem_var_hash_1.c_str());
1045
1046 if (all_variable_data) {
1047 std::vector<float> elem_var_data(num_elem_var_values);
1048 float min = FLT_MAX-1;
1049 float max = -1*min;
1050 if (DVS_NONE != elem_block->get_variable_data(var_index, nullptr, elem_var_data.data())) {
1051 fprintf(stdout, "ERROR: Could not get elemental var data\n");
1052 }
1053 fprintf(stdout, "VarData:");
1054 for (const auto& val : elem_var_data) {
1055 fprintf(stdout, " %f", val);
1056 if (val < min) {
1057 min = val;
1058 }
1059 if (val > max) {
1060 max = val;
1061 }
1062 }
1063 fprintf(stdout, "\n");
1064 fprintf(stdout, "Min: %f, Max: %f\n", min, max);
1065 }
1066 }
1067
1068
1069 fprintf(stdout, "*******************************\n"
1070 "Elem Block: Test New Interfaces for Floats\n"
1071 "*******************************\n");
1072 uint32_t num_elemental_vars_floats = 0;
1073 if (DVS_NONE != elem_block->get_num_variables(num_elemental_vars_floats, DVS::VAR_TYPE::FLOAT)) {
1074 fprintf(stdout, "ERROR: Could not get num elemental vars\n");
1075 }
1076 for (uint32_t var_index = 0; var_index < num_elemental_vars_floats; var_index++) {
1077 auto var = elem_block->get_variable(var_index, DVS::VAR_TYPE::FLOAT);
1079 fprintf(stdout, "ERROR: Var is not elemental and should be\n");
1080 }
1081
1082 uint32_t num_elem_var_values = 0;
1083 if (DVS_NONE != elem_block->get_variable_size(var_index, num_elem_var_values, DVS::VAR_TYPE::FLOAT)) {
1084 fprintf(stdout, "ERROR: Could not get elemental var data\n");
1085 }
1086 std::string elem_var_hash_1(elem_block->get_var_hash_size(var_index, DVS::VAR_TYPE::FLOAT), 0);
1087 std::string elem_var_hash_2(elem_block->get_var_hash_size(var), 0);
1088 if (elem_var_hash_1.empty() || DVS_NONE != elem_block->get_var_hash(var_index, &(elem_var_hash_1[0]), DVS::VAR_TYPE::FLOAT)) {
1089 fprintf(stdout, "ERROR: Could not get elem var hash 1\n");
1090 }
1091 if (elem_var_hash_2.empty() || DVS_NONE != elem_block->get_var_hash(var, &(elem_var_hash_2[0]))) {
1092 fprintf(stdout, "ERROR: Could not get elem var hash 2\n");
1093 }
1094 if (elem_var_hash_1 != elem_var_hash_2) {
1095 fprintf(stdout, "ERROR: Elem var hashes do not match\n");
1096 }
1097 fprintf(stdout, "Elemental Var: %s, Num Values: %u, Hash: %s\n", var->get_name(), num_elem_var_values, elem_var_hash_1.c_str());
1098
1099 if (all_variable_data) {
1100 std::vector<float> elem_var_data(num_elem_var_values);
1101 float min = FLT_MAX-1;
1102 float max = -1*min;
1103 if (DVS_NONE != elem_block->get_variable_data(var_index, elem_var_data.data())) {
1104 fprintf(stdout, "ERROR: Could not get elemental var data\n");
1105 }
1106 fprintf(stdout, "VarData:");
1107 for (const auto& val : elem_var_data) {
1108 fprintf(stdout, " %f", val);
1109 if (val < min) {
1110 min = val;
1111 }
1112 if (val > max) {
1113 max = val;
1114 }
1115 }
1116 fprintf(stdout, "\n");
1117 fprintf(stdout, "Min: %f, Max: %f\n", min, max);
1118 }
1119 }
1120
1121
1122 fprintf(stdout, "*******************************\n"
1123 "Elem Block: Test New Interfaces for INT64S\n"
1124 "*******************************\n");
1125 uint32_t num_elemental_vars_int64s = 0;
1126 if (DVS_NONE != elem_block->get_num_variables(num_elemental_vars_int64s, DVS::VAR_TYPE::INT64)) {
1127 fprintf(stdout, "ERROR: Could not get num elemental vars\n");
1128 }
1129 for (uint32_t var_index = 0; var_index < num_elemental_vars_int64s; var_index++) {
1130 auto var = elem_block->get_variable(var_index, DVS::VAR_TYPE::INT64);
1132 fprintf(stdout, "ERROR: Var is not elemental and should be\n");
1133 }
1134
1135 uint32_t num_elem_var_values = 0;
1136 if (DVS_NONE != elem_block->get_variable_size(var_index, num_elem_var_values, DVS::VAR_TYPE::INT64)) {
1137 fprintf(stdout, "ERROR: Could not get elemental var data\n");
1138 }
1139 std::string elem_var_hash_1(elem_block->get_var_hash_size(var_index, DVS::VAR_TYPE::INT64), 0);
1140 std::string elem_var_hash_2(elem_block->get_var_hash_size(var), 0);
1141 if (elem_var_hash_1.empty() || DVS_NONE != elem_block->get_var_hash(var_index, &(elem_var_hash_1[0]), DVS::VAR_TYPE::INT64)) {
1142 fprintf(stdout, "ERROR: Could not get elem var hash 1\n");
1143 }
1144 if (elem_var_hash_2.empty() || DVS_NONE != elem_block->get_var_hash(var, &(elem_var_hash_2[0]))) {
1145 fprintf(stdout, "ERROR: Could not get elem var hash 2\n");
1146 }
1147 if (elem_var_hash_1 != elem_var_hash_2) {
1148 fprintf(stdout, "ERROR: Elem var hashes do not match\n");
1149 }
1150 fprintf(stdout, "Elemental Var: %s, Num Values: %u, Hash: %s\n", var->get_name(), num_elem_var_values, elem_var_hash_1.c_str());
1151
1152 if (all_variable_data) {
1153 std::vector<int64_t> elem_var_data(num_elem_var_values);
1154 int64_t min = INT64_MAX-1;
1155 int64_t max = -1*min;
1156 if (DVS_NONE != elem_block->get_variable_data(var_index, elem_var_data.data())) {
1157 fprintf(stdout, "ERROR: Could not get elemental var data\n");
1158 }
1159 fprintf(stdout, "VarData:");
1160 for (const auto& val : elem_var_data) {
1161 std::cout << " " << val;
1162 if (val < min) {
1163 min = val;
1164 }
1165 if (val > max) {
1166 max = val;
1167 }
1168 }
1169 fprintf(stdout, "\n");
1170 std::cout << "Min: " << min << ", Max: " << max << std::endl;
1171 }
1172 }
1173
1174
1175
1176 }
1177 } // For elem block types
1178 }
1179 fprintf (stdout, "\n");
1180 } // For mesh chunks
1181
1182 fprintf(stdout, "---------------------------\n");
1183 fprintf(stdout, "Listing All Plot Chunks for Query\n");
1184 fprintf(stdout, "---------------------------\n");
1185
1186 uint32_t num_plot_chunks = 0;
1187 err = dataset_query->get_num_plot_chunks(num_plot_chunks);
1188 if (DVS_NONE != err) {
1189 fprintf(stdout, "Error getting number of plot chunks\n");
1190 return err;
1191 }
1192 for (uint32_t plot_index = 0; plot_index < num_plot_chunks; plot_index++) {
1193 auto plot = dataset_query->get_plot_chunk(plot_index);
1194 if (plot) {
1195 auto plot_def = plot->get_object();
1196 std::string name;
1197 if (plot_def) {
1198 name = plot_def->get_name();
1199 }
1200 else {
1201 fprintf(stdout, "ERROR: No plot definition for plot data\n");
1202 }
1203 float time = plot->get_time();
1204 uint32_t rank = plot->get_rank();
1205
1206 std::string hash(plot->get_hash_size(), 0);
1207 if (hash.empty() || DVS_NONE != plot->get_hash(&(hash[0]))) {
1208 fprintf(stdout, "ERROR: Could not get plot hash\n");
1209 }
1210
1211 fprintf(stdout, "Plot: %s, Time: %f, Rank: %d, Hash: %s\n",
1212 name.c_str(), time, rank, hash.c_str());
1213
1214 uint32_t num_values = 0;
1215 if (DVS_NONE != plot->get_data(&num_values, nullptr, nullptr)) {
1216 fprintf(stdout, "ERROR: Could not get plot number of values\n");
1217 }
1218
1219 if (num_values > 0) {
1220 std::vector<float> x_values(num_values);
1221 std::vector<float> y_values(num_values);
1222
1223 if (DVS_NONE != plot->get_data(nullptr, x_values.data(), y_values.data())) {
1224 fprintf(stdout, "ERROR: Could not get plot data values\n");
1225 }
1226
1227 fprintf(stdout, "X Values:");
1228 for (uint32_t i = 0; i < num_values; i++) {
1229 fprintf(stdout, " %f", x_values[i]);
1230 }
1231 fprintf(stdout, "\n");
1232
1233 fprintf(stdout, "Y Values:");
1234 for (uint32_t i = 0; i < num_values; i++) {
1235 fprintf(stdout, " %f", y_values[i]);
1236 }
1237 fprintf(stdout, "\n");
1238 }
1239 }
1240 }
1241
1242 return 0;
1243
1244
1245}
Interface for datasets for the DVS Reader API.
virtual uint32_t get_num_ranks() const =0
Get the number of ranks for the dataset.
virtual uint32_t get_num_plots() const =0
Get the number of plots for this datasets.
virtual uint32_t get_num_chunks_per_rank() const =0
Get the size of the chunks_per_rank array for get_chunks_per_rank()
virtual uint32_t get_num_parts() const =0
Get the number of parts for this dataset.
virtual const DVS::IObject * get_plot(uint32_t index) const =0
Get the plot object.
virtual const DVS::IVar * get_var(uint32_t index) const =0
Get the var object.
virtual dvs_ret get_ranks(uint32_t *ranks) const =0
Get an array of the ranks for this dataset query.
virtual uint32_t get_num_variables() const =0
Get the number of variables for this dataset.
virtual const DVS::IObject * get_part(uint32_t index) const =0
Get a part by index.
virtual const char * get_unit_system() const =0
Get the unit system of the dataset.
virtual dvs_ret get_chunks_per_rank(uint32_t *chunks_per_rank) const =0
Get the number of chunks for each rank.
virtual dvs_ret get_hash(char *hash) const =0
Get the hash of the data.
virtual uint32_t get_hash_size() const =0
Get the size of the hash to use with IHash::get_hash()
Mesh Chunk Interface for DVS Reader API.
virtual dvs_ret get_num_variables(uint32_t &num_vars, VAR_TYPE type=VAR_TYPE::FLOAT) const =0
Get the number of nodal variables this mesh chunk has data for, based on the specified type.
virtual dvs_ret get_coords_size(uint32_t &component_size)=0
Get the size of each coordinate component for unstructured meshes.
virtual float get_time() const =0
Get the time for this mesh chunk.
virtual dvs_ret get_coords_interleaved(float *coords)=0
Get the coords for a unstructured meshes interleaved in a single array.
virtual const DVS::IVar * get_variable(uint32_t index, VAR_TYPE type=VAR_TYPE::FLOAT) const =0
Get the variable definition associates with the nodal variable for this index and the specified type.
virtual dvs_ret get_element_block_types(dvs_element_type *element_types) const =0
Get an array of the element block types for this mesh chunk.
virtual dvs_ret get_coords_curv_interleaved(float local_ijk_min[3], float local_ijk_max[3], float global_ijk_max[3], float *coords)=0
Get the coords for structured curvilinear meshes interleaved in a single array.
virtual dvs_ret get_num_element_blocks(uint32_t &num_elem_blocks) const =0
Get the number of element blocks for this mesh chunk.
virtual uint32_t get_chunk() const =0
Get the chunk for this mesh chunk.
virtual uint32_t get_rank() const =0
Get the rank for the mesh chunk.
virtual dvs_ret get_variable_size(uint32_t index, uint32_t &num_values, VAR_TYPE type=VAR_TYPE::FLOAT) const =0
Get the variable size via the index and specified type.
virtual dvs_ret get_coords_curv_size(uint32_t &component_size)=0
Get the size of each coordinate component for structured curvilinear meshes.
virtual dvs_ret get_coords(float *x_coords, float *y_coords, float *z_coords)=0
Get the coordinates for an unstructured mesh.
virtual DVS::IElementBlock * get_element_block_by_type(dvs_element_type type)=0
Get the element block by element type.
MeshType
The different mesh types allowed.
@ PARALLELEPIPED
Parallelepiped structured mesh data.
@ CURVILINEAR
Curvilinear structured mesh data.
@ UNSTRUCTURED
Unstructured mesh data.
virtual dvs_ret get_coords_curv(float local_ijk_min[3], float local_ijk_max[3], float global_ijk_max[3], float *x_coords, float *y_coords, float *z_coords)=0
Get coordinate data for a structured curvilinear mesh.
virtual dvs_ret get_coords_parallele(float origin[3], float dir_vec_i[3], float dir_vec_j[3], float dir_vec_k[3], float local_ijk_min[3], float local_ijk_max[3], float global_ijk_max[3], float *i_vals, float *j_vals, float *k_vals)=0
Get the ijk mesh information for structured parallelepiped mesh chunks.
virtual MeshType get_type() const =0
Get the type of mesh chunk.
virtual const DVS::IObject * get_object() const =0
Get the object definiton this mesh chunk is associated with.
virtual dvs_ret get_coords_parallele_size(uint32_t &i_vals_size, uint32_t &j_vals_size, uint32_t &k_vals_size)=0
Get the size of each ijk component for structured parallelpiped meshes.
virtual dvs_ret get_variable_data(uint32_t index, float *array) const =0
Get the variable data by index.
Interface for part/plot objects for DVS Reader API.
virtual const char * get_metadata_key(uint32_t index) const =0
Get the metadata key by index.
virtual uint32_t get_num_metadata() const =0
Get the number of metadata objects.
virtual const char * get_name() const =0
Get the name of the object.
virtual const char * get_metadata_value(uint32_t index) const =0
Get the metadata value by index.
@ PART
Type for a part object.
@ PLOT
Type for a plot object.
virtual const DVS::IDataset * get_dataset() const =0
Get the reference dataset for this object.
The query interface for the DVS Reader API.
virtual void release()=0
Release the memory of the query.
virtual void set_logger(DVS::ILogger *logger)=0
Set the logger object.
Interface class used to run a dynamic data server in a thread accepting incoming client connections.
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 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
virtual dvs_ret startup_unthreaded(uint32_t server_number, uint32_t local_ranks)=0
Startup a server manually without threads.
virtual dvs_ret update()=0
Perform a server update.
virtual DVS::IQuery * create_query(const std::string &filter=std::string(), DVS::IQuery *parent=nullptr)=0
Create a DVS query instance. This will inherit the DVS server reader instance.
virtual dvs_ret get_var_hash(uint32_t index, char *hash, VAR_TYPE type=VAR_TYPE::FLOAT) const =0
Get the hash of the variable data.
virtual uint32_t get_var_hash_size(uint32_t index, VAR_TYPE type=VAR_TYPE::FLOAT) const =0
Get the size of the hash to use with IVarHash::get_var_hash()
Interface for variables for the DVS Reader API.
virtual const char * get_name() const =0
Get the name of the variable.
virtual const char * get_metadata_value(uint32_t index) const =0
Get the metadata value base on the index.
virtual uint32_t get_num_metadata() const =0
Get the num metadata values on this var.
virtual const char * get_unit_dimension() const =0
Get the unit dimensions as string.
virtual dvs_var_location get_var_location() const =0
Get the var location.
virtual uint32_t get_float_count_per_value() const =0
Get the number of floats per value.
virtual const char * get_unit_label() const =0
Get the unit label as string.
virtual const DVS::IDataset * get_dataset() const =0
Get the reference dataset for this var.
virtual const char * get_metadata_key(uint32_t index) const =0
Get a metadata key based on the index.
virtual dvs_var_type get_var_type() const =0
Get the type of var.
Logger class based on verbosity.
C++ Server API for using Dynamic Visualization Store Server.
@ DVS_VERBOSE
Displays informational messages, warnings, errors.
@ PART
This is a variable for an entire part.
@ ELEMENT
This is a field variable per each element of a part.
@ NODE
This is a field variable per each node of a part's mesh.
@ CASE
This is a variable for an entire case (i.e. dataset)
int32_t dvs_ret
Return value of methods, TODO.
#define DVS_NONE
No detected error has occurred.
Verbosity based logger for DVS.
int main(int argc, char **argv)
Main method of test reader application.

Connect with Ansys