From a63fc62a25411a7357ff0522922e2a27c03ef2d1 Mon Sep 17 00:00:00 2001 From: Willem Deconinck Date: Mon, 7 Nov 2022 16:43:53 +0000 Subject: [PATCH] Make Cells::global_index() using StructuredMeshGenerator for RegularLonLatGrid independent of partitioning The cell numbering now matches the Shifted Grid --- .../detail/StructuredMeshGenerator.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/atlas/meshgenerator/detail/StructuredMeshGenerator.cc b/src/atlas/meshgenerator/detail/StructuredMeshGenerator.cc index af796ea0d..c0fe3d4bf 100644 --- a/src/atlas/meshgenerator/detail/StructuredMeshGenerator.cc +++ b/src/atlas/meshgenerator/detail/StructuredMeshGenerator.cc @@ -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; @@ -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 { @@ -1557,7 +1568,9 @@ void StructuredMeshGenerator::generate_mesh(const StructuredGrid& rg, const grid } } } - generateGlobalElementNumbering(mesh); + if (not regular_cells_glb_idx) { + generateGlobalElementNumbering(mesh); + } } namespace {