Skip to content

Commit 62c375f

Browse files
authored
Add spherical-mean-value to interpolation factory (#349)
1 parent 5ae6339 commit 62c375f

File tree

2 files changed

+110
-27
lines changed

2 files changed

+110
-27
lines changed

src/atlas/interpolation/method/MethodFactory.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "unstructured/FiniteElement.h"
2929
#include "unstructured/ConservativeSphericalPolygonInterpolation.h"
3030
#include "unstructured/UnstructuredBilinearLonLat.h"
31+
#include "unstructured/SphericalMeanValue.h"
3132

3233

3334
namespace atlas {
@@ -55,6 +56,7 @@ void force_link() {
5556
MethodBuilder<method::SphericalVector>();
5657
MethodBuilder<method::Binning>();
5758
MethodBuilder<method::ConservativeSphericalPolygonInterpolation>();
59+
MethodBuilder<method::SphericalMeanValue>();
5860
}
5961
} link;
6062
}

src/tests/interpolation/test_interpolation_spherical_vector.cc

Lines changed: 108 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -129,33 +129,29 @@ struct FieldSpecFixtures {
129129
// Helper struct to key different interpolation schemes to strings
130130
struct InterpSchemeFixtures {
131131
static const Config& get(const std::string& fixture) {
132-
static const auto cubedsphereBilinear =
133-
option::type("cubedsphere-bilinear") | Config("adjoint", true);
134-
static const auto finiteElement =
135-
option::type("finite-element") | Config("adjoint", true);
136-
static const auto structuredLinear = option::type("structured-bilinear") |
137-
option::halo(1) |
138-
Config("adjoint", true);
139-
static const auto structuredCubic = option::type("structured-bicubic") |
140-
option::halo(2) |
141-
Config("adjoint", true);
142-
static const auto sphericalVector =
143-
option::type("spherical-vector") | Config("adjoint", true);
144-
145-
static const auto interpSchemes = std::map<std::string_view, Config>{
146-
{"cubedsphere_bilinear", cubedsphereBilinear},
147-
{"finite_element", finiteElement},
148-
{"structured_linear", structuredLinear},
149-
{"structured_cubic", structuredCubic},
150-
{"cubedsphere_bilinear_spherical",
151-
sphericalVector | Config("scheme", cubedsphereBilinear)},
152-
{"finite_element_spherical",
153-
sphericalVector | Config("scheme", finiteElement)},
154-
{"structured_linear_spherical",
155-
sphericalVector | Config("scheme", structuredLinear)},
156-
{"structured_cubic_spherical",
157-
sphericalVector | Config("scheme", structuredCubic)}};
158-
return interpSchemes.at(fixture);
132+
static const auto cubedsphereBilinear = option::type("cubedsphere-bilinear") | Config("adjoint", true);
133+
static const auto sphericalMeanValue = option::type("spherical-mean-value") | Config("normalisation", false);
134+
static const auto sphericalMeanValueNormalised =
135+
option::type("spherical-mean-value") | Config("normalisation", true);
136+
static const auto finiteElement = option::type("finite-element") | Config("adjoint", true);
137+
static const auto structuredLinear =
138+
option::type("structured-bilinear") | option::halo(1) | Config("adjoint", true);
139+
static const auto structuredCubic =
140+
option::type("structured-bicubic") | option::halo(2) | Config("adjoint", true);
141+
static const auto sphericalVector = option::type("spherical-vector") | Config("adjoint", true);
142+
143+
static const auto interpSchemes = std::map<std::string_view, Config>{
144+
{"cubedsphere_bilinear", cubedsphereBilinear},
145+
{"finite_element", finiteElement},
146+
{"structured_linear", structuredLinear},
147+
{"structured_cubic", structuredCubic},
148+
{"cubedsphere_bilinear_spherical", sphericalVector | Config("scheme", cubedsphereBilinear)},
149+
{"finite_element_spherical", sphericalVector | Config("scheme", finiteElement)},
150+
{"structured_linear_spherical", sphericalVector | Config("scheme", structuredLinear)},
151+
{"structured_cubic_spherical", sphericalVector | Config("scheme", structuredCubic)},
152+
{"spherical_mean_value", sphericalVector | Config("scheme", sphericalMeanValue)},
153+
{"spherical_mean_value_normalised", sphericalVector | Config("scheme", sphericalMeanValueNormalised)}};
154+
return interpSchemes.at(fixture);
159155
}
160156
};
161157

@@ -486,6 +482,91 @@ CASE("structured columns O96 vector interpolation (2d-field, 2-vector, hi-res)")
486482
testInterpolation<Rank2dField>((config));
487483
}
488484

485+
CASE("cubed sphere CS-LFR-48 scalar spherical mean value interpolation (3d-field, scalar)") {
486+
const auto config = Config("source_fixture", "cubedsphere_mesh")
487+
.set("target_fixture", "gaussian_mesh")
488+
.set("field_spec_fixture", "scalar")
489+
.set("interp_fixture", "spherical_mean_value")
490+
.set("file_id", "spherical_vector_cs2")
491+
.set("tol", 0.00096);
492+
493+
testInterpolation<Rank3dField>((config));
494+
}
495+
496+
CASE("cubed sphere CS-LFR-48 scalar normalised spherical mean value interpolation (3d-field, scalar)") {
497+
const auto config = Config("source_fixture", "cubedsphere_mesh")
498+
.set("target_fixture", "gaussian_mesh")
499+
.set("field_spec_fixture", "scalar")
500+
.set("interp_fixture", "spherical_mean_value_normalised")
501+
.set("file_id", "spherical_vector_cs2")
502+
.set("tol", 0.00096);
503+
504+
testInterpolation<Rank3dField>((config));
505+
}
506+
507+
CASE("cubed sphere CS-LFR-48 vector spherical mean value interpolation (3d-field, 2-vector)") {
508+
const auto config = Config("source_fixture", "cubedsphere_mesh")
509+
.set("target_fixture", "gaussian_mesh")
510+
.set("field_spec_fixture", "2vector")
511+
.set("interp_fixture", "spherical_mean_value")
512+
.set("file_id", "spherical_vector_cs2")
513+
.set("tol", 0.00018);
514+
515+
testInterpolation<Rank3dField>((config));
516+
}
517+
518+
519+
CASE("cubed sphere CS-LFR-48 vector normalised spherical mean value interpolation (3d-field, 2-vector)") {
520+
const auto config = Config("source_fixture", "cubedsphere_mesh")
521+
.set("target_fixture", "gaussian_mesh")
522+
.set("field_spec_fixture", "2vector")
523+
.set("interp_fixture", "spherical_mean_value_normalised")
524+
.set("file_id", "spherical_vector_cs2")
525+
.set("tol", 0.00018);
526+
527+
testInterpolation<Rank3dField>((config));
528+
}
529+
530+
CASE("cubed sphere CS-LFR-48 vector spherical mean value interpolation (3d-field, 3-vector)") {
531+
const auto config = Config("source_fixture", "cubedsphere_mesh")
532+
.set("target_fixture", "gaussian_mesh")
533+
.set("field_spec_fixture", "3vector")
534+
.set("interp_fixture", "spherical_mean_value")
535+
.set("file_id", "spherical_vector_cs3")
536+
.set("tol", 0.00096);
537+
538+
testInterpolation<Rank3dField>((config));
539+
}
540+
541+
CASE("cubed sphere CS-LFR-48 vector normalised spherical mean value interpolation (3d-field, 3-vector)") {
542+
const auto config = Config("source_fixture", "cubedsphere_mesh")
543+
.set("target_fixture", "gaussian_mesh")
544+
.set("field_spec_fixture", "3vector")
545+
.set("interp_fixture", "spherical_mean_value_normalised")
546+
.set("file_id", "spherical_vector_cs3")
547+
.set("tol", 0.00096);
548+
549+
testInterpolation<Rank3dField>((config));
550+
}
551+
552+
CASE("cubed sphere CS-LFR-48 (spherical mean value) to empty point cloud") {
553+
const auto config = Config("source_fixture", "cubedsphere_mesh")
554+
.set("target_fixture", "empty_point_cloud")
555+
.set("field_spec_fixture", "2vector")
556+
.set("interp_fixture", "spherical_mean_value");
557+
558+
testInterpolation<Rank2dField>((config));
559+
}
560+
561+
CASE("cubed sphere CS-LFR-48 (normalised spherical mean value) to empty point cloud") {
562+
const auto config = Config("source_fixture", "cubedsphere_mesh")
563+
.set("target_fixture", "empty_point_cloud")
564+
.set("field_spec_fixture", "2vector")
565+
.set("interp_fixture", "spherical_mean_value_normalised");
566+
567+
testInterpolation<Rank2dField>((config));
568+
}
569+
489570
CASE("separate vector field components") {
490571
const auto sourceFunctionSpace =
491572
FunctionSpaceFixtures::get("structured_columns");

0 commit comments

Comments
 (0)