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_multi_topo.cpp
10 ///
11 //-----------------------------------------------------------------------------
12
13
14 #include "gtest/gtest.h"
15
16 #include <ascent.hpp>
17
18 #include <iostream>
19 #include <math.h>
20
21 #include <conduit_blueprint.hpp>
22
23 #include "t_config.hpp"
24 #include "t_utils.hpp"
25
26 using namespace std;
27 using namespace conduit;
28 using namespace ascent;
29
30 //-----------------------------------------------------------------------------
TEST(ascent_multi_topo,test_render)31 TEST(ascent_multi_topo, test_render)
32 {
33 Node n;
34 ascent::about(n);
35 // only run this test if ascent was built with vtkm support
36 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
37 {
38 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
39 return;
40 }
41
42 //
43 // Create an example mesh.
44 //
45 Node data;
46 build_multi_topo(data,10);
47
48 ASCENT_INFO("Render multiple topologies");
49
50
51 string output_path = prepare_output_dir();
52 string output_file = conduit::utils::join_file_path(output_path,"tout_multi_topo");
53
54 // remove old images before rendering
55 remove_test_image(output_file);
56
57
58 //
59 // Create the actions.
60 //
61
62 conduit::Node scenes;
63 scenes["s1/plots/p1/type"] = "pseudocolor";
64 scenes["s1/plots/p1/field"] = "braid";
65 scenes["s1/plots/p1/color_table/name"] = "Inferno";
66
67 scenes["s1/plots/p2/type"] = "pseudocolor";
68 scenes["s1/plots/p2/field"] = "point_braid";
69 scenes["s1/plots/p2/points/radius"] = .5f;
70
71 scenes["s1/renders/r1/image_prefix"] = output_file;
72 scenes["s1/renders/r1/annotations"] = "false";
73 scenes["s1/renders/r1/camera/azimuth"] = 30;
74 scenes["s1/renders/r1/camera/elevation"] = 11;
75
76 conduit::Node actions;
77 // add the scenes
78 conduit::Node &add_scenes= actions.append();
79 add_scenes["action"] = "add_scenes";
80 add_scenes["scenes"] = scenes;
81
82 //
83 // Run Ascent
84 //
85
86 Ascent ascent;
87
88 Node ascent_opts;
89 ascent_opts["runtime/type"] = "ascent";
90 ascent.open(ascent_opts);
91 ascent.publish(data);
92 ascent.execute(actions);
93 ascent.close();
94
95 // check that we created an image
96 EXPECT_TRUE(check_test_image(output_file, 0.02));
97 std::string msg = "Example of rendering multiple topologies";
98 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
99 }
100 //-----------------------------------------------------------------------------
TEST(ascent_multi_topo,single_ghost)101 TEST(ascent_multi_topo, single_ghost)
102 {
103 Node n;
104 ascent::about(n);
105 // only run this test if ascent was built with vtkm support
106 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
107 {
108 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
109 return;
110 }
111
112 //
113 // Create an example mesh.
114 //
115 Node data;
116 build_multi_topo(data,10);
117
118 ASCENT_INFO("single ghost test with multiple topologies");
119
120
121 string output_path = prepare_output_dir();
122 string output_file = conduit::utils::join_file_path(output_path,"tout_multi_topo_single_ghost");
123
124 // remove old images before rendering
125 remove_test_image(output_file);
126
127
128 //
129 // Create the actions.
130 //
131
132 conduit::Node scenes;
133 scenes["s1/plots/p1/type"] = "pseudocolor";
134 scenes["s1/plots/p1/field"] = "braid";
135
136 scenes["s1/plots/p2/type"] = "pseudocolor";
137 scenes["s1/plots/p2/field"] = "point_braid";
138 scenes["s1/plots/p2/points/radius"] = .5f;
139
140 scenes["s1/renders/r1/image_prefix"] = output_file;
141 scenes["s1/renders/r1/annotations"] = "false";
142 scenes["s1/renders/r1/camera/azimuth"] = 30;
143 scenes["s1/renders/r1/camera/elevation"] = 11;
144
145 conduit::Node actions;
146 // add the scenes
147 conduit::Node &add_scenes= actions.append();
148 add_scenes["action"] = "add_scenes";
149 add_scenes["scenes"] = scenes;
150
151 //
152 // Run Ascent
153 //
154
155 Ascent ascent;
156
157 Node ascent_opts;
158 ascent_opts["runtime/type"] = "ascent";
159 ascent_opts["ghost_field_name"] = "cell_ghosts";
160 ascent.open(ascent_opts);
161 ascent.publish(data);
162 ascent.execute(actions);
163 ascent.close();
164
165 // check that we created an image
166 EXPECT_TRUE(check_test_image(output_file, 0.02));
167 std::string msg = "Example of adding 1 ghost field with 2 topologies";
168 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
169 }
170 //-----------------------------------------------------------------------------
TEST(ascent_multi_topo,multi_ghosts)171 TEST(ascent_multi_topo, multi_ghosts)
172 {
173 Node n;
174 ascent::about(n);
175 // only run this test if ascent was built with vtkm support
176 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
177 {
178 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
179 return;
180 }
181
182 //
183 // Create an example mesh.
184 //
185 Node data;
186 build_multi_topo(data,10);
187
188 ASCENT_INFO("multi ghost test");
189
190
191 string output_path = prepare_output_dir();
192 string output_file = conduit::utils::join_file_path(output_path,"tout_multi_topo_ghosts");
193
194 // remove old images before rendering
195 remove_test_image(output_file);
196
197
198 //
199 // Create the actions.
200 //
201
202 conduit::Node scenes;
203 scenes["s1/plots/p1/type"] = "pseudocolor";
204 scenes["s1/plots/p1/field"] = "braid";
205
206 scenes["s1/plots/p2/type"] = "pseudocolor";
207 scenes["s1/plots/p2/field"] = "point_braid";
208 scenes["s1/plots/p2/points/radius"] = .5f;
209
210 scenes["s1/renders/r1/image_prefix"] = output_file;
211 scenes["s1/renders/r1/annotations"] = "false";
212 scenes["s1/renders/r1/camera/azimuth"] = 30;
213 scenes["s1/renders/r1/camera/elevation"] = 11;
214
215 conduit::Node actions;
216 // add the scenes
217 conduit::Node &add_scenes= actions.append();
218 add_scenes["action"] = "add_scenes";
219 add_scenes["scenes"] = scenes;
220
221 //
222 // Run Ascent
223 //
224
225 Ascent ascent;
226
227 Node ascent_opts;
228 ascent_opts["runtime/type"] = "ascent";
229 ascent_opts["ghost_field_name"].append() = "cell_ghosts";
230 ascent_opts["ghost_field_name"].append() = "point_ghosts";
231 ascent.open(ascent_opts);
232 ascent.publish(data);
233 ascent.execute(actions);
234 ascent.close();
235
236 // check that we created an image
237 EXPECT_TRUE(check_test_image(output_file, 0.02));
238 std::string msg = "Example of adding multple ghosts with 2 topologies";
239 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
240 }
241 //-----------------------------------------------------------------------------
main(int argc,char * argv[])242 int main(int argc, char* argv[])
243 {
244 int result = 0;
245
246 ::testing::InitGoogleTest(&argc, argv);
247
248 result = RUN_ALL_TESTS();
249 return result;
250 }
251
252
253