//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// // Copyright (c) Lawrence Livermore National Security, LLC and other Ascent // Project developers. See top-level LICENSE AND COPYRIGHT files for dates and // other details. No copyright assignment is required to contribute to Ascent. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //----------------------------------------------------------------------------- /// /// file: t_ascent_recenter.cpp /// //----------------------------------------------------------------------------- #include "gtest/gtest.h" #include #include #include #include #include "t_config.hpp" #include "t_utils.hpp" using namespace std; using namespace conduit; using namespace ascent; index_t EXAMPLE_MESH_SIDE_DIM = 20; //----------------------------------------------------------------------------- TEST(ascent_recenter, test_recenter_to_element) { Node n; ascent::about(n); // only run this test if ascent was built with vtkm support if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled") { ASCENT_INFO("Ascent vtkm support disabled, skipping test"); return; } // // Create an example mesh. // Node data, verify_info; conduit::blueprint::mesh::examples::braid("hexs", EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, data); EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info)); ASCENT_INFO("Testing recenter of field"); string output_path = prepare_output_dir(); string output_file = conduit::utils::join_file_path(output_path,"tout_recenter_element"); // remove old images before rendering remove_test_image(output_file); // // Create the actions. // conduit::Node pipelines; // pipeline 1 pipelines["pl1/f1/type"] = "recenter"; conduit::Node ¶ms = pipelines["pl1/f1/params"]; params["field"] = "radial"; // name of the input field params["association"] = "vertex"; // new field association conduit::Node scenes; scenes["s1/plots/p1/type"] = "pseudocolor"; scenes["s1/plots/p1/field"] = "radial"; scenes["s1/plots/p1/pipeline"] = "pl1"; scenes["s1/image_prefix"] = output_file; conduit::Node actions; // add the pipeline conduit::Node &add_pipelines = actions.append(); add_pipelines["action"] = "add_pipelines"; add_pipelines["pipelines"] = pipelines; // add the scenes conduit::Node &add_scenes= actions.append(); add_scenes["action"] = "add_scenes"; add_scenes["scenes"] = scenes; // // Run Ascent // Ascent ascent; Node ascent_opts; ascent_opts["runtime/type"] = "ascent"; ascent.open(ascent_opts); ascent.publish(data); ascent.execute(actions); ascent.close(); // check that we created an image EXPECT_TRUE(check_test_image(output_file)); std::string msg = "An example if using the re-center filter (to vertex)."; ASCENT_ACTIONS_DUMP(actions,output_file,msg); } //----------------------------------------------------------------------------- TEST(ascent_recenter, test_recenter_to_vertex) { Node n; ascent::about(n); // only run this test if ascent was built with vtkm support if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled") { ASCENT_INFO("Ascent vtkm support disabled, skipping test"); return; } // // Create an example mesh. // Node data, verify_info; conduit::blueprint::mesh::examples::braid("hexs", EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, data); EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info)); ASCENT_INFO("Testing recenter of field"); string output_path = prepare_output_dir(); string output_file = conduit::utils::join_file_path(output_path,"tout_recenter_vertex"); // remove old images before rendering remove_test_image(output_file); // // Create the actions. // conduit::Node pipelines; // pipeline 1 pipelines["pl1/f1/type"] = "recenter"; conduit::Node ¶ms = pipelines["pl1/f1/params"]; params["field"] = "braid"; // name of the input field params["association"] = "element"; // new field association conduit::Node scenes; scenes["s1/plots/p1/type"] = "pseudocolor"; scenes["s1/plots/p1/field"] = "braid"; scenes["s1/plots/p1/pipeline"] = "pl1"; scenes["s1/image_prefix"] = output_file; conduit::Node actions; // add the pipeline conduit::Node &add_pipelines = actions.append(); add_pipelines["action"] = "add_pipelines"; add_pipelines["pipelines"] = pipelines; // add the scenes conduit::Node &add_scenes= actions.append(); add_scenes["action"] = "add_scenes"; add_scenes["scenes"] = scenes; // // Run Ascent // Ascent ascent; Node ascent_opts; ascent_opts["runtime/type"] = "ascent"; ascent.open(ascent_opts); ascent.publish(data); ascent.execute(actions); ascent.close(); // check that we created an image EXPECT_TRUE(check_test_image(output_file)); std::string msg = "An example if using the re-center filter (to element)."; ASCENT_ACTIONS_DUMP(actions,output_file,msg); } //----------------------------------------------------------------------------- int main(int argc, char* argv[]) { int result = 0; ::testing::InitGoogleTest(&argc, argv); // allow override of the data size via the command line if(argc == 2) { EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]); } result = RUN_ALL_TESTS(); return result; }