@@ -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+
98136CASE (" cubedsphere_scalar_interpolation" ) {
99137
100138 const auto fixture = CubedSphereInterpolationFixture{};
0 commit comments