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_patch_amr.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
37 //-----------------------------------------------------------------------------
TEST(ascent_amr,test_patct_amr_2d)38 TEST(ascent_amr, test_patct_amr_2d)
39 {
40 // the vtkm runtime is currently our only rendering runtime
41 Node n;
42 ascent::about(n);
43 // only run this test if ascent was built with vtkm support
44 if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
45 {
46 ASCENT_INFO("Ascent vtkm support disabled, skipping test");
47 return;
48 }
49
50 //
51 // Create an example mesh.
52 //
53 Node data, verify_info;
54 //conduit::blueprint::mesh::examples::braid("hexs",
55 // EXAMPLE_MESH_SIDE_DIM,
56 // EXAMPLE_MESH_SIDE_DIM,
57 // EXAMPLE_MESH_SIDE_DIM,
58 // data);
59 conduit::blueprint::mesh::examples::misc("nestsets",10,10,0,data);
60 data.print();
61 EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
62
63 ASCENT_INFO("Testing 2D AMR");
64
65
66 string output_path = prepare_output_dir();
67 string output_file = conduit::utils::join_file_path(output_path,"tout_amr_2d");
68
69 // remove old images before rendering
70 remove_test_image(output_file);
71
72
73 //
74 // Create the actions.
75 //
76
77 conduit::Node scenes;
78 scenes["s1/plots/p1/type"] = "pseudocolor";
79 scenes["s1/plots/p1/field"] = "radial";
80 scenes["s1/plots/p2/type"] = "mesh";
81 scenes["s1/image_prefix"] = output_file;
82
83 conduit::Node actions;
84 // add the pipeline
85 conduit::Node &add_scenes= actions.append();
86 add_scenes["action"] = "add_scenes";
87 add_scenes["scenes"] = scenes;
88
89 //
90 // Run Ascent
91 //
92
93 Ascent ascent;
94
95 Node ascent_opts;
96 ascent_opts["runtime/type"] = "ascent";
97 ascent.open(ascent_opts);
98 ascent.publish(data);
99 ascent.execute(actions);
100 ascent.close();
101
102 // check that we created an image
103 // EXPECT_TRUE(check_test_image(output_file));
104 }
105
106
107 //-----------------------------------------------------------------------------
main(int argc,char * argv[])108 int main(int argc, char* argv[])
109 {
110 int result = 0;
111
112 ::testing::InitGoogleTest(&argc, argv);
113
114 // allow override of the data size via the command line
115 if(argc == 2)
116 {
117 EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]);
118 }
119
120 result = RUN_ALL_TESTS();
121 return result;
122 }
123
124
125