/
t_blueprint_mesh_examples.cpp
999 lines (803 loc) · 34.3 KB
/
t_blueprint_mesh_examples.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
// Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
// other details. No copyright assignment is required to contribute to Conduit.
//-----------------------------------------------------------------------------
///
/// file: t_blueprint_mesh_examples.cpp
///
//-----------------------------------------------------------------------------
#include "conduit.hpp"
#include "conduit_blueprint.hpp"
#include "conduit_relay.hpp"
#include "conduit_log.hpp"
#include <math.h>
#include <iostream>
#include "gtest/gtest.h"
using namespace conduit;
using namespace conduit::utils;
index_t OUTPUT_NUM_AXIS_POINTS = 5;
std::string PROTOCOL_VER = CONDUIT_VERSION;
//-----------------------------------------------------------------------------
bool
check_if_hdf5_enabled()
{
Node io_protos;
relay::io::about(io_protos["io"]);
return io_protos["io/protocols/hdf5"].as_string() == "enabled";
}
//-----------------------------------------------------------------------------
void
test_save_mesh_helper(const conduit::Node &dsets,
const std::string &base_name)
{
Node opts;
opts["file_style"] = "root_only";
opts["suffix"] = "none";
relay::io::blueprint::save_mesh(dsets, base_name + "_yaml", "yaml", opts);
if(check_if_hdf5_enabled())
{
relay::io::blueprint::save_mesh(dsets, base_name + "_hdf5", "hdf5", opts);
}
}
//-----------------------------------------------------------------------------
void
braid_save_helper(const conduit::Node &dsets,
const std::string &base_name)
{
Node root, info;
root["data"].set_external(dsets);
Node bpindex;
NodeConstIterator itr = dsets.children();
while(itr.has_next())
{
const Node &mesh = itr.next();
const std::string mesh_name = itr.name();
// NOTE: Skip all domains containing one or more mixed-shape topologies
// because this type of mesh isn't fully supported yet.
bool is_domain_index_valid = true;
NodeConstIterator topo_iter = mesh["topologies"].children();
while(topo_iter.has_next())
{
const Node &topo = topo_iter.next();
is_domain_index_valid &= (
!::conduit::blueprint::mesh::topology::unstructured::verify(topo, info) ||
!topo["elements"].has_child("element_types"));
}
if(is_domain_index_valid)
{
::conduit::blueprint::mesh::generate_index(mesh,
mesh_name,
1,
bpindex[mesh_name]);
}
}
std::string ofile = base_name + "_yaml.root";
root["blueprint_index"] = bpindex;
root["protocol/name"].set("yaml");
root["protocol/version"].set(CONDUIT_VERSION);
root["number_of_files"].set(1);
root["number_of_trees"].set(1);
root["file_pattern"].set(ofile);
root["tree_pattern"].set("/data");
relay::io::save(root,ofile,"yaml");
if(check_if_hdf5_enabled())
{
ofile = base_name + "_hdf5.root";
root["protocol/name"].set("hdf5");
root["file_pattern"].set(ofile);
relay::io::save(root,ofile,"hdf5");
}
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, mesh_2d)
{
Node io_protos;
relay::io::about(io_protos["io"]);
bool silo_enabled = io_protos["io/protocols/conduit_silo"].as_string() == "enabled";
bool hdf5_enabled = io_protos["io/protocols/hdf5"].as_string() == "enabled";
// we are using one node to hold group of example meshes purely out of convenience
Node dsets;
// can be overridden via command line
index_t npts_x = OUTPUT_NUM_AXIS_POINTS;
index_t npts_y = OUTPUT_NUM_AXIS_POINTS;
index_t npts_z = 1; // 2D examples ...
blueprint::mesh::examples::braid("uniform",
npts_x,
npts_y,
npts_z,
dsets["uniform"]);
blueprint::mesh::examples::braid("rectilinear",
npts_x,
npts_y,
npts_z,
dsets["rect"]);
blueprint::mesh::examples::braid("structured",
npts_x,
npts_y,
npts_z,
dsets["struct"]);
blueprint::mesh::examples::braid("lines",
npts_x,
npts_y,
npts_z,
dsets["lines"]);
blueprint::mesh::examples::braid("tris",
npts_x,
npts_y,
npts_z,
dsets["tris"]);
blueprint::mesh::examples::braid("quads",
npts_x,
npts_y,
npts_z,
dsets["quads"]);
blueprint::mesh::examples::braid("quads_and_tris",
npts_x,
npts_y,
npts_z,
dsets["quads_and_tris"]);
blueprint::mesh::examples::braid("quads_and_tris_offsets",
npts_x,
npts_y,
npts_z,
dsets["quads_and_tris_offsets"]);
blueprint::mesh::examples::braid("points",
npts_x,
npts_y,
npts_z,
dsets["points"]);
blueprint::mesh::examples::braid("points_implicit",
npts_x,
npts_y,
npts_z,
dsets["points_implicit"]);
Node info;
NodeConstIterator itr = dsets.children();
while(itr.has_next())
{
const Node &mesh = itr.next();
EXPECT_TRUE(blueprint::mesh::verify(mesh,info));
CONDUIT_INFO(info.to_yaml());
}
// TODO: Add VisIt support for rendering mixed element and implicit point
// meshes so they don't have to be removed before outputting mesh data.
dsets.remove("quads_and_tris");
dsets.remove("quads_and_tris_offsets");
dsets.remove("points_implicit");
braid_save_helper(dsets,"braid_2d_examples");
if(silo_enabled)
{
// we removed datasets above, so we need an updated iterator
itr = dsets.children();
while(itr.has_next())
{
const Node &mesh = itr.next();
std::string name = itr.name();
// Skip output of silo mesh for mixed mesh of tris and quads for now.
// The silo output is not yet defined and it throws an exception
// in conduit_silo.cpp::silo_write_ucd_zonelist()
// in the following line that is looking for the 'shape' node:
// std::string topo_shape = shape_block->fetch("shape").as_string();
// which does not exist for indexed_stream meshes.
// The silo writer needs to be updated for this case.
if( name == "quads_and_tris" || name == "quads_and_tris_offsets" )
{
CONDUIT_INFO("\tNOTE: skipping output to SILO -- ")
CONDUIT_INFO("feature is unavailable for mixed element meshes")
continue;
}
relay::io::save(mesh,
"braid_2d_" + name + "_example.silo:mesh",
"conduit_silo_mesh");
}
}
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, mesh_3d)
{
Node io_protos;
relay::io::about(io_protos["io"]);
bool silo_enabled = io_protos["io/protocols/conduit_silo"].as_string() == "enabled";
bool hdf5_enabled = io_protos["io/protocols/hdf5"].as_string() == "enabled";
// we are using one node to hold group of example meshes purely out of convenience
Node dsets;
// can be overridden via command line
index_t npts_x = OUTPUT_NUM_AXIS_POINTS;
index_t npts_y = OUTPUT_NUM_AXIS_POINTS;
index_t npts_z = OUTPUT_NUM_AXIS_POINTS; // 3D examples ...
blueprint::mesh::examples::braid("uniform",
npts_x,
npts_y,
npts_z,
dsets["uniform"]);
blueprint::mesh::examples::braid("rectilinear",
npts_x,
npts_y,
npts_z,
dsets["rect"]);
blueprint::mesh::examples::braid("structured",
npts_x,
npts_y,
npts_z,
dsets["struct"]);
blueprint::mesh::examples::braid("points",
npts_x,
npts_y,
npts_z,
dsets["points"]);
blueprint::mesh::examples::braid("points_implicit",
npts_x,
npts_y,
npts_z,
dsets["points_implicit"]);
blueprint::mesh::examples::braid("lines",
npts_x,
npts_y,
npts_z,
dsets["lines"]);
blueprint::mesh::examples::braid("tets",
npts_x,
npts_y,
npts_z,
dsets["tets"]);
blueprint::mesh::examples::braid("hexs",
npts_x,
npts_y,
npts_z,
dsets["hexs"]);
blueprint::mesh::examples::braid("hexs_and_tets",
npts_x,
npts_y,
npts_z,
dsets["hexs_and_tets"]);
Node info;
NodeConstIterator itr = dsets.children();
while(itr.has_next())
{
const Node &mesh = itr.next();
EXPECT_TRUE(blueprint::mesh::verify(mesh,info));
CONDUIT_INFO(info.to_yaml());
}
// TODO: Add VisIt support for rendering mixed element and implicit point
// meshes so they don't have to be removed before outputting mesh data.
dsets.remove("hexs_and_tets");
dsets.remove("points_implicit");
braid_save_helper(dsets,"braid_3d_examples");
if(silo_enabled)
{
// we removed datasets above, so we need an updated iterator
itr = dsets.children();
while(itr.has_next())
{
const Node &mesh = itr.next();
std::string name = itr.name();
// Skip output of silo mesh for mixed mesh of hexs and tets for now.
// The silo output is not yet defined and it throws an exception
// in conduit_silo.cpp::silo_write_ucd_zonelist()
// in the following line that is looking for the 'shape' node:
// std::string topo_shape = shape_block->fetch("shape").as_string();
// which does not exist for indexed_stream meshes.
// The silo writer needs to be updated for this case.
if(name == "hexs_and_tets")
{
CONDUIT_INFO("\tNOTE: skipping output to SILO -- ")
CONDUIT_INFO("feature is unavailable for mixed element meshes")
continue;
}
relay::io::save(mesh,
"braid_3d_" + name + "_example.silo:mesh",
"conduit_silo_mesh");
}
}
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, braid_too_small_npts)
{
std::vector<std::string> braid_type_strings;
braid_type_strings.push_back("uniform");
braid_type_strings.push_back("lines");
braid_type_strings.push_back("rectilinear");
braid_type_strings.push_back("structured");
// 2d extra
braid_type_strings.push_back("tris");
braid_type_strings.push_back("quads");
// 3d extra
braid_type_strings.push_back("tets");
braid_type_strings.push_back("hexs");
Node mesh;
for(size_t i = 0; i < braid_type_strings.size(); i++)
{
mesh.reset();
EXPECT_THROW(blueprint::mesh::examples::braid(braid_type_strings[i],
1,
1,
1,
mesh), conduit::Error);
}
braid_type_strings.clear();
braid_type_strings.push_back("points");
braid_type_strings.push_back("points_implicit");
for(size_t i = 0; i < braid_type_strings.size(); i++)
{
mesh.reset();
blueprint::mesh::examples::braid(braid_type_strings[i],
1,
1,
1,
mesh);
Node info;
EXPECT_TRUE(blueprint::mesh::verify(mesh,info));
}
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, julia)
{
Node res;
blueprint::mesh::examples::julia(500, 500, // nx, ny
-2.0, 2.0, // x range
-2.0, 2.0, // y range
0.285, 0.01, // c value
res);
Node info;
EXPECT_TRUE(blueprint::mesh::verify(res,info));
CONDUIT_INFO(info.to_yaml());
test_save_mesh_helper(res,"julia_example");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, spiral)
{
int ndoms = 10;
Node res;
blueprint::mesh::examples::spiral(ndoms,res["spiral"]);
Node info;
EXPECT_TRUE(blueprint::mesh::verify(res["spiral/domain_000000"],info));
CONDUIT_INFO(info.to_yaml());
blueprint::mesh::generate_index(res["spiral/domain_000000"],
"",
ndoms,
res["blueprint_index/spiral"]);
// save json
res["protocol/name"] = "json";
res["protocol/version"] = PROTOCOL_VER;
res["number_of_files"] = 1;
res["number_of_trees"] = ndoms;
res["file_pattern"] = "spiral_example.blueprint_root";
res["tree_pattern"] = "spiral/domain_%06d";
CONDUIT_INFO("Creating: spiral_example.blueprint_root")
relay::io::save(res,"spiral_example.blueprint_root","json");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, polytess)
{
const index_t nlevels = 3;
Node res;
blueprint::mesh::examples::polytess(nlevels,
res);
Node info;
EXPECT_TRUE(blueprint::mesh::verify(res,info));
CONDUIT_INFO(info.to_yaml());
test_save_mesh_helper(res,"polytess_example");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, 2d_braid_zero_z_check)
{
Node mesh, info;
// these checks make sure braid generates valid fields even when
// # of z pointers == 0
int npts_x = 5;
int npts_y = 5;
int npts_z = 0;
std::vector<std::string> braid_type_strings;
braid_type_strings.push_back("points");
braid_type_strings.push_back("points_implicit");
braid_type_strings.push_back("lines");
braid_type_strings.push_back("rectilinear");
braid_type_strings.push_back("structured");
braid_type_strings.push_back("tris");
braid_type_strings.push_back("quads");
for(size_t i = 0; i < braid_type_strings.size(); i++)
{
mesh.reset();
blueprint::mesh::examples::braid(braid_type_strings[i],
npts_x,
npts_y,
npts_z,
mesh);
// make the braid vertex-assoced field has with more than zero entries
EXPECT_GT(mesh["fields/braid/values"].dtype().number_of_elements(),0);
mesh.print();
}
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, mesh_misc)
{
// for each "misc" mesh example, generate a small 2d mesh and
// save to yaml
std::vector<std::string> misc_type_strings;
misc_type_strings.push_back("matsets");
misc_type_strings.push_back("specsets");
misc_type_strings.push_back("adjsets");
misc_type_strings.push_back("nestsets");
Node mesh;
int npts_x = 5;
int npts_y = 5;
for(size_t i = 0; i < misc_type_strings.size(); i++)
{
mesh.reset();
blueprint::mesh::examples::misc(misc_type_strings[i],
npts_x,
npts_y,
1,
mesh);
mesh.save("misc_example_" + misc_type_strings[i] + ".yaml");
}
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, check_gen_index_state_prop)
{
// braid provides cycle and time, make sure those make it into
// an index created with generate_index
Node mesh;
blueprint::mesh::examples::braid("hexs",
5,
5,
5,
mesh);
Node idx;
blueprint::mesh::generate_index(mesh,
"",
1,
idx);
EXPECT_TRUE(idx.has_path("state/cycle"));
EXPECT_TRUE(idx.has_path("state/time"));
}
//-----------------------------------------------------------------------------
void venn_test_small_yaml(const std::string &venn_type)
{
// provide small example save to yaml for folks to look at
const int nx = 4, ny = 4;
const double radius = 0.25;
Node res, info, n_idx;
blueprint::mesh::examples::venn(venn_type, nx, ny, radius, res);
EXPECT_TRUE(blueprint::mesh::verify(res, info));
info.print();
blueprint::mesh::generate_index(res,"",1,n_idx);
EXPECT_TRUE(blueprint::verify("mesh/index",n_idx,info));
std::string ofbase= "venn_small_example_" + venn_type;
// save yaml and hdf5 versions
relay::io::blueprint::save_mesh(res,
ofbase + "_yaml",
"yaml");
Node io_protos;
relay::io::about(io_protos["io"]);
bool hdf5_enabled =io_protos["io/protocols/hdf5"].as_string() == "enabled";
if(hdf5_enabled)
{
relay::io::blueprint::save_mesh(res,
ofbase + "_hdf5",
"hdf5");
}
}
//-----------------------------------------------------------------------------
void venn_test(const std::string &venn_type)
{
const int nx = 100, ny = 100;
const double radius = 0.25;
Node res, info;
blueprint::mesh::examples::venn(venn_type, nx, ny, radius, res);
EXPECT_TRUE(blueprint::mesh::verify(res, info));
utils::log::remove_valid(info);
CONDUIT_INFO(info.to_yaml());
CONDUIT_INFO(res.schema().to_json());
std::string ofbase = "venn_example_" + venn_type;
std::cout << "[Saving " << ofbase << "]" << std::endl;
std::string ofile_root= "venn_small_example_" + venn_type;
// save yaml and hdf5 versions
relay::io::blueprint::save_mesh(res,
ofbase + "_yaml",
"yaml");
Node io_protos;
relay::io::about(io_protos["io"]);
bool hdf5_enabled =io_protos["io/protocols/hdf5"].as_string() == "enabled";
if(hdf5_enabled)
{
relay::io::blueprint::save_mesh(res,
ofbase + "_hdf5",
"hdf5");
}
{
std::cout << "[Verifying field area is correct]" << std::endl;
Node &area_actual = res["fields/area/values"];
Node area_expected;
area_expected.set(std::vector<double>(
area_actual.dtype().number_of_elements(), 1.0 / (nx * ny)));
bool actual_matches_expected = !area_expected.diff(area_actual, info);
EXPECT_TRUE(actual_matches_expected);
if(!actual_matches_expected)
{
CONDUIT_INFO(info.to_yaml());
}
}
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, venn_full)
{
venn_test("full");
venn_test_small_yaml("full");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, venn_sparse_by_material)
{
venn_test("sparse_by_material");
venn_test_small_yaml("sparse_by_material");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, venn_sparse_by_element)
{
venn_test("sparse_by_element");
venn_test_small_yaml("sparse_by_element");
}
TEST(conduit_blueprint_mesh_examples, mesh_julia_nestset_simple)
{
Node mesh;
Node res;
blueprint::mesh::examples::julia_nestsets_simple(-2.0, 2.0, // x range
-2.0, 2.0, // y range
0.285, 0.01, // c value
res["julia_nestset_simple"]);
index_t ndoms = res["julia_nestset_simple"].number_of_children();
Node info;
if(!blueprint::mesh::verify(res["julia_nestset_simple"],info))
{
info.print();
}
blueprint::mesh::generate_index(res["julia_nestset_simple/domain_000000"],
"",
ndoms,
res["blueprint_index/julia_nestset_simple"]);
// save json
res["protocol/name"] = "json";
res["protocol/version"] = PROTOCOL_VER;
res["number_of_files"] = 1;
res["number_of_trees"] = ndoms;
res["file_pattern"] = "julia_nestset_simple.blueprint_root";
res["tree_pattern"] = "julia_nestset_simple/domain_%06d";
CONDUIT_INFO("Creating: julia_nestset_simple.blueprint_root")
relay::io::save(res,"julia_nestset_simple.blueprint_root","json");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, mesh_julia_nestset)
{
Node mesh;
Node res;
blueprint::mesh::examples::julia_nestsets_complex(20, 20, // nx, ny
-2.0, 2.0, // x range
-2.0, 2.0, // y range
0.285, 0.01, // c value
3, // amr levels
res["julia_nestset_complex"]);
index_t ndoms = res["julia_nestset_complex"].number_of_children();
Node info;
if(!blueprint::mesh::verify(res["julia_nestset_complex"],info))
{
info.print();
}
blueprint::mesh::generate_index(res["julia_nestset_complex/domain_000000"],
"",
ndoms,
res["blueprint_index/julia_nestset_complex"]);
// save json
res["protocol/name"] = "json";
res["protocol/version"] = PROTOCOL_VER;
res["number_of_files"] = 1;
res["number_of_trees"] = ndoms;
res["file_pattern"] = "julia_nestset_complex_example.blueprint_root";
res["tree_pattern"] = "julia_nestset_complex/domain_%06d";
CONDUIT_INFO("Creating: julia_nestset_complex_example.blueprint_root")
relay::io::save(res,"julia_nestset_complex_example.blueprint_root","json");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, save_adjset_uniform)
{
Node io_protos;
relay::io::about(io_protos["io"]);
bool hdf5_enabled =io_protos["io/protocols/hdf5"].as_string() == "enabled";
// skip if we don't have hdf5 since this example has several domains
if(!hdf5_enabled)
return;
Node mesh,idx;
blueprint::mesh::examples::adjset_uniform(mesh);
blueprint::mesh::generate_index(mesh[0],
"",
8,
mesh["blueprint_index/adj_uniform"]);
mesh["protocol/name"] = "hdf5";
mesh["protocol/version"] = PROTOCOL_VER;
mesh["number_of_files"] = 1;
mesh["number_of_trees"] = 8;
mesh["file_pattern"] = "adj_uniform_example.blueprint_root";
mesh["tree_pattern"] = "domain_%06d";
CONDUIT_INFO("Creating: adj_uniform_example.blueprint_root")
relay::io::save(mesh,"adj_uniform_example.blueprint_root","json");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, basic_bad_inputs)
{
Node res;
// several with bad inputs
EXPECT_THROW(blueprint::mesh::examples::basic("uniform",
-1,
2,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::basic("uniform",
1,
1,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::basic("uniform",
2,
-1,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::basic("tets",
2,
2,
1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::basic("hexs",
2,
2,
0,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::basic("polyhedra",
2,
2,
-1,
res),conduit::Error);
// a few ok
blueprint::mesh::examples::basic("uniform",
2,
2,
2,
res);
blueprint::mesh::examples::basic("tets",
2,
2,
2,
res);
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, braid_bad_inputs)
{
Node res;
// several with bad inputs
EXPECT_THROW(blueprint::mesh::examples::braid("uniform",
-1,
2,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("uniform",
1,
1,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("uniform",
2,
-1,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("tets",
2,
2,
1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("hexs",
2,
2,
0,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("hexs_poly",
2,
2,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("points",
0,
0,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("points_implicit",
0,
0,
-1,
res),conduit::Error);
EXPECT_THROW(blueprint::mesh::examples::braid("points",
1,
1,
-1,
res),conduit::Error);
// a few ok
blueprint::mesh::examples::braid("points",
1,
1,
0,
res);
res.print();
// check conn array, should have 1 entry
EXPECT_EQ(res["topologies/mesh/elements/connectivity"].dtype().number_of_elements(),1);
// should be 2d
EXPECT_EQ(res["coordsets/coords/values"].number_of_children(),2);
blueprint::mesh::examples::braid("points",
1,
1,
2,
res);
// should be 3d
EXPECT_EQ(res["coordsets/coords/values"].number_of_children(),3);
blueprint::mesh::examples::braid("uniform",
2,
2,
2,
res);
blueprint::mesh::examples::braid("tets",
2,
2,
2,
res);
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, braid_diff_dims)
{
Node mesh;
conduit::blueprint::mesh::examples::braid("quads", 2, 3, 0, mesh);
test_save_mesh_helper(mesh,"braid_quads_2_3");
conduit::blueprint::mesh::examples::braid("tris", 2, 3, 0, mesh);
test_save_mesh_helper(mesh,"braid_tris_2_3");
conduit::blueprint::mesh::examples::braid("tets", 2, 3, 4, mesh);
test_save_mesh_helper(mesh,"braid_tets_2_3_4");
conduit::blueprint::mesh::examples::braid("hexs", 2, 3, 4, mesh);
test_save_mesh_helper(mesh,"braid_hexs_2_3_4");
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, number_of_domains)
{
// test both multi dom and non multi dom case
Node data;
// braid
blueprint::mesh::examples::braid("uniform",
10,10,10,
data);
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(data),1);
// now check a multi domain mesh ...
// spiral with 3 domains
conduit::blueprint::mesh::examples::spiral(3,data);
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(data),3);
// spiral with 7 domains
conduit::blueprint::mesh::examples::spiral(7,data);
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(data),7);
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_examples, polyhedral_chain)
{
Node res;
blueprint::mesh::examples::polyhedral_chain(7, // number of cubes
res);
Node info;
EXPECT_TRUE(blueprint::mesh::verify(res,info));
CONDUIT_INFO(info.to_yaml());
test_save_mesh_helper(res,"polyhedral_chain_example");
}
//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
int result = 0;
::testing::InitGoogleTest(&argc, argv);
// allow override of the data size via the command line
if(argc == 2)
{
OUTPUT_NUM_AXIS_POINTS = atoi(argv[1]);
}
result = RUN_ALL_TESTS();
return result;
}