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_particle_advection.cpp
10 ///
11 //-----------------------------------------------------------------------------
12
13
14 #include "gtest/gtest.h"
15
16 #include <ascent.hpp>
17 #include <iostream>
18 #include <math.h>
19 #include <conduit_blueprint.hpp>
20
21 #include "t_config.hpp"
22 #include "t_utils.hpp"
23
24 using namespace std;
25 using namespace conduit;
26 using namespace ascent;
27
28 index_t EXAMPLE_MESH_SIDE_DIM = 20;
29
testFilter(bool isStreamline)30 void testFilter(bool isStreamline)
31 {
32 // the vtkm runtime is currently our only rendering runtime
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 string output_path = ASCENT_T_BIN_DIR;
44
45 ASCENT_INFO("Execute test from folder: " + output_path + "/ascent");
46 output_path = conduit::utils::join_file_path(output_path,"ascent/output");
47 ASCENT_INFO("Creating output folder: " + output_path);
48 if(!conduit::utils::is_directory(output_path))
49 {
50 conduit::utils::create_directory(output_path);
51 }
52
53 //
54 // Create an example mesh.
55 //
56 Node data, verify_info;
57 conduit::blueprint::mesh::examples::braid("uniform",
58 EXAMPLE_MESH_SIDE_DIM,
59 EXAMPLE_MESH_SIDE_DIM,
60 EXAMPLE_MESH_SIDE_DIM,
61 data);
62
63 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
64
65 string output_file, msg;
66 if (isStreamline)
67 {
68 ASCENT_INFO("Testing Streamline filter");
69 output_file = conduit::utils::join_file_path(output_path,"tout_streamline");
70 msg = "An example of using the streamline flow filter.";
71 }
72 else
73 {
74 ASCENT_INFO("Testing Particle Advection filter");
75 output_file = conduit::utils::join_file_path(output_path,"tout_particle_advection");
76 msg = "An example of using the particle_advection flow filter.";
77 }
78 ASCENT_INFO("POO POO");
79 ASCENT_INFO(output_file);
80
81 // remove old stuff before rendering
82 remove_test_file(output_file);
83
84 //
85 // Create the actions.
86 //
87
88 conduit::Node pipelines;
89 // pipeline 1
90 if (isStreamline)
91 pipelines["pl1/f1/type"] = "streamline";
92 else
93 pipelines["pl1/f1/type"] = "particle_advection";
94
95 // filter knobs
96 conduit::Node &sl_params = pipelines["pl1/f1/params"];
97 sl_params["field"] = "vel";
98 sl_params["num_seeds"] = 2;
99 sl_params["num_steps"] = 100;
100 sl_params["step_size"] = 0.01;
101 sl_params["seed_bounding_box_xmin"] = 0.0;
102 sl_params["seed_bounding_box_xmax"] = 1.0;
103 sl_params["seed_bounding_box_ymin"] = 0.0;
104 sl_params["seed_bounding_box_ymax"] = 1.0;
105 sl_params["seed_bounding_box_zmin"] = 0.0;
106 sl_params["seed_bounding_box_zmax"] = 1.0;
107
108 conduit::Node actions;
109 // add the pipeline
110 conduit::Node &add_pipelines = actions.append();
111 add_pipelines["action"] = "add_pipelines";
112 add_pipelines["pipelines"] = pipelines;
113
114 //
115 // Run Ascent
116 //
117
118 Ascent ascent;
119
120 Node ascent_opts;
121 ascent_opts["runtime/type"] = "ascent";
122 ascent.open(ascent_opts);
123 ascent.publish(data);
124 ascent.execute(actions);
125 ascent.close();
126
127 // check that we created the right output
128 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
129 //EXPECT_TRUE(check_test_file(output_file));
130
131 // clean up
132 remove_test_file(output_file);
133 conduit::utils::remove_directory(output_path);
134 }
135
136 //-----------------------------------------------------------------------------
TEST(ascent_streamline,test_streamline)137 TEST(ascent_streamline, test_streamline)
138 {
139 testFilter(true);
140 }
141
TEST(ascent_particle_advection,test_particle_advection)142 TEST(ascent_particle_advection, test_particle_advection)
143 {
144 testFilter(false);
145 }
146
147 //-----------------------------------------------------------------------------
main(int argc,char * argv[])148 int main(int argc, char* argv[])
149 {
150 int result = 0;
151
152 ::testing::InitGoogleTest(&argc, argv);
153
154 // allow override of the data size via the command line
155 if(argc == 2)
156 {
157 EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
158 }
159
160 result = RUN_ALL_TESTS();
161 return result;
162 }
163