Skip to content

Commit 010ac88

Browse files
committed
This might fail some CI...
1 parent 930c10f commit 010ac88

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/tests/interpolation/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ ecbuild_add_test( TARGET atlas_test_interpolation_structured2D_to_points
129129
ecbuild_add_test( TARGET atlas_test_interpolation_cubedsphere
130130
SOURCES test_interpolation_cubedsphere.cc
131131
LIBS atlas
132-
MPI 6
132+
MPI 3
133+
OMP 3
133134
CONDITION eckit_HAVE_MPI AND MPI_SLOTS GREATER_EQUAL 6
134135
ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
135136
)

src/tests/interpolation/test_interpolation_cubedsphere.cc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,44 @@ double dotProd(const Field& a, const Field& b) {
9595
return prod;
9696
}
9797

98+
CASE("cubedsphere_to_cubedsphere_interpolation") {
99+
100+
// Check that interpolation scheme correctly maps a cubedsphere on to itself.
101+
102+
const auto fixture = CubedSphereInterpolationFixture{};
103+
auto sourceField = fixture.sourceFunctionSpace_.createField<double>(option::name("test_field"));
104+
{
105+
const auto lonlat = array::make_view<double, 2>(fixture.sourceFunctionSpace_.lonlat());
106+
auto view = array::make_view<double, 1>(sourceField);
107+
for (idx_t i = 0; i < fixture.sourceFunctionSpace_.size(); ++i) {
108+
view(i) = util::function::vortex_rollup(lonlat(i, LON), lonlat(i, LAT), 1.);
109+
}
110+
}
111+
const auto targetMesh = MeshGenerator("cubedsphere_dual").generate(fixture.sourceGrid_, fixture.targetPartitioner_);
112+
const auto targetFunctionSpace = functionspace::CubedSphereNodeColumns(targetMesh);
113+
114+
const auto scheme = util::Config("type", "cubedsphere-bilinear");
115+
const auto interp = Interpolation(scheme, fixture.sourceFunctionSpace_, targetFunctionSpace);
116+
117+
auto targetField = targetFunctionSpace.createField<double>(option::name("test_field"));
118+
interp.execute(sourceField, targetField);
119+
targetField.haloExchange();
120+
121+
// iterate over target field and check that error is zero.
122+
{
123+
const auto lonlat = array::make_view<double, 2>(targetFunctionSpace.lonlat());
124+
auto targetView = array::make_view<double, 1>(targetField);
125+
for (idx_t i = 0; i < targetFunctionSpace.size(); ++i) {
126+
const auto val = util::function::vortex_rollup(lonlat(i, LON), lonlat(i, LAT), 1.);
127+
EXPECT_APPROX_EQ(targetView(i), val, 1e-14);
128+
}
129+
}
130+
131+
// output source and target fields.
132+
gmshOutput("cubedsphere_to_cubedsphere_source.msh", FieldSet{sourceField});
133+
gmshOutput("cubedsphere_to_cubedsphere_target.msh", FieldSet{targetField});
134+
}
135+
98136
CASE("cubedsphere_scalar_interpolation") {
99137

100138
const auto fixture = CubedSphereInterpolationFixture{};

0 commit comments

Comments
 (0)