Skip to content

Commit

Permalink
Wrap out-of-bounds source cells into the domain (#211)
Browse files Browse the repository at this point in the history
Change originally proposed by s-good, twsearle is just here for the PR
admin.

Co-authored-by: s-good <[email protected]>
  • Loading branch information
twsearle and s-good authored Jul 4, 2024
1 parent 7ad6d4d commit 8981cd1
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,22 @@ Method::Triplets UnstructuredBilinearLonLat::projectPointToElements(size_t ip, c
}
// shift cells on the east-west periodic boundary from the east to the west
// so that the quad surrounds a point with output longitude in [0,360)
if (lons[0] > lons[1] || lons[3] > lons[2]) {
lons[0] -= 360;
lons[3] -= 360;
double minlon = std::numeric_limits<double>::max();
for ( int i = 0; i < 4; i++ ) {
minlon = std::min( minlon, lons[i] );
}
for ( int i = 0; i < 4; i++ ) {
if ( (lons[i] - minlon) > 180 ) {
lons[i] -= 360;
}
}

element::Quad2D quad(
PointLonLat{lons[0], (*ilonlat_)(idx[0], LAT)}, PointLonLat{lons[1], (*ilonlat_)(idx[1], LAT)},
PointLonLat{lons[2], (*ilonlat_)(idx[2], LAT)}, PointLonLat{lons[3], (*ilonlat_)(idx[3], LAT)});

ATLAS_ASSERT( quad.validate() );

if (itc == elems.begin()) {
inv_dist_weight_quad(quad, o_loc, inv_dist_w);
}
Expand Down

0 comments on commit 8981cd1

Please sign in to comment.