From 890d5caa1b466849fe41c7d48a03a27f3145a576 Mon Sep 17 00:00:00 2001 From: odlomax Date: Mon, 4 Mar 2024 10:05:45 +0000 Subject: [PATCH 1/7] Added workaround to avoid FixupHalos in interpolation test. --- .../test_interpolation_spherical_vector.cc | 180 +++++++++--------- 1 file changed, 85 insertions(+), 95 deletions(-) diff --git a/src/tests/interpolation/test_interpolation_spherical_vector.cc b/src/tests/interpolation/test_interpolation_spherical_vector.cc index 19c778fdd..97d374739 100644 --- a/src/tests/interpolation/test_interpolation_spherical_vector.cc +++ b/src/tests/interpolation/test_interpolation_spherical_vector.cc @@ -18,11 +18,10 @@ #include "atlas/mesh.h" #include "atlas/meshgenerator.h" #include "atlas/output/Gmsh.h" -#include "atlas/util/Point.h" #include "atlas/util/Config.h" #include "atlas/util/Constants.h" +#include "atlas/util/Point.h" #include "atlas/util/function/VortexRollup.h" - #include "tests/AtlasTestEnvironment.h" namespace atlas { @@ -37,14 +36,11 @@ constexpr auto Rank3dField = 3; // Return (u, v) field with vortex_rollup as the streamfunction. // This has no physical significance, but it makes a nice swirly field. std::pair vortexHorizontal(double lon, double lat) { - // set hLon and hLat step size. const double hLon = 0.0001; const double hLat = 0.0001; // Get finite differences. - - // Set u. const double u = (function::vortex_rollup(lon, lat + 0.5 * hLat, 0.1) - function::vortex_rollup(lon, lat - 0.5 * hLat, 0.1)) / hLat; @@ -61,7 +57,6 @@ double vortexVertical(double lon, double lat) { } void gmshOutput(const std::string& fileName, const FieldSet& fieldSet) { - const auto functionSpace = fieldSet[0].functionspace(); const auto structuredColums = functionspace::StructuredColumns(functionSpace); const auto nodeColumns = functionspace::NodeColumns(functionSpace); @@ -72,7 +67,6 @@ void gmshOutput(const std::string& fileName, const FieldSet& fieldSet) { Config("info", true); const auto gmsh = output::Gmsh(fileName, gmshConfig); - gmsh.write(mesh); gmsh.write(fieldSet, functionSpace); } @@ -118,7 +112,6 @@ struct FieldSpecFixtures { // Helper stcut to key different interpolation schemes to strings struct InterpSchemeFixtures { static const Config& get(const std::string& fixture) { - static const auto cubedsphereBilinear = option::type("cubedsphere-bilinear"); static const auto finiteElement = option::type("finite-element"); @@ -147,8 +140,9 @@ double dotProduct(const array::ArrayView& a, const array::ArrayView& b) { auto dotProd = 0.; arrayForEachDim(std::make_integer_sequence{}, std::tie(a, b), - [&](const double& aElem, - const double& bElem) { dotProd += aElem * bElem; }); + [&](const double& aElem, const double& bElem) { + dotProd += aElem * bElem; + }); return dotProd; } @@ -157,16 +151,15 @@ int countNans(const array::ArrayView& view) { auto nNans = 0; arrayForEachDim(std::make_integer_sequence{}, std::tie(view), [&](const double& viewElem) { - if (!std::isfinite(viewElem)) { - ++nNans; - } - }); + if (!std::isfinite(viewElem)) { + ++nNans; + } + }); return nNans; } template void testInterpolation(const Config& config) { - const auto& sourceFunctionSpace = FunctionSpaceFixtures::get(config.getString("source_fixture")); const auto& targetFunctionSpace = @@ -192,22 +185,28 @@ void testInterpolation(const Config& config) { auto sourceView = array::make_view(sourceField); auto targetView = array::make_view(targetField); - ArrayForEach<0>::apply(std::tie(sourceLonLat, sourceView), - [](auto&& lonLat, auto&& sourceColumn) { - - const auto setElems = [&](auto&& sourceElem) { - std::tie(sourceElem(0), sourceElem(1)) = - vortexHorizontal(lonLat(0), lonLat(1)); - if (sourceElem.size() == 3) { - sourceElem(2) = vortexVertical(lonLat(0), lonLat(1)); - } - }; - if constexpr (Rank == 2) { setElems(sourceColumn); } - else if constexpr (Rank == 3) { - ArrayForEach<0>::apply(std::tie(sourceColumn), setElems); - } - }); - sourceFieldSet.set_dirty(false); + ArrayForEach<0>::apply( + std::tie(sourceLonLat, sourceView), + [](auto&& lonLat, auto&& sourceColumn) { + const auto setElems = [&](auto&& sourceElem) { + std::tie(sourceElem(0), sourceElem(1)) = + vortexHorizontal(lonLat(0), lonLat(1)); + if (sourceElem.size() == 3) { + sourceElem(2) = vortexVertical(lonLat(0), lonLat(1)); + } + }; + if constexpr (Rank == 2) { + setElems(sourceColumn); + } else if constexpr (Rank == 3) { + ArrayForEach<0>::apply(std::tie(sourceColumn), setElems); + } + }); + + if (functionspace::StructuredColumns(sourceFunctionSpace)) { + sourceFieldSet[0].metadata().set("type", "scalar"); + sourceFieldSet[0].haloExchange(); + sourceFieldSet[0].metadata().set("type", "vector"); + } const auto interp = Interpolation( InterpSchemeFixtures::get(config.getString("interp_fixture")), @@ -224,42 +223,40 @@ void testInterpolation(const Config& config) { errorView.assign(0.); auto maxError = 0.; - ArrayForEach<0>::apply(std::tie(targetLonLat, targetView, errorView), - [&](auto&& lonLat, auto&& targetColumn, - auto&& errorColumn) { - - const auto calcError = [&](auto&& targetElem, auto&& errorElem) { - auto trueValue = std::vector(targetElem.size()); - std::tie(trueValue[0], trueValue[1]) = - vortexHorizontal(lonLat(0), lonLat(1)); - if (targetElem.size() == 3) { - trueValue[2] = vortexVertical(lonLat(0), lonLat(1)); - } - - auto errorSqrd = 0.; - for (auto k = 0; k < targetElem.size(); ++k) { - errorSqrd += - (targetElem(k) - trueValue[k]) * (targetElem(k) - trueValue[k]); - } - - errorElem = std::sqrt(errorSqrd); - maxError = std::max(maxError, static_cast(errorElem)); - }; - - if - constexpr(Rank == 2) { calcError(targetColumn, errorColumn); } - else if - constexpr(Rank == 3) { - ArrayForEach<0>::apply(std::tie(targetColumn, errorColumn), calcError); - } - }); + ArrayForEach<0>::apply( + std::tie(targetLonLat, targetView, errorView), + [&](auto&& lonLat, auto&& targetColumn, auto&& errorColumn) { + const auto calcError = [&](auto&& targetElem, auto&& errorElem) { + auto trueValue = std::vector(targetElem.size()); + std::tie(trueValue[0], trueValue[1]) = + vortexHorizontal(lonLat(0), lonLat(1)); + if (targetElem.size() == 3) { + trueValue[2] = vortexVertical(lonLat(0), lonLat(1)); + } + + auto errorSqrd = 0.; + for (auto k = 0; k < targetElem.size(); ++k) { + errorSqrd += + (targetElem(k) - trueValue[k]) * (targetElem(k) - trueValue[k]); + } + + errorElem = std::sqrt(errorSqrd); + maxError = std::max(maxError, static_cast(errorElem)); + }; + + if constexpr (Rank == 2) { + calcError(targetColumn, errorColumn); + } else if constexpr (Rank == 3) { + ArrayForEach<0>::apply(std::tie(targetColumn, errorColumn), + calcError); + } + }); EXPECT_APPROX_EQ(maxError, 0., config.getDouble("tol")); gmshOutput(config.getString("file_id") + "_source.msh", sourceFieldSet); gmshOutput(config.getString("file_id") + "_target.msh", targetFieldSet); - // Adjoint test auto targetAdjoint = targetFunctionSpace.createField(fieldSpec); auto targetAdjointView = array::make_view(targetAdjoint); @@ -269,8 +266,8 @@ void testInterpolation(const Config& config) { auto sourceAdjoint = sourceFunctionSpace.createField(fieldSpec); auto sourceAdjointView = array::make_view(sourceAdjoint); sourceAdjointView.assign(0.); - sourceAdjoint.set_dirty(false); + sourceAdjoint.set_dirty(false); interp.execute_adjoint(sourceAdjoint, targetAdjoint); // Check fields for nans or +/-inf @@ -311,57 +308,50 @@ CASE("cubed sphere vector interpolation (3d-field, 3-vector)") { } CASE("finite element vector interpolation (2d-field, 2-vector)") { - const auto config = - Config("source_fixture", "gaussian_mesh") - .set("target_fixture", "cubedsphere_mesh") - .set("field_spec_fixture", "2vector") - .set("interp_fixture", "finite_element_spherical") - .set("file_id", "spherical_vector_fe") - .set("tol", 0.00015); + const auto config = Config("source_fixture", "gaussian_mesh") + .set("target_fixture", "cubedsphere_mesh") + .set("field_spec_fixture", "2vector") + .set("interp_fixture", "finite_element_spherical") + .set("file_id", "spherical_vector_fe") + .set("tol", 0.00015); testInterpolation((config)); } CASE("structured columns vector interpolation (2d-field, 2-vector)") { - - const auto config = - Config("source_fixture", "structured_columns") - .set("target_fixture", "cubedsphere_mesh") - .set("field_spec_fixture", "2vector") - .set("interp_fixture", "structured_linear_spherical") - .set("file_id", "spherical_vector_sc") - .set("tol", 0.00017); + const auto config = Config("source_fixture", "structured_columns") + .set("target_fixture", "cubedsphere_mesh") + .set("field_spec_fixture", "2vector") + .set("interp_fixture", "structured_linear_spherical") + .set("file_id", "spherical_vector_sc") + .set("tol", 0.00017); testInterpolation((config)); } CASE("structured columns vector interpolation (2d-field, 2-vector, low-res)") { - - const auto config = - Config("source_fixture", "structured_columns_lowres") - .set("target_fixture", "gaussian_mesh") - .set("field_spec_fixture", "2vector") - .set("interp_fixture", "structured_linear_spherical") - .set("file_id", "spherical_vector_sc_lr") - .set("tol", 0.00056); + const auto config = Config("source_fixture", "structured_columns_lowres") + .set("target_fixture", "gaussian_mesh") + .set("field_spec_fixture", "2vector") + .set("interp_fixture", "structured_linear_spherical") + .set("file_id", "spherical_vector_sc_lr") + .set("tol", 0.00056); testInterpolation((config)); } CASE("structured columns vector interpolation (2d-field, 2-vector, hi-res)") { - - const auto config = - Config("source_fixture", "structured_columns_hires") - .set("target_fixture", "gaussian_mesh") - .set("field_spec_fixture", "2vector") - .set("interp_fixture", "structured_linear_spherical") - .set("file_id", "spherical_vector_sc_hr") - .set("tol", 0.000044); + const auto config = Config("source_fixture", "structured_columns_hires") + .set("target_fixture", "gaussian_mesh") + .set("field_spec_fixture", "2vector") + .set("interp_fixture", "structured_linear_spherical") + .set("file_id", "spherical_vector_sc_hr") + .set("tol", 0.000044); testInterpolation((config)); } -} -} +} // namespace test +} // namespace atlas int main(int argc, char** argv) { return atlas::test::run(argc, argv); } From cf5c6307ffa8b90dfae338f31f482c9358a91fb0 Mon Sep 17 00:00:00 2001 From: odlomax Date: Mon, 4 Mar 2024 14:29:36 +0000 Subject: [PATCH 2/7] Realised StructuredColumns weight corrections cancel due to Euler identity. --- .../method/sphericalvector/SphericalVector.cc | 8 ++------ .../interpolation/test_interpolation_spherical_vector.cc | 6 ------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc b/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc index 4d46225ae..981a32596 100644 --- a/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc +++ b/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc @@ -78,13 +78,9 @@ void SphericalVector::do_setup(const FunctionSpace& source, option::variables(2)); auto targetLonLats = target_.createField(option::name("lonlat") | option::variables(2)); - sourceLonLats.array().copy(source_.lonlat()); - targetLonLats.array().copy(target_.lonlat()); - sourceLonLats.haloExchange(); - targetLonLats.haloExchange(); - const auto sourceLonLatsView = array::make_view(sourceLonLats); - const auto targetLonLatsView = array::make_view(targetLonLats); + const auto sourceLonLatsView = array::make_view(source_.lonlat()); + const auto targetLonLatsView = array::make_view(target_.lonlat()); const auto unitSphere = geometry::UnitSphere{}; diff --git a/src/tests/interpolation/test_interpolation_spherical_vector.cc b/src/tests/interpolation/test_interpolation_spherical_vector.cc index 97d374739..e0a1987ba 100644 --- a/src/tests/interpolation/test_interpolation_spherical_vector.cc +++ b/src/tests/interpolation/test_interpolation_spherical_vector.cc @@ -202,12 +202,6 @@ void testInterpolation(const Config& config) { } }); - if (functionspace::StructuredColumns(sourceFunctionSpace)) { - sourceFieldSet[0].metadata().set("type", "scalar"); - sourceFieldSet[0].haloExchange(); - sourceFieldSet[0].metadata().set("type", "vector"); - } - const auto interp = Interpolation( InterpSchemeFixtures::get(config.getString("interp_fixture")), sourceFunctionSpace, targetFunctionSpace); From ad0c800ba45214c4612ddf0c4ab31195150c5160 Mon Sep 17 00:00:00 2001 From: odlomax Date: Mon, 4 Mar 2024 17:20:11 +0000 Subject: [PATCH 3/7] Added great-circle course tests for points on the pole. --- .../method/sphericalvector/SphericalVector.cc | 1 - src/tests/util/test_unitsphere.cc | 31 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc b/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc index 981a32596..a8cc3a96f 100644 --- a/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc +++ b/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc @@ -78,7 +78,6 @@ void SphericalVector::do_setup(const FunctionSpace& source, option::variables(2)); auto targetLonLats = target_.createField(option::name("lonlat") | option::variables(2)); - const auto sourceLonLatsView = array::make_view(source_.lonlat()); const auto targetLonLatsView = array::make_view(target_.lonlat()); diff --git a/src/tests/util/test_unitsphere.cc b/src/tests/util/test_unitsphere.cc index d390334a5..5343ac561 100644 --- a/src/tests/util/test_unitsphere.cc +++ b/src/tests/util/test_unitsphere.cc @@ -5,9 +5,11 @@ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. */ -#include "atlas/util/Point.h" -#include "atlas/util/Geometry.h" +#include +#include "atlas/util/Constants.h" +#include "atlas/util/Geometry.h" +#include "atlas/util/Point.h" #include "tests/AtlasTestEnvironment.h" namespace atlas { @@ -16,28 +18,43 @@ namespace test { using namespace atlas::util; CASE("great-circle course") { - geometry::UnitSphere g; const auto point1 = PointLonLat(-71.6, -33.0); // Valparaiso const auto point2 = PointLonLat(121.8, 31.4); // Shanghai const auto point3 = PointLonLat(0., 89.); const auto point4 = PointLonLat(180., 89.); + const auto point5 = PointLonLat(0., 90.); + const auto point6 = PointLonLat(180., 90.); const auto targetCourse1 = -94.41; const auto targetCourse2 = -78.42; const auto targetCourse3 = 0.; const auto targetCourse4 = 180.; + const auto targetCourse5 = 0.; + const auto targetCourse6 = 180.; + const auto targetCourse7 = 0.; + const auto targetCourse8 = 0.; + + + const auto [course1, course2] = g.greatCircleCourse(point1, point2); + const auto [course3, course4] = g.greatCircleCourse(point3, point4); + + // Colocated points on pole. + const auto [course5, course6] = g.greatCircleCourse(point5, point6); + const auto [course7, course8] = g.greatCircleCourse(point5, point5); - const auto[ course1, course2 ] = g.greatCircleCourse(point1, point2); - const auto[ course3, course4 ] = g.greatCircleCourse(point3, point4); EXPECT_APPROX_EQ(course1, targetCourse1, 0.01); EXPECT_APPROX_EQ(course2, targetCourse2, 0.01); EXPECT_APPROX_EQ(course3, targetCourse3, 1.e-14); EXPECT_APPROX_EQ(std::abs(course4), targetCourse4, 1.e-14); + EXPECT_APPROX_EQ(std::abs(course5), targetCourse5, 1.e-14); + EXPECT_APPROX_EQ(std::abs(course6), targetCourse6, 1.e-14); + EXPECT_APPROX_EQ(std::abs(course7), targetCourse7, 1.e-14); + EXPECT_APPROX_EQ(std::abs(course8), targetCourse8, 1.e-14); } -} // namespace test -} // namespace atlas +} // namespace test +} // namespace atlas int main(int argc, char** argv) { return atlas::test::run(argc, argv); } From 6a3f0c997f02bdad90baf4f2cfd0a4a4dc9da02a Mon Sep 17 00:00:00 2001 From: odlomax Date: Mon, 4 Mar 2024 17:43:09 +0000 Subject: [PATCH 4/7] Added great-circle course special case where lonlat1 == lonlat2. --- src/atlas/util/Geometry.cc | 122 +++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/src/atlas/util/Geometry.cc b/src/atlas/util/Geometry.cc index 074d72d34..ddb699e19 100644 --- a/src/atlas/util/Geometry.cc +++ b/src/atlas/util/Geometry.cc @@ -3,21 +3,20 @@ * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * In applying this licence, ECMWF does not waive the privileges and immGeometryies - * granted to it by virtue of its status as an intergovernmental organisation - * nor does it submit to any jurisdiction. + * In applying this licence, ECMWF does not waive the privileges and + * immGeometryies granted to it by virtue of its status as an intergovernmental + * organisation nor does it submit to any jurisdiction. */ #include "atlas/util/Geometry.h" #include -#include "eckit/geometry/Point2.h" -#include "eckit/geometry/Point3.h" - #include "atlas/library/config.h" #include "atlas/runtime/Exception.h" #include "atlas/util/Constants.h" +#include "eckit/geometry/Point2.h" +#include "eckit/geometry/Point3.h" namespace atlas { @@ -25,16 +24,15 @@ namespace geometry { namespace detail { void GeometrySphere::lonlat2xyz(const Point2& lonlat, Point3& xyz) const { #if ATLAS_ECKIT_VERSION_AT_LEAST(1, 24, 0) - Sphere::convertSphericalToCartesian(radius_, lonlat, xyz, 0., true); + Sphere::convertSphericalToCartesian(radius_, lonlat, xyz, 0., true); #else - Sphere::convertSphericalToCartesian(radius_, lonlat, xyz); + Sphere::convertSphericalToCartesian(radius_, lonlat, xyz); #endif } void GeometrySphere::xyz2lonlat(const Point3& xyz, Point2& lonlat) const { - Sphere::convertCartesianToSpherical(radius_, xyz, lonlat); + Sphere::convertCartesianToSpherical(radius_, xyz, lonlat); } - /// @brief Calculate great-cricle course between points /// /// @details Calculates the direction (clockwise from north) of a great-circle @@ -45,7 +43,10 @@ void GeometrySphere::xyz2lonlat(const Point3& xyz, Point2& lonlat) const { /// @ref https://en.wikipedia.org/wiki/Great-circle_navigation /// std::pair greatCircleCourse(const Point2& lonLat1, - const Point2& lonLat2) { + const Point2& lonLat2) { + if (lonLat1 == lonLat2) { + return std::make_pair(0., 0.); + } const auto lambda1 = lonLat1[0] * util::Constants::degreesToRadians(); const auto lambda2 = lonLat2[0] * util::Constants::degreesToRadians(); @@ -71,71 +72,76 @@ std::pair greatCircleCourse(const Point2& lonLat1, alpha2 * util::Constants::radiansToDegrees()); }; - -} // namespace detail -} // namespace geometry +} // namespace detail +} // namespace geometry extern "C" { // ------------------------------------------------------------------ // C wrapper interfaces to C++ routines Geometry::Implementation* atlas__Geometry__new_name(const char* name) { - Geometry::Implementation* geometry; - { - Geometry handle{std::string{name}}; - geometry = handle.get(); - geometry->attach(); - } - geometry->detach(); - return geometry; + Geometry::Implementation* geometry; + { + Geometry handle{std::string{name}}; + geometry = handle.get(); + geometry->attach(); + } + geometry->detach(); + return geometry; } -geometry::detail::GeometryBase* atlas__Geometry__new_radius(const double radius) { - Geometry::Implementation* geometry; - { - Geometry handle{radius}; - geometry = handle.get(); - geometry->attach(); - } - geometry->detach(); - return geometry; +geometry::detail::GeometryBase* atlas__Geometry__new_radius( + const double radius) { + Geometry::Implementation* geometry; + { + Geometry handle{radius}; + geometry = handle.get(); + geometry->attach(); + } + geometry->detach(); + return geometry; } void atlas__Geometry__delete(Geometry::Implementation* This) { - ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); - delete This; + ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); + delete This; } -void atlas__Geometry__xyz2lonlat(Geometry::Implementation* This, const double x, const double y, const double z, - double& lon, double& lat) { - ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); - PointLonLat lonlat; - This->xyz2lonlat(PointXYZ{x, y, z}, lonlat); - lon = lonlat.lon(); - lat = lonlat.lat(); +void atlas__Geometry__xyz2lonlat(Geometry::Implementation* This, const double x, + const double y, const double z, double& lon, + double& lat) { + ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); + PointLonLat lonlat; + This->xyz2lonlat(PointXYZ{x, y, z}, lonlat); + lon = lonlat.lon(); + lat = lonlat.lat(); } -void atlas__Geometry__lonlat2xyz(Geometry::Implementation* This, const double lon, const double lat, double& x, +void atlas__Geometry__lonlat2xyz(Geometry::Implementation* This, + const double lon, const double lat, double& x, double& y, double& z) { - ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); - PointXYZ xyz; - This->lonlat2xyz(PointLonLat{lon, lat}, xyz); - x = xyz.x(); - y = xyz.y(); - z = xyz.z(); + ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); + PointXYZ xyz; + This->lonlat2xyz(PointLonLat{lon, lat}, xyz); + x = xyz.x(); + y = xyz.y(); + z = xyz.z(); } -double atlas__Geometry__distance_lonlat(Geometry::Implementation* This, const double lon1, const double lat1, +double atlas__Geometry__distance_lonlat(Geometry::Implementation* This, + const double lon1, const double lat1, const double lon2, const double lat2) { - ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); - return This->distance(PointLonLat{lon1, lat1}, PointLonLat{lon2, lat2}); + ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); + return This->distance(PointLonLat{lon1, lat1}, PointLonLat{lon2, lat2}); } -double atlas__Geometry__distance_xyz(Geometry::Implementation* This, const double x1, const double y1, const double z1, - const double x2, const double y2, const double z2) { - ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); - return This->distance(PointXYZ{x1, y1, z1}, PointXYZ{x2, y2, z2}); +double atlas__Geometry__distance_xyz(Geometry::Implementation* This, + const double x1, const double y1, + const double z1, const double x2, + const double y2, const double z2) { + ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); + return This->distance(PointXYZ{x1, y1, z1}, PointXYZ{x2, y2, z2}); } double atlas__Geometry__radius(Geometry::Implementation* This) { - ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); - return This->radius(); + ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); + return This->radius(); } double atlas__Geometry__area(Geometry::Implementation* This) { - ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); - return This->area(); + ATLAS_ASSERT(This != nullptr, "Cannot access uninitialised atlas_Geometry"); + return This->area(); } } // ------------------------------------------------------------------ From dc24f5a2133aaedb5518cd599593545c65cd8f39 Mon Sep 17 00:00:00 2001 From: odlomax Date: Mon, 4 Mar 2024 20:53:41 +0000 Subject: [PATCH 5/7] Removed unecessary headers. --- src/tests/util/test_unitsphere.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/tests/util/test_unitsphere.cc b/src/tests/util/test_unitsphere.cc index 5343ac561..8bc249c6a 100644 --- a/src/tests/util/test_unitsphere.cc +++ b/src/tests/util/test_unitsphere.cc @@ -5,9 +5,6 @@ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. */ -#include - -#include "atlas/util/Constants.h" #include "atlas/util/Geometry.h" #include "atlas/util/Point.h" #include "tests/AtlasTestEnvironment.h" From ffd61b3fae114c403b2958bd5344e1b3f7e4bebe Mon Sep 17 00:00:00 2001 From: odlomax Date: Mon, 4 Mar 2024 20:55:05 +0000 Subject: [PATCH 6/7] Fixed mangled copyright. --- src/atlas/util/Geometry.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/atlas/util/Geometry.cc b/src/atlas/util/Geometry.cc index ddb699e19..d39d1dc5e 100644 --- a/src/atlas/util/Geometry.cc +++ b/src/atlas/util/Geometry.cc @@ -3,9 +3,9 @@ * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * In applying this licence, ECMWF does not waive the privileges and - * immGeometryies granted to it by virtue of its status as an intergovernmental - * organisation nor does it submit to any jurisdiction. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation + * nor does it submit to any jurisdiction. */ #include "atlas/util/Geometry.h" From 27ddc3bd366adf76db530168cf5f5a5743ebbdba Mon Sep 17 00:00:00 2001 From: Willem Deconinck Date: Wed, 6 Mar 2024 09:54:42 +0100 Subject: [PATCH 7/7] Fixup: atlas/util/Point.h was already included --- src/atlas/util/Geometry.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/atlas/util/Geometry.cc b/src/atlas/util/Geometry.cc index d39d1dc5e..a274d2ead 100644 --- a/src/atlas/util/Geometry.cc +++ b/src/atlas/util/Geometry.cc @@ -15,8 +15,6 @@ #include "atlas/library/config.h" #include "atlas/runtime/Exception.h" #include "atlas/util/Constants.h" -#include "eckit/geometry/Point2.h" -#include "eckit/geometry/Point3.h" namespace atlas {