1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2 // Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
3 // Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
4 // other details. No copyright assignment is required to contribute to Ascent.
5 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
6
7 //-----------------------------------------------------------------------------
8 ///
9 /// file: t_ascent_hola.cpp
10 ///
11 //-----------------------------------------------------------------------------
12
13 #include "gtest/gtest.h"
14
15 #include <ascent.hpp>
16 #include <ascent_hola.hpp>
17
18 #include "t_config.hpp"
19 #include "t_utils.hpp"
20
21 using namespace std;
22 using namespace conduit;
23 using ascent::Ascent;
24
25
26 //-----------------------------------------------------------------------------
TEST(ascent_hola,test_hola_relay_blueprint_mesh)27 TEST(ascent_hola, test_hola_relay_blueprint_mesh)
28 {
29 // the vtkm runtime is currently our only rendering runtime
30 Node n;
31 ascent::about(n);
32 // only run this test if ascent was built with vtkm support
33 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
34 {
35 ASCENT_INFO("Ascent support disabled, skipping test");
36 return;
37 }
38
39 //
40 // Create example data
41 //
42 Node data, verify_info;
43 conduit::blueprint::mesh::examples::braid("hexs",
44 10,
45 10,
46 10,
47 data);
48
49 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
50 int cycle = 101;
51 data["state/cycle"] = cycle;
52
53 // make sure the _output dir exists
54 string output_path = prepare_output_dir();
55
56
57 string output_file = "tout_hola_relay_blueprint_mesh";
58 //
59 // Create the actions to export the dataset
60 //
61
62 conduit::Node actions;
63 // add the extracts
64 conduit::Node &add_extract = actions.append();
65 add_extract["action"] = "add_extracts";
66 add_extract["extracts/e1/type"] = "relay";
67 add_extract["extracts/e1/params/path"] = output_file;
68 add_extract["extracts/e1/params/protocol"] = "blueprint/mesh/hdf5";
69
70 //
71 // Run Ascent
72 //
73
74 Ascent ascent;
75
76 Node ascent_opts;
77 ascent_opts["messages"] = "verbose";
78 ascent.open(ascent_opts);
79 ascent.publish(data);
80 ascent.execute(actions);
81 ascent.close();
82
83 // use hola to say hello to the data gain
84
85 Node hola_data, hola_opts;
86 char cyc_fmt_buff[64];
87 snprintf(cyc_fmt_buff, sizeof(cyc_fmt_buff), "%06d",cycle);
88
89 ostringstream oss;
90 oss << output_file << ".cycle_" << cyc_fmt_buff << ".root";
91 std::string output_root = oss.str();
92
93 hola_opts["root_file"] = output_root;
94 ascent::hola("relay/blueprint/mesh", hola_opts, hola_data);
95
96 string output_image = conduit::utils::join_file_path(output_path,
97 "tout_hola_bp_test_render");
98 // remove old image before rendering
99 remove_test_image(output_image);
100
101 Ascent ascent2;
102 ascent2.open(ascent_opts);
103 //
104 // Create rendering actions.
105 //
106 actions.reset();
107
108 conduit::Node &add_scene = actions.append();
109 add_scene["action"] = "add_scenes";
110 add_scene["scenes/scene1/plots/plt1/type"] = "pseudocolor";
111 add_scene["scenes/scene1/plots/plt1/field"] = "braid";
112 add_scene["scenes/scene1/image_prefix"] = output_file;
113
114
115 ascent2.publish(hola_data);
116 ascent2.execute(actions);
117 ascent2.close();
118
119 std::string msg = "An example of using hola with a blueprint hdf5 file";
120 ASCENT_ACTIONS_DUMP(actions,output_file, msg);
121 }
122
123