Skip to content

Commit

Permalink
Make Cells::global_index() using StructuredMeshGenerator for RegularL…
Browse files Browse the repository at this point in the history
…onLatGrid independent of partitioning

The cell numbering now matches the Shifted Grid
  • Loading branch information
wdeconinck committed Nov 9, 2022
1 parent d30709c commit a63fc62
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/atlas/meshgenerator/detail/StructuredMeshGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,10 @@ void StructuredMeshGenerator::generate_mesh(const StructuredGrid& rg, const grid
nodes[1] = tmp;
};

bool regular_cells_glb_idx = atlas::RegularLonLatGrid(rg);
if( options.getBool("triangulate") ) {
regular_cells_glb_idx = false;
}

for (idx_t jlat = region.north; jlat < region.south; ++jlat) {
idx_t ilat = jlat - region.north;
Expand Down Expand Up @@ -1297,6 +1301,13 @@ void StructuredMeshGenerator::generate_mesh(const StructuredGrid& rg, const grid
node_connectivity.set(jcell, quad_nodes);
cells_glb_idx(jcell) = jcell + 1;
cells_part(jcell) = mypart;
if( regular_cells_glb_idx ) {
gidx_t nx = rg.nx(jlatN) - 1;
if (periodic_east_west) {
++nx;
}
cells_glb_idx(jcell) = jlatN * nx + region.lat_begin[jlat] + jelem;
}
}
else // This is a triag
{
Expand Down Expand Up @@ -1557,7 +1568,9 @@ void StructuredMeshGenerator::generate_mesh(const StructuredGrid& rg, const grid
}
}
}
generateGlobalElementNumbering(mesh);
if (not regular_cells_glb_idx) {
generateGlobalElementNumbering(mesh);
}
}

namespace {
Expand Down

0 comments on commit a63fc62

Please sign in to comment.