|
1 | 1 | #include <catch2/catch.hpp> |
2 | 2 |
|
3 | | -#include "share/manager/mesh_free_grids_manager.hpp" |
4 | 3 | #include "share/grid/point_grid.hpp" |
5 | | -#include "share/grid/se_grid.hpp" |
6 | | -#include "share/grid/grid_utils.hpp" |
7 | 4 | #include "share/core/eamxx_setup_random_test.hpp" |
8 | 5 | #include "share/core/eamxx_types.hpp" |
9 | 6 |
|
10 | | -#include <ekat_pack.hpp> |
11 | | - |
12 | 7 | #include <algorithm> |
13 | 8 |
|
14 | | -namespace { |
15 | | - |
16 | | -using namespace scream; |
17 | | -using namespace scream::ShortFieldTagsNames; |
18 | | - |
19 | | -TEST_CASE("point_grid", "") { |
20 | | - |
21 | | - ekat::Comm comm(MPI_COMM_WORLD); |
22 | | - |
23 | | - const int num_procs = comm.size(); |
24 | | - const int num_local_cols = 128; |
25 | | - const int num_global_cols = num_local_cols*num_procs; |
26 | | - const int num_levels = 72; |
27 | | - |
28 | | - auto grid = create_point_grid("my_grid", num_global_cols, num_levels, comm); |
29 | | - REQUIRE(grid->type() == GridType::Point); |
30 | | - REQUIRE(grid->name() == "my_grid"); |
31 | | - REQUIRE(grid->get_num_vertical_levels() == num_levels); |
32 | | - REQUIRE(grid->get_num_local_dofs() == num_local_cols); |
33 | | - REQUIRE(grid->get_num_global_dofs() == num_global_cols); |
34 | | - REQUIRE(grid->is_unique()); |
35 | | - |
36 | | - // Point grids should have (global) gids spanning the interval [min_gid, min_gid+num_global_dofs) |
37 | | - const auto max_gid = grid->get_global_max_dof_gid(); |
38 | | - const auto min_gid = grid->get_global_min_dof_gid(); |
39 | | - REQUIRE( (max_gid-min_gid+1)==grid->get_num_global_dofs() ); |
40 | | - |
41 | | - auto lid_to_idx = grid->get_lid_to_idx_map().get_view<int**,Host>(); |
42 | | - for (int i = 0; i < grid->get_num_local_dofs(); ++i) { |
43 | | - REQUIRE(lid_to_idx.extent_int(1) == 1); |
44 | | - REQUIRE(i == lid_to_idx(i, 0)); |
45 | | - } |
46 | | - |
47 | | - auto layout = grid->get_2d_scalar_layout(); |
48 | | - REQUIRE(layout.tags().size() == 1); |
49 | | - REQUIRE(layout.tag(0) == COL); |
50 | | - |
51 | | - auto shallow_copy = grid->clone("shallow",true); |
52 | | - auto deep_copy = grid->clone("deep",false); |
53 | | - |
54 | | - using gid_type = AbstractGrid::gid_type; |
55 | | - |
56 | | - auto grid_gids = grid->get_dofs_gids().get_view<const gid_type*,Host>(); |
57 | | - auto scopy_gids = shallow_copy->get_dofs_gids().get_view<const gid_type*,Host>(); |
58 | | - auto dcopy_gids = deep_copy->get_dofs_gids().get_view<const gid_type*,Host>(); |
59 | | - REQUIRE (scopy_gids.data()==grid_gids.data()); |
60 | | - REQUIRE (dcopy_gids.data()!=grid_gids.data()); |
61 | | - for (int i=0; i<grid->get_num_local_dofs(); ++i) { |
62 | | - REQUIRE (dcopy_gids[i]==grid_gids[i]); |
63 | | - } |
64 | | - |
65 | | - shallow_copy->reset_num_vertical_lev(4); |
66 | | - REQUIRE (shallow_copy->get_num_vertical_levels()==4); |
67 | | -} |
68 | | - |
69 | | -TEST_CASE("se_grid", "") { |
70 | | - ekat::Comm comm(MPI_COMM_WORLD); |
71 | | - |
72 | | - const int num_local_elems = 10; |
73 | | - const int num_gp = 4; |
74 | | - const int num_levels = 72; |
75 | | - |
76 | | - auto gm = create_mesh_free_grids_manager(comm,num_local_elems,num_gp,num_levels,0); |
77 | | - gm->build_grids(); |
78 | | - |
79 | | - // SE grid |
80 | | - auto se_grid = gm->get_grid("SE Grid"); |
81 | | - |
82 | | - REQUIRE(se_grid->type() == GridType::SE); |
83 | | - REQUIRE(se_grid->name() == "SE Grid"); |
84 | | - REQUIRE(se_grid->get_num_vertical_levels() == num_levels); |
85 | | - REQUIRE(se_grid->get_num_local_dofs() == num_local_elems*num_gp*num_gp); |
86 | | - |
87 | | - auto layout = se_grid->get_2d_scalar_layout(); |
88 | | - REQUIRE(layout.tags().size() == 3); |
89 | | - REQUIRE(layout.tag(0) == EL); |
90 | | - REQUIRE(layout.tag(1) == GP); |
91 | | - REQUIRE(layout.tag(2) == GP); |
92 | | - |
93 | | - REQUIRE (se_grid->is_unique()); |
94 | | - |
95 | | - const auto max_gid = se_grid->get_global_max_dof_gid(); |
96 | | - const auto min_gid = se_grid->get_global_min_dof_gid(); |
97 | | - REQUIRE( (max_gid-min_gid+1)==se_grid->get_num_global_dofs() ); |
98 | | - |
99 | | - auto shallow_copy = se_grid->clone("shallow",true); |
100 | | - auto deep_copy = se_grid->clone("deep",false); |
101 | | - |
102 | | - using gid_type = AbstractGrid::gid_type; |
103 | | - |
104 | | - auto grid_gids = se_grid->get_dofs_gids().get_view<const gid_type*,Host>(); |
105 | | - auto scopy_gids = shallow_copy->get_dofs_gids().get_view<const gid_type*,Host>(); |
106 | | - auto dcopy_gids = deep_copy->get_dofs_gids().get_view<const gid_type*,Host>(); |
107 | | - REQUIRE (scopy_gids.data()==grid_gids.data()); |
108 | | - REQUIRE (dcopy_gids.data()!=grid_gids.data()); |
109 | | - for (int i=0; i<se_grid->get_num_local_dofs(); ++i) { |
110 | | - REQUIRE (dcopy_gids[i]==grid_gids[i]); |
111 | | - } |
112 | | -} |
| 9 | +namespace scream { |
113 | 10 |
|
114 | 11 | TEST_CASE ("get_owners") { |
115 | 12 | ekat::Comm comm(MPI_COMM_WORLD); |
@@ -218,4 +115,4 @@ TEST_CASE ("get_remote_pids_and_lids") { |
218 | 115 | } |
219 | 116 | } |
220 | 117 |
|
221 | | -} // anonymous namespace |
| 118 | +} // namespace scream |
0 commit comments