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_slice.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 
27 
28 
29 using namespace std;
30 using namespace conduit;
31 using namespace ascent;
32 
33 
34 index_t EXAMPLE_MESH_SIDE_DIM = 20;
35 
36 //-----------------------------------------------------------------------------
TEST(ascent_scale,test_scale)37 TEST(ascent_scale, test_scale)
38 {
39     Node n;
40     ascent::about(n);
41     // only run this test if ascent was built with vtkm support
42     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
43     {
44         ASCENT_INFO("Ascent vtkm support disabled, skipping test");
45         return;
46     }
47 
48     //
49     // Create an example mesh.
50     //
51     Node data, verify_info;
52     conduit::blueprint::mesh::examples::braid("hexs",
53                                               EXAMPLE_MESH_SIDE_DIM,
54                                               EXAMPLE_MESH_SIDE_DIM,
55                                               EXAMPLE_MESH_SIDE_DIM,
56                                               data);
57     EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
58 
59     ASCENT_INFO("Testing scale");
60 
61 
62     string output_path = prepare_output_dir();
63     string output_file = conduit::utils::join_file_path(output_path,"tout_scale");
64 
65     // remove old images before rendering
66     remove_test_image(output_file);
67 
68 
69     //
70     // Create the actions.
71     //
72 
73     conduit::Node pipelines;
74     // pipeline 1
75     pipelines["pl1/f1/type"] = "scale";
76     conduit::Node &params = pipelines["pl1/f1/params"];
77     params["x_scale"] = 2.f;
78     params["y_scale"] = 2.f;
79     params["z_scale"] = 2.f;
80 
81     conduit::Node scenes;
82     scenes["s1/plots/p1/type"]         = "pseudocolor";
83     scenes["s1/plots/p1/field"] = "braid";
84     scenes["s1/plots/p1/pipeline"] = "pl1";
85 
86     scenes["s1/image_prefix"] = output_file;
87 
88     conduit::Node actions;
89     // add the pipeline
90     conduit::Node &add_pipelines = actions.append();
91     add_pipelines["action"] = "add_pipelines";
92     add_pipelines["pipelines"] = pipelines;
93     // add the scenes
94     conduit::Node &add_scenes= actions.append();
95     add_scenes["action"] = "add_scenes";
96     add_scenes["scenes"] = scenes;
97 
98     //
99     // Run Ascent
100     //
101 
102     Ascent ascent;
103 
104     Node ascent_opts;
105     ascent_opts["runtime/type"] = "ascent";
106     ascent.open(ascent_opts);
107     ascent.publish(data);
108     ascent.execute(actions);
109     ascent.close();
110 
111     // check that we created an image
112     EXPECT_TRUE(check_test_image(output_file));
113     std::string msg = "An example of using the log filter.";
114     ASCENT_ACTIONS_DUMP(actions,output_file,msg);
115 }
116 //-----------------------------------------------------------------------------
main(int argc,char * argv[])117 int main(int argc, char* argv[])
118 {
119     int result = 0;
120 
121     ::testing::InitGoogleTest(&argc, argv);
122 
123     // allow override of the data size via the command line
124     if(argc == 2)
125     {
126         EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
127     }
128 
129     result = RUN_ALL_TESTS();
130     return result;
131 }
132 
133 
134