Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
6d8b40e
add a test function for limiter testing
sbrdar Sep 29, 2025
c703e79
add util::function::SlottedCylinder based on Zalesak (1978)
sbrdar Sep 30, 2025
5051176
introduce limit_ to indentify problematic target values in the 2nd or…
sbrdar Sep 30, 2025
9664d78
1) implement matrix-free 2nd order for cell2cell; 2) reactivate the u…
sbrdar Oct 1, 2025
6c14572
implement other combination of 2nd order matrix free cons. interpolation
sbrdar Oct 1, 2025
eeef9c2
cleanup
sbrdar Oct 1, 2025
0136983
rearrange code lines
sbrdar Oct 1, 2025
184f9db
cell2cell limiter for the 2nd order - close but not working yet
sbrdar Oct 2, 2025
a605e85
make limiter work for cell-to-cell
sbrdar Oct 2, 2025
1ad2cbc
introduce different limiters: none, zeroslope, clip
sbrdar Oct 13, 2025
47e13d5
rename limit_ to limiter_
sbrdar Oct 13, 2025
17bae02
improve the clip limiter
sbrdar Oct 13, 2025
cd9130b
use relative-to-source conservation error (tnx M. Diamantakis)
sbrdar Oct 13, 2025
ab49056
remove ConservativeSpeericalPolygon::Data::print, it is reported in i…
sbrdar Oct 13, 2025
7d6f831
1) introduce conservation_error_percent_of_source alongside with cons…
sbrdar Oct 14, 2025
52db115
cosmetics
sbrdar Oct 14, 2025
08b7ff3
add scaling of the slotted_cylinder initial data to study the limiters
sbrdar Oct 14, 2025
d03c4fd
forgot to add files for the last commit
sbrdar Oct 14, 2025
85a805d
use ATLAS_INTERPOLATION_LIMITER = 1 to output the impact of limiter i…
sbrdar Oct 16, 2025
fe9536a
fix detector of the zeroslope limiter to work with XStep initial data
sbrdar Oct 14, 2025
fc83a7f
fix limiter detection thresholds and make sure the limiter does not c…
sbrdar Oct 16, 2025
e11425a
improve namings in the cons. interp. metadata
sbrdar Oct 16, 2025
c269d45
make unit test pass again
sbrdar Oct 17, 2025
60c0b11
fix a bug in matrix_free 2nd order for cell2node and node2cell
sbrdar Oct 17, 2025
1456d0b
move xstep function away from the poles
sbrdar Oct 17, 2025
76b843c
make 2nd order cons. matrix-free implementation work plausibly on the…
sbrdar Oct 17, 2025
01bd467
add interpolation metadata on source and target mass: mass.src, mass.tgt
sbrdar Oct 27, 2025
6d4c3ba
Merge branch 'develop' into feature/cons_interp_limiter
sbrdar Jan 20, 2026
01b2533
1) move cons. limiter to a separate file; 2) bug fixes (tnx Willem)
sbrdar Feb 4, 2026
6d867f8
remove warnings
sbrdar Feb 4, 2026
1d0b29d
bug fix for the matrix-free version
sbrdar Feb 4, 2026
7cd3d4d
tweak ATLAS_INTERPOLATION_LIMITER to allow showing of violation+colla…
sbrdar Feb 4, 2026
31800b6
compute limiter mass change when --statistics.conservation is used
sbrdar Feb 23, 2026
25cdfd7
Merge branch 'develop' into feature/cons_interp_limiter
sbrdar Feb 23, 2026
375b6f2
remove superfluous std out
sbrdar Feb 23, 2026
48fa629
fix unit tests
sbrdar Feb 23, 2026
b653191
fix the effective area of zeroslope limiter (ATLAS_INTERPOLATION_LIMI…
sbrdar Feb 23, 2026
3bc8d20
prepare to limit target cells caused by a given source cell (on the s…
sbrdar Feb 24, 2026
edc670e
encapsule limiting due to one source cell in a separate function
sbrdar Feb 24, 2026
1f6f91b
encapsulate detection of tcell out of the limit function
sbrdar Feb 24, 2026
ef383d5
parallel version of the conservative -zeroslope- limiter (but only fo…
sbrdar Feb 26, 2026
ea918d5
fix the limiter mass-loss computation, now the parallel version of li…
sbrdar Feb 26, 2026
f98caa3
fix the unit tests - it never checked for the interpolation accuracy …
sbrdar Feb 27, 2026
c9927db
initialise Statistics (Copilot suggestion)
sbrdar Feb 27, 2026
eff03e0
correct scaling for SlottedCylinder functions
sbrdar Feb 27, 2026
dbd3b2f
Update src/atlas/interpolation/method/unstructured/ConservativeSpheri…
sbrdar Feb 27, 2026
50a7401
InterpolationParameters carry polygon ids and not cell ids (correctly…
sbrdar Feb 27, 2026
8a6ea84
bug fix in limiter exchange of source cell ids
sbrdar Feb 27, 2026
2132532
improve code coverage
sbrdar Mar 2, 2026
01fc2e5
revert CMakeLists entry for SparseMatrixTriplet.h
sbrdar Mar 2, 2026
db98345
cleanup in the unit test for conservative interpolation
sbrdar Mar 2, 2026
52897a0
expand the cons interpolation unit test to check for matrix free inte…
sbrdar Mar 2, 2026
fc18961
The config option -validate- should be not be used, rather some of th…
sbrdar Mar 2, 2026
024fb0d
trying to fixing the CI
sbrdar Mar 3, 2026
5fcd8c1
make matrix-free and matrix-version identical (some differences still…
sbrdar Mar 3, 2026
2fbc016
make matrix-free and matrix-version give identical results
sbrdar Mar 3, 2026
8178311
tidy up the cons interpolation unit testsa
sbrdar Mar 3, 2026
c1713ba
better output in the unit test
sbrdar Mar 3, 2026
e267b20
add test for the 2nd order cons. limiter
sbrdar Mar 5, 2026
cfdf36a
add conservation after the limiter to the unit test
sbrdar Mar 5, 2026
cb16cb4
fixing the CI: tiny threshold change in the cons. interpolation unit …
sbrdar Mar 5, 2026
2039af4
consistent naming in util/function/
sbrdar Mar 5, 2026
3e2d01b
clean up
sbrdar Mar 5, 2026
a401d65
Merge branch 'develop' into feature/cons_interp_limiter
sbrdar Mar 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/atlas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@ interpolation/method/structured/kernels/QuasiCubic3DKernel.h
interpolation/method/structured/kernels/QuasiCubicHorizontalKernel.h
interpolation/method/unstructured/ConservativeSphericalPolygonInterpolation.cc
interpolation/method/unstructured/ConservativeSphericalPolygonInterpolation.h
interpolation/method/unstructured/ConservativeSphericalPolygonInterpolationLimiter.cc
interpolation/method/unstructured/ConservativeSphericalPolygonInterpolationLimiter.h
interpolation/method/unstructured/FiniteElement.cc
interpolation/method/unstructured/FiniteElement.h
interpolation/method/unstructured/SphericalMeanValue.cc
Expand Down Expand Up @@ -733,8 +735,8 @@ linalg/sparse/SparseMatrixMultiply_OpenMP.cc
linalg/sparse/SparseMatrixStorage.cc
linalg/sparse/SparseMatrixStorage.h
linalg/sparse/SparseMatrixToTriplets.h
linalg/sparse/SparseMatrixView.h
linalg/sparse/SparseMatrixTriplet.h
linalg/sparse/SparseMatrixView.h
linalg/dense.h
linalg/dense/Backend.h
linalg/dense/Backend.cc
Expand Down Expand Up @@ -901,14 +903,18 @@ util/detail/Cache.h
util/detail/KDTree.h
util/detail/filesystem.cc
util/detail/filesystem.h
util/function/MDPI_functions.h
util/function/MDPI_functions.cc
util/function/MDPI.h
util/function/MDPI.cc
util/function/SlottedCylinder.h
util/function/SlottedCylinder.cc
util/function/SolidBodyRotation.h
util/function/SolidBodyRotation.cc
util/function/SphericalHarmonic.h
util/function/SphericalHarmonic.cc
util/function/VortexRollup.h
util/function/VortexRollup.cc
util/function/XStep.h
util/function/XStep.cc
)


Expand Down
2 changes: 0 additions & 2 deletions src/atlas/interpolation/AssembleGlobalMatrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ linalg::SparseMatrixStorage assemble_global_matrix(const Interpolation& interpol


linalg::SparseMatrixStorage assemble_global_matrix(size_t nrows, size_t ncols, const Interpolation& interpolation, int mpi_root) {


auto src_fs = interpolation.source();
auto tgt_fs = interpolation.target();

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "atlas/functionspace.h"
#include "atlas/interpolation/method/Method.h"
// #include "atlas/interpolation/method/unstructured/ConservativeSphericalPolygonInterpolationLimiter.h"
#include "atlas/util/ConvexSphericalPolygon.h"

namespace atlas {
Expand All @@ -22,6 +23,9 @@ namespace method {
using Indices = std::vector<idx_t>;


class ConservativeSphericalPolygonInterpolationLimiter;


class ConservativeSphericalPolygonInterpolation : public Method {
public:
struct InterpolationParameters { // one polygon intersection
Expand All @@ -37,10 +41,10 @@ class ConservativeSphericalPolygonInterpolation : public Method {
size_t footprint() const override;
static std::string static_type() { return "ConservativeSphericalPolygonInterpolation"; }
std::string type() const override { return static_type(); }
void print(std::ostream& out) const;

private:
friend class ConservativeSphericalPolygonInterpolation;
friend class ConservativeSphericalPolygonInterpolationLimiter;

struct PolygonsData {
enum class Context { SOURCE, TARGET } context;
Expand Down Expand Up @@ -73,6 +77,7 @@ class ConservativeSphericalPolygonInterpolation : public Method {
} timings;

std::vector<InterpolationParameters> tgt_iparam_;
std::vector<InterpolationParameters> src_iparam_; // only for validate_ and limiter_

// Reconstructible if need be
FunctionSpace src_fs_;
Expand Down Expand Up @@ -128,28 +133,36 @@ class ConservativeSphericalPolygonInterpolation : public Method {

private:
friend class ConservativeSphericalPolygonInterpolation;
friend class ConservativeSphericalPolygonInterpolationLimiter;
Cache(std::shared_ptr<InterpolationCacheEntry> entry);
const Data* entry_{nullptr};
};

struct Statistics {
enum Counts {
NUM_SRC_PLG = 0, // index, number of source polygons
NUM_TGT_PLG, // index, number of target polygons
NUM_INT_PLG, // index, number of intersection polygons
NUM_UNCVR_FULL_TGT, // index, number of completely non covered target polygons
NUM_UNCVR_PART_TGT, // index, number of partially non covered target polygons
NUM_SRC_PLG = 0, // index, number of source polygons
NUM_TGT_PLG, // index, number of target polygons
NUM_INT_PLG, // index, number of intersection polygons
NUM_UNCVR_FULL_TGT, // index, number of completely non covered target polygons
NUM_UNCVR_PART_TGT, // index, number of partially non covered target polygons
NUM_ENUM_SIZE
};
enum Errors {
ERR_TGT_INTERSECTPLG_L1 = 0, // see above
ERR_TGT_INTERSECTPLG_LINF, // see above
ERR_SRCTGT_INTERSECTPLG_DIFF, // index, 1/(unit_sphere.area) ( \sum_{scell} scell.area - \sum{tcell} tcell.area )
ERR_REMAP_CONS, // index, error in mass conservation
ERR_REMAP_L2, // index, error accuracy for given analytical function
ERR_REMAP_LINF, // index, like REMAP_L2 but in L_infinity norm
ERR_TGT_INTERSECTPLG_L1 = 0, // see above
ERR_TGT_INTERSECTPLG_LINF, // see above
ERR_SRCTGT_INTERSECTPLG_DIFF, // index, 1/(unit_sphere.area) ( \sum_{scell} scell.area - \sum{tcell} tcell.area )
ERR_REMAP_CONS, // index, error in mass conservation
ERR_REMAP_RELCONS, // index, error in mass conservation as percentage of source mass
ERR_REMAP_L2, // index, error accuracy for given analytical function
ERR_REMAP_LINF, // index, like REMAP_L2 but in L_infinity norm
ERR_ENUM_SIZE
};
enum Mass {
MASS_SRC = 0, // total source mass
MASS_TGT,
MASS_LIMITER,
MASS_ENUM_SIZE
};
enum Timings {
TIME_SRC_PLG = 0, // index, max time in second per task to build source polygons
TIME_TGT_PLG, // index, max time in second per task to build target polygons
Expand Down Expand Up @@ -178,13 +191,14 @@ class ConservativeSphericalPolygonInterpolation : public Method {
MEM_IPARAM, // index, max memory size per task of stored intersection parameters
MEM_ENUM_SIZE
};
std::array<int, NUM_ENUM_SIZE> counts;
std::array<double, ERR_ENUM_SIZE> errors;
std::array<size_t, MEM_ENUM_SIZE> memory;
std::array<double, TIME_ENUM_SIZE> time;

double tgt_area_sum;
double src_area_sum;
std::array<int, NUM_ENUM_SIZE> counts = {-1};
std::array<double, ERR_ENUM_SIZE> errors = {-1.};
std::array<double, MASS_ENUM_SIZE> mass = {-1.};
std::array<size_t, MEM_ENUM_SIZE> memory = {1};
std::array<double, TIME_ENUM_SIZE> time = {-1};

double tgt_area_sum = 0.;
double src_area_sum = 0.;
bool all;
bool accuracy;
bool conservation;
Expand All @@ -201,6 +215,8 @@ class ConservativeSphericalPolygonInterpolation : public Method {


public:
friend class ConservativeSphericalPolygonInterpolationLimiter;

ConservativeSphericalPolygonInterpolation(const Config& = util::NoConfig());

using Method::do_setup;
Expand All @@ -222,7 +238,18 @@ class ConservativeSphericalPolygonInterpolation : public Method {

interpolation::Cache createCache() const override;


private:

struct Workspace_get_cell_neighbours {
PointXYZ p0;
PointLonLat p0_ll;
PointXYZ p1;
PointLonLat p1_ll;
};

private:

using Polygon = util::ConvexSphericalPolygon;
using PolygonArray = std::vector<util::ConvexSphericalPolygon>;

Expand All @@ -236,15 +263,12 @@ class ConservativeSphericalPolygonInterpolation : public Method {
void dump_intersection(const std::string, const Polygon& plg_1, const PolygonArray& plg_2_array,
const Indices& plg_2_idx_array) const;

struct Workspace_get_cell_neighbours;
std::vector<idx_t> get_cell_neighbours(Mesh&, idx_t jcell, Workspace_get_cell_neighbours&) const;

struct Workspace_get_node_neighbours;
std::vector<idx_t> get_node_neighbours(Mesh&, idx_t jcell, Workspace_get_node_neighbours&) const;

void init_polygons_data(FunctionSpace fs, Data::PolygonsData& md);


Polygon get_csp_celldata(idx_t csp_id, const Mesh& mesh, const Data::PolygonsData& md);
Polygon get_csp_nodedata(idx_t csp_id, const Mesh& mesh, Data::PolygonsData& md);

Expand All @@ -261,7 +285,7 @@ class ConservativeSphericalPolygonInterpolation : public Method {

std::pair<idx_t, idx_t> csp_to_cell_and_subcell(idx_t csp_id, const Data::PolygonsData& md) const {
auto iterator_upper_bound = std::upper_bound(md.csp_index.begin(), md.csp_index.end(), csp_id);
idx_t idx = iterator_upper_bound-1 - md.csp_index.begin();
idx_t idx = iterator_upper_bound - 1 - md.csp_index.begin();
idx_t cell = md.csp_cell_index[idx];
idx_t subcell = csp_id - md.csp_index[idx];
return std::make_pair(cell, subcell);
Expand Down Expand Up @@ -289,7 +313,8 @@ class ConservativeSphericalPolygonInterpolation : public Method {
return md.cell_data ? get_polygons_celldata(fs, md) : get_polygons_nodedata(fs, md);
}


PointXYZ src_gradient_celldata(idx_t scell, const array::ArrayView<double, 1>& src_vals) const;
PointXYZ src_gradient_nodedata(idx_t snode, const array::ArrayView<double, 1>& src_vals) const;
int next_index(int current_index, int size) const;
int prev_index(int current_index, int size) const;

Expand All @@ -304,6 +329,7 @@ class ConservativeSphericalPolygonInterpolation : public Method {
mutable Mesh src_mesh_;
mutable Mesh tgt_mesh_;
bool normalise_;
std::string limiter_;
int order_;
bool matrix_free_;

Expand Down
Loading
Loading