Skip to content

Coupler transfer API#337

Draft
jacobmerson wants to merge 31 commits into
developfrom
jacobmerson/coupler-transfer-api
Draft

Coupler transfer API#337
jacobmerson wants to merge 31 commits into
developfrom
jacobmerson/coupler-transfer-api

Conversation

@jacobmerson

@jacobmerson jacobmerson commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Brings field transfer back into the coupler API. PCMS had transfer in the coupler years ago, but it was compile-time / type-erased and hard to work with; this is the pcms2 take with a more usable design.

Highlights:

  • Coupler transfer API + transfer/transfer_method.hpp
  • test_coupler_transfer.cpp end-to-end coverage

Base is jacobmerson/field-function-split (#336). Retarget to develop once that's merged.

@jacobmerson
jacobmerson force-pushed the jacobmerson/field-function-split branch from c74eefe to bcb83df Compare July 12, 2026 18:29
@jacobmerson
jacobmerson force-pushed the jacobmerson/coupler-transfer-api branch 2 times, most recently from 15b2bea to 01f44e5 Compare July 12, 2026 20:09
@jacobmerson
jacobmerson force-pushed the jacobmerson/field-function-split branch 2 times, most recently from 0716c22 to a16f1ea Compare July 12, 2026 22:50
@jacobmerson
jacobmerson force-pushed the jacobmerson/coupler-transfer-api branch from 01f44e5 to e94d943 Compare July 12, 2026 22:50
…trix / load_vector)

Squashed original commits: 0a27b53, 0c0e697
…nsfer

Squashed original commits: bad8434, eca15d1, b4af186, 26f35c6, b8baf3b, 6b1d7f2, dba7966, 5baf365, 4b00ac1
(mesh_fields_rhs_integrator churn from 26f35c6/b8baf3b dropped)
Squashed original commits: 844dc1c, b4a4545, 629419f (sobol_sequence churn dropped)
…y buffers

Squashed original commits: e7488c6, 4e68c80
Currently the petsc-based solver is only needed for conservative
projection which requires MeshFields. So petsc is only linked when
PCMS_ENABLE_PETSC and PCMS_ENABLE_MESHFIELDS
Add a shared, format-agnostic GID-to-local permutation and use it so the
transfer operators handle sparse or reordered global IDs correctly.

This allows us to reuse the global-to-local mapping for things outside
of the serialization such as setting up the petsc arrays.
…olders

Split the GID (layout) message from the field (data) message and reuse the
field GID-permutation primitives so exchanges handle overlap masks and
reordered global IDs without corrupting payloads.
The python pcms module links libpetsc.so dynamically when python_api is
ON, so PETSc lib dir must be on LD_LIBRARY_PATH for import to succeed.
clang-tidy bugprone-implicit-widening-of-multiplication-result (treated
as error) flagged int*int products used to size 64-bit Views in the
intersection/MC RHS integrators and the field-exchange-planner test.
Perform the multiplication in size_t via an explicit cast.
We had kokkos lambdas in private functions which does not compile.
First pass is to just make a host mirror. Long term, we need to ask
PETSc team if there is a better way to handle this.
The idea is as follows: a function space creates a function. A
Function<T> represents an object that can be evaluated. A Function<T> is
a Field<T>. A Field<T> itself does not have evaluation capabilities, but
has everything needed to be sent over the network.
We had transfer in coupler a few years ago, but everything was compile
time/type erasure so it made things very difficult to acomplish. This
time around (pcms2) is taking a different approach and that seems to be
leading us in a fairly positive direction in terms of usability.
naming model, removing AddLayout.

Our goal was to remove the need for AddLayout and forcing the user to
*know* what layouts they needed to add.

This was the simplest strategy of the ones we tested. It also aligns to
the idea that fields are likely to have names anyways. So, having a
field and layout both have names allows convenient cacheing of the
layout communicator and naming of fields that follows on its
construction.
test_coupler_transfer.cpp pulls in the PETSc-dependent transfer headers,
so the target cannot compile when PETSc is disabled. Guard it like the
other transfer tests (PCMS_ENABLE_PETSC AND PCMS_ENABLE_MESHFIELDS).
With Function<T> being the object that handles evaluatable fields and
Field<T> being the non-evaluatable object that can be used for sending
over the network. This commit makes the function naming/usage consisent.
@jacobmerson
jacobmerson force-pushed the jacobmerson/field-function-split branch from a16f1ea to fed617a Compare July 13, 2026 07:11
@jacobmerson
jacobmerson force-pushed the jacobmerson/coupler-transfer-api branch from e94d943 to be23975 Compare July 13, 2026 07:11
Give TransferOperator a protected constructor that stores the source and
target function spaces it is built for, exposed via SourceSpace()/
TargetSpace(). This makes the space-to-space contract explicit and lets
callers verify a bound field's space matches the operator before applying
it.
@jacobmerson
jacobmerson changed the base branch from jacobmerson/field-function-split to develop July 21, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant