Skip to content

Commit

Permalink
bug fix in the wrong index; test different grids
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrdar committed Jan 21, 2025
1 parent 9de94d8 commit 84a884b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
7 changes: 2 additions & 5 deletions src/atlas/interpolation/AssembleGlobalMatrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ std::unique_ptr<atlas::linalg::SparseMatrixStorage> assemble_global_matrix(
auto src_fs = interpolation.source();
auto tgt_fs = interpolation.target();

ATLAS_DEBUG_VAR( src_fs.type() );
ATLAS_DEBUG_VAR( tgt_fs.type() );

auto cache = interpolation.createCache();
const auto& original_matrix = interpolation::MatrixCache( cache ).matrix();

Expand Down Expand Up @@ -134,14 +131,14 @@ std::unique_ptr<atlas::linalg::SparseMatrixStorage> assemble_global_matrix(
std::vector<gidx_t> all_rows;
std::vector<double> all_vals;
if (mpi::comm().rank() == mpi_root) {
size_t pos = 0;
all_cols.resize(ntriplets);
all_rows.resize(ntriplets);
all_vals.resize(ntriplets);
size_t pos = 0;
size_t pos_root = 0;
for (int i = 0; i < mpi::comm().size(); ++i) {
if (i == mpi_root) {
pos += triplet_sizes[i - 1];
pos += (i == 0) ? 0 : triplet_sizes[i - 1];
pos_root = pos;
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,7 @@ std::string output_gridname(const std::string& default_grid) {

CASE("test_interpolation_structured using grid API") {

// USAGE:
// atlas_test_interpolation_serialized_sparsematrix --input-grid <grid> --output-grid <grid> --scheme <scheme>
//
// For available schemes see above
// Using the grid API we can hide interpolation method specific requirements
// such as which functionspace needs to be set-up.

auto do_global_matrix = [&](const std::string scheme_str, const Grid& input_grid, const Grid& output_grid, const int mpi_root) {
auto do_global_matrix = [&](const std::string scheme_str, const Grid& input_grid, const Grid& output_grid, const int mpi_root) {
Interpolation interpolator;
Config scheme = config_scheme(scheme_str);
auto scheme_type = scheme.getString("type");
Expand Down Expand Up @@ -123,16 +116,10 @@ CASE("test_interpolation_structured using grid API") {
view_in(j) = util::function::vortex_rollup(lonlat_in(j,0),lonlat_in(j,1), 1.);
}
interpolator.execute(field_in, tgt_field);
output::Gmsh gmsh("par-"+scheme.getString("name") + "-output-section" + std::to_string(_subsection) + ".msh",
Config("coordinates", "lonlat") | Config("ghost", "true"));
if( functionspace::NodeColumns(tgt_field.functionspace())) {
gmsh.write(functionspace::NodeColumns(tgt_field.functionspace()).mesh());
tgt_field.haloExchange();
gmsh.write(tgt_field);
}
}

auto matrix = interpolation::assemble_global_matrix(interpolator, mpi_root);
return;

// Allocate and initialise own memory here to show possibilities
std::vector<double> src_data(input_grid.size());
Expand All @@ -154,10 +141,6 @@ CASE("test_interpolation_structured using grid API") {
ATLAS_TRACE_SCOPE("output from mpi_root") {
mpi::Scope mpi_scope("self");
auto tgt_field = Field("tgt",tgt_data.data(),array::make_shape(tgt_data.size())); // wrap
output::Gmsh gmsh(scheme.getString("name") + "-output-section" + std::to_string(_subsection) + ".msh",
Config("coordinates", "lonlat") | Config("ghost", "true"));
gmsh.write(MeshGenerator("structured",util::Config("three_dimensional",true)).generate(output_grid));
gmsh.write(tgt_field, StructuredColumns(output_grid));
}
}

Expand All @@ -172,10 +155,11 @@ CASE("test_interpolation_structured using grid API") {
do_global_matrix("quasicubic", input_grid, output_grid, 0);
do_global_matrix("conservative", input_grid, output_grid, 2); // run with 3 mpi tasks
do_global_matrix("finite-element", input_grid, output_grid, 0);
//do_global_matrix("grid-box-average", input_grid, output_grid, 1);
};

test_2mpi_tasks(Grid{input_gridname("O6")}, Grid{output_gridname("O80")});
test_2mpi_tasks(Grid("O6"), Grid("O80"));
test_2mpi_tasks(Grid("H16"), Grid("O64"));
test_2mpi_tasks(Grid("O8"), Grid("H15"));
}


Expand Down

0 comments on commit 84a884b

Please sign in to comment.