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 /// file: t_ascent_cinema_a.cpp
9 ///
10 //-----------------------------------------------------------------------------
11 
12 #include "gtest/gtest.h"
13 
14 #include <ascent.hpp>
15 
16 #include <iostream>
17 #include <math.h>
18 
19 #include <conduit_blueprint.hpp>
20 
21 #include "t_config.hpp"
22 #include "t_utils.hpp"
23 
24 
25 
26 using namespace std;
27 using namespace conduit;
28 using namespace ascent;
29 
30 index_t EXAMPLE_MESH_SIDE_DIM = 32;
31 
32 //-----------------------------------------------------------------------------
TEST(ascent_cinema_a,test_cinema_a)33 TEST(ascent_cinema_a, test_cinema_a)
34 {
35     // the vtkm runtime is currently our only rendering runtime
36     Node n;
37     ascent::about(n);
38     // only run this test if ascent was built with vtkm support
39     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
40     {
41         ASCENT_INFO("Ascent support disabled, skipping test");
42         return;
43     }
44 
45     //
46     // Create example mesh.
47     //
48     Node data, verify_info;
49     conduit::blueprint::mesh::examples::braid("hexs",
50                                                EXAMPLE_MESH_SIDE_DIM,
51                                                EXAMPLE_MESH_SIDE_DIM,
52                                                EXAMPLE_MESH_SIDE_DIM,
53                                                data);
54 
55     EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
56     std::string db_name = "test_db1";
57     string output_path = "./cinema_databases/" + db_name;
58     string output_file = conduit::utils::join_file_path(output_path, "info.json");
59     // remove old file before rendering
60     if(conduit::utils::is_file(output_file))
61     {
62         conduit::utils::remove_file(output_file);
63     }
64 
65     //
66     // Create the actions.
67     //
68     Node actions;
69 
70     conduit::Node pipelines;
71     // pipeline 1
72     pipelines["pl1/f1/type"] = "contour";
73     // filter knobs
74     conduit::Node &contour_params = pipelines["pl1/f1/params"];
75     contour_params["field"] = "braid";
76     contour_params["iso_values"] = 0.;
77 
78     conduit::Node scenes;
79     scenes["scene1/plots/plt1/type"] = "pseudocolor";
80     scenes["scene1/plots/plt1/pipeline"] = "pl1";
81     scenes["scene1/plots/plt1/field"] = "braid";
82     // setup required cinema params
83     scenes["scene1/renders/r1/type"] = "cinema";
84     scenes["scene1/renders/r1/phi"] = 2;
85     scenes["scene1/renders/r1/theta"] = 2;
86     scenes["scene1/renders/r1/db_name"] = "test_db1";
87     //scenes["scene1/renders/r1/annotations"] = "false";
88     scenes["scene1/renders/r1/camera/zoom"] = 1.0; // no zoom
89 
90     // add the pipeline
91     conduit::Node &add_pipelines = actions.append();
92     add_pipelines["action"] = "add_pipelines";
93     add_pipelines["pipelines"] = pipelines;
94     // add scene
95     conduit::Node &add_scenes = actions.append();
96     add_scenes["action"] = "add_scenes";
97     add_scenes["scenes"] = scenes;
98     actions.print();
99 
100     //
101     // Run Ascent
102     //
103 
104     Ascent ascent;
105     Node ascent_opts;
106     // default is now ascent
107     ascent_opts["runtime/type"] = "ascent";
108     ascent.open(ascent_opts);
109     ascent.publish(data);
110     ascent.execute(actions);
111     ascent.close();
112 
113     // check that we created an image
114     EXPECT_TRUE(conduit::utils::is_file(output_file));
115 }
116 
117 //-----------------------------------------------------------------------------
TEST(ascent_cinema_a,test_angle_range_1)118 TEST(ascent_cinema_a, test_angle_range_1)
119 {
120     // the vtkm runtime is currently our only rendering runtime
121     Node n;
122     ascent::about(n);
123     // only run this test if ascent was built with vtkm support
124     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
125     {
126         ASCENT_INFO("Ascent support disabled, skipping test");
127         return;
128     }
129 
130     //
131     // Create example mesh.
132     //
133     Node data, verify_info;
134     conduit::blueprint::mesh::examples::braid("hexs",
135                                                EXAMPLE_MESH_SIDE_DIM,
136                                                EXAMPLE_MESH_SIDE_DIM,
137                                                EXAMPLE_MESH_SIDE_DIM,
138                                                data);
139 
140     EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
141     std::string db_name = "test_db2";
142     string output_path = "./cinema_databases/" + db_name;
143     string output_file = conduit::utils::join_file_path(output_path, "info.json");
144     // remove old file before rendering
145     if(conduit::utils::is_file(output_file))
146     {
147         conduit::utils::remove_file(output_file);
148     }
149 
150     //
151     // Create the actions.
152     //
153     Node actions;
154 
155     conduit::Node pipelines;
156     // pipeline 1
157     pipelines["pl1/f1/type"] = "contour";
158     // filter knobs
159     conduit::Node &contour_params = pipelines["pl1/f1/params"];
160     contour_params["field"] = "braid";
161     contour_params["iso_values"] = 0.;
162 
163     conduit::Node scenes;
164     scenes["scene1/plots/plt1/type"] = "pseudocolor";
165     scenes["scene1/plots/plt1/pipeline"] = "pl1";
166     scenes["scene1/plots/plt1/field"] = "braid";
167     // setup required cinema params
168     scenes["scene1/renders/r1/type"] = "cinema";
169     scenes["scene1/renders/r1/phi_range"].set({-180., 180.});
170     scenes["scene1/renders/r1/dphi"] = 90.;
171     scenes["scene1/renders/r1/theta_range"].set({0., 180.});
172     scenes["scene1/renders/r1/dtheta"] = 90.;
173     scenes["scene1/renders/r1/db_name"] = "test_db2";
174     //scenes["scene1/renders/r1/annotations"] = "false";
175     scenes["scene1/renders/r1/camera/zoom"] = 1.0; // no zoom
176 
177     // add the pipeline
178     conduit::Node &add_pipelines = actions.append();
179     add_pipelines["action"] = "add_pipelines";
180     add_pipelines["pipelines"] = pipelines;
181     // add scene
182     conduit::Node &add_scenes = actions.append();
183     add_scenes["action"] = "add_scenes";
184     add_scenes["scenes"] = scenes;
185     actions.print();
186 
187     //
188     // Run Ascent
189     //
190 
191     Ascent ascent;
192     Node ascent_opts;
193     // default is now ascent
194     ascent_opts["runtime/type"] = "ascent";
195     ascent.open(ascent_opts);
196     ascent.publish(data);
197     ascent.execute(actions);
198     ascent.close();
199 
200     // check that we created an image
201     EXPECT_TRUE(conduit::utils::is_file(output_file));
202 }
203 
204 //-----------------------------------------------------------------------------
TEST(ascent_cinema_a,test_angle_range_2)205 TEST(ascent_cinema_a, test_angle_range_2)
206 {
207     // the vtkm runtime is currently our only rendering runtime
208     Node n;
209     ascent::about(n);
210     // only run this test if ascent was built with vtkm support
211     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
212     {
213         ASCENT_INFO("Ascent support disabled, skipping test");
214         return;
215     }
216 
217     //
218     // Create example mesh.
219     //
220     Node data, verify_info;
221     conduit::blueprint::mesh::examples::braid("hexs",
222                                                EXAMPLE_MESH_SIDE_DIM,
223                                                EXAMPLE_MESH_SIDE_DIM,
224                                                EXAMPLE_MESH_SIDE_DIM,
225                                                data);
226 
227     EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
228     std::string db_name = "test_db3";
229     string output_path = "./cinema_databases/" + db_name;
230     string output_file = conduit::utils::join_file_path(output_path, "info.json");
231     // remove old file before rendering
232     if(conduit::utils::is_file(output_file))
233     {
234         conduit::utils::remove_file(output_file);
235     }
236 
237     //
238     // Create the actions.
239     //
240     Node actions;
241 
242     conduit::Node pipelines;
243     // pipeline 1
244     pipelines["pl1/f1/type"] = "contour";
245     // filter knobs
246     conduit::Node &contour_params = pipelines["pl1/f1/params"];
247     contour_params["field"] = "braid";
248     contour_params["iso_values"] = 0.;
249 
250     conduit::Node scenes;
251     scenes["scene1/plots/plt1/type"] = "pseudocolor";
252     scenes["scene1/plots/plt1/pipeline"] = "pl1";
253     scenes["scene1/plots/plt1/field"] = "braid";
254     // setup required cinema params
255     scenes["scene1/renders/r1/type"] = "cinema";
256     scenes["scene1/renders/r1/phi_range"].set({-180., 180.});
257     scenes["scene1/renders/r1/phi_num_angles"] = 5;
258     scenes["scene1/renders/r1/theta_range"].set({0., 180.});
259     scenes["scene1/renders/r1/theta_num_angles"] = 3;
260     scenes["scene1/renders/r1/db_name"] = "test_db3";
261     //scenes["scene1/renders/r1/annotations"] = "false";
262     scenes["scene1/renders/r1/camera/zoom"] = 1.0; // no zoom
263 
264     // add the pipeline
265     conduit::Node &add_pipelines = actions.append();
266     add_pipelines["action"] = "add_pipelines";
267     add_pipelines["pipelines"] = pipelines;
268     // add scene
269     conduit::Node &add_scenes = actions.append();
270     add_scenes["action"] = "add_scenes";
271     add_scenes["scenes"] = scenes;
272     actions.print();
273 
274     //
275     // Run Ascent
276     //
277 
278     Ascent ascent;
279     Node ascent_opts;
280     // default is now ascent
281     ascent_opts["runtime/type"] = "ascent";
282     ascent.open(ascent_opts);
283     ascent.publish(data);
284     ascent.execute(actions);
285     ascent.close();
286 
287     // check that we created an image
288     EXPECT_TRUE(conduit::utils::is_file(output_file));
289 }
290 
291 //-----------------------------------------------------------------------------
TEST(ascent_cinema_a,test_angle_values)292 TEST(ascent_cinema_a, test_angle_values)
293 {
294     // the vtkm runtime is currently our only rendering runtime
295     Node n;
296     ascent::about(n);
297     // only run this test if ascent was built with vtkm support
298     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
299     {
300         ASCENT_INFO("Ascent support disabled, skipping test");
301         return;
302     }
303 
304     //
305     // Create example mesh.
306     //
307     Node data, verify_info;
308     conduit::blueprint::mesh::examples::braid("hexs",
309                                                EXAMPLE_MESH_SIDE_DIM,
310                                                EXAMPLE_MESH_SIDE_DIM,
311                                                EXAMPLE_MESH_SIDE_DIM,
312                                                data);
313 
314     EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
315     std::string db_name = "test_db4";
316     string output_path = "./cinema_databases/" + db_name;
317     string output_file = conduit::utils::join_file_path(output_path, "info.json");
318     // remove old file before rendering
319     if(conduit::utils::is_file(output_file))
320     {
321         conduit::utils::remove_file(output_file);
322     }
323 
324     //
325     // Create the actions.
326     //
327     Node actions;
328 
329     conduit::Node pipelines;
330     // pipeline 1
331     pipelines["pl1/f1/type"] = "contour";
332     // filter knobs
333     conduit::Node &contour_params = pipelines["pl1/f1/params"];
334     contour_params["field"] = "braid";
335     contour_params["iso_values"] = 0.;
336 
337     conduit::Node scenes;
338     scenes["scene1/plots/plt1/type"] = "pseudocolor";
339     scenes["scene1/plots/plt1/pipeline"] = "pl1";
340     scenes["scene1/plots/plt1/field"] = "braid";
341     // setup required cinema params
342     scenes["scene1/renders/r1/type"] = "cinema";
343     scenes["scene1/renders/r1/phi_angles"].set({-180., -90., 0., 90., 180.});
344     scenes["scene1/renders/r1/theta_angles"].set({0., 90., 180.});
345     scenes["scene1/renders/r1/db_name"] = "test_db4";
346     //scenes["scene1/renders/r1/annotations"] = "false";
347     scenes["scene1/renders/r1/camera/zoom"] = 1.0; // no zoom
348 
349     // add the pipeline
350     conduit::Node &add_pipelines = actions.append();
351     add_pipelines["action"] = "add_pipelines";
352     add_pipelines["pipelines"] = pipelines;
353     // add scene
354     conduit::Node &add_scenes = actions.append();
355     add_scenes["action"] = "add_scenes";
356     add_scenes["scenes"] = scenes;
357     actions.print();
358 
359     //
360     // Run Ascent
361     //
362 
363     Ascent ascent;
364     Node ascent_opts;
365     // default is now ascent
366     ascent_opts["runtime/type"] = "ascent";
367     ascent.open(ascent_opts);
368     ascent.publish(data);
369     ascent.execute(actions);
370     ascent.close();
371 
372     // check that we created an image
373     EXPECT_TRUE(conduit::utils::is_file(output_file));
374 }
375 
376 //-----------------------------------------------------------------------------
TEST(ascent_cinema_a,test_phi_theta_positions)377 TEST(ascent_cinema_a, test_phi_theta_positions)
378 {
379     // the vtkm runtime is currently our only rendering runtime
380     Node n;
381     ascent::about(n);
382     // only run this test if ascent was built with vtkm support
383     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
384     {
385         ASCENT_INFO("Ascent support disabled, skipping test");
386         return;
387     }
388 
389     //
390     // Create example mesh.
391     //
392     Node data, verify_info;
393     conduit::blueprint::mesh::examples::braid("hexs",
394                                                EXAMPLE_MESH_SIDE_DIM,
395                                                EXAMPLE_MESH_SIDE_DIM,
396                                                EXAMPLE_MESH_SIDE_DIM,
397                                                data);
398 
399     EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
400     std::string db_name = "test_db5";
401     string output_path = "./cinema_databases/" + db_name;
402     string output_file = conduit::utils::join_file_path(output_path, "info.json");
403     // remove old file before rendering
404     if(conduit::utils::is_file(output_file))
405     {
406         conduit::utils::remove_file(output_file);
407     }
408 
409     //
410     // Create the actions.
411     //
412     Node actions;
413 
414     conduit::Node pipelines;
415     // pipeline 1
416     pipelines["pl1/f1/type"] = "contour";
417     // filter knobs
418     conduit::Node &contour_params = pipelines["pl1/f1/params"];
419     contour_params["field"] = "braid";
420     contour_params["iso_values"] = 0.;
421 
422     conduit::Node scenes;
423     scenes["scene1/plots/plt1/type"] = "pseudocolor";
424     scenes["scene1/plots/plt1/pipeline"] = "pl1";
425     scenes["scene1/plots/plt1/field"] = "braid";
426     // setup required cinema params
427     scenes["scene1/renders/r1/type"] = "cinema";
428     conduit::Node positions;
429     positions.append().set({   0.,   0.});
430     positions.append().set({-180.,  90.});
431     positions.append().set({ -90.,  90.});
432     positions.append().set({   0.,  90.});
433     positions.append().set({  90.,  90.});
434     positions.append().set({ 180.,  90.});
435     positions.append().set({   0., 180.});
436     scenes["scene1/renders/r1/phi_theta_positions"] = positions;
437     scenes["scene1/renders/r1/db_name"] = "test_db5";
438     //scenes["scene1/renders/r1/annotations"] = "false";
439     scenes["scene1/renders/r1/camera/zoom"] = 1.0; // no zoom
440 
441     // add the pipeline
442     conduit::Node &add_pipelines = actions.append();
443     add_pipelines["action"] = "add_pipelines";
444     add_pipelines["pipelines"] = pipelines;
445     // add scene
446     conduit::Node &add_scenes = actions.append();
447     add_scenes["action"] = "add_scenes";
448     add_scenes["scenes"] = scenes;
449     actions.print();
450 
451     //
452     // Run Ascent
453     //
454 
455     Ascent ascent;
456     Node ascent_opts;
457     // default is now ascent
458     ascent_opts["runtime/type"] = "ascent";
459     ascent.open(ascent_opts);
460     ascent.publish(data);
461     ascent.execute(actions);
462     ascent.close();
463 
464     // check that we created an image
465     EXPECT_TRUE(conduit::utils::is_file(output_file));
466 }
467 
468 //-----------------------------------------------------------------------------
main(int argc,char * argv[])469 int main(int argc, char* argv[])
470 {
471     int result = 0;
472 
473     ::testing::InitGoogleTest(&argc, argv);
474 
475     // allow override of the data size via the command line
476     if(argc == 2)
477     {
478         EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
479     }
480 
481     result = RUN_ALL_TESTS();
482     return result;
483 }
484 
485 
486