Skip to main content

Post-processing tools 2024 R1

test_dvs_reader

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