Skip to content

Simple support for tripolar grid topology - #96

Open
Mikolaj-A-Kowalski wants to merge 20 commits into
mainfrom
tripolar-connection-quick
Open

Mikolaj-A-Kowalski wants to merge 20 commits into
mainfrom
tripolar-connection-quick

Conversation

@Mikolaj-A-Kowalski

@Mikolaj-A-Kowalski Mikolaj-A-Kowalski commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

This PR is stacked on #95 and #87

Resolves #86

Adds a 'least effort' support for the tripolar topology, here I have aimed to minimise any modification to the existing code.

I am also sneaking a set -u in the integration test script since it improves error messages when one tries to run it locally without all the env variables set ;-)

TODO:

  • Assert preconditions. For example that the x size of the tripolar grid must be even. This (and potentially other) assumptions we are relying on need to be verified. I am thinking during the Grid construction
  • Remove the intersection function. At the moment it is not used (and hence should not be commited yet). I haven't done it yet since getting it out of the history requires more work and I wanted to have this PR opened ASAP
  • Add more test case. In particular we need one with single rank and 2 domains but with the split that is 'off the centre'. (addressed by 5749a37)

@TomMelt I think it would be a good to have a quick review of this PR, in particular 2nd pair of eyes to spot some edge cases that might appear would be appreciated. Especially if we can translate them into test.

I want to hold off polishing this PR to after I can create a asister draft PR in the nextsim which will implement the halo exchange with the tripolar data.

@Mikolaj-A-Kowalski

Mikolaj-A-Kowalski commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor Author

The tests passed locally I promise (failing on CI like that is nothing short of a public betrayal! I have a feeling we will be on bad terms going forward...)

Will try to have a look for the cause of the discrepancy later.

EDIT:
The reason for failure comes from #87 and #94. The tests should be OK when #87 is updated and we can rebase on the new version.

@TomMelt TomMelt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Mikolaj-A-Kowalski on initial inspection it looks good to me. You have found the most minimal way to implement the feature and improved some of the existing functionality

Comment thread test/integration-test.sh Outdated
Comment thread test/integration-test.sh
Comment thread unit_test/main.cpp
Comment thread unit_test/test_DomainUtils.cpp
Comment thread Grid.cpp Outdated
Comment thread main.cpp
Comment thread DomainUtils.hpp
Comment thread DomainUtils.hpp Outdated
Comment thread DomainUtils.hpp Outdated
Comment thread DomainUtils.cpp
Having an arithmetic operators of the Points will simplify any
geometrical operations.

Point reflection is the geometric operation required by the tripolar
topology (it is what happens at the top edge).

Extra construction function is required to build 'valid' domains from
any two points. We don't want to impose it though since it is likely we
will expand the Domain to represent "empty" intersections. In that case
we would like to allow points p1 and p2 not satisfy invariant:
`p1.x <= p2.x && p1.y <= p2.y` which we will be able to use to represent
empty domain.
Together with the utility methods to check the dimensionality(?) of the
domain ( i.e. if it represents an area, line, point or is empty) we can
now easily compute the neighborhood relations between the domains.
Only use SUBCASE where there is a need to a common set-up/tear-down.
A boolean switch that indicates that grid follows a tripolar topology.
It is exclusive with the periodicity settings. It implies:
- Periodic left and right boundary
- Non-periodic bottom boundary
- Special 'folded' periodic top boundary
A simple case without any land and 2 ranks. This results in a simple
split in the middle of the domain.

Note that when domains touch by a single corner point, like in the case
of this test, there are two possible positions in the send buffer. Hence
this test may fail even when correct data is produced if the convention
which point should be chosen is altered.
This implementation follows the 'path of least resistance' and tries to
modify the minimal amount of existing code required to get things
working.

We can determine the neighbours by comparing against their image in the
'reflected' regon above the TOP edge. In tripolar topology, to produce
the reflection we apply a point symmetry through the middle of the top
edge.

We only need to take care to use the right 'real domain'/'image'
combination when calculateing the send/recv buffers.
We do it with a global attribute in the metadata file. It is optional.
It is failing due to bugs in corner Send buffer location calculations.
Implements a simple scheme based on checking the halfspaces containing
the extreme edges of the domain.

The implementation is still quite ugly and should be refactored.
@Mikolaj-A-Kowalski
Mikolaj-A-Kowalski force-pushed the tripolar-connection-quick branch from 218d51b to 251cddd Compare October 15, 2026 14:31
@Mikolaj-A-Kowalski

Copy link
Copy Markdown
Contributor Author

Rebased on the current main to get rid of the commits coming from other PRs this one was based on.

Since function was working on a point, it was a bit ambiguous what does
the point refer to in the old name.
It is not used at the moment so there is no reason to have it linger in
the codebase. This commit may need to be reversed if a need for this
function ever arises.
@Mikolaj-A-Kowalski
Mikolaj-A-Kowalski marked this pull request as ready for review October 15, 2026 15:40
@Mikolaj-A-Kowalski

Copy link
Copy Markdown
Contributor Author

@jatkinson1000 Tagging for review. I think it is ready for a look.

Comment thread ZoltanPartitioner.cpp Outdated

@jatkinson1000 jatkinson1000 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Mikolaj-A-Kowalski there is nothing insane to my reading here, so happy for this to be merged, with the regular caveat that I am not deeply familiar with decomp yet.

I'd suggest opening issues for potential follow-up work on perfection, but let these sit for future development as we need to get this delivered.

Disclosure, I did not read the cdl changes closely so trust you here.

This is just a note for the future. No need to make it an issue since it
will become relevant only if there is a 2nd implementation of the
Partiotioner interface.
@Mikolaj-A-Kowalski

Copy link
Copy Markdown
Contributor Author

Ok @jatkinson1000 @niravshah241 I think this one is ready to go in.

If we are happy I will squash the fixup comments follow by squash and merge.

Note to self, I would need to prepare a branch with the Domain intersection functionality to keep it alive in case it is needed in the future.

@jatkinson1000

Copy link
Copy Markdown

Sounds like a plan!
You may fire when ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compute tripolar boundary metadata

3 participants