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_divergence.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_vorticity,vel_vorticity)37 TEST(ascent_vorticity, vel_vorticity)
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 the vorticity of a field");
60
61
62 string output_path = prepare_output_dir();
63 string output_file = conduit::utils::join_file_path(output_path,"tout_vorticity_vel");
64
65 // remove old images before rendering
66 remove_test_image(output_file);
67
68 //
69 // Create the actions.
70 //
71
72 conduit::Node pipelines;
73 // pipeline 1
74
75 pipelines["pl1/f2/type"] = "vorticity";
76 conduit::Node ¶ms2 = pipelines["pl1/f2/params"];
77 params2["field"] = "vel"; // name of the input field
78 params2["output_name"] = "vel_vorticity"; // name of the output field
79 params2["use_cell_gradient"] = "false";
80
81 pipelines["pl1/f1/type"] = "vector_magnitude";
82 conduit::Node ¶ms = pipelines["pl1/f1/params"];
83 params["field"] = "vel_vorticity"; // name of the vector field
84 params["output_name"] = "mag_vorticity"; // name of the output field
85
86 conduit::Node scenes;
87 scenes["s1/plots/p1/type"] = "pseudocolor";
88 scenes["s1/plots/p1/field"] = "mag_vorticity";
89 scenes["s1/plots/p1/pipeline"] = "pl1";
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 using the gradient filter "
119 "and plotting the magnitude.";
120 ASCENT_ACTIONS_DUMP(actions,output_file,msg);
121
122 }
123
124 //-----------------------------------------------------------------------------
main(int argc,char * argv[])125 int main(int argc, char* argv[])
126 {
127 int result = 0;
128
129 ::testing::InitGoogleTest(&argc, argv);
130
131 // allow override of the data size via the command line
132 if(argc == 2)
133 {
134 EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
135 }
136
137 result = RUN_ALL_TESTS();
138 return result;
139 }
140
141
142