Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMelt committed Dec 9, 2024
1 parent 81f0a5c commit e5c31a6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ else()
set(NSDG_NetCDF_Library "netcdf-cxx4")
else()
set(NSDG_NetCDF_Library "netcdf_c++4")
set(NSDG_NetCDF_Library "netcdf-cxx4")
endif()
endif()
target_include_directories(nextsimlib PUBLIC "${netCDF_INCLUDE_DIR}")
Expand Down
45 changes: 26 additions & 19 deletions core/test/HaloExchange_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
using Slice = ArraySlicer::Slice;
using SliceIter = ArraySlicer::SliceIter;

const auto nx = 9;
const auto ny = 5;
const auto nz = 3;
const auto nx = 6;
const auto ny = 3;
const auto nz = 2;

namespace Nextsim {

Expand Down Expand Up @@ -55,7 +55,7 @@ MPI_TEST_CASE("test halo exchange", 3)
// Create the ParametricMesh object
auto CoordinateSystem = Nextsim::CARTESIAN;
ParametricMesh smesh(CoordinateSystem);
smesh.nx = nx + 2;
smesh.nx = localNx + 2;
smesh.ny = ny + 2;
smesh.nnodes = smesh.nx * smesh.ny;
smesh.nelements = smesh.nnodes;
Expand All @@ -66,13 +66,32 @@ MPI_TEST_CASE("test halo exchange", 3)
smesh.vertices(i * ny + j, 1) = j;
}
}
// DGModelArray::ma2dg<DG>(testfield, dgvec);

DGVector<DG> dgvec(smesh);

ModelArraySlice source(testfield, { { {}, {} } });
SliceIter::MultiDim eigDim = { smesh.nx, smesh.ny };
Slice centreBlock { { { 1, -1 }, { 1, -1 } } };
SliceIter eigCentre(centreBlock, eigDim);
Slice wholeArray { { {}, {} } };

source.copyToDataSlice(dgvec, { { { 1, localNx + 1 }, { 1, ny + 1 } } });
// all spatial dims are collapsed into the first dimension (0). The other dimensions are for
// higher-order DG components
auto eig0 = dgvec.array().col(0);

testfield[wholeArray].copyToSlicedBuffer(eig0, eigCentre);
// testfield[{{{}, {}}}].copyToSlicedBuffer(eig0, { { { 1, localNx + 1 }, { 1, ny + 1 } } });

for (size_t j = 0; j < ny; ++j) {
for (size_t i = 0; i < localNx; ++i) {
printf("testfield[%zu, %zu, 0] = %f\n", i, j, testfield(i, j));
}
}
for (size_t j = 0; j < smesh.ny; ++j) {
for (size_t i = 0; i < smesh.nx; ++i) {
size_t targetPoint = ModelArray::indexFromLocation(ModelArray::Type::DG, { i, j });
printf("dgvec[%zu, %zu, 0] = %f\n", i, j, dgvec(targetPoint, 0));
}
}

int ierr;
enum Edge { BOTTOM, RIGHT, TOP, LEFT, N_EDGE };
Expand All @@ -97,17 +116,6 @@ MPI_TEST_CASE("test halo exchange", 3)

slice.copyToBuffer(vectorBuffer);

// ModelArray source(ModelArray::Type::H);
// source.resize();
// // Fill with data
// for (size_t i = 0; i < nx; ++i) {
// for (size_t j = 0; j < ny; j++) {
// source(i, j) = j + mx * (i);
// }
// }

// CHECK(source(14, 12) == 12 + mx * (14));

// ierr = MPI_Scatterv()

if (test_rank == 0) {
Expand All @@ -119,5 +127,4 @@ MPI_TEST_CASE("test halo exchange", 3)
exit(1);
}
}

}
2 changes: 1 addition & 1 deletion run/config_benchmark.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[model]
init_file = init_benchmark_32x32.nc
start = 2023-01-01T00:00:00Z
stop = 2023-01-03T00:00:00Z
stop = 2023-01-02T00:00:00Z
time_step = P0-0T00:02:00

[Modules]
Expand Down

0 comments on commit e5c31a6

Please sign in to comment.