diff --git a/CHANGELOG.md b/CHANGELOG.md index d2161e28c..e28d73113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s - Fixed partitioner so it reverses vertex order as needed in polyhedral face definitions when extracting mesh elements. - Changed `conduit::blueprint::mesh::partition_map_back()` function so it will attempt to reuse existing field memory when mapping fields back. This permits `partition_map_back()` to send data from a partitioned mesh into the original mesh where fields were provided from a host code using `Node::set_external()`. - Changed `generate_sides` to be robust to the case where no fields exist. +- Deprecated braid `quads_and_tris` example in favor of `mixed_2d`. +- Deprecated braid `braid_quads_and_tris_offsets` example in favor of `mixed_2d`. +- Deprecated braid `hexs_and_tris` example in favor of `mixed`. #### Relay - Changed `conduit::relay::mpi::communicate_using_schema` to avoid an invalid tag MPI error message on some MPI distributions. diff --git a/src/libs/blueprint/conduit_blueprint_mesh_examples.cpp b/src/libs/blueprint/conduit_blueprint_mesh_examples.cpp index 5efc159c6..95cf0757e 100644 --- a/src/libs/blueprint/conduit_blueprint_mesh_examples.cpp +++ b/src/libs/blueprint/conduit_blueprint_mesh_examples.cpp @@ -1624,9 +1624,13 @@ braid_quads(index_t npts_x, //---------------------------------------------------------------------------// void braid_quads_and_tris(index_t npts_x, - index_t npts_y, - Node &res) + index_t npts_y, + Node &res) { + CONDUIT_INFO("This braid example is deprecated in favor of mixed_2d.") + + // TODO remove in conduit 0.9.4 + res.reset(); int32 nele_x = (int32)(npts_x - 1); @@ -1675,7 +1679,6 @@ braid_quads_and_tris(index_t npts_x, ++ielem; } // END for all i - } // END for all j @@ -1744,12 +1747,16 @@ braid_quads_and_tris(index_t npts_x, // fields["radial"]); } + //---------------------------------------------------------------------------// void braid_quads_and_tris_offsets(index_t npts_x, index_t npts_y, Node &res) { + CONDUIT_INFO("This braid example is deprecated in favor of mixed_2d.") + + // TODO remove in conduit 0.9.4 res.reset(); @@ -2650,6 +2657,9 @@ braid_hexs_and_tets(index_t npts_x, index_t npts_z, Node &res) { + CONDUIT_INFO("This braid example is deprecated in favor of mixed.") + + // TODO remove in conduit 0.9.4 // WARNING -- The code below is UNTESTED. // The SILO writer is missing an implementation for diff --git a/src/tests/blueprint/t_blueprint_mesh_examples.cpp b/src/tests/blueprint/t_blueprint_mesh_examples.cpp index 56935d1a7..b1c0d63a0 100644 --- a/src/tests/blueprint/t_blueprint_mesh_examples.cpp +++ b/src/tests/blueprint/t_blueprint_mesh_examples.cpp @@ -165,18 +165,6 @@ TEST(conduit_blueprint_mesh_examples, mesh_2d) npts_z, dsets["quads"]); - blueprint::mesh::examples::braid("quads_and_tris", - npts_x, - npts_y, - npts_z, - dsets["quads_and_tris"]); - - blueprint::mesh::examples::braid("quads_and_tris_offsets", - npts_x, - npts_y, - npts_z, - dsets["quads_and_tris_offsets"]); - blueprint::mesh::examples::braid("points", npts_x, npts_y, @@ -204,12 +192,6 @@ TEST(conduit_blueprint_mesh_examples, mesh_2d) CONDUIT_INFO(info.to_yaml()); } - // TODO: Add VisIt support for rendering mixed element and implicit point - // meshes so they don't have to be removed before outputting mesh data. - dsets.remove("quads_and_tris"); - dsets.remove("quads_and_tris_offsets"); - dsets.remove("mixed_2d"); - braid_save_helper(dsets,"braid_2d_examples"); #if defined (CONDUIT_RELAY_IO_SILO_ENABLED) if(silo_enabled) @@ -228,7 +210,7 @@ TEST(conduit_blueprint_mesh_examples, mesh_2d) // std::string topo_shape = shape_block->fetch("shape").as_string(); // which does not exist for indexed_stream meshes. // The silo writer needs to be updated for this case. - if( name == "quads_and_tris" || name == "quads_and_tris_offsets" || name == "mixed_2d") + if(name == "mixed_2d") { CONDUIT_INFO("\tNOTE: skipping output to SILO -- ") CONDUIT_INFO("feature is unavailable for mixed element meshes") @@ -306,12 +288,6 @@ TEST(conduit_blueprint_mesh_examples, mesh_3d) npts_z, dsets["hexs"]); - blueprint::mesh::examples::braid("hexs_and_tets", - npts_x, - npts_y, - npts_z, - dsets["hexs_and_tets"]); - blueprint::mesh::examples::braid("mixed", npts_x, npts_y, @@ -339,11 +315,6 @@ TEST(conduit_blueprint_mesh_examples, mesh_3d) CONDUIT_INFO(info.to_yaml()); } - // TODO: Add VisIt support for rendering mixed element and implicit point - // meshes so they don't have to be removed before outputting mesh data. - dsets.remove("hexs_and_tets"); - dsets.remove("mixed"); - braid_save_helper(dsets,"braid_3d_examples"); #if defined (CONDUIT_RELAY_IO_SILO_ENABLED) if(silo_enabled) @@ -355,14 +326,14 @@ TEST(conduit_blueprint_mesh_examples, mesh_3d) const Node &mesh = itr.next(); std::string name = itr.name(); - // Skip output of silo mesh for mixed mesh of hexs and tets for now. + // Skip output of silo mesh for mixed mesh for now. // The silo output is not yet defined and it throws an exception // in conduit_silo.cpp::silo_write_ucd_zonelist() // in the following line that is looking for the 'shape' node: // std::string topo_shape = shape_block->fetch("shape").as_string(); // which does not exist for indexed_stream meshes. // The silo writer needs to be updated for this case. - if(name == "hexs_and_tets" || name == "mixed") + if (name == "mixed") { CONDUIT_INFO("\tNOTE: skipping output to SILO -- ") CONDUIT_INFO("feature is unavailable for mixed element meshes") @@ -504,6 +475,8 @@ TEST(conduit_blueprint_mesh_examples, strided_structured_2d) test_save_mesh_helper(res, "strided_structured_2d_pad"); } + +//----------------------------------------------------------------------------- TEST(conduit_blueprint_mesh_examples, strided_structured_3d) { Node res; @@ -664,6 +637,346 @@ TEST(conduit_blueprint_mesh_examples, strided_structured_colmajor) test_save_mesh_helper(res, "strided_structured_colmajor"); } +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_mesh_examples, mixed_mesh_simple_2d) +{ + Node data, verify_info; + + // + // Create example mesh. + // + + // create simple mixed 2d mesh with triangles and quads + /* + 3 *-------*-------* (8, 9, 10) + / \ / \ / \ + / d \ e / f \ g / h \ + / \ / \ / \ + 1 *------*-------*------* (4, 5, 6, 7) + | a | b | c | + 0 *------*-------*------* + 0 1 2 3 + */ + + data["coordsets/coords/type"] = "explicit"; + data["coordsets/coords/values/x"].set(DataType::float64(11)); + data["coordsets/coords/values/y"].set(DataType::float64(11)); + + data["coordsets/coords/values/x"] = { 0.0, 1.0, 2.0, 3.0, + 0.0, 1.0, 2.0, 3.0, + 0.5, 1.5, 2.5 }; + data["coordsets/coords/values/y"] = { 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, + 3.0, 3.0, 3.0}; + + data["topologies/topo/type"] = "unstructured"; + data["topologies/topo/coordset"] = "coords"; + data["topologies/topo/elements/shape"] = "mixed"; + data["topologies/topo/elements/shape_map/tri"] = 5; + data["topologies/topo/elements/shape_map/quad"] = 9; + data["topologies/topo/elements/shapes"] = { 9, 9, 9, + 5, 5, 5, 5, 5}; + data["topologies/topo/elements/sizes"] = { 4, 4, 4, + 3, 3, 3, 3, 3}; + data["topologies/topo/elements/offsets"] = {0, 4, 8, + 12, 15, 18, 21, 24}; + + data["topologies/topo/elements/connectivity"] = {0, 1, 5, 4, + 1, 2, 6, 5, + 2, 3, 7, 6, + 4, 5, 8, + 8, 5, 9, + 5, 6, 9, + 9, 6, 10, + 6, 7, 10}; + + data["fields/ele_id/topology"] = "topo"; + data["fields/ele_id/association"] = "element"; + data["fields/ele_id/values"] = { 0, 1, 2, + 3, 4, 5, 6, 7}; + + // also add a points topo to help with debugging + + data["topologies/pts/type"] = "points"; + data["topologies/pts/coordset"] = "coords"; + data["fields/pts_id/topology"] = "pts"; + data["fields/pts_id/association"] = "element"; + data["fields/pts_id/values"] = { 0, 1, 2, 3, + 4, 5, 6, 7, + 8, 9, 10}; + + //data.print(); + + EXPECT_TRUE(blueprint::mesh::verify(data, verify_info)); + CONDUIT_INFO(verify_info.to_yaml()); + + test_save_mesh_helper(data, "mixed_mesh_simple_2d"); +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_mesh_examples, mixed_mesh_polygonal_2d) +{ + Node data, verify_info; + + // + // Create example mesh. + // + + // create simple mixed 2d mesh with triangles, quads, and a polygon + /* + 3 *-------*-------* (8, 9, 10) + / \ / \ + / d \ e / f \ + / \ / ---*--- \ + 1 *------*---/ | \--* (4, 5, 6, 7) + | a | b | c | + 0 *------*-------*------* + 0 1 2 3 + */ + + data["coordsets/coords/type"] = "explicit"; + data["coordsets/coords/values/x"].set(DataType::float64(11)); + data["coordsets/coords/values/y"].set(DataType::float64(11)); + + data["coordsets/coords/values/x"] = { 0.0, 1.0, 2.0, 3.0, + 0.0, 1.0, 2.0, 3.0, + 0.5, 1.5, 2.5 }; + data["coordsets/coords/values/y"] = { 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.5, 1.0, + 3.0, 3.0, 3.0}; + + data["topologies/topo/type"] = "unstructured"; + data["topologies/topo/coordset"] = "coords"; + data["topologies/topo/elements/shape"] = "mixed"; + data["topologies/topo/elements/shape_map/tri"] = 5; + data["topologies/topo/elements/shape_map/quad"] = 9; + data["topologies/topo/elements/shape_map/polygonal"] = 7; + data["topologies/topo/elements/shapes"] = { 9, 9, 9, + 5, 5, + 7}; + data["topologies/topo/elements/sizes"] = { 4, 4, 4, + 3, 3, + 5}; + data["topologies/topo/elements/offsets"] = {0, 4, 8, + 12, 15, + 18}; + + data["topologies/topo/elements/connectivity"] = {0, 1, 5, 4, + 1, 2, 6, 5, + 2, 3, 7, 6, + 4, 5, 8, + 8, 5, 9, + 5, 6, 7, 10, 9}; + + data["fields/ele_id/topology"] = "topo"; + data["fields/ele_id/association"] = "element"; + data["fields/ele_id/values"] = { 0, 1, 2, + 3, 4, + 5}; + + // also add a points topo to help with debugging + + data["topologies/pts/type"] = "points"; + data["topologies/pts/coordset"] = "coords"; + data["fields/pts_id/topology"] = "pts"; + data["fields/pts_id/association"] = "element"; + data["fields/pts_id/values"] = { 0, 1, 2, 3, + 4, 5, 6, 7, + 8, 9, 10}; + + //data.print(); + + EXPECT_TRUE(blueprint::mesh::verify(data, verify_info)); + CONDUIT_INFO(verify_info.to_yaml()); + + test_save_mesh_helper(data, "mixed_mesh_polygonal_2d"); +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_mesh_examples, mixed_mesh_simple_3d) +{ + Node data, verify_info; + + // + // Create example mesh. + // + + // create simple mixed 3d mesh with hexs and pyramids + /* + * * * ( x: 0.5, 1.5, 2.5). 16, 17, 18 + ( y: 2, 2, 2) + ( z: 0.5, 0.5, 0.5) + 1 *------*-------*------* (12, 13, 14, 15) (back upper) + z / /. /. /| + 0 1 *------*-------*------* | (8, 9, 10, 11) (front upper) + y | a | b | c | / + 0 *------*-------*------* (4, 5, 6, 7) (back lower) + 0 1 2 3 + */ + + data["coordsets/coords/type"] = "explicit"; + data["coordsets/coords/values/x"] = { 0.0, 1.0, 2.0, 3.0, + 0.0, 1.0, 2.0, 3.0, + 0.0, 1.0, 2.0, 3.0, + 0.0, 1.0, 2.0, 3.0, + 0.5, 1.5, 2.5}; + + data["coordsets/coords/values/y"] = { 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0}; + + data["coordsets/coords/values/z"] = { 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, + 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, + 0.5, 0.5, 0.5}; + + + data["topologies/topo/type"] = "unstructured"; + data["topologies/topo/coordset"] = "coords"; + data["topologies/topo/elements/shape"] = "mixed"; + data["topologies/topo/elements/shape_map/hex"] = 12; + data["topologies/topo/elements/shape_map/pyramid"] = 14; + data["topologies/topo/elements/shapes"] = { 12, 12, 12, 14, 14, 14 }; + data["topologies/topo/elements/sizes"] = { 8, 8, 8, 5, 5, 5}; + data["topologies/topo/elements/offsets"] = { 0, 8, 16, + 24, 29, 34}; + + data["topologies/topo/elements/connectivity"] = { 0, 1, 5, 4, 8, 9, 13, 12, + 1, 2, 6, 5, 9, 10, 14, 13, + 2, 3, 7, 6, 10, 11, 15, 14, + 8, 9, 13, 12, 16, + 9, 10, 14, 13, 17, + 10, 11, 15, 14, 18 + }; + + data["fields/ele_id/topology"] = "topo"; + data["fields/ele_id/association"] = "element"; + data["fields/ele_id/values"] = { 0, 1, 2, 3, 4, 5}; + + // also add a points topo to help with debugging + + data["topologies/pts/type"] = "points"; + data["topologies/pts/coordset"] = "coords"; + data["fields/pts_id/topology"] = "pts"; + data["fields/pts_id/association"] = "element"; + data["fields/pts_id/values"] = { 0, 1, 2, 3, + 4, 5, 6, 7, + 8, 9, 10, 11, + 12, 13, 14, 15, + 16, 17, 18}; + + //data.print(); + + EXPECT_TRUE(blueprint::mesh::verify(data, verify_info)); + CONDUIT_INFO(verify_info.to_yaml()); + + test_save_mesh_helper(data, "mixed_mesh_simple_3d"); +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_mesh_examples, mixed_mesh_polyhedral_3d) +{ + Node data, verify_info; + + // TODO we should explore why this looks wrong in VisIt. I think + // generate_sides is the culprit. https://github.com/LLNL/conduit/issues/1289 + + // + // Create example mesh. + // + + // create mixed 3d mesh with hexs and pyramids and concave polyhedra + /* + * * * ( x: 0.5, 1.5, 2.5). 16, 17, 18 + ( y: 2, 2, 2) + ( z: 0.5, 0.5, 0.5) + 1 *------*-------*------* (12, 13, 14, 15) (back upper) + z / /. /. /| + 0 1 *------*-------*------* | (8, 9, 10, 11) (front upper) + y | a | b | c | / + 0 *------*-------*------* (4, 5, 6, 7) (back lower) + 0 1 2 3 + */ + + data["coordsets/coords/type"] = "explicit"; + data["coordsets/coords/values/x"] = { 0.75, 1.0, 2.0, 3.0, + 0.75, 1.0, 2.0, 3.0, + 0.0, 1.0, 2.0, 3.0, + 0.0, 1.0, 2.0, 3.0, + 0.5, 1.5, 2.5}; + + data["coordsets/coords/values/y"] = { 0.75, 0.0, 0.0, 0.0, + 0.75, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0}; + + data["coordsets/coords/values/z"] = { 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, + 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, + 0.5, 0.5, 0.5}; + + + data["topologies/topo/type"] = "unstructured"; + data["topologies/topo/coordset"] = "coords"; + data["topologies/topo/elements/shape"] = "mixed"; + data["topologies/topo/elements/shape_map/hex"] = 12; + data["topologies/topo/elements/shape_map/pyramid"] = 14; + data["topologies/topo/elements/shape_map/polyhedral"] = 42; + data["topologies/topo/elements/shapes"] = { 42, 12, 12, 14, 14, 14 }; + data["topologies/topo/elements/sizes"] = { 6, 8, 8, 5, 5, 5}; + data["topologies/topo/elements/offsets"] = { 0, 6, 14, + 22, 27, 32}; + + data["topologies/topo/elements/connectivity"] = { 0, 1, 2, 3, 4, 5, + 1, 2, 6, 5, 9, 10, 14, 13, + 2, 3, 7, 6, 10, 11, 15, 14, + 8, 9, 13, 12, 16, + 9, 10, 14, 13, 17, + 10, 11, 15, 14, 18 + }; + + data["topologies/topo/subelements/shape"] = "mixed"; + data["topologies/topo/subelements/shape_map/quad"] = 9; + data["topologies/topo/subelements/shapes"] = { 9, 9, 9, 9, 9, 9 }; + + data["topologies/topo/subelements/sizes"] = {4, 4, 4, 4, 4, 4}; + data["topologies/topo/subelements/offsets"] = {0, 4, 8, 12, 16, 20}; + data["topologies/topo/subelements/connectivity"] = {0, 1, 5, 4, + 0, 8, 9, 1, + 1, 9, 13, 5, + 5, 13, 12, 4, + 4, 12, 8, 0, + 9, 8, 12, 13}; + + data["fields/ele_id/topology"] = "topo"; + data["fields/ele_id/association"] = "element"; + data["fields/ele_id/values"] = { 0, 1, 2, 3, 4, 5}; + + // also add a points topo to help with debugging + + data["topologies/pts/type"] = "points"; + data["topologies/pts/coordset"] = "coords"; + data["fields/pts_id/topology"] = "pts"; + data["fields/pts_id/association"] = "element"; + data["fields/pts_id/values"] = { 0, 1, 2, 3, + 4, 5, 6, 7, + 8, 9, 10, 11, + 12, 13, 14, 15, + 16, 17, 18}; + + //data.print(); + + EXPECT_TRUE(blueprint::mesh::verify(data, verify_info)); + CONDUIT_INFO(verify_info.to_yaml()); + + test_save_mesh_helper(data, "mixed_mesh_polyhedral_3d"); +} + //----------------------------------------------------------------------------- TEST(conduit_blueprint_mesh_examples, julia) { @@ -939,7 +1252,7 @@ TEST(conduit_blueprint_mesh_examples, venn_sparse_by_element) venn_test_small_yaml("sparse_by_element"); } - +//----------------------------------------------------------------------------- TEST(conduit_blueprint_mesh_examples, mesh_julia_nestset_simple) { diff --git a/src/tests/conduit/python/t_python_conduit_node.py b/src/tests/conduit/python/t_python_conduit_node.py index 97721fabb..c07eae5c1 100644 --- a/src/tests/conduit/python/t_python_conduit_node.py +++ b/src/tests/conduit/python/t_python_conduit_node.py @@ -365,7 +365,7 @@ def test_string(self): print(n) self.assertEqual(n.value(),"my string!") # test numpy string - nps = np.string_("my numpy string!") + nps = np.bytes_("my numpy string!") n.set(nps) print(n) print(repr(n))