1 // Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
2 // Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
3 // other details. No copyright assignment is required to contribute to Conduit.
4
5 //-----------------------------------------------------------------------------
6 ///
7 /// file: t_blueprint_mesh_verify.cpp
8 ///
9 //-----------------------------------------------------------------------------
10
11 #include "conduit.hpp"
12 #include "conduit_blueprint.hpp"
13 #include "conduit_blueprint_mesh_utils.hpp"
14 #include "conduit_relay.hpp"
15 #include "conduit_log.hpp"
16
17 #include <algorithm>
18 #include <vector>
19 #include <string>
20 #include "gtest/gtest.h"
21
22 using namespace conduit;
23 using namespace conduit::utils;
24 namespace bputils = conduit::blueprint::mesh::utils;
25
26 /// Testing Constants ///
27
get_log_keywords()28 std::vector<std::string> get_log_keywords()
29 {
30 Node log_node;
31 log::info(log_node,"","");
32 log::optional(log_node,"","");
33 log::error(log_node,"","");
34 log::validation(log_node,false);
35 return log_node.child_names();
36 }
37
38 const std::vector<std::string> LOG_KEYWORDS = get_log_keywords();
39 const std::vector<std::string> COORDINATE_COORDSYSS[] =
40 {bputils::CARTESIAN_AXES, bputils::CYLINDRICAL_AXES, bputils::SPHERICAL_AXES};
41
42 typedef bool (*VerifyFun)(const Node&, Node&);
43
44 /// Helper Functions ///
45 /// Testing Helpers ///
braid_bound_npts_z(const std::string & mesh_type,index_t npts_z)46 index_t braid_bound_npts_z(const std::string &mesh_type, index_t npts_z)
47 {
48 if(mesh_type == "tris" ||
49 mesh_type == "quads" ||
50 mesh_type == "quads_poly" ||
51 mesh_type == "quads_and_tris" ||
52 mesh_type == "quads_and_tris_offsets")
53 {
54 return 0;
55 }
56 else
57 {
58 return npts_z;
59 }
60 }
61
62
is_valid_coordsys(bool (* coordsys_valid_fun)(const Node &,Node &),const std::vector<std::string> & coordsys)63 bool is_valid_coordsys(bool (*coordsys_valid_fun)(const Node&, Node&),
64 const std::vector<std::string>& coordsys)
65 {
66 Node n, info;
67
68 bool is_valid = true;
69 for(size_t ci = 0; ci < coordsys.size(); ci++)
70 {
71 const std::string& coordsys_dim = coordsys[ci];
72
73 n[coordsys_dim].set("test");
74 is_valid &= !coordsys_valid_fun(n,info);
75
76 n[coordsys_dim].set(10);
77 is_valid &= coordsys_valid_fun(n,info);
78
79 // FIXME: The coordinate system checking functions shouldn't accept
80 // systems such as (y) or (x, z); all successive dimensions should
81 // require the existence of previous coordsys dimensions.
82 /*
83 if( ci > 0 )
84 {
85 const std::string& prev_dim = coordsys[ci-1];
86 n.remove(prev_dim);
87 is_valid &= !coordsys_valid_fun(n,info);
88 n[coordsys_dim].set(10);
89 }
90 */
91 }
92
93 return is_valid;
94 }
95
96
has_empty_warning(const Node & info)97 bool has_empty_warning(const Node &info)
98 {
99 bool res = false;
100
101 if((info.dtype().is_object() && info.has_child("info")) &&
102 (info["info"].dtype().is_object() || info["info"].dtype().is_list()))
103 {
104 NodeConstIterator iitr = info["info"].children();
105 while(iitr.has_next())
106 {
107 const Node &ichld = iitr.next();
108 res |= ichld.dtype().is_char8_str() &&
109 ichld.to_string().find("is an empty mesh", 0) != std::string::npos;
110 }
111 }
112
113 return res;
114 }
115
116
has_consistent_validity(const Node & n)117 bool has_consistent_validity(const Node &n)
118 {
119 // TODO(JRC): This function will have problems for given nodes containing
120 // nested lists.
121 bool is_consistent = !n.dtype().is_object() ||
122 (n.has_child("valid") && n["valid"].dtype().is_string() &&
123 (n["valid"].as_string() == "true" || n["valid"].as_string() == "false"));
124
125 NodeConstIterator itr = n.children();
126 while(itr.has_next())
127 {
128 const Node &chld= itr.next();
129 const std::string chld_name = itr.name();
130 if(std::find(LOG_KEYWORDS.begin(), LOG_KEYWORDS.end(), chld_name) ==
131 LOG_KEYWORDS.end())
132 {
133 is_consistent &= has_consistent_validity(chld);
134 if(is_consistent)
135 {
136 bool n_valid = n["valid"].as_string() == "true";
137 bool c_valid = chld["valid"].as_string() == "true";
138 is_consistent &= !(n_valid && !c_valid);
139 }
140 }
141 }
142
143 return is_consistent;
144 }
145
146 /// Wrapper Functions ///
147
verify_coordset_protocol(const Node & n,Node & info)148 bool verify_coordset_protocol(const Node &n, Node &info)
149 {
150 return blueprint::mesh::verify("coordset",n,info);
151 }
152
verify_topology_protocol(const Node & n,Node & info)153 bool verify_topology_protocol(const Node &n, Node &info)
154 {
155 return blueprint::mesh::verify("topology",n,info);
156 }
157
verify_matset_protocol(const Node & n,Node & info)158 bool verify_matset_protocol(const Node &n, Node &info)
159 {
160 return blueprint::mesh::verify("matset",n,info);
161 }
162
verify_specset_protocol(const Node & n,Node & info)163 bool verify_specset_protocol(const Node &n, Node &info)
164 {
165 return blueprint::mesh::verify("specset",n,info);
166 }
167
verify_field_protocol(const Node & n,Node & info)168 bool verify_field_protocol(const Node &n, Node &info)
169 {
170 return blueprint::mesh::verify("field",n,info);
171 }
172
verify_adjset_protocol(const Node & n,Node & info)173 bool verify_adjset_protocol(const Node &n, Node &info)
174 {
175 return blueprint::mesh::verify("adjset",n,info);
176 }
177
verify_nestset_protocol(const Node & n,Node & info)178 bool verify_nestset_protocol(const Node &n, Node &info)
179 {
180 return blueprint::mesh::verify("nestset",n,info);
181 }
182
verify_index_protocol(const Node & n,Node & info)183 bool verify_index_protocol(const Node &n, Node &info)
184 {
185 return blueprint::mesh::verify("index",n,info);
186 }
187
verify_coordset_index_protocol(const Node & n,Node & info)188 bool verify_coordset_index_protocol(const Node &n, Node &info)
189 {
190 return blueprint::mesh::verify("coordset/index",n,info);
191 }
192
verify_topology_index_protocol(const Node & n,Node & info)193 bool verify_topology_index_protocol(const Node &n, Node &info)
194 {
195 return blueprint::mesh::verify("topology/index",n,info);
196 }
197
verify_matset_index_protocol(const Node & n,Node & info)198 bool verify_matset_index_protocol(const Node &n, Node &info)
199 {
200 return blueprint::mesh::verify("matset/index",n,info);
201 }
202
verify_specset_index_protocol(const Node & n,Node & info)203 bool verify_specset_index_protocol(const Node &n, Node &info)
204 {
205 return blueprint::mesh::verify("specset/index",n,info);
206 }
207
verify_field_index_protocol(const Node & n,Node & info)208 bool verify_field_index_protocol(const Node &n, Node &info)
209 {
210 return blueprint::mesh::verify("field/index",n,info);
211 }
212
verify_adjset_index_protocol(const Node & n,Node & info)213 bool verify_adjset_index_protocol(const Node &n, Node &info)
214 {
215 return blueprint::mesh::verify("adjset/index",n,info);
216 }
217
verify_nestset_index_protocol(const Node & n,Node & info)218 bool verify_nestset_index_protocol(const Node &n, Node &info)
219 {
220 return blueprint::mesh::verify("nestset/index",n,info);
221 }
222
verify_mesh_multi_domain_protocol(const Node & n,Node & info)223 bool verify_mesh_multi_domain_protocol(const Node &n, Node &info)
224 {
225 // we can only call is_multi_domain if verify is true
226 return blueprint::mesh::verify(n,info) &&
227 blueprint::mesh::is_multi_domain(n);
228 }
229
230
231 /// Helper for mesh verify checks ///
232
233 #define CHECK_MESH(verify, n, info, expected) \
234 { \
235 \
236 if(verify(n, info) != expected) \
237 { \
238 std::cout << "[verify test failed!]\n" \
239 << "[expected result: " \
240 << expected << "]\n" \
241 << "[details:]\n"; \
242 n.print(); \
243 info.print(); \
244 } \
245 \
246 EXPECT_EQ(verify(n, info), expected); \
247 EXPECT_TRUE(has_consistent_validity(info)); \
248 } \
249
250 #define CHECK_MATSET(n, iub, ied) \
251 { \
252 EXPECT_EQ(blueprint::mesh::matset::is_uni_buffer(n), iub); \
253 EXPECT_EQ(blueprint::mesh::matset::is_multi_buffer(n), !iub); \
254 EXPECT_EQ(blueprint::mesh::matset::is_element_dominant(n), ied); \
255 EXPECT_EQ(blueprint::mesh::matset::is_material_dominant(n), !ied); \
256 } \
257
258 /// Mesh Coordinate Set Tests ///
259
260 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_logical_dims)261 TEST(conduit_blueprint_mesh_verify, coordset_logical_dims)
262 {
263 VerifyFun verify_coordset_logical = blueprint::mesh::logical_dims::verify;
264
265 Node n, info;
266 CHECK_MESH(verify_coordset_logical,n,info,false);
267
268 EXPECT_TRUE(is_valid_coordsys(verify_coordset_logical,bputils::LOGICAL_AXES));
269
270 EXPECT_FALSE(is_valid_coordsys(verify_coordset_logical,bputils::CARTESIAN_AXES));
271 }
272
273
274 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_uniform_origin)275 TEST(conduit_blueprint_mesh_verify, coordset_uniform_origin)
276 {
277 VerifyFun verify_uniform_origin = blueprint::mesh::coordset::uniform::origin::verify;
278
279 Node n, info;
280 // FIXME: The origin verification function shouldn't accept an empty node.
281 // CHECK_MESH(verify_uniform_origin,n,info,false);
282
283 EXPECT_TRUE(is_valid_coordsys(verify_uniform_origin,bputils::CARTESIAN_AXES));
284 EXPECT_TRUE(is_valid_coordsys(verify_uniform_origin,bputils::SPHERICAL_AXES));
285 EXPECT_TRUE(is_valid_coordsys(verify_uniform_origin,bputils::CYLINDRICAL_AXES));
286
287 EXPECT_FALSE(is_valid_coordsys(verify_uniform_origin,bputils::LOGICAL_AXES));
288 }
289
290
291 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_uniform_spacing)292 TEST(conduit_blueprint_mesh_verify, coordset_uniform_spacing)
293 {
294 VerifyFun verify_uniform_spacing = blueprint::mesh::coordset::uniform::spacing::verify;
295
296 Node n, info;
297 // FIXME: The spacing verification function shouldn't accept an empty node.
298 // CHECK_MESH(verify_uniform_spacing,n,info,false);
299
300 EXPECT_TRUE(is_valid_coordsys(verify_uniform_spacing,{"dx","dy","dz"}));
301 EXPECT_TRUE(is_valid_coordsys(verify_uniform_spacing,{"dr","dtheta","dphi"}));
302 EXPECT_TRUE(is_valid_coordsys(verify_uniform_spacing,{"dr","dz"}));
303
304 EXPECT_FALSE(is_valid_coordsys(verify_uniform_spacing,{"di","dj","dk"}));
305 }
306
307
308 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_uniform)309 TEST(conduit_blueprint_mesh_verify, coordset_uniform)
310 {
311 VerifyFun verify_uniform_coordset = blueprint::mesh::coordset::uniform::verify;
312
313 Node n, info;
314 CHECK_MESH(verify_uniform_coordset,n,info,false);
315
316 n["type"].set("uniform");
317 CHECK_MESH(verify_uniform_coordset,n,info,false);
318
319 n["dims"]["i"].set(1);
320 n["dims"]["j"].set(2);
321 CHECK_MESH(verify_uniform_coordset,n,info,true);
322
323 n["dims"]["k"].set("test");
324 CHECK_MESH(verify_uniform_coordset,n,info,false);
325 n["dims"]["k"].set(3);
326 CHECK_MESH(verify_uniform_coordset,n,info,true);
327
328 Node dims = n["dims"];
329 n.remove("dims");
330
331 n["origin"]["x"].set(10);
332 n["origin"]["y"].set(20);
333 CHECK_MESH(verify_uniform_coordset,n,info,false);
334
335 n["dims"].set(dims);
336 CHECK_MESH(verify_uniform_coordset,n,info,true);
337
338 n["origin"]["z"].set("test");
339 CHECK_MESH(verify_uniform_coordset,n,info,false);
340 n["origin"]["z"].set(30);
341 CHECK_MESH(verify_uniform_coordset,n,info,true);
342
343 n["spacing"]["dx"].set(0.1);
344 n["spacing"]["dy"].set(0.2);
345 CHECK_MESH(verify_uniform_coordset,n,info,true);
346
347 n["spacing"]["dz"].set("test");
348 CHECK_MESH(verify_uniform_coordset,n,info,false);
349 n["spacing"]["dz"].set(0.3);
350 CHECK_MESH(verify_uniform_coordset,n,info,true);
351
352 n["type"].set("rectilinear");
353 CHECK_MESH(verify_uniform_coordset,n,info,false);
354 }
355
356
357 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_rectilinear)358 TEST(conduit_blueprint_mesh_verify, coordset_rectilinear)
359 {
360 VerifyFun verify_rectilinear_coordset = blueprint::mesh::coordset::rectilinear::verify;
361
362 Node n, info;
363 CHECK_MESH(verify_rectilinear_coordset,n,info,false);
364
365 n["values"].set("test");
366 CHECK_MESH(verify_rectilinear_coordset,n,info,false);
367
368 n["type"].set("rectilinear");
369 CHECK_MESH(verify_rectilinear_coordset,n,info,false);
370
371 for(size_t ci = 0; ci < 3; ci++)
372 {
373 const std::vector<std::string>& coord_coordsys = COORDINATE_COORDSYSS[ci];
374
375 n["values"].reset();
376 for(size_t cj = 0; cj < coord_coordsys.size(); cj++)
377 {
378 n["values"][coord_coordsys[cj]].set(DataType::float64(10));
379 CHECK_MESH(verify_rectilinear_coordset,n,info,true);
380 // info.print();
381 }
382 }
383
384 // check case where number of elements for each child doesn't match
385 // (rectilinear coordsets use cross product of input coord arrays, they
386 // don't need to be mcarrays)
387 for(size_t ci = 0; ci < 3; ci++)
388 {
389 const std::vector<std::string>& coord_coordsys = COORDINATE_COORDSYSS[ci];
390
391 n["values"].reset();
392 for(size_t cj = 0; cj < coord_coordsys.size(); cj++)
393 {
394 n["values"][coord_coordsys[cj]].set(DataType::float64(cj + 5));
395 CHECK_MESH(verify_rectilinear_coordset,n,info,true);
396 // info.print();
397 }
398 }
399
400 n["type"].set("uniform");
401 CHECK_MESH(verify_rectilinear_coordset,n,info,false);
402
403
404 // FIXME: The logical coordinate system shouldn't be an accepted value
405 // for the rectilinear verify function.
406 /*
407 n["values"].reset();
408 for(index_t ci = 0; ci < bputils::LOGICAL_AXES.size(); ci++)
409 {
410 n["values"][bputils::LOGICAL_AXES[ci]].set(DataType::float64(10));
411 CHECK_MESH(verify_rectilinear_coordset,n,info,false);
412 }
413 */
414 }
415
416
417 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_explicit)418 TEST(conduit_blueprint_mesh_verify, coordset_explicit)
419 {
420 VerifyFun verify_explicit_coordset = blueprint::mesh::coordset::_explicit::verify;
421
422 Node n, info;
423 CHECK_MESH(verify_explicit_coordset,n,info,false);
424
425 n["values"].set("test");
426 CHECK_MESH(verify_explicit_coordset,n,info,false);
427
428 n["type"].set("explicit");
429 CHECK_MESH(verify_explicit_coordset,n,info,false);
430
431 for(size_t ci = 0; ci < 3; ci++)
432 {
433 const std::vector<std::string>& coord_coordsys = COORDINATE_COORDSYSS[ci];
434
435 n["values"].reset();
436 for(size_t cj = 0; cj < coord_coordsys.size(); cj++)
437 {
438 n["values"][coord_coordsys[cj]].set(DataType::float64(10));
439 CHECK_MESH(verify_explicit_coordset,n,info,true);
440 }
441 }
442
443 n["type"].set("uniform");
444 CHECK_MESH(verify_explicit_coordset,n,info,false);
445
446 // FIXME: The logical coordinate system shouldn't be an accepted value
447 // for the explicit verify function.
448 /*
449 n["values"].reset();
450 for(index_t ci = 0; ci < bputils::LOGICAL_AXES.size(); ci++)
451 {
452 n["values"][bputils::LOGICAL_AXES[ci]].set(DataType::float64(10));
453 CHECK_MESH(verify_explicit_coordset,n,info,false);
454 }
455 */
456 }
457
458 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_types)459 TEST(conduit_blueprint_mesh_verify, coordset_types)
460 {
461 VerifyFun verify_coordset = blueprint::mesh::coordset::verify;
462
463 Node n, info;
464
465 const std::string coordset_types[] = {"uniform", "rectilinear", "explicit"};
466 const std::string coordset_fids[] = {"uniform", "rectilinear", "quads"};
467 for(index_t ci = 0; ci < 3; ci++)
468 {
469 n.reset();
470 blueprint::mesh::examples::braid(coordset_fids[ci],10,10,0,n);
471 Node& coordset_node = n["coordsets/coords"];
472 CHECK_MESH(verify_coordset,coordset_node,info,true);
473
474 coordset_node["type"].set(0);
475 CHECK_MESH(verify_coordset,coordset_node,info,false);
476
477 coordset_node["type"].set("unstructured");
478 CHECK_MESH(verify_coordset,coordset_node,info,false);
479
480 if(ci != 2)
481 {
482 coordset_node["type"].set(coordset_types[2]);
483 EXPECT_FALSE(blueprint::mesh::topology::verify(coordset_node,info));
484 }
485
486 coordset_node["type"].set(coordset_types[ci]);
487 CHECK_MESH(verify_coordset,coordset_node,info,true);
488 }
489 }
490
491 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_coordsys)492 TEST(conduit_blueprint_mesh_verify, coordset_coordsys)
493 {
494 VerifyFun verify_coordset_coordsys = blueprint::mesh::coordset::coord_system::verify;
495
496 Node n, info;
497 CHECK_MESH(verify_coordset_coordsys,n,info,false);
498
499 const std::string coordsys_types[] = {"cartesian", "cylindrical", "spherical"};
500 for(index_t ci = 0; ci < 3; ci++)
501 {
502 n.reset();
503 info.reset();
504
505 n["type"].set(coordsys_types[ci]);
506 CHECK_MESH(verify_coordset_coordsys,n,info,false);
507
508 n["axes"].set(0);
509 CHECK_MESH(verify_coordset_coordsys,n,info,false);
510
511 n["axes"].reset();
512 const std::vector<std::string>& coordsys = COORDINATE_COORDSYSS[ci];
513 for(size_t ai = 0; ai < coordsys.size(); ai++)
514 {
515 n["axes"][coordsys[ai]].set(10);
516 CHECK_MESH(verify_coordset_coordsys,n,info,true);
517 }
518
519 n["type"].set(coordsys_types[(ci == 0) ? 2 : ci - 1]);
520 CHECK_MESH(verify_coordset_coordsys,n,info,false);
521
522 n["type"].set("barycentric");
523 CHECK_MESH(verify_coordset_coordsys,n,info,false);
524
525 n["type"].set(10);
526 CHECK_MESH(verify_coordset_coordsys,n,info,false);
527 }
528 }
529
530
531 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,coordset_general)532 TEST(conduit_blueprint_mesh_verify, coordset_general)
533 {
534 VerifyFun verify_coordset_funs[] = {
535 blueprint::mesh::coordset::verify,
536 verify_coordset_protocol};
537
538 for(index_t fi = 0; fi < 2; fi++)
539 {
540 VerifyFun verify_coordset = verify_coordset_funs[fi];
541
542 Node mesh, info;
543 CHECK_MESH(verify_coordset,mesh,info,false);
544
545 blueprint::mesh::examples::braid("uniform",10,10,10,mesh);
546 Node& n = mesh["coordsets"]["coords"];
547
548 n.remove("type");
549 CHECK_MESH(verify_coordset,n,info,false);
550 n["type"].set("structured");
551 CHECK_MESH(verify_coordset,n,info,false);
552 n["type"].set("rectilinear");
553 CHECK_MESH(verify_coordset,n,info,false);
554
555 n["type"].set("uniform");
556 CHECK_MESH(verify_coordset,n,info,true);
557 }
558 }
559
560 /// Mesh Topology Tests ///
561
562 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_points)563 TEST(conduit_blueprint_mesh_verify, topology_points)
564 {
565 VerifyFun verify_points_topology = blueprint::mesh::topology::points::verify;
566 Node n, info;
567
568 CHECK_MESH(verify_points_topology,n,info,false);
569
570 n["coordset"].set("coords");
571 n["type"].set("points");
572 CHECK_MESH(verify_points_topology,n,info,true);
573
574 n["coordset"].set(1);
575 CHECK_MESH(verify_points_topology,n,info,false);
576
577 n["coordset"].set("coords");
578 n["type"].set(1);
579 CHECK_MESH(verify_points_topology,n,info,false);
580
581 n["type"].set("uniform");
582 CHECK_MESH(verify_points_topology,n,info,false);
583 }
584
585 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_uniform)586 TEST(conduit_blueprint_mesh_verify, topology_uniform)
587 {
588 VerifyFun verify_uniform_topology = blueprint::mesh::topology::uniform::verify;
589 Node n, info;
590
591 CHECK_MESH(verify_uniform_topology,n,info,false);
592
593 n["coordset"].set("coords");
594 n["type"].set("uniform");
595 CHECK_MESH(verify_uniform_topology,n,info,true);
596
597 n["coordset"].set(1);
598 CHECK_MESH(verify_uniform_topology,n,info,false);
599
600 n["coordset"].set("coords");
601 n["type"].set(1);
602 CHECK_MESH(verify_uniform_topology,n,info,false);
603
604 n["type"].set("points");
605 CHECK_MESH(verify_uniform_topology,n,info,false);
606 }
607
608
609 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_rectilinear)610 TEST(conduit_blueprint_mesh_verify, topology_rectilinear)
611 {
612 VerifyFun verify_rectilinear_topology = blueprint::mesh::topology::rectilinear::verify;
613 Node n, info;
614
615 CHECK_MESH(verify_rectilinear_topology,n,info,false);
616
617 n["coordset"].set("coords");
618 n["type"].set("rectilinear");
619 CHECK_MESH(verify_rectilinear_topology,n,info,true);
620
621 n["coordset"].set(1);
622 CHECK_MESH(verify_rectilinear_topology,n,info,false);
623
624 n["coordset"].set("coords");
625 n["type"].set(1);
626 CHECK_MESH(verify_rectilinear_topology,n,info,false);
627
628 n["type"].set("points");
629 CHECK_MESH(verify_rectilinear_topology,n,info,false);
630 }
631
632
633 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_structured)634 TEST(conduit_blueprint_mesh_verify, topology_structured)
635 {
636 VerifyFun verify_structured_topology = blueprint::mesh::topology::structured::verify;
637
638 Node n, info;
639 CHECK_MESH(verify_structured_topology,n,info,false);
640
641 n["coordset"].set("coords");
642 n["type"].set("structured");
643 CHECK_MESH(verify_structured_topology,n,info,false);
644
645 n["elements"].set(0);
646 CHECK_MESH(verify_structured_topology,n,info,false);
647
648 n["elements"].reset();
649 n["elements"]["dims"].set(0);
650 CHECK_MESH(verify_structured_topology,n,info,false);
651
652 n["elements"]["dims"].reset();
653 n["elements"]["dims"]["x"].set(5);
654 n["elements"]["dims"]["y"].set(10);
655 CHECK_MESH(verify_structured_topology,n,info,false);
656
657 n["elements"]["dims"].reset();
658 n["elements"]["dims"]["i"].set(15);
659 n["elements"]["dims"]["j"].set(20);
660 CHECK_MESH(verify_structured_topology,n,info,true);
661
662 n["elements"]["dims"]["k"].set(25);
663 CHECK_MESH(verify_structured_topology,n,info,true);
664
665 n["type"].set("unstructured");
666 CHECK_MESH(verify_structured_topology,n,info,false);
667 }
668
669
670 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_unstructured)671 TEST(conduit_blueprint_mesh_verify, topology_unstructured)
672 {
673 VerifyFun verify_unstructured_topology = blueprint::mesh::topology::unstructured::verify;
674
675 Node n, info;
676 CHECK_MESH(verify_unstructured_topology,n,info,false);
677
678 n["coordset"].set("coords");
679 n["type"].set("unstructured");
680 CHECK_MESH(verify_unstructured_topology,n,info,false);
681
682 n["elements"].set(0);
683 CHECK_MESH(verify_unstructured_topology,n,info,false);
684
685 { // Single Shape Topology Tests //
686 n["elements"].reset();
687 n["elements"]["shape"].set("undefined");
688 CHECK_MESH(verify_unstructured_topology,n,info,false);
689
690 n["elements"]["shape"].set("quad");
691 CHECK_MESH(verify_unstructured_topology,n,info,false);
692
693 n["elements"]["connectivity"].set("quad");
694 CHECK_MESH(verify_unstructured_topology,n,info,false);
695 n["elements"]["connectivity"].set(DataType::float64(10));
696 CHECK_MESH(verify_unstructured_topology,n,info,false);
697
698 n["elements"]["connectivity"].set(DataType::int32(1));
699 CHECK_MESH(verify_unstructured_topology,n,info,true);
700 n["elements"]["connectivity"].set(DataType::int32(10));
701 CHECK_MESH(verify_unstructured_topology,n,info,true);
702
703 n["elements"]["offsets"].set(DataType::float64(10));
704 CHECK_MESH(verify_unstructured_topology,n,info,true);
705 n["elements"]["offsets"].set(DataType::int32(10));
706 CHECK_MESH(verify_unstructured_topology,n,info,true);
707 n["elements"].remove("offsets");
708 CHECK_MESH(verify_unstructured_topology,n,info,true);
709
710 n["type"].set("structured");
711 CHECK_MESH(verify_unstructured_topology,n,info,false);
712 n["type"].set("unstructured");
713 CHECK_MESH(verify_unstructured_topology,n,info,true);
714 }
715
716 { // Single Shape Unstructured Polygon Tests //
717 n["elements"].reset();
718 n["elements"]["shape"].set("undefined");
719 CHECK_MESH(verify_unstructured_topology,n,info,false);
720
721 n["elements"]["shape"].set("polygonal");
722 CHECK_MESH(verify_unstructured_topology,n,info,false);
723
724 n["elements"]["connectivity"].set(DataType::int32(10));
725 n["elements"]["offsets"].set(DataType::int32(10));
726 n["elements"]["sizes"].set(DataType::int32(10));
727 CHECK_MESH(verify_unstructured_topology,n,info,true);
728
729 n["elements"]["connectivity"].set(DataType::float64(10));
730 CHECK_MESH(verify_unstructured_topology,n,info,false);
731 n["elements"]["connectivity"].set(DataType::int32(10));
732 CHECK_MESH(verify_unstructured_topology,n,info,true);
733
734 n["elements"]["offsets"].set(DataType::float64(10));
735 CHECK_MESH(verify_unstructured_topology,n,info,false);
736 n["elements"].remove("offsets");
737 CHECK_MESH(verify_unstructured_topology,n,info,false);
738 n["elements"]["offsets"].set(DataType::int32(10));
739 CHECK_MESH(verify_unstructured_topology,n,info,true);
740
741 n["elements"]["sizes"].set(DataType::float64(10));
742 CHECK_MESH(verify_unstructured_topology,n,info,false);
743 n["elements"]["sizes"].set(DataType::int32(10));
744 CHECK_MESH(verify_unstructured_topology,n,info,true);
745
746 n["type"].set("structured");
747 CHECK_MESH(verify_unstructured_topology,n,info,false);
748 n["type"].set("unstructured");
749 CHECK_MESH(verify_unstructured_topology,n,info,true);
750 }
751
752 { // Single Shape Unstructured Polyhedral Tests //
753 n["elements"].reset();
754 n["elements"]["shape"].set("undefined");
755 CHECK_MESH(verify_unstructured_topology,n,info,false);
756
757 n["elements"]["shape"].set("polyhedral");
758 CHECK_MESH(verify_unstructured_topology,n,info,false);
759
760 n["elements"]["connectivity"].set(DataType::int32(10));
761 CHECK_MESH(verify_unstructured_topology,n,info,false);
762 n["elements"]["offsets"].set(DataType::int32(10));
763 CHECK_MESH(verify_unstructured_topology,n,info,false);
764 n["elements"]["sizes"].set(DataType::int32(10));
765 CHECK_MESH(verify_unstructured_topology,n,info,false);
766
767 n["subelements"]["shape"].set("polygonal");
768 CHECK_MESH(verify_unstructured_topology,n,info,false);
769 n["subelements"]["connectivity"].set(DataType::int32(10));
770 CHECK_MESH(verify_unstructured_topology,n,info,true);
771 n["subelements"]["offsets"].set(DataType::int32(10));
772 CHECK_MESH(verify_unstructured_topology,n,info,false);
773 n["subelements"]["sizes"].set(DataType::int32(10));
774 CHECK_MESH(verify_unstructured_topology,n,info,true);
775
776 n["elements"]["connectivity"].set(DataType::float64(10));
777 CHECK_MESH(verify_unstructured_topology,n,info,false);
778 n["elements"]["connectivity"].set(DataType::int32(10));
779 CHECK_MESH(verify_unstructured_topology,n,info,true);
780
781 n["subelements"]["connectivity"].set(DataType::float64(10));
782 CHECK_MESH(verify_unstructured_topology,n,info,false);
783 n["subelements"]["connectivity"].set(DataType::int32(10));
784 CHECK_MESH(verify_unstructured_topology,n,info,true);
785
786 n["elements"]["offsets"].set(DataType::float64(10));
787 CHECK_MESH(verify_unstructured_topology,n,info,false);
788 n["elements"].remove("offsets");
789 CHECK_MESH(verify_unstructured_topology,n,info,false);
790 n["elements"]["offsets"].set(DataType::int32(10));
791 CHECK_MESH(verify_unstructured_topology,n,info,true);
792
793 n["subelements"]["offsets"].set(DataType::float64(10));
794 CHECK_MESH(verify_unstructured_topology,n,info,false);
795 n["subelements"].remove("offsets");
796 CHECK_MESH(verify_unstructured_topology,n,info,false);
797 n["subelements"]["offsets"].set(DataType::int32(10));
798 CHECK_MESH(verify_unstructured_topology,n,info,true);
799
800 n["elements"]["sizes"].set(DataType::float64(10));
801 CHECK_MESH(verify_unstructured_topology,n,info,false);
802 n["elements"]["sizes"].set(DataType::int32(10));
803 CHECK_MESH(verify_unstructured_topology,n,info,true);
804
805 n["subelements"]["sizes"].set(DataType::float64(10));
806 CHECK_MESH(verify_unstructured_topology,n,info,false);
807 n["subelements"]["sizes"].set(DataType::int32(10));
808 CHECK_MESH(verify_unstructured_topology,n,info,true);
809
810 n["type"].set("structured");
811 CHECK_MESH(verify_unstructured_topology,n,info,false);
812 n["type"].set("unstructured");
813 CHECK_MESH(verify_unstructured_topology,n,info,true);
814 }
815
816 { // Mixed Shape Topology List Tests //
817 n["elements"].reset();
818
819 n["elements"]["a"].set(0);
820 CHECK_MESH(verify_unstructured_topology,n,info,false);
821
822 n["elements"]["a"]["shape"].set("quad");
823 n["elements"]["a"]["connectivity"].set(DataType::int32(5));
824 CHECK_MESH(verify_unstructured_topology,n,info,true);
825
826 n["elements"]["b"]["shape"].set("undefined");
827 CHECK_MESH(verify_unstructured_topology,n,info,false);
828 n["elements"]["b"]["shape"].set("quad");
829 CHECK_MESH(verify_unstructured_topology,n,info,false);
830 n["elements"]["b"]["connectivity"].set(DataType::float32(3));
831 CHECK_MESH(verify_unstructured_topology,n,info,false);
832 n["elements"]["b"]["connectivity"].set(DataType::int32(1));
833 CHECK_MESH(verify_unstructured_topology,n,info,true);
834
835 n["elements"]["c"]["shape"].set("tri");
836 n["elements"]["c"]["connectivity"].set(DataType::int32(5));
837 n["elements"]["c"]["offsets"].set(DataType::int32(5));
838 CHECK_MESH(verify_unstructured_topology,n,info,true);
839
840 n["elements"]["d"]["shape"].set("polygonal");
841 n["elements"]["d"]["connectivity"].set(DataType::int32(6));
842 CHECK_MESH(verify_unstructured_topology,n,info,true);
843 n["elements"]["d"]["offsets"].set(DataType::int32(3));
844 CHECK_MESH(verify_unstructured_topology,n,info,false);
845 n["elements"]["d"]["sizes"].set(DataType::int32(2));
846 CHECK_MESH(verify_unstructured_topology,n,info,false);
847 n["elements"]["d"]["sizes"].set(DataType::int32(3));
848 CHECK_MESH(verify_unstructured_topology,n,info,true);
849
850 n["elements"]["e"]["shape"].set("polyhedral");
851 n["elements"]["e"]["connectivity"].set(DataType::int32(6));
852 CHECK_MESH(verify_unstructured_topology,n,info,false);
853 n["elements"]["e"]["offsets"].set(DataType::int32(3));
854 CHECK_MESH(verify_unstructured_topology,n,info,false);
855 n["elements"]["e"]["sizes"].set(DataType::int32(2));
856 CHECK_MESH(verify_unstructured_topology,n,info,false);
857 n["elements"]["e"]["sizes"].set(DataType::int32(3));
858 CHECK_MESH(verify_unstructured_topology,n,info,false);
859
860 n["subelements"]["e"]["shape"].set("polygonal");
861 CHECK_MESH(verify_unstructured_topology,n,info,false);
862 n["subelements"]["e"]["connectivity"].set(DataType::int32(6));
863 CHECK_MESH(verify_unstructured_topology,n,info,true);
864 n["subelements"]["e"]["offsets"].set(DataType::int32(3));
865 CHECK_MESH(verify_unstructured_topology,n,info,false);
866 n["subelements"]["e"]["sizes"].set(DataType::int32(3));
867 CHECK_MESH(verify_unstructured_topology,n,info,true);
868
869 n["type"].set("structured");
870 CHECK_MESH(verify_unstructured_topology,n,info,false);
871 }
872
873 { // Multiple Shape Topology Stream Tests //
874 // FIXME: Implement once multiple unstructured shape topologies are implemented.
875 n["elements"].reset();
876 }
877 }
878
879 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_types)880 TEST(conduit_blueprint_mesh_verify, topology_types)
881 {
882 VerifyFun verify_topology = blueprint::mesh::topology::verify;
883
884 Node n, info;
885
886 const std::string topology_types[] = {
887 "points", "uniform", "rectilinear", "structured", "unstructured"};
888 const std::string topology_fids[] = {
889 "points_implicit", "uniform", "rectilinear", "structured", "quads"};
890 const index_t topo_type_count = sizeof(topology_types) / sizeof(std::string);
891
892 for(index_t ti = 0; ti < topo_type_count; ti++)
893 {
894 n.reset();
895 blueprint::mesh::examples::braid(topology_fids[ti],10,10,0,n);
896 Node& topology_node = n["topologies/mesh"];
897 CHECK_MESH(verify_topology,topology_node,info,true);
898
899 topology_node["type"].set(0);
900 CHECK_MESH(verify_topology,topology_node,info,false);
901
902 topology_node["type"].set("explicit");
903 CHECK_MESH(verify_topology,topology_node,info,false);
904
905 if(ti != 4)
906 {
907 topology_node["type"].set(topology_types[4]);
908 CHECK_MESH(verify_topology,topology_node,info,false);
909 }
910
911 topology_node["type"].set(topology_types[ti]);
912 CHECK_MESH(verify_topology,topology_node,info,true);
913 }
914 }
915
916 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_shape)917 TEST(conduit_blueprint_mesh_verify, topology_shape)
918 {
919 VerifyFun verify_topology = blueprint::mesh::topology::verify;
920
921 Node n, info;
922
923 const std::string topology_shapes[] = {
924 "point", "line",
925 "tri", "quad", "polygonal",
926 "tet", "hex", "polyhedral"};
927 const std::string topology_fids[] = {
928 "points", "lines",
929 "tris", "quads", "quads_poly",
930 "tets", "hexs", "hexs_poly"};
931 const index_t topo_shape_count = sizeof(topology_shapes) / sizeof(std::string);
932
933 for(index_t ti = 0; ti < topo_shape_count; ti++)
934 {
935 n.reset();
936 blueprint::mesh::examples::braid(topology_fids[ti],
937 10,
938 10,
939 braid_bound_npts_z(topology_fids[ti], 2),
940 n);
941 Node& topology_node = n["topologies/mesh"];
942 CHECK_MESH(verify_topology,topology_node,info,true);
943
944 topology_node["elements/shape"].set(0);
945 CHECK_MESH(verify_topology,topology_node,info,false);
946
947 topology_node["elements/shape"].set("unstructured");
948 CHECK_MESH(verify_topology,topology_node,info,false);
949
950 topology_node["elements/shape"].set(topology_shapes[ti]);
951 CHECK_MESH(verify_topology,topology_node,info,true);
952 }
953 }
954
955 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,topology_general)956 TEST(conduit_blueprint_mesh_verify, topology_general)
957 {
958 VerifyFun verify_topology_funs[] = {
959 blueprint::mesh::topology::verify,
960 verify_topology_protocol};
961
962 for(index_t fi = 0; fi < 2; fi++)
963 {
964 VerifyFun verify_topology = verify_topology_funs[fi];
965
966 Node mesh, info;
967 CHECK_MESH(verify_topology,mesh,info,false);
968
969 blueprint::mesh::examples::braid("quads",10,10,0,mesh);
970 Node& n = mesh["topologies"]["mesh"];
971
972 { // Type Field Tests //
973 n.remove("type");
974 CHECK_MESH(verify_topology,n,info,false);
975 n["type"].set("explicit");
976 CHECK_MESH(verify_topology,n,info,false);
977
978 // FIXME: Remove the comments from the following line once the verify functions
979 // for uniform and rectilinear topologies have been implemented.
980 const std::string topology_types[] = {/*"uniform", "rectilinear", */"structured"};
981 for(index_t ti = 0; ti < 1; ti++)
982 {
983 n["type"].set(topology_types[ti]);
984 CHECK_MESH(verify_topology,n,info,false);
985 }
986
987 n["type"].set("unstructured");
988 CHECK_MESH(verify_topology,n,info,true);
989 }
990
991 { // Coordset Field Tests //
992 n.remove("coordset");
993 CHECK_MESH(verify_topology,n,info,false);
994
995 n["coordset"].set(0);
996 CHECK_MESH(verify_topology,n,info,false);
997
998 n["coordset"].set("coords");
999 CHECK_MESH(verify_topology,n,info,true);
1000 }
1001
1002 { // Grid Function Field Tests //
1003 n["grid_function"].set(10);
1004 CHECK_MESH(verify_topology,n,info,false);
1005 n["grid_function"].set("coords_gf");
1006 CHECK_MESH(verify_topology,n,info,true);
1007 }
1008 }
1009 }
1010
1011 /// Mesh Matsets Tests ///
1012
1013 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,matset_general)1014 TEST(conduit_blueprint_mesh_verify, matset_general)
1015 {
1016 VerifyFun verify_matset_funs[] = {
1017 blueprint::mesh::matset::verify,
1018 verify_matset_protocol};
1019
1020 const bool is_uni_buffer = true, is_multi_buffer = false;
1021 const bool is_element_dominant = true, is_material_dominant = false;
1022
1023 for(index_t fi = 0; fi < 2; fi++)
1024 {
1025 VerifyFun verify_matset = verify_matset_funs[fi];
1026
1027 Node mesh, info;
1028 CHECK_MESH(verify_matset,mesh,info,false);
1029
1030 blueprint::mesh::examples::misc("matsets",10,10,1,mesh);
1031 Node& n = mesh["matsets"]["mesh"];
1032 CHECK_MESH(verify_matset,n,info,true);
1033
1034 { // Topology Field Tests //
1035 n.remove("topology");
1036 CHECK_MESH(verify_matset,n,info,false);
1037 n["topology"].set(10);
1038 CHECK_MESH(verify_matset,n,info,false);
1039 n["topology"].set("mesh");
1040 CHECK_MESH(verify_matset,n,info,true);
1041 }
1042
1043 { // Volume Fractions Field Tests //
1044 Node vfs = n["volume_fractions"];
1045
1046 n.remove("volume_fractions");
1047 CHECK_MESH(verify_matset,n,info,false);
1048 n["volume_fractions"].set("values");
1049 CHECK_MESH(verify_matset,n,info,false);
1050 n["volume_fractions"].set(DataType::float64(10));
1051 CHECK_MESH(verify_matset,n,info,false);
1052
1053 n["volume_fractions"].reset();
1054 n["volume_fractions"]["x"].set("Hello, ");
1055 n["volume_fractions"]["y"].set("World!");
1056 CHECK_MESH(verify_matset,n,info,false);
1057
1058 n["volume_fractions"].reset();
1059 n["volume_fractions"]["m1"].set(DataType::float64(5));
1060 n["volume_fractions"]["m2"].set(DataType::float64(5));
1061 CHECK_MESH(verify_matset,n,info,true);
1062
1063 { // Uni-Buffer Tests //
1064 n.reset();
1065 n["topology"].set("mesh");
1066
1067 n["volume_fractions"].set(DataType::float64(5));
1068 CHECK_MESH(verify_matset,n,info,false);
1069
1070 n["material_ids"].set(DataType::uint32(5));
1071 CHECK_MESH(verify_matset,n,info,false);
1072 n.remove("material_ids");
1073 n["material_map"]["m1"].set(1);
1074 CHECK_MESH(verify_matset,n,info,false);
1075 n["material_ids"].set(DataType::uint32(5));
1076 CHECK_MESH(verify_matset,n,info,true);
1077 CHECK_MATSET(n,is_uni_buffer,is_element_dominant);
1078
1079 n["indices"].set(DataType::uint32(5));
1080 CHECK_MESH(verify_matset,n,info,true);
1081 n["sizes"].set(DataType::uint32(5));
1082 n["offsets"].set(DataType::uint32(5));
1083 CHECK_MESH(verify_matset,n,info,true);
1084 CHECK_MATSET(n,is_uni_buffer,is_element_dominant);
1085
1086 //--------------------------------------//
1087 // check for bad material_maps
1088 //--------------------------------------//
1089
1090 // - bad material_maps - //
1091
1092 // not an object (empty)
1093 n["material_map"].reset();
1094 CHECK_MESH(verify_matset,n,info,false);
1095
1096 // not an object (leaf)
1097 n["material_map"] = "bananas";
1098 CHECK_MESH(verify_matset,n,info,false);
1099
1100 // child leaves not an integer
1101 n["material_map"].reset();
1102 n["material_map/m1"] = "bananas";
1103 CHECK_MESH(verify_matset,n,info,false);
1104 }
1105
1106 { // Multi-Buffer Tests //
1107 n.reset();
1108 n["topology"].set("mesh");
1109
1110 n["volume_fractions"]["m1"]["values"].set(DataType::float64(8));
1111 n["volume_fractions"]["m1"]["indices"].set(DataType::uint32(5));
1112 CHECK_MESH(verify_matset,n,info,true);
1113 CHECK_MATSET(n,is_multi_buffer,is_element_dominant);
1114
1115 n["volume_fractions"]["m2"]["indices"].set(DataType::uint32(5));
1116 CHECK_MESH(verify_matset,n,info,false);
1117 n["volume_fractions"]["m2"]["values"].set(DataType::float64(10));
1118 CHECK_MESH(verify_matset,n,info,true);
1119 CHECK_MATSET(n,is_multi_buffer,is_element_dominant);
1120
1121 n["volume_fractions"]["m3"]["sizes"].set(DataType::uint32(3));
1122 n["volume_fractions"]["m3"]["values"].set(DataType::float64(30));
1123 CHECK_MESH(verify_matset,n,info,false);
1124 n["volume_fractions"]["m3"]["offsets"].set(DataType::uint32(3));
1125 CHECK_MESH(verify_matset,n,info,true);
1126 CHECK_MATSET(n,is_multi_buffer,is_element_dominant);
1127
1128 n["volume_fractions"]["m4"]["test"]["values"].set(DataType::uint32(3));
1129 CHECK_MESH(verify_matset,n,info,false);
1130 n["volume_fractions"]["m4"]["indices"].set(DataType::uint32(5));
1131 CHECK_MESH(verify_matset,n,info,false);
1132
1133 // make sure we are in good shape for opt material_map checks
1134 n["volume_fractions"].remove("m4");
1135 CHECK_MESH(verify_matset,n,info,true);
1136
1137 //--------------------------------------//
1138 // check for optional use of material_map
1139 //--------------------------------------//
1140
1141 // - good material_map - //
1142 n["material_map"].reset();
1143 n["material_map/m1"] = 0;
1144 n["material_map/m2"] = 1;
1145 n["material_map/m3"] = 2;
1146
1147 CHECK_MESH(verify_matset,n,info,true);
1148
1149 // - bad material_maps - //
1150
1151 // not an object (empty)
1152 n["material_map"].reset();
1153 CHECK_MESH(verify_matset,n,info,false);
1154
1155 // not an object (leaf)
1156 n["material_map"] = "bananas";
1157 CHECK_MESH(verify_matset,n,info,false);
1158
1159 // child leaves not an integer
1160 n["material_map"].reset();
1161 n["material_map/m1"] = 0;
1162 n["material_map/m2"] = "bananas";
1163 n["material_map/m3"] = "mangoes";
1164 CHECK_MESH(verify_matset,n,info,false);
1165
1166 // material_map ents don't match vfs
1167 // (more mat map ents than vfs)
1168 n["material_map"].reset();
1169 n["material_map/m1"] = 0;
1170 n["material_map/m2"] = 1;
1171 n["material_map/m3"] = 2;
1172 n["material_map/m4"] = 4;
1173
1174 CHECK_MESH(verify_matset,n,info,false);
1175
1176 // material_map ents are subset of vfs
1177 // (should be true)
1178 n["material_map"].reset();
1179 n["material_map/m1"] = 0;
1180 n["material_map/m3"] = 2;
1181 CHECK_MESH(verify_matset,n,info,true);
1182 }
1183
1184 { // Element ID Tests //
1185 // Multi-Buffer Volume Fractions //
1186 n.reset();
1187 n["topology"].set("mesh");
1188 n["volume_fractions"]["m1"].set(DataType::float64(5));
1189 n["volume_fractions"]["m2"].set(DataType::float64(5));
1190
1191 n["element_ids"].reset();
1192 n["element_ids"].set(DataType::float64(5));
1193 CHECK_MESH(verify_matset,n,info,false);
1194 n["element_ids"].set(DataType::int64(5));
1195 CHECK_MESH(verify_matset,n,info,false);
1196
1197 n["element_ids"].reset();
1198 n["element_ids"]["m1"].set(DataType::int64(5));
1199 CHECK_MESH(verify_matset,n,info,false);
1200 n["element_ids"]["m2"].set(DataType::int64(5));
1201 CHECK_MESH(verify_matset,n,info,true);
1202 n["element_ids"]["m3"].set(DataType::int64(5));
1203 CHECK_MESH(verify_matset,n,info,false);
1204
1205 n["element_ids"].reset();
1206 n["element_ids"]["m1"].set(DataType::int64(5));
1207 n["element_ids"]["m2"].set(DataType::float32(5));
1208 CHECK_MESH(verify_matset,n,info,false);
1209 n["element_ids"]["m2"].set(DataType::int32(5));
1210 CHECK_MESH(verify_matset,n,info,true);
1211 CHECK_MATSET(n,is_multi_buffer,is_material_dominant);
1212
1213 //--------------------------------------//
1214 // check for optional use of material_map
1215 //--------------------------------------//
1216
1217 // - good material_map - //
1218 n["material_map"].reset();
1219 n["material_map/m1"] = 0;
1220 n["material_map/m2"] = 1;
1221 CHECK_MESH(verify_matset,n,info,true);
1222
1223 // - bad material_maps - //
1224
1225 // not an object (empty)
1226 n["material_map"].reset();
1227 CHECK_MESH(verify_matset,n,info,false);
1228
1229 // not an object (leaf)
1230 n["material_map"] = "bananas";
1231 CHECK_MESH(verify_matset,n,info,false);
1232
1233 // child leaves not an integer
1234 n["material_map"].reset();
1235 n["material_map/m1"] = 0;
1236 n["material_map/m2"] = "bananas";
1237 n["material_map/m3"] = "mangoes";
1238 CHECK_MESH(verify_matset,n,info,false);
1239
1240 // material_map ents don't match vfs
1241 n["material_map"].reset();
1242 n["material_map/banana"] = 0;
1243 n["material_map/mango"] = 1;
1244 CHECK_MESH(verify_matset,n,info,false);
1245
1246
1247 n.remove("material_map");
1248
1249 // Uni-Buffer Volume Fractions //
1250 n["volume_fractions"].reset();
1251 n["volume_fractions"].set(DataType::float64(5));
1252 n["material_map"]["m1"].set(1);
1253 n["material_ids"].set(DataType::uint32(5));
1254
1255 n["element_ids"].reset();
1256 n["element_ids"]["m1"].set(DataType::int64(5));
1257 n["element_ids"]["m2"].set(DataType::int64(5));
1258 CHECK_MESH(verify_matset,n,info,false);
1259
1260 n["element_ids"].reset();
1261 n["element_ids"].set(DataType::float64(5));
1262 CHECK_MESH(verify_matset,n,info,false);
1263 n["element_ids"].set(DataType::int32(5));
1264 CHECK_MESH(verify_matset,n,info,true);
1265 CHECK_MATSET(n,is_uni_buffer,is_material_dominant);
1266
1267 //--------------------------------------//
1268 // check for optional use of material_map
1269 //--------------------------------------//
1270
1271 // - good material_map - //
1272 n["material_map"].reset();
1273 n["material_map/m1"] = 0;
1274 n["material_map/m2"] = 1;
1275 CHECK_MESH(verify_matset,n,info,true);
1276
1277 // - bad material_maps - //
1278
1279 // not an object (empty)
1280 n["material_map"].reset();
1281 CHECK_MESH(verify_matset,n,info,false);
1282
1283 // not an object (leaf)
1284 n["material_map"] = "bananas";
1285 CHECK_MESH(verify_matset,n,info,false);
1286
1287 // child leaves not an integer
1288 n["material_map"].reset();
1289 n["material_map/m1"] = 0;
1290 n["material_map/m2"] = "bananas";
1291 n["material_map/m3"] = "mangoes";
1292 CHECK_MESH(verify_matset,n,info,false);
1293
1294 }
1295
1296 n.reset();
1297 n["topology"].set("mesh");
1298 n["volume_fractions"].set(vfs);
1299 CHECK_MESH(verify_matset,n,info,true);
1300 }
1301 }
1302 }
1303
1304 /// Mesh Specsets Tests ///
1305
1306 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,specset_general)1307 TEST(conduit_blueprint_mesh_verify, specset_general)
1308 {
1309 VerifyFun verify_specset_funs[] = {
1310 blueprint::mesh::specset::verify,
1311 verify_specset_protocol};
1312
1313 for(index_t fi = 0; fi < 2; fi++)
1314 {
1315 VerifyFun verify_specset = verify_specset_funs[fi];
1316
1317 Node mesh, info;
1318 CHECK_MESH(verify_specset,mesh,info,false);
1319
1320 blueprint::mesh::examples::misc("specsets",10,10,1,mesh);
1321 Node& n = mesh["specsets"]["mesh"];
1322 CHECK_MESH(verify_specset,n,info,true);
1323
1324 { // Matset Field Tests //
1325 n.remove("matset");
1326 CHECK_MESH(verify_specset,n,info,false);
1327 n["matset"].set(10);
1328 CHECK_MESH(verify_specset,n,info,false);
1329 n["matset"].set("mesh");
1330 CHECK_MESH(verify_specset,n,info,true);
1331 }
1332
1333 { // Matset Values Field Tests //
1334 Node mfs = n["matset_values"];
1335
1336 n.remove("matset_values");
1337 CHECK_MESH(verify_specset,n,info,false);
1338 n["matset_values"].set("values");
1339 CHECK_MESH(verify_specset,n,info,false);
1340 n["matset_values"].set(DataType::float64(10));
1341 CHECK_MESH(verify_specset,n,info,false);
1342
1343 n["matset_values"].reset();
1344 n["matset_values"]["x"].set("Hello, ");
1345 n["matset_values"]["y"].set("World!");
1346 CHECK_MESH(verify_specset,n,info,false);
1347
1348 n["matset_values"].reset();
1349 n["matset_values"]["m1"].set(DataType::float64(5));
1350 n["matset_values"]["m2"].set(DataType::float64(5));
1351 CHECK_MESH(verify_specset,n,info,false);
1352
1353 n["matset_values"].reset();
1354 n["matset_values"]["m1"].append().set(DataType::float64(5));
1355 n["matset_values"]["m1"].append().set(DataType::float64(5));
1356 CHECK_MESH(verify_specset,n,info,true);
1357 n["matset_values"]["m2"].append().set(DataType::float64(5));
1358 CHECK_MESH(verify_specset,n,info,true);
1359
1360 n["matset_values"].reset();
1361 n["matset_values"]["m1"]["s1"].set(DataType::float64(5));
1362 n["matset_values"]["m2"]["s1"].set(DataType::float64(5));
1363 CHECK_MESH(verify_specset,n,info,true);
1364
1365 n["matset_values"].reset();
1366 n["matset_values"]["m1"]["s1"].set(DataType::float64(5));
1367 n["matset_values"]["m2"]["s2"].set(DataType::float64(5));
1368 CHECK_MESH(verify_specset,n,info,true);
1369 n["matset_values"]["m2"]["s3"].set(DataType::float64(5));
1370 CHECK_MESH(verify_specset,n,info,true);
1371
1372 n["matset_values"].reset();
1373 n["matset_values"]["m1"]["s1"].set(DataType::float64(5));
1374 n["matset_values"]["m1"]["s2"].set(DataType::float64(6));
1375 CHECK_MESH(verify_specset,n,info,false);
1376
1377 n["matset_values"].reset();
1378 n["matset_values"]["m1"]["s1"].set(DataType::float64(5));
1379 n["matset_values"]["m1"]["s2"].set(DataType::float64(5));
1380 CHECK_MESH(verify_specset,n,info,true);
1381 n["matset_values"]["m2"]["s3"].set(DataType::float64(6));
1382 CHECK_MESH(verify_specset,n,info,false);
1383
1384 n["matset_values"].reset();
1385 n["matset_values"].set(mfs);
1386 CHECK_MESH(verify_specset,n,info,true);
1387 }
1388 }
1389 }
1390
1391 /// Mesh Field Tests ///
1392
1393 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,field_general)1394 TEST(conduit_blueprint_mesh_verify, field_general)
1395 {
1396 VerifyFun verify_field_funs[] = {
1397 blueprint::mesh::field::verify,
1398 verify_field_protocol};
1399
1400 for(index_t fi = 0; fi < 2; fi++)
1401 {
1402 VerifyFun verify_field = verify_field_funs[fi];
1403
1404 Node mesh, info;
1405 CHECK_MESH(verify_field,mesh,info,false);
1406
1407 blueprint::mesh::examples::braid("quads",10,10,0,mesh);
1408 Node& n = mesh["fields"]["braid"];
1409
1410 { // Topology Field Tests //
1411 n.remove("topology");
1412 CHECK_MESH(verify_field,n,info,false);
1413 n["topology"].set(10);
1414 CHECK_MESH(verify_field,n,info,false);
1415 n["topology"].set("mesh");
1416 CHECK_MESH(verify_field,n,info,true);
1417 }
1418
1419 { // Values Field Tests //
1420 Node values = n["values"];
1421
1422 n.remove("values");
1423 CHECK_MESH(verify_field,n,info,false);
1424 n["values"].set("values");
1425 CHECK_MESH(verify_field,n,info,false);
1426 n["values"].set(DataType::float64(10));
1427 CHECK_MESH(verify_field,n,info,true);
1428
1429 n["values"].reset();
1430 n["values"]["x"].set("Hello, ");
1431 n["values"]["y"].set("World!");
1432 CHECK_MESH(verify_field,n,info,false);
1433
1434 n["values"].reset();
1435 n["values"]["x"].set(DataType::float64(5));
1436 n["values"]["y"].set(DataType::float64(5));
1437 CHECK_MESH(verify_field,n,info,true);
1438
1439 n["values"].set(values);
1440 CHECK_MESH(verify_field,n,info,true);
1441 }
1442
1443 { // Association/Basis Field Tests //
1444 n.remove("association");
1445 CHECK_MESH(verify_field,n,info,false);
1446
1447 n["association"].set("zone");
1448 CHECK_MESH(verify_field,n,info,false);
1449 n["association"].set("vertex");
1450 CHECK_MESH(verify_field,n,info,true);
1451
1452 n.remove("association");
1453 n["basis"].set(0);
1454 CHECK_MESH(verify_field,n,info,false);
1455 n["basis"].set("basis");
1456 CHECK_MESH(verify_field,n,info,true);
1457
1458 n["association"].set("vertex");
1459 CHECK_MESH(verify_field,n,info,true);
1460 }
1461 }
1462 }
1463
1464 /// Mesh Domain Adjacencies Tests ///
1465
1466 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,adjset_general)1467 TEST(conduit_blueprint_mesh_verify, adjset_general)
1468 {
1469 VerifyFun verify_adjset_funs[] = {
1470 blueprint::mesh::adjset::verify,
1471 verify_adjset_protocol};
1472
1473 for(index_t fi = 0; fi < 2; fi++)
1474 {
1475 VerifyFun verify_adjset = verify_adjset_funs[fi];
1476
1477 Node mesh, info;
1478 CHECK_MESH(verify_adjset,mesh,info,false);
1479
1480 blueprint::mesh::examples::grid("quads",10,10,0,2,2,1,mesh);
1481 Node& n = mesh.child(0)["adjsets"].child(0);
1482 CHECK_MESH(verify_adjset,n,info,true);
1483
1484 { // Topology Field Tests //
1485 n.remove("topology");
1486 CHECK_MESH(verify_adjset,n,info,false);
1487 n["topology"].set(10);
1488 CHECK_MESH(verify_adjset,n,info,false);
1489 n["topology"].set("mesh");
1490 CHECK_MESH(verify_adjset,n,info,true);
1491 }
1492
1493 { // Groups Field Tests //
1494 Node groups = n["groups"];
1495
1496 n.remove("groups");
1497 CHECK_MESH(verify_adjset,n,info,false);
1498 n["groups"].set("groups");
1499 CHECK_MESH(verify_adjset,n,info,false);
1500 n["groups"].set(DataType::float64(10));
1501 CHECK_MESH(verify_adjset,n,info,false);
1502
1503 n["groups"].reset();
1504 n["groups"]["g1"].set("Hello, ");
1505 CHECK_MESH(verify_adjset,n,info,false);
1506 n["groups"]["g2"].set("World!");
1507 CHECK_MESH(verify_adjset,n,info,false);
1508
1509 n["groups"].reset();
1510 n["groups"]["g1"]["neighbors"].set(DataType::int32(5));
1511 CHECK_MESH(verify_adjset,n,info,true);
1512 n["groups"]["g1"]["values"].set(DataType::float32(5));
1513 CHECK_MESH(verify_adjset,n,info,false);
1514 n["groups"]["g1"]["values"].set(DataType::int32(5));
1515 CHECK_MESH(verify_adjset,n,info,true);
1516
1517 n["groups"].reset();
1518 n["groups"]["g1"]["neighbors"].set(DataType::int32(5));
1519 n["groups"]["g1"]["values"].set(DataType::int32(5));
1520 CHECK_MESH(verify_adjset,n,info,true);
1521 n["groups"]["g2"]["neighbors"].set(DataType::int32(5));
1522 n["groups"]["g2"]["values"].set(DataType::int32(5));
1523 CHECK_MESH(verify_adjset,n,info,true);
1524
1525 n["groups"].reset();
1526 n["groups"].set(groups);
1527 CHECK_MESH(verify_adjset,n,info,true);
1528 }
1529
1530 { // Association Field Tests //
1531 n.remove("association");
1532 CHECK_MESH(verify_adjset,n,info,false);
1533
1534 n["association"].set("zone");
1535 CHECK_MESH(verify_adjset,n,info,false);
1536 n["association"].set("vertex");
1537 CHECK_MESH(verify_adjset,n,info,true);
1538 }
1539 }
1540 }
1541
1542
1543 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,adjset_structured)1544 TEST(conduit_blueprint_mesh_verify, adjset_structured)
1545 {
1546 VerifyFun verify_adjset_funs[] = {
1547 blueprint::mesh::adjset::verify,
1548 verify_adjset_protocol};
1549
1550 for(index_t fi = 0; fi < 2; fi++)
1551 {
1552 VerifyFun verify_adjset = verify_adjset_funs[fi];
1553
1554 Node mesh, info;
1555 CHECK_MESH(verify_adjset,mesh,info,false);
1556
1557 blueprint::mesh::examples::adjset_uniform(mesh);
1558
1559 NodeConstIterator itr = mesh.children();
1560 while(itr.has_next())
1561 {
1562 const Node &chld= itr.next();
1563 const std::string chld_name = itr.name();
1564
1565 const Node& n = chld["adjsets/adjset"];
1566 CHECK_MESH(verify_adjset,n,info[chld_name],true);
1567 }
1568 }
1569 }
1570
1571 /// Mesh Domain Nesting (AMR) Tests ///
1572
1573 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,nestset_types)1574 TEST(conduit_blueprint_mesh_verify, nestset_types)
1575 {
1576 VerifyFun verify_nestset = blueprint::mesh::nestset::verify;
1577
1578 Node n, info;
1579
1580 const std::string nestset_types[] = {"parent", "child"};
1581 for(index_t ti = 0; ti < 2; ti++)
1582 {
1583 n.reset();
1584 blueprint::mesh::examples::misc("nestsets",5,5,1,n);
1585 Node& nestset_node = n.child(0)["nestsets/mesh_nest"];
1586 Node& window_node = nestset_node["windows"].child(0);
1587 CHECK_MESH(verify_nestset,nestset_node,info,true);
1588
1589 window_node["domain_type"].set(0);
1590 CHECK_MESH(verify_nestset,nestset_node,info,false);
1591
1592 window_node["domain_type"].set("ancestor");
1593 CHECK_MESH(verify_nestset,nestset_node,info,false);
1594
1595 window_node["domain_type"].set(nestset_types[ti]);
1596 CHECK_MESH(verify_nestset,nestset_node,info,true);
1597 }
1598 }
1599
1600
1601 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,nestset_general)1602 TEST(conduit_blueprint_mesh_verify, nestset_general)
1603 {
1604 VerifyFun verify_nestset_funs[] = {
1605 blueprint::mesh::nestset::verify,
1606 verify_nestset_protocol};
1607 const std::string nestset_logical_fields[3] = {"ratio", "origin", "dims"};
1608
1609 Node logical_template, window_template_slim, window_template_full;
1610 {
1611 logical_template["i"].set(DataType::int32(1));
1612 logical_template["j"].set(DataType::int32(1));
1613
1614 window_template_slim["domain_id"].set(DataType::int32(1));
1615 window_template_slim["domain_type"].set("child");
1616 window_template_slim["ratio"].set(logical_template);
1617
1618 window_template_full.set(window_template_slim);
1619 window_template_full["origin"].set(logical_template);
1620 window_template_full["dims"].set(logical_template);
1621 }
1622
1623 for(index_t fi = 0; fi < 2; fi++)
1624 {
1625 VerifyFun verify_nestset = verify_nestset_funs[fi];
1626
1627 Node mesh, info;
1628 CHECK_MESH(verify_nestset,mesh,info,false);
1629
1630 blueprint::mesh::examples::misc("nestsets",5,5,1,mesh);
1631 Node& n = mesh.child(0)["nestsets"].child(0);
1632 CHECK_MESH(verify_nestset,n,info,true);
1633
1634 { // Topology Field Tests //
1635 n.remove("topology");
1636 CHECK_MESH(verify_nestset,n,info,false);
1637 n["topology"].set(10);
1638 CHECK_MESH(verify_nestset,n,info,false);
1639 n["topology"].set("mesh");
1640 CHECK_MESH(verify_nestset,n,info,true);
1641 }
1642
1643 { // Windows Field Tests //
1644 Node windows = n["windows"];
1645
1646 n.remove("windows");
1647 CHECK_MESH(verify_nestset,n,info,false);
1648 n["windows"].set("windows");
1649 CHECK_MESH(verify_nestset,n,info,false);
1650 n["windows"].set(DataType::float64(10));
1651 CHECK_MESH(verify_nestset,n,info,false);
1652
1653 n["windows"].reset();
1654 n["windows"]["w1"].set("Hello, ");
1655 CHECK_MESH(verify_nestset,n,info,false);
1656 n["windows"]["w2"].set("World!");
1657 CHECK_MESH(verify_nestset,n,info,false);
1658
1659 n["windows"].reset();
1660 n["windows"]["w1"].set(window_template_slim);
1661 CHECK_MESH(verify_nestset,n,info,true);
1662 n["windows"]["w1"]["domain_id"].set(DataType::float32(1));
1663 CHECK_MESH(verify_nestset,n,info,false);
1664
1665 n["windows"].reset();
1666 n["windows"]["w1"].set(window_template_slim);
1667 CHECK_MESH(verify_nestset,n,info,true);
1668 n["windows"]["w1"]["domain_type"].set(0);
1669 CHECK_MESH(verify_nestset,n,info,false);
1670 n["windows"]["w1"]["domain_type"].set("ancestor");
1671 CHECK_MESH(verify_nestset,n,info,false);
1672
1673 for(index_t fi = 0; fi < 3; fi++)
1674 {
1675 const std::string& logical_field = nestset_logical_fields[fi];
1676
1677 n["windows"].reset();
1678 n["windows"]["w1"].set(window_template_full);
1679 CHECK_MESH(verify_nestset,n,info,true);
1680 n["windows"]["w1"][logical_field].set(0);
1681 CHECK_MESH(verify_nestset,n,info,false);
1682 n["windows"]["w1"][logical_field].reset();
1683 n["windows"]["w1"][logical_field]["i"].set(DataType::int32(1));
1684 CHECK_MESH(verify_nestset,n,info,false);
1685 n["windows"]["w1"][logical_field]["j"].set(DataType::int32(1));
1686 CHECK_MESH(verify_nestset,n,info,true);
1687 }
1688
1689 n["windows"].reset();
1690 n["windows"]["w1"].set(window_template_full);
1691 CHECK_MESH(verify_nestset,n,info,true);
1692 n["windows"]["w2"].set(window_template_slim);
1693 CHECK_MESH(verify_nestset,n,info,true);
1694 n["windows"]["w3"].set(window_template_full);
1695 CHECK_MESH(verify_nestset,n,info,true);
1696
1697 n["windows"].reset();
1698 n["windows"].set(windows);
1699 CHECK_MESH(verify_nestset,n,info,true);
1700 }
1701
1702 { // Association Field Tests //
1703 n.remove("association");
1704 CHECK_MESH(verify_nestset,n,info,false);
1705
1706 n["association"].set("zone");
1707 CHECK_MESH(verify_nestset,n,info,false);
1708 n["association"].set("element");
1709 CHECK_MESH(verify_nestset,n,info,true);
1710 }
1711 }
1712 }
1713
1714 /// Mesh Index Tests ///
1715
1716 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_coordset)1717 TEST(conduit_blueprint_mesh_verify, index_coordset)
1718 {
1719 VerifyFun verify_coordset_index_funs[] = {
1720 blueprint::mesh::coordset::index::verify,
1721 verify_coordset_index_protocol};
1722
1723 for(index_t fi = 0; fi < 2; fi++)
1724 {
1725 VerifyFun verify_coordset_index = verify_coordset_index_funs[fi];
1726
1727 Node mesh, index, info;
1728 CHECK_MESH(verify_coordset_index,mesh,info,false);
1729
1730 blueprint::mesh::examples::braid("quads",10,10,0,mesh);
1731 blueprint::mesh::generate_index(mesh,"quads",1,index);
1732 Node& cindex = index["coordsets"]["coords"];
1733 CHECK_MESH(verify_coordset_index,cindex,info,true);
1734
1735 { // Type Field Tests //
1736 cindex.remove("type");
1737 CHECK_MESH(verify_coordset_index,cindex,info,false);
1738
1739 cindex["type"].set("undefined");
1740 CHECK_MESH(verify_coordset_index,cindex,info,false);
1741
1742 cindex["type"].set("explicit");
1743 CHECK_MESH(verify_coordset_index,cindex,info,true);
1744 }
1745
1746 { // Coord System Field Tests //
1747 Node coordsys = cindex["coord_system"];
1748 cindex.remove("coord_system");
1749
1750 CHECK_MESH(verify_coordset_index,cindex,info,false);
1751 cindex["coord_system"].set("invalid");
1752 CHECK_MESH(verify_coordset_index,cindex,info,false);
1753
1754 cindex["coord_system"].reset();
1755 cindex["coord_system"]["type"].set("logical");
1756 cindex["coord_system"]["axes"]["i"].set(10);
1757 cindex["coord_system"]["axes"]["j"].set(10);
1758 CHECK_MESH(verify_coordset_index,cindex,info,false);
1759
1760 cindex["coord_system"].reset();
1761 cindex["coord_system"].set(coordsys);
1762 CHECK_MESH(verify_coordset_index,cindex,info,true);
1763 }
1764
1765 { // Path Field Tests //
1766 cindex.remove("path");
1767 CHECK_MESH(verify_coordset_index,cindex,info,false);
1768
1769 cindex["path"].set(5);
1770 CHECK_MESH(verify_coordset_index,cindex,info,false);
1771
1772 cindex["path"].set("path");
1773 CHECK_MESH(verify_coordset_index,cindex,info,true);
1774 }
1775 }
1776 }
1777
1778
1779 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_topology)1780 TEST(conduit_blueprint_mesh_verify, index_topology)
1781 {
1782 VerifyFun verify_topo_index_funs[] = {
1783 blueprint::mesh::topology::index::verify,
1784 verify_topology_index_protocol};
1785
1786 for(index_t fi = 0; fi < 2; fi++)
1787 {
1788 VerifyFun verify_topo_index = verify_topo_index_funs[fi];
1789
1790 Node mesh, index, info;
1791 CHECK_MESH(verify_topo_index,mesh,info,false);
1792
1793 blueprint::mesh::examples::braid("quads",10,10,0,mesh);
1794 blueprint::mesh::generate_index(mesh,"quads",1,index);
1795 Node& tindex = index["topologies"]["mesh"];
1796 CHECK_MESH(verify_topo_index,tindex,info,true);
1797
1798 { // Type Field Tests //
1799 tindex.remove("type");
1800 CHECK_MESH(verify_topo_index,tindex,info,false);
1801
1802 tindex["type"].set("undefined");
1803 CHECK_MESH(verify_topo_index,tindex,info,false);
1804
1805 tindex["type"].set("unstructured");
1806 CHECK_MESH(verify_topo_index,tindex,info,true);
1807 }
1808
1809 { // Coordset Field Tests //
1810 tindex.remove("coordset");
1811 CHECK_MESH(verify_topo_index,tindex,info,false);
1812
1813 tindex["coordset"].set(0);
1814 CHECK_MESH(verify_topo_index,tindex,info,false);
1815
1816 tindex["coordset"].set("path");
1817 CHECK_MESH(verify_topo_index,tindex,info,true);
1818 }
1819
1820 { // Path Field Tests //
1821 tindex.remove("path");
1822 CHECK_MESH(verify_topo_index,tindex,info,false);
1823
1824 tindex["path"].set(5);
1825 CHECK_MESH(verify_topo_index,tindex,info,false);
1826
1827 tindex["path"].set("path");
1828 CHECK_MESH(verify_topo_index,tindex,info,true);
1829 }
1830
1831 { // Grid Function Field Tests //
1832 tindex["grid_function"].set(10);
1833 CHECK_MESH(verify_topo_index,tindex,info,false);
1834
1835 tindex["grid_function"].set("path");
1836 CHECK_MESH(verify_topo_index,tindex,info,true);
1837 }
1838 }
1839 }
1840
1841
1842 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_matset)1843 TEST(conduit_blueprint_mesh_verify, index_matset)
1844 {
1845 VerifyFun verify_matset_index_funs[] = {
1846 blueprint::mesh::matset::index::verify,
1847 verify_matset_index_protocol};
1848
1849 for(index_t fi = 0; fi < 2; fi++)
1850 {
1851 VerifyFun verify_matset_index = verify_matset_index_funs[fi];
1852
1853 Node mesh, index, info;
1854 CHECK_MESH(verify_matset_index,mesh,info,false);
1855
1856 blueprint::mesh::examples::misc("matsets",10,10,0,mesh);
1857 blueprint::mesh::generate_index(mesh,"quads",1,index);
1858 Node& mindex = index["matsets"]["mesh"];
1859 CHECK_MESH(verify_matset_index,mindex,info,true);
1860
1861 { // Topology Field Tests //
1862 mindex.remove("topology");
1863 CHECK_MESH(verify_matset_index,mindex,info,false);
1864
1865 mindex["topology"].set(0);
1866 CHECK_MESH(verify_matset_index,mindex,info,false);
1867
1868 mindex["topology"].set("path");
1869 CHECK_MESH(verify_matset_index,mindex,info,true);
1870 }
1871
1872 if(mindex.has_child("materials"))
1873 { // Materials Field Tests //
1874 mindex.remove("materials");
1875 CHECK_MESH(verify_matset_index,mindex,info,false);
1876
1877 mindex["materials"];
1878 CHECK_MESH(verify_matset_index,mindex,info,false);
1879
1880 mindex["materials/mat1"].set(1);
1881 CHECK_MESH(verify_matset_index,mindex,info,true);
1882 mindex["materials/mat2"].set(2);
1883 CHECK_MESH(verify_matset_index,mindex,info,true);
1884 }
1885
1886 if(mindex.has_child("material_maps"))
1887 { // Materials Field Tests //
1888 mindex.remove("material_map");
1889 CHECK_MESH(verify_matset_index,mindex,info,false);
1890
1891 mindex["material_map"];
1892 CHECK_MESH(verify_matset_index,mindex,info,false);
1893
1894 mindex["material_map/mat1"].set(1);
1895 CHECK_MESH(verify_matset_index,mindex,info,true);
1896 mindex["material_map/mat2"].set(2);
1897 CHECK_MESH(verify_matset_index,mindex,info,true);
1898 }
1899
1900 { // Path Field Tests //
1901 mindex.remove("path");
1902 CHECK_MESH(verify_matset_index,mindex,info,false);
1903
1904 mindex["path"].set(5);
1905 CHECK_MESH(verify_matset_index,mindex,info,false);
1906
1907 mindex["path"].set("path");
1908 CHECK_MESH(verify_matset_index,mindex,info,true);
1909 }
1910 }
1911 }
1912
1913
1914 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_specset)1915 TEST(conduit_blueprint_mesh_verify, index_specset)
1916 {
1917 VerifyFun verify_specset_index_funs[] = {
1918 blueprint::mesh::specset::index::verify,
1919 verify_specset_index_protocol};
1920
1921 for(index_t fi = 0; fi < 2; fi++)
1922 {
1923 VerifyFun verify_specset_index = verify_specset_index_funs[fi];
1924
1925 Node mesh, index, info;
1926 CHECK_MESH(verify_specset_index,mesh,info,false);
1927
1928 blueprint::mesh::examples::misc("specsets",10,10,0,mesh);
1929 blueprint::mesh::generate_index(mesh,"quads",1,index);
1930 Node& mindex = index["specsets"]["mesh"];
1931 CHECK_MESH(verify_specset_index,mindex,info,true);
1932
1933 { // Matset Field Tests //
1934 mindex.remove("matset");
1935 CHECK_MESH(verify_specset_index,mindex,info,false);
1936
1937 mindex["matset"].set(0);
1938 CHECK_MESH(verify_specset_index,mindex,info,false);
1939
1940 mindex["matset"].set("path");
1941 CHECK_MESH(verify_specset_index,mindex,info,true);
1942 }
1943
1944 { // Spcies Field Tests //
1945 mindex.remove("species");
1946 CHECK_MESH(verify_specset_index,mindex,info,false);
1947
1948 mindex["species"];
1949 CHECK_MESH(verify_specset_index,mindex,info,false);
1950
1951 mindex["species/spec1"].set(1);
1952 CHECK_MESH(verify_specset_index,mindex,info,true);
1953 mindex["species/spec2"].set(2);
1954 CHECK_MESH(verify_specset_index,mindex,info,true);
1955 }
1956
1957 { // Path Field Tests //
1958 mindex.remove("path");
1959 CHECK_MESH(verify_specset_index,mindex,info,false);
1960
1961 mindex["path"].set(5);
1962 CHECK_MESH(verify_specset_index,mindex,info,false);
1963
1964 mindex["path"].set("path");
1965 CHECK_MESH(verify_specset_index,mindex,info,true);
1966 }
1967 }
1968 }
1969
1970
1971 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_field)1972 TEST(conduit_blueprint_mesh_verify, index_field)
1973 {
1974 VerifyFun verify_field_index_funs[] = {
1975 blueprint::mesh::field::index::verify,
1976 verify_field_index_protocol};
1977
1978 for(index_t fi = 0; fi < 2; fi++)
1979 {
1980 VerifyFun verify_field_index = verify_field_index_funs[fi];
1981
1982 Node mesh, index, info;
1983 CHECK_MESH(verify_field_index,mesh,info,false);
1984
1985 blueprint::mesh::examples::braid("quads",10,10,0,mesh);
1986 blueprint::mesh::generate_index(mesh,"quads",1,index);
1987 Node& findex = index["fields"]["braid"];
1988 CHECK_MESH(verify_field_index,findex,info,true);
1989
1990 { // Topology Field Tests //
1991 Node topo = findex["topology"];
1992 findex.remove("topology");
1993
1994 CHECK_MESH(verify_field_index,findex,info,false);
1995 findex["topology"].set(0);
1996 CHECK_MESH(verify_field_index,findex,info,false);
1997
1998 findex["topology"].set("path");
1999 CHECK_MESH(verify_field_index,findex,info,true);
2000
2001 findex["topology"].reset();
2002 findex["topology"].set(topo);
2003 CHECK_MESH(verify_field_index,findex,info,true);
2004 }
2005
2006 { // Component Count Field Tests //
2007 Node comps = findex["number_of_components"];
2008 findex.remove("number_of_components");
2009
2010 CHECK_MESH(verify_field_index,findex,info,false);
2011 findex["number_of_components"].set("three");
2012 CHECK_MESH(verify_field_index,findex,info,false);
2013
2014 findex["number_of_components"].set(3);
2015 CHECK_MESH(verify_field_index,findex,info,true);
2016
2017 findex["number_of_components"].reset();
2018 findex["number_of_components"].set(comps);
2019 CHECK_MESH(verify_field_index,findex,info,true);
2020 }
2021
2022 { // Path Field Tests //
2023 Node path = findex["path"];
2024 findex.remove("path");
2025
2026 CHECK_MESH(verify_field_index,findex,info,false);
2027 findex["path"].set(0);
2028 CHECK_MESH(verify_field_index,findex,info,false);
2029
2030 findex["path"].set("path");
2031 CHECK_MESH(verify_field_index,findex,info,true);
2032
2033 findex["path"].reset();
2034 findex["path"].set(path);
2035 CHECK_MESH(verify_field_index,findex,info,true);
2036 }
2037
2038 { // Association Field Tests //
2039 findex["association"].set("zone");
2040 CHECK_MESH(verify_field_index,findex,info,false);
2041 findex["association"].set("vertex");
2042 CHECK_MESH(verify_field_index,findex,info,true);
2043
2044 findex.remove("association");
2045 findex["basis"].set(0);
2046 CHECK_MESH(verify_field_index,findex,info,false);
2047 findex["basis"].set("basis");
2048 CHECK_MESH(verify_field_index,findex,info,true);
2049 }
2050 }
2051 }
2052
2053
2054 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_adjset)2055 TEST(conduit_blueprint_mesh_verify, index_adjset)
2056 {
2057 VerifyFun verify_adjset_index_funs[] = {
2058 blueprint::mesh::adjset::index::verify,
2059 verify_adjset_index_protocol};
2060
2061 for(index_t fi = 0; fi < 2; fi++)
2062 {
2063 VerifyFun verify_adjset_index = verify_adjset_index_funs[fi];
2064
2065 Node mesh, index, info;
2066 CHECK_MESH(verify_adjset_index,mesh,info,false);
2067
2068 blueprint::mesh::examples::grid("quads",10,10,0,2,2,1,mesh);
2069 blueprint::mesh::generate_index(mesh["domain0"],"quads",1,index);
2070 Node& aindex = index["adjsets"].child(0);
2071 CHECK_MESH(verify_adjset_index,aindex,info,true);
2072
2073 { // Topology Field Tests //
2074 Node topo = aindex["topology"];
2075 aindex.remove("topology");
2076
2077 CHECK_MESH(verify_adjset_index,aindex,info,false);
2078 aindex["topology"].set(0);
2079 CHECK_MESH(verify_adjset_index,aindex,info,false);
2080
2081 aindex["topology"].set("path");
2082 CHECK_MESH(verify_adjset_index,aindex,info,true);
2083
2084 aindex["topology"].reset();
2085 aindex["topology"].set(topo);
2086 CHECK_MESH(verify_adjset_index,aindex,info,true);
2087 }
2088
2089 { // Path Field Tests //
2090 Node path = aindex["path"];
2091 aindex.remove("path");
2092
2093 CHECK_MESH(verify_adjset_index,aindex,info,false);
2094 aindex["path"].set(0);
2095 CHECK_MESH(verify_adjset_index,aindex,info,false);
2096
2097 aindex["path"].set("path");
2098 CHECK_MESH(verify_adjset_index,aindex,info,true);
2099
2100 aindex["path"].reset();
2101 aindex["path"].set(path);
2102 CHECK_MESH(verify_adjset_index,aindex,info,true);
2103 }
2104
2105 { // Association Field Tests //
2106 Node assoc = aindex["association"];
2107 aindex.remove("association");
2108
2109 aindex["association"].set("zone");
2110 CHECK_MESH(verify_adjset_index,aindex,info,false);
2111 aindex["association"].set("vertex");
2112 CHECK_MESH(verify_adjset_index,aindex,info,true);
2113
2114 aindex["association"].reset();
2115 aindex["association"].set(assoc);
2116 CHECK_MESH(verify_adjset_index,aindex,info,true);
2117 }
2118 }
2119 }
2120
2121
2122 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_nestset)2123 TEST(conduit_blueprint_mesh_verify, index_nestset)
2124 {
2125 VerifyFun verify_nestset_index_funs[] = {
2126 blueprint::mesh::nestset::index::verify,
2127 verify_nestset_index_protocol};
2128
2129 for(index_t fi = 0; fi < 2; fi++)
2130 {
2131 VerifyFun verify_nestset_index = verify_nestset_index_funs[fi];
2132
2133 Node mesh, index, info;
2134 CHECK_MESH(verify_nestset_index,mesh,info,false);
2135
2136 blueprint::mesh::examples::misc("nestsets",5,5,0,mesh);
2137 blueprint::mesh::generate_index(mesh["domain0"],"quads",1,index);
2138 Node& aindex = index["nestsets"].child(0);
2139 CHECK_MESH(verify_nestset_index,aindex,info,true);
2140
2141 { // Topology Field Tests //
2142 Node topo = aindex["topology"];
2143 aindex.remove("topology");
2144
2145 CHECK_MESH(verify_nestset_index,aindex,info,false);
2146 aindex["topology"].set(0);
2147 CHECK_MESH(verify_nestset_index,aindex,info,false);
2148
2149 aindex["topology"].set("path");
2150 CHECK_MESH(verify_nestset_index,aindex,info,true);
2151
2152 aindex["topology"].reset();
2153 aindex["topology"].set(topo);
2154 CHECK_MESH(verify_nestset_index,aindex,info,true);
2155 }
2156
2157 { // Path Field Tests //
2158 Node path = aindex["path"];
2159 aindex.remove("path");
2160
2161 CHECK_MESH(verify_nestset_index,aindex,info,false);
2162 aindex["path"].set(0);
2163 CHECK_MESH(verify_nestset_index,aindex,info,false);
2164
2165 aindex["path"].set("path");
2166 CHECK_MESH(verify_nestset_index,aindex,info,true);
2167
2168 aindex["path"].reset();
2169 aindex["path"].set(path);
2170 CHECK_MESH(verify_nestset_index,aindex,info,true);
2171 }
2172
2173 { // Association Field Tests //
2174 Node assoc = aindex["association"];
2175 aindex.remove("association");
2176
2177 aindex["association"].set("zone");
2178 CHECK_MESH(verify_nestset_index,aindex,info,false);
2179 aindex["association"].set("vertex");
2180 CHECK_MESH(verify_nestset_index,aindex,info,true);
2181
2182 aindex["association"].reset();
2183 aindex["association"].set(assoc);
2184 CHECK_MESH(verify_nestset_index,aindex,info,true);
2185 }
2186 }
2187 }
2188
2189
2190 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,index_general)2191 TEST(conduit_blueprint_mesh_verify, index_general)
2192 {
2193 VerifyFun verify_index_funs[] = {
2194 blueprint::mesh::index::verify,
2195 verify_index_protocol};
2196
2197 for(index_t fi = 0; fi < 2; fi++)
2198 {
2199 VerifyFun verify_index = verify_index_funs[fi];
2200
2201 Node mesh, index, info;
2202 CHECK_MESH(verify_index,mesh,info,false);
2203
2204 blueprint::mesh::examples::braid("quads",10,10,0,mesh);
2205 blueprint::mesh::generate_index(mesh,"quads",1,index);
2206 CHECK_MESH(verify_index,index,info,true);
2207
2208 { // Coordsets Field Tests //
2209 info.reset();
2210 Node coords = index["coordsets"];
2211 index.remove("coordsets");
2212
2213 CHECK_MESH(verify_index,index,info,false);
2214 index["coordsets"].set("coords");
2215 CHECK_MESH(verify_index,index,info,false);
2216
2217 index["coordsets"].reset();
2218 index["coordsets"]["coords1"].set("coords");
2219 index["coordsets"]["coords2"].set("coords");
2220 CHECK_MESH(verify_index,index,info,false);
2221
2222 index["coordsets"].reset();
2223 index["coordsets"].set(coords);
2224 CHECK_MESH(verify_index,index,info,true);
2225 }
2226
2227 { // Topologies Field Tests //
2228 info.reset();
2229 Node topos = index["topologies"];
2230 index.remove("topologies");
2231
2232 CHECK_MESH(verify_index,index,info,false);
2233 index["topologies"].set("topo");
2234 CHECK_MESH(verify_index,index,info,false);
2235
2236 index["topologies"].reset();
2237 index["topologies"]["topo1"].set("topo");
2238 index["topologies"]["topo2"].set("topo");
2239 CHECK_MESH(verify_index,index,info,false);
2240
2241 index["topologies"].reset();
2242 index["topologies"]["mesh"]["type"].set("invalid");
2243 index["topologies"]["mesh"]["path"].set("quads/topologies/mesh");
2244 index["topologies"]["mesh"]["coordset"].set("coords");
2245 CHECK_MESH(verify_index,index,info,false);
2246 index["topologies"]["mesh"]["type"].set("unstructured");
2247 CHECK_MESH(verify_index,index,info,true);
2248
2249 index["topologies"]["mesh"]["coordset"].set("nonexistent");
2250 CHECK_MESH(verify_index,index,info,false);
2251 index["topologies"]["mesh"]["coordset"].set("coords");
2252 CHECK_MESH(verify_index,index,info,true);
2253
2254 index["coordsets"]["coords"]["type"].set("invalid");
2255 CHECK_MESH(verify_index,index,info,false);
2256 index["coordsets"]["coords"]["type"].set("explicit");
2257 CHECK_MESH(verify_index,index,info,true);
2258
2259 index["topologies"].reset();
2260 index["topologies"].set(topos);
2261 CHECK_MESH(verify_index,index,info,true);
2262 }
2263
2264 { // Matsets Field Tests //
2265 info.reset();
2266 Node matsets = index["matsets"];
2267 index.remove("matsets");
2268 CHECK_MESH(verify_index,index,info,true);
2269
2270 index["matsets"].set("matset");
2271 CHECK_MESH(verify_index,index,info,false);
2272
2273 index["matsets"].reset();
2274 index["matsets"]["matset1"].set("matset1");
2275 index["matsets"]["matset1"].set("matset2");
2276 CHECK_MESH(verify_index,index,info,false);
2277
2278 index["matsets"].reset();
2279 index["matsets"]["matset"]["topology"].set("mesh");
2280 index["matsets"]["matset"]["materials"].set("invalid");
2281 index["matsets"]["matset"]["path"].set("quads/matsets/matset");
2282 CHECK_MESH(verify_index,index,info,false);
2283 index["matsets"]["matset"]["materials"]["mat1"];
2284 CHECK_MESH(verify_index,index,info,true);
2285 index["matsets"]["matset"]["materials"]["mat2"];
2286 CHECK_MESH(verify_index,index,info,true);
2287
2288 index["matsets"]["matset"]["topology"].set("nonexistent");
2289 CHECK_MESH(verify_index,index,info,false);
2290 index["matsets"]["matset"]["topology"].set("mesh");
2291 CHECK_MESH(verify_index,index,info,true);
2292
2293 // TODO(JRC): Change this code so that the "matsets" section is
2294 // re-added once it's included in the test Blueprint mesh.
2295 index["matsets"].reset();
2296 index.remove("matsets");
2297 CHECK_MESH(verify_index,index,info,true);
2298 }
2299
2300 { // Fields Field Tests //
2301 info.reset();
2302 Node fields = index["fields"];
2303 index.remove("fields");
2304 CHECK_MESH(verify_index,index,info,true);
2305
2306 index["fields"].set("field");
2307 CHECK_MESH(verify_index,index,info,false);
2308
2309 index["fields"].reset();
2310 index["fields"]["field1"].set("field1");
2311 index["fields"]["field1"].set("field2");
2312 CHECK_MESH(verify_index,index,info,false);
2313
2314 index["fields"].reset();
2315 index["fields"]["field"]["number_of_components"].set("invalid");
2316 index["fields"]["field"]["association"].set("vertex");
2317 index["fields"]["field"]["path"].set("quads/fields/braid");
2318 index["fields"]["field"]["topology"].set("mesh");
2319 CHECK_MESH(verify_index,index,info,false);
2320 index["fields"]["field"]["number_of_components"].set(1);
2321 CHECK_MESH(verify_index,index,info,true);
2322
2323 index["fields"]["field"]["topology"].set("nonexistent");
2324 CHECK_MESH(verify_index,index,info,false);
2325 index["fields"]["field"]["topology"].set("mesh");
2326 CHECK_MESH(verify_index,index,info,true);
2327
2328 index["topologies"]["mesh"]["type"].set("invalid");
2329 CHECK_MESH(verify_index,index,info,false);
2330 index["topologies"]["mesh"]["type"].set("unstructured");
2331 CHECK_MESH(verify_index,index,info,true);
2332
2333 index["fields"].reset();
2334 index["fields"].set(fields);
2335 CHECK_MESH(verify_index,index,info,true);
2336 }
2337
2338 { // Adjsets Field Tests //
2339 info.reset();
2340 Node adjsets = index["adjsets"];
2341 index.remove("adjsets");
2342 CHECK_MESH(verify_index,index,info,true);
2343
2344 index["adjsets"].set("adjset");
2345 CHECK_MESH(verify_index,index,info,false);
2346
2347 index["adjsets"].reset();
2348 index["adjsets"]["adjset1"].set("adjset1");
2349 index["adjsets"]["adjset1"].set("adjset2");
2350 CHECK_MESH(verify_index,index,info,false);
2351
2352 index["adjsets"].reset();
2353 index["adjsets"]["adjset"]["topology"].set("mesh");
2354 index["adjsets"]["adjset"]["association"].set("vertex");
2355 index["adjsets"]["adjset"]["path"].set(0);
2356 CHECK_MESH(verify_index,index,info,false);
2357 index["adjsets"]["adjset"]["path"].set("quads/adjsets/adjset");
2358 CHECK_MESH(verify_index,index,info,true);
2359
2360 index["adjsets"]["adjset"]["topology"].set("nonexistent");
2361 CHECK_MESH(verify_index,index,info,false);
2362 index["adjsets"]["adjset"]["topology"].set("mesh");
2363 CHECK_MESH(verify_index,index,info,true);
2364
2365 index["adjsets"]["adjset"]["association"].set("nonexistent");
2366 CHECK_MESH(verify_index,index,info,false);
2367 index["adjsets"]["adjset"]["association"].set("element");
2368 CHECK_MESH(verify_index,index,info,true);
2369
2370 // TODO(JRC): Change this code so that the "adjsets" section is
2371 // re-added once it's included in the test Blueprint mesh.
2372 index["adjsets"].reset();
2373 index.remove("adjsets");
2374 CHECK_MESH(verify_index,index,info,true);
2375 }
2376
2377 { // Nestsets Field Tests //
2378 info.reset();
2379 Node nestsets = index["nestsets"];
2380 index.remove("nestsets");
2381 CHECK_MESH(verify_index,index,info,true);
2382
2383 index["nestsets"].set("nestset");
2384 CHECK_MESH(verify_index,index,info,false);
2385
2386 index["nestsets"].reset();
2387 index["nestsets"]["nestset1"].set("nestset1");
2388 index["nestsets"]["nestset1"].set("nestset2");
2389 CHECK_MESH(verify_index,index,info,false);
2390
2391 index["nestsets"].reset();
2392 index["nestsets"]["nestset"]["topology"].set("mesh");
2393 index["nestsets"]["nestset"]["association"].set("vertex");
2394 index["nestsets"]["nestset"]["path"].set(0);
2395 CHECK_MESH(verify_index,index,info,false);
2396 index["nestsets"]["nestset"]["path"].set("quads/nestsets/nestset");
2397 CHECK_MESH(verify_index,index,info,true);
2398
2399 index["nestsets"]["nestset"]["topology"].set("nonexistent");
2400 CHECK_MESH(verify_index,index,info,false);
2401 index["nestsets"]["nestset"]["topology"].set("mesh");
2402 CHECK_MESH(verify_index,index,info,true);
2403
2404 index["nestsets"]["nestset"]["association"].set("nonexistent");
2405 CHECK_MESH(verify_index,index,info,false);
2406 index["nestsets"]["nestset"]["association"].set("element");
2407 CHECK_MESH(verify_index,index,info,true);
2408
2409 // TODO(JRC): Change this code so that the "nestsets" section is
2410 // re-added once it's included in the test Blueprint mesh.
2411 index["nestsets"].reset();
2412 index.remove("nestsets");
2413 CHECK_MESH(verify_index,index,info,true);
2414 }
2415 }
2416 }
2417
2418 /// Mesh Integration Tests ///
2419
2420 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,mesh_multi_domain)2421 TEST(conduit_blueprint_mesh_verify, mesh_multi_domain)
2422 {
2423 Node mesh, info;
2424 EXPECT_TRUE(blueprint::mesh::verify(mesh,info) &&
2425 blueprint::mesh::is_multi_domain(mesh));
2426 EXPECT_TRUE(has_empty_warning(info));
2427
2428 Node domains[2];
2429 blueprint::mesh::examples::braid("quads",10,10,0,domains[0]);
2430 blueprint::mesh::to_multi_domain(domains[0],mesh);
2431 EXPECT_TRUE(blueprint::mesh::is_multi_domain(mesh));
2432
2433 blueprint::mesh::examples::braid("quads",5,5,0,domains[1]);
2434 mesh.append().set_external(domains[1]);
2435 EXPECT_TRUE(blueprint::mesh::is_multi_domain(mesh));
2436
2437 { // Redundant "to_multi_domain" Tests //
2438 Node temp;
2439 blueprint::mesh::to_multi_domain(mesh,temp);
2440 EXPECT_TRUE(blueprint::mesh::is_multi_domain(temp));
2441 }
2442
2443 for(index_t di = 0; di < 2; di++)
2444 {
2445 Node& domain = mesh.child(di);
2446 EXPECT_FALSE(blueprint::mesh::is_multi_domain(domain));
2447
2448 // is_multi_domain can only be called if mesh verify is true
2449 Node coordsets = domain["coordsets"];
2450 domain.remove("coordsets");
2451 EXPECT_FALSE(blueprint::mesh::verify(mesh,info) &&
2452 blueprint::mesh::is_multi_domain(mesh));
2453
2454 domain["coordsets"].reset();
2455 domain["coordsets"].set(coordsets);
2456 EXPECT_TRUE(blueprint::mesh::is_multi_domain(mesh));
2457 }
2458 }
2459
2460
2461 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,mesh_general)2462 TEST(conduit_blueprint_mesh_verify, mesh_general)
2463 {
2464 VerifyFun verify_mesh_funs[] = {
2465 blueprint::mesh::verify, // single_domain verify
2466 blueprint::mesh::verify, // multi_domain verify
2467 verify_mesh_multi_domain_protocol};
2468
2469 for(index_t fi = 0; fi < 3; fi++)
2470 {
2471 VerifyFun verify_mesh = verify_mesh_funs[fi];
2472
2473 Node mesh, mesh_data, info;
2474 CHECK_MESH(verify_mesh,mesh,info,true);
2475 EXPECT_TRUE(has_empty_warning(info));
2476
2477 blueprint::mesh::examples::braid("quads",10,10,0,mesh_data);
2478
2479 Node* domain_ptr = NULL;
2480 if(fi == 0)
2481 {
2482 mesh.set_external(mesh_data);
2483 domain_ptr = &mesh;
2484 }
2485 else
2486 {
2487 blueprint::mesh::to_multi_domain(mesh_data,mesh);
2488 domain_ptr = &mesh.child(0);
2489 }
2490 Node& domain = *domain_ptr;
2491
2492 CHECK_MESH(verify_mesh,mesh,info,true);
2493 EXPECT_FALSE(has_empty_warning(info));
2494 // info.print();
2495
2496 { // Coordsets Field Tests //
2497 Node coordsets = domain["coordsets"];
2498 domain.remove("coordsets");
2499 CHECK_MESH(verify_mesh,mesh,info,false);
2500
2501 domain["coordsets"].set("path");
2502 CHECK_MESH(verify_mesh,mesh,info,false);
2503
2504 domain["coordsets"].reset();
2505 domain["coordsets"]["coords"]["type"].set("invalid");
2506 domain["coordsets"]["coords"]["values"]["x"].set(DataType::float64(10));
2507 domain["coordsets"]["coords"]["values"]["y"].set(DataType::float64(10));
2508 CHECK_MESH(verify_mesh,mesh,info,false);
2509
2510 domain["coordsets"]["coords"]["type"].set("explicit");
2511 CHECK_MESH(verify_mesh,mesh,info,true);
2512 domain["coordsets"]["coords2"]["type"].set("invalid");
2513 CHECK_MESH(verify_mesh,mesh,info,false);
2514
2515 domain["coordsets"].reset();
2516 domain["coordsets"].set(coordsets);
2517 CHECK_MESH(verify_mesh,mesh,info,true);
2518 }
2519
2520 { // Topologies Field Tests //
2521 Node topologies = domain["topologies"];
2522 domain.remove("topologies");
2523 CHECK_MESH(verify_mesh,mesh,info,false);
2524
2525 domain["topologies"].set("path");
2526 CHECK_MESH(verify_mesh,mesh,info,false);
2527
2528 domain["topologies"].reset();
2529 domain["topologies"]["mesh"]["type"].set("invalid");
2530 domain["topologies"]["mesh"]["coordset"].set("coords");
2531 domain["topologies"]["mesh"]["elements"]["shape"].set("quad");
2532 domain["topologies"]["mesh"]["elements"]["connectivity"].set(DataType::int32(10));
2533 CHECK_MESH(verify_mesh,mesh,info,false);
2534 domain["topologies"]["mesh"]["type"].set("unstructured");
2535 CHECK_MESH(verify_mesh,mesh,info,true);
2536
2537 domain["coordsets"]["coords"]["type"].set("invalid");
2538 CHECK_MESH(verify_mesh,mesh,info,false);
2539 domain["coordsets"]["coords"]["type"].set("explicit");
2540 CHECK_MESH(verify_mesh,mesh,info,true);
2541
2542 domain["topologies"]["mesh"]["coordset"].set("invalid");
2543 CHECK_MESH(verify_mesh,mesh,info,false);
2544 domain["topologies"]["mesh"]["coordset"].set("coords");
2545 CHECK_MESH(verify_mesh,mesh,info,true);
2546
2547 domain["topologies"]["grid"]["type"].set("invalid");
2548 CHECK_MESH(verify_mesh,mesh,info,false);
2549
2550 domain["topologies"].reset();
2551 domain["topologies"].set(topologies);
2552 CHECK_MESH(verify_mesh,mesh,info,true);
2553 }
2554
2555 { // Matsets Field Tests //
2556 Node matsets = domain["matsets"];
2557 domain.remove("matsets");
2558 CHECK_MESH(verify_mesh,mesh,info,true);
2559
2560 domain["matsets"].set("path");
2561 CHECK_MESH(verify_mesh,mesh,info,false);
2562
2563 domain["matsets"].reset();
2564 domain["matsets"]["mesh"]["topology"].set("mesh");
2565 domain["matsets"]["mesh"]["volume_fractions"];
2566 CHECK_MESH(verify_mesh,mesh,info,false);
2567
2568 Node &vfs = domain["matsets"]["mesh"]["volume_fractions"];
2569 vfs["mat1"].set(DataType::float32(10));
2570 CHECK_MESH(verify_mesh,mesh,info,true);
2571 vfs["mat2"].set(DataType::float32(10));
2572 CHECK_MESH(verify_mesh,mesh,info,true);
2573
2574 domain["matsets"]["mesh"]["topology"].set("invalid");
2575 CHECK_MESH(verify_mesh,mesh,info,false);
2576 domain["matsets"]["mesh"]["topology"].set("mesh");
2577 CHECK_MESH(verify_mesh,mesh,info,true);
2578
2579 domain["matsets"]["boundary"]["topology"].set("mesh");
2580 CHECK_MESH(verify_mesh,mesh,info,false);
2581
2582 // TODO(JRC): Change this code so that the "matsets" section is
2583 // re-added once it's included in the test Blueprint mesh.
2584 domain["matsets"].reset();
2585 domain.remove("matsets");
2586 CHECK_MESH(verify_mesh,mesh,info,true);
2587 }
2588
2589 { // Fields Field Tests //
2590 Node fields = domain["fields"];
2591 domain.remove("fields");
2592 CHECK_MESH(verify_mesh,mesh,info,true);
2593
2594 domain["fields"].set("path");
2595 CHECK_MESH(verify_mesh,mesh,info,false);
2596
2597 domain["fields"].reset();
2598 domain["fields"]["temp"]["association"].set("invalid");
2599 domain["fields"]["temp"]["topology"].set("mesh");
2600 domain["fields"]["temp"]["values"].set(DataType::float64(10));
2601 CHECK_MESH(verify_mesh,mesh,info,false);
2602 domain["fields"]["temp"]["association"].set("vertex");
2603 CHECK_MESH(verify_mesh,mesh,info,true);
2604
2605 domain["topologies"]["mesh"]["type"].set("invalid");
2606 CHECK_MESH(verify_mesh,mesh,info,false);
2607 domain["topologies"]["mesh"]["type"].set("unstructured");
2608 CHECK_MESH(verify_mesh,mesh,info,true);
2609
2610 domain["fields"]["temp"]["topology"].set("invalid");
2611 CHECK_MESH(verify_mesh,mesh,info,false);
2612 domain["fields"]["temp"]["topology"].set("mesh");
2613 CHECK_MESH(verify_mesh,mesh,info,true);
2614
2615 domain["fields"]["accel"]["association"].set("invalid");
2616 CHECK_MESH(verify_mesh,mesh,info,false);
2617
2618 domain["fields"].reset();
2619 domain["fields"].set(fields);
2620 CHECK_MESH(verify_mesh,mesh,info,true);
2621 }
2622
2623 { // Grid Function Field Tests //
2624 Node topologies = domain["topologies"];
2625 Node fields = domain["fields"];
2626 domain.remove("fields");
2627
2628 domain["topologies"]["mesh"]["grid_function"].set("braid");
2629 CHECK_MESH(verify_mesh,mesh,info,false);
2630
2631 domain["fields"].set(fields);
2632 domain["topologies"]["mesh"]["grid_function"].set("invalid");
2633 CHECK_MESH(verify_mesh,mesh,info,false);
2634 domain["topologies"]["mesh"]["grid_function"].set("braid");
2635 CHECK_MESH(verify_mesh,mesh,info,true);
2636
2637 domain["fields"]["braid"]["association"].set("invalid");
2638 CHECK_MESH(verify_mesh,mesh,info,false);
2639 domain["fields"]["braid"]["association"].set("vertex");
2640
2641 domain["topologies"].reset();
2642 domain["topologies"].set(topologies);
2643 CHECK_MESH(verify_mesh,mesh,info,true);
2644 }
2645
2646 { // Adjsets Field Tests //
2647 Node adjsets = domain["adjsets"];
2648 domain.remove("adjsets");
2649 CHECK_MESH(verify_mesh,mesh,info,true);
2650
2651 domain["adjsets"].set("path");
2652 CHECK_MESH(verify_mesh,mesh,info,false);
2653
2654 domain["adjsets"].reset();
2655 domain["adjsets"]["mesh"]["association"].set("vertex");
2656 domain["adjsets"]["mesh"]["topology"].set("mesh");
2657 domain["adjsets"]["mesh"]["groups"];
2658 CHECK_MESH(verify_mesh,mesh,info,false);
2659
2660 Node &groups = domain["adjsets"]["mesh"]["groups"];
2661 groups["g1"]["neighbors"].set(DataType::int32(10));
2662 CHECK_MESH(verify_mesh,mesh,info,true);
2663 groups["g1"]["values"].set(DataType::float32(10));
2664 CHECK_MESH(verify_mesh,mesh,info,false);
2665 groups["g1"]["values"].set(DataType::int32(10));
2666 CHECK_MESH(verify_mesh,mesh,info,true);
2667 groups["g2"].set(groups["g1"]);
2668 CHECK_MESH(verify_mesh,mesh,info,true);
2669
2670 domain["adjsets"]["mesh"]["topology"].set("invalid");
2671 CHECK_MESH(verify_mesh,mesh,info,false);
2672 domain["adjsets"]["mesh"]["topology"].set("mesh");
2673 CHECK_MESH(verify_mesh,mesh,info,true);
2674
2675 domain["adjsets"]["mesh"]["association"].set("invalid");
2676 CHECK_MESH(verify_mesh,mesh,info,false);
2677 domain["adjsets"]["mesh"]["association"].set("element");
2678 CHECK_MESH(verify_mesh,mesh,info,true);
2679
2680 // TODO(JRC): Change this code so that the "adjsets" section is
2681 // re-added once it's included in the test Blueprint mesh.
2682 domain["adjsets"].reset();
2683 domain.remove("adjsets");
2684 CHECK_MESH(verify_mesh,mesh,info,true);
2685 }
2686 }
2687 }
2688
2689 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,mesh_bad_spacing_name)2690 TEST(conduit_blueprint_mesh_verify, mesh_bad_spacing_name)
2691 {
2692
2693 Node n_test;
2694 n_test["coordsets/coords/type"]= "uniform";
2695 n_test["coordsets/coords/dims/i"] = 10;
2696 n_test["coordsets/coords/dims/j"] = 10;
2697 n_test["coordsets/coords/dims/k"] = 10;
2698 n_test["coordsets/coords/spacing/x"] = 10;
2699 n_test["coordsets/coords/spacing/y"] = 10;
2700 n_test["coordsets/coords/spacing/z"] = 10;
2701 n_test["topologies/topo/coordset"] = "coords";
2702 n_test["topologies/topo/type"] = "uniform";
2703 Node info;
2704 bool res = blueprint::mesh::verify(n_test,info);
2705 // info.print();
2706 Node n_idx;
2707 blueprint::mesh::generate_index(n_test,"",1,n_idx);
2708 }
2709
2710 //-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_verify,empty_mesh_vs_gen_index)2711 TEST(conduit_blueprint_mesh_verify, empty_mesh_vs_gen_index)
2712 {
2713 Node empty;
2714 Node info;
2715 bool res = blueprint::mesh::verify(empty,info);
2716 EXPECT_TRUE(res);
2717 // expect this to throw, while mesh bp can have empty domains
2718 // we can't create an index for the input domain case
2719 Node n_idx;
2720 EXPECT_THROW(blueprint::mesh::generate_index(empty,"",1,n_idx),conduit::Error);
2721
2722
2723 }
2724
2725