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_pipelines_to_pipelines,test_pipelines_to_pipelines)37 TEST(ascent_pipelines_to_pipelines, test_pipelines_to_pipelines)
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 pipelines to pipelines");
60
61
62 string output_path = prepare_output_dir();
63 string output_file = conduit::utils::join_file_path(output_path,"tout_pipelines");
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"] = "vector_magnitude";
76 conduit::Node ¶ms = pipelines["pl1/f1/params"];
77 params["field"] = "vel"; // name of the vector field
78 params["output_name"] = "mag"; // name of the output field
79
80 pipelines["pl2/pipeline"] = "pl1";
81 pipelines["pl2/f1/type"] = "log";
82 conduit::Node ¶ms2 = pipelines["pl2/f1/params"];
83 params2["field"] = "mag"; // name of the input field
84 params2["output_name"] = "log_mag"; // name of the output field
85
86 conduit::Node scenes;
87 scenes["s1/plots/p1/type"] = "pseudocolor";
88 scenes["s1/plots/p1/field"] = "log_mag";
89 scenes["s1/plots/p1/pipeline"] = "pl2";
90
91 scenes["s1/image_prefix"] = output_file;
92
93 conduit::Node actions;
94 // add the pipeline
95 conduit::Node &add_pipelines = actions.append();
96 add_pipelines["action"] = "add_pipelines";
97 add_pipelines["pipelines"] = pipelines;
98 // add the scenes
99 conduit::Node &add_scenes= actions.append();
100 add_scenes["action"] = "add_scenes";
101 add_scenes["scenes"] = scenes;
102
103 //
104 // Run Ascent
105 //
106
107 Ascent ascent;
108
109 Node ascent_opts;
110 ascent_opts["runtime/type"] = "ascent";
111 ascent.open(ascent_opts);
112 ascent.publish(data);
113 ascent.execute(actions);
114 ascent.close();
115
116 // check that we created an image
117 EXPECT_TRUE(check_test_image(output_file));
118 std::string msg = "An example of the interconnecting pipelines.";
119 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
120 }
121 //-----------------------------------------------------------------------------
main(int argc,char * argv[])122 int main(int argc, char* argv[])
123 {
124 int result = 0;
125
126 ::testing::InitGoogleTest(&argc, argv);
127
128 // allow override of the data size via the command line
129 if(argc == 2)
130 {
131 EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
132 }
133
134 result = RUN_ALL_TESTS();
135 return result;
136 }
137
138
139