Skip to content

Commit

Permalink
Added tests for logical 3d selections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Whitlock committed Jul 21, 2021
1 parent 8941a8b commit dbaa578
Show file tree
Hide file tree
Showing 17 changed files with 2,079 additions and 81 deletions.
6 changes: 3 additions & 3 deletions src/libs/blueprint/conduit_blueprint_mesh_partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,7 @@ partitioner::create_new_uniform_topo(const conduit::Node &n_topo,
"elements/origin/k"};
for(int i = 0; i < 3; i++)
{
if(n_topo.has_child(keys[i]))
if(n_topo.has_path(keys[i]))
{
const conduit::Node &value = n_topo[keys[i]];
n_new_topo[keys[i]].set(static_cast<conduit::int64>(value.to_uint64() + start[i]));
Expand All @@ -2010,7 +2010,7 @@ partitioner::create_new_rectilinear_topo(const conduit::Node &n_topo,
"elements/origin/k"};
for(int i = 0; i < 3; i++)
{
if(n_topo.has_child(keys[i]))
if(n_topo.has_path(keys[i]))
{
const conduit::Node &value = n_topo[keys[i]];
n_new_topo[keys[i]].set(static_cast<conduit::int64>(value.to_uint64() + start[i]));
Expand All @@ -2029,7 +2029,7 @@ partitioner::create_new_structured_topo(const conduit::Node &n_topo,
conduit::Node &n_dims = n_new_topo["elements/dims"];
n_dims["i"].set(static_cast<conduit::int64>(end[0] - start[0] + 1));
n_dims["j"].set(static_cast<conduit::int64>(end[1] - start[1] + 1));
if(n_topo.has_child("elements/dims/k"))
if(n_topo.has_path("elements/dims/k"))
n_dims["k"].set(static_cast<conduit::int64>(end[2] - start[2] + 1));
const char *keys[] = {"elements/origin/i0",
"elements/origin/j0",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

181 changes: 103 additions & 78 deletions src/tests/blueprint/t_blueprint_mesh_partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,128 +320,135 @@ test_logical_selection_2d(const std::string &topo, const std::string &base)

//-----------------------------------------------------------------------------
void
test_logical_selection_3d(const std::string &topo)
test_logical_selection_3d(const std::string &topo, const std::string &base)
{
conduit::utils::set_error_handler(tmp_err_handler);


// Make 10x10x10 cell mesh.
// Make 10x10x1 cell mesh.
conduit::Node input, output, options, msg;
conduit::index_t vdims[] = {11,11,11};
conduit::index_t vdims[] = {11,11,4};
conduit::blueprint::mesh::examples::braid(topo, vdims[0], vdims[1], vdims[2], input);
// Override with int64 because YAML loses int/uint information.
conduit::int64 i100 = 100;
input["state/cycle"].set(i100); // override with int64.
input["state/cycle"].set(i100);

// With no options, test that output==input
conduit::blueprint::mesh::partition(input, options, output);
cout << "output=";
output.print();
EXPECT_EQ(input.diff(output, msg, 0.0), false);
#if 0
std::string b00 = baseline_file(base + "_00");
save_visit(b00, output);

// Select the whole thing but divide it into target domains.
const char *opt1 =
"target: 4";
options.parse(opt1, "yaml");
"target: 2";
options.reset(); options.parse(opt1, "yaml");
conduit::blueprint::mesh::partition(input, options, output);
EXPECT_EQ(output.number_of_children(), 4);
EXPECT_EQ(conduit::blueprint::mesh::is_multi_domain(output), true);
// TODO: test output mesh contents.
output.print();
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(output), 2);
std::string b01 = baseline_file(base + "_01");
save_visit(b01, output);
#ifdef GENERATE_BASELINES
make_baseline(b01, output);
#else
EXPECT_EQ(compare_baseline(b01, output), true);
#endif

// Select a portion of the input mesh cells using options.
// Select the whole thing but divide it into target domains.
const char *opt2 =
"selections:\n"
" -\n"
" type: \"logical\"\n"
" domain: 0\n"
" start: [0,0,0]\n"
" end: [4,4,4]\n";
options.parse(opt2, "yaml");
"target: 4";
options.reset(); options.parse(opt2, "yaml");
conduit::blueprint::mesh::partition(input, options, output);
// EXPECT_EQ(conduit::blueprint::mesh::utils::topology::length(output[0]), 5*5*5);
output.print();
// TODO: test output mesh contents.
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(output), 4);
std::string b02 = baseline_file(base + "_02");
save_visit(b02, output);
#ifdef GENERATE_BASELINES
make_baseline(b02, output);
#else
EXPECT_EQ(compare_baseline(b02, output), true);
#endif

// Select a larger portion of the input mesh using options but split into
// multiple domains.
// Select the whole thing but go out of bounds to see if the selections
// clamp to good values.
const char *opt3 =
"selections:\n"
" -\n"
" type: \"logical\"\n"
" domain: 0\n"
" start: [0,0,0]\n"
" end: [4,9,9]\n"
"target: 8\n";
options.parse(opt3, "yaml");
" end: [100,100,100]";
options.reset(); options.parse(opt3, "yaml");
conduit::blueprint::mesh::partition(input, options, output);
EXPECT_EQ(conduit::blueprint::mesh::utils::topology::length(output[0]), 5*5*5);
output.print();
// TODO: test output mesh contents.
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(output), 1);
EXPECT_EQ(conduit::blueprint::mesh::is_multi_domain(output), false);
std::string b03 = baseline_file(base + "_03");
save_visit(b03, output);
#ifdef GENERATE_BASELINES
make_baseline(b03, output);
#else
EXPECT_EQ(compare_baseline(b03, output), true);
#endif

// Select 2 logical subsets of the input mesh using options.
// - expect 2 output domains.
// Select 3 parts.
const char *opt4 =
"selections:\n"
" -\n"
" type: \"logical\"\n"
" type: logical\n"
" domain: 0\n"
" start: [0,0,0]\n"
" end: [4,4,4]\n"
" end: [4,9,2]\n"
" -\n"
" type: \"logical\"\n"
" type: logical\n"
" domain: 0\n"
" start: [5,0,0]\n"
" end: [9,4,4]\n";
options.parse(opt2, "yaml");
" end: [9,4,2]\n"
" -\n"
" type: logical\n"
" domain: 0\n"
" start: [5,5,0]\n"
" end: [9,9,2]";
options.reset(); options.parse(opt4, "yaml");
conduit::blueprint::mesh::partition(input, options, output);
output.print();
EXPECT_EQ(output.number_of_children(), 2);
EXPECT_EQ(conduit::blueprint::mesh::is_multi_domain(output), true);
// These fail right now.
// EXPECT_EQ(output[0]["type"].as_string(), topo);
// EXPECT_EQ(output[1]["type"].as_string(), topo);
EXPECT_EQ(conduit::blueprint::mesh::utils::topology::length(output[0]), 5*5*5);
EXPECT_EQ(conduit::blueprint::mesh::utils::topology::length(output[1]), 5*5*5);

// Select 2 logical subsets of the input mesh using options but turn them
// into 1 domain.
// - expect 1 domain
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(output), 3);
std::string b04 = baseline_file(base + "_04");
save_visit(b04, output);
#ifdef GENERATE_BASELINES
make_baseline(b04, output);
#else
EXPECT_EQ(compare_baseline(b04, output), true);
#endif

// Select 3 parts with 4 targets.
const char *opt5 =
"selections:\n"
" -\n"
" type: \"logical\"\n"
" type: logical\n"
" domain: 0\n"
" start: [0,0,0]\n"
" end: [9,7,4]\n"
" end: [4,9,2]\n"
" -\n"
" type: \"logical\"\n"
" type: logical\n"
" domain: 0\n"
" start: [0,0,5]\n"
" end: [9,7,9]\n"
"target: 1\n";

options.parse(opt5, "yaml");
" start: [5,0,0]\n"
" end: [9,4,2]\n"
" -\n"
" type: logical\n"
" domain: 0\n"
" start: [5,5,0]\n"
" end: [9,9,2]\n"
"target: 4";
options.reset(); options.parse(opt5, "yaml"); options.print();
conduit::blueprint::mesh::partition(input, options, output);
output.print();
EXPECT_EQ(output.number_of_children(), 1);
EXPECT_EQ(conduit::blueprint::mesh::is_multi_domain(output), false);
// These fail right now.
// EXPECT_EQ(output[0]["type"].as_string(), topo);
// EXPECT_EQ(output[1]["type"].as_string(), topo);
// EXPECT_EQ(conduit::blueprint::mesh::utils::topology::length(output[0]), 10*8*5);
// EXPECT_EQ(conduit::blueprint::mesh::utils::topology::length(output[1]), 10*8*5);


// TODO: Make a multi domain mesh and test pulling out multiple logical
// selections from it.


// TODO: Make a multi domain mesh and test pulling out multiple logical
// selections from it and set target to 1 or 2 so we trigger combining.
EXPECT_EQ(conduit::blueprint::mesh::number_of_domains(output), 4);
std::string b05 = baseline_file(base + "_05");
save_visit(b05, output);
#ifdef GENERATE_BASELINES
make_baseline(b05, output);
#else
EXPECT_EQ(compare_baseline(b05, output), true);
#endif

// TODO: try opt5 but target 2 to see if we combine down to 2 domains.
}

#if 0
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_partition, uniform_logical_2d)
{
Expand All @@ -453,13 +460,31 @@ TEST(conduit_blueprint_mesh_partition, rectilinear_logical_2d)
{
test_logical_selection_2d("rectilinear", "rectilinear_logical_2d");
}
#endif

//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_partition, structured_logical_2d)
{
test_logical_selection_2d("structured", "structured_logical_2d");
}

//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_partition, uniform_logical_3d)
{
test_logical_selection_3d("uniform", "uniform_logical_3d");
}

//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_partition, rectilinear_logical_3d)
{
test_logical_selection_3d("rectilinear", "rectilinear_logical_3d");
}

//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_partition, structured_logical_3d)
{
test_logical_selection_3d("structured", "structured_logical_3d");
}

#if 0
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mesh_partition, uniform_logical_3d)
Expand Down

0 comments on commit dbaa578

Please sign in to comment.