Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fc3c470
Build out basic implementation of SfcCoupling
andrewdnolan Jun 25, 2026
fcfcaa4
Add attachData and importFromCoupler methods
andrewdnolan Jun 26, 2026
0c535de
Propogate Surface -> Sfc everyhere
andrewdnolan Jun 26, 2026
3583ffb
Add `applyImportFields` method and refactor tests
andrewdnolan Jun 26, 2026
27c1d0f
Rename Meridional to Merid
andrewdnolan Jun 29, 2026
7cd18da
Support cpl pointer array larger than used fields
andrewdnolan Jul 1, 2026
5b1c7d5
Add getter for private member NAccumSteps
andrewdnolan Jul 2, 2026
1ae8ff7
Add compute method to OcnToCpl fields names
andrewdnolan Jul 2, 2026
e84eee1
Add updateExportFields method that runs on device
andrewdnolan Jul 2, 2026
54a4d56
Fix bug in OcnToCpl stride for MCT layout
andrewdnolan Jul 2, 2026
aac4a83
Make all test use a cell varrying expected value
andrewdnolan Jul 2, 2026
5670454
Make flatIdx function work for both import/export
andrewdnolan Jul 2, 2026
e1fd048
Add copyToHost and resetField methods to OcnToCpl
andrewdnolan Jul 2, 2026
7be65c5
Add exportToCoupler method
andrewdnolan Jul 2, 2026
ececcec
Used `isApprox` for comparison
andrewdnolan Jul 2, 2026
be5d80f
Add first pass at documentation
andrewdnolan Jul 2, 2026
4a281cf
Fix up comments
andrewdnolan Jul 2, 2026
a78e783
Fix bug where NImportFields was passed twice
andrewdnolan Jul 2, 2026
6c1f301
Add test for non-default name and erasing
andrewdnolan Jul 2, 2026
5e7874f
Temp. conversion once per cpl interval on device
andrewdnolan Jul 3, 2026
1ac36a3
Rename upate method and fix spelling errors
andrewdnolan Jul 3, 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
83 changes: 83 additions & 0 deletions components/omega/doc/devGuide/SfcCoupling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
(omega-dev-sfc-coupling)=

# Surface Coupling

The `SfcCoupling` class manages the variables exchanged to (`o2x`) and from
(`x2o`) the coupler. It handles import/export of the raw coupler data,
application of imported fields to the [`Forcing`](#omega-dev-forcing) object,
and accumulation of export fields over the coupling interval. It is possible
to have multiple `SfcCoupling` instances; every instance has a name and is
tracked in a static C++ map called `AllSfcCoupling`.

## Initialization

The static method:
```c++
OMEGA::SfcCoupling::init(CouplingInitParams);
```
initializes the default `SfcCoupling` given a `CouplingInitParams` struct
(number of import/export fields, name-to-index maps, coupling time step, and
coupling `Layout`, i.e. `MCT` or `MOAB`) supplied by the coupler. A pointer to
the default instance can be retrieved at any time using:
```c++
OMEGA::SfcCoupling* DefSfcCoupling = OMEGA::SfcCoupling::getDefault();
```

## Creation of non-default surface coupling objects

A non-default instance can be created with the static `create` method,
which returns a pointer to the newly created object:
```c++
OMEGA::SfcCoupling* NewSfcCoupling = OMEGA::SfcCoupling::create(
Name, Mesh, NImportFields, NExportFields, ImportIdx, ExportIdx,
Stepper, CouplingTimeStep, Layout);
```
Given its name, a pointer to a named instance can be obtained at any time:
```c++
OMEGA::SfcCoupling* NewSfcCoupling = OMEGA::SfcCoupling::get(Name);
```

## Data exchange

Before import/export, unmanaged views must be attached to the raw coupler
data pointers:
```c++
SfcCoupling.attachData(CplToOcnData, OcnToCplData);
```
To copy data from the coupler into the `CplToOcn` fields, and from the
`OcnToCpl` fields back out to the coupler:
```c++
SfcCoupling.importFromCoupler();
SfcCoupling.exportToCoupler();
```
Imported fields are applied to a `Forcing` object with:
```c++
SfcCoupling.applyImportFields(ForcingPtr);
```
Export fields are accumulated (running average) each ocean time step with:
```c++
SfcCoupling.updateExportFields(State, TracerArray);
```

## Units

`OcnToCplFields`'s averaged temperature is Conservative Temperature (deg C)
on device (`AvgSfcTemperature`), invariant at all times. `copyToHost()`
converts it to in-situ temperature in Kelvin (via TEOS-10, when in use)
into the host mirror `AvgSfcTemperatureH`, once per coupling interval.
All other averaged fields keep the same units and value on host and device.

To keep this invariant, `OcnToCplFields`'s averaged device arrays are
private: they can only be written via `updateAverages()` (called each
ocean time step from `updateExportFields()`) and read via `copyToHost()`.

## Removal of surface coupling objects

To erase a specific named instance use `erase`:
```c++
OMEGA::SfcCoupling::erase(Name);
```
To clear all instances do:
```c++
OMEGA::SfcCoupling::clear();
```
2 changes: 2 additions & 0 deletions components/omega/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ userGuide/Timing
userGuide/VerticalMixingCoeff
userGuide/VertAdv
userGuide/Forcing
userGuide/SfcCoupling
```

```{toctree}
Expand Down Expand Up @@ -100,6 +101,7 @@ devGuide/Timing
devGuide/VerticalMixingCoeff
devGuide/VertAdv
devGuide/Forcing
devGuide/SfcCoupling
```

```{toctree}
Expand Down
7 changes: 7 additions & 0 deletions components/omega/doc/userGuide/SfcCoupling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(omega-user-sfc-coupling)=

## Surface Coupling

The `SfcCoupling` class manages the exchange of surface variables with the
coupler (MCT or MOAB) between Omega and the other components of E3SM. There are
no user-configurable options.
Loading