Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e8085ac
Build out basic implementation of SfcCoupling
andrewdnolan Jun 25, 2026
1fb44ed
Add attachData and importFromCoupler methods
andrewdnolan Jun 26, 2026
a3cc9d3
Propogate Surface -> Sfc everyhere
andrewdnolan Jun 26, 2026
036c393
Add `applyImportFields` method and refactor tests
andrewdnolan Jun 26, 2026
63d6365
Rename Meridional to Merid
andrewdnolan Jun 29, 2026
8c3ced2
Support cpl pointer array larger than used fields
andrewdnolan Jul 1, 2026
2865a74
Add getter for private member NAccumSteps
andrewdnolan Jul 2, 2026
8ecbd56
Add compute method to OcnToCpl fields names
andrewdnolan Jul 2, 2026
9141128
Add updateExportFields method that runs on device
andrewdnolan Jul 2, 2026
8e4420d
Fix bug in OcnToCpl stride for MCT layout
andrewdnolan Jul 2, 2026
cee980d
Make all test use a cell varrying expected value
andrewdnolan Jul 2, 2026
ef68693
Make flatIdx function work for both import/export
andrewdnolan Jul 2, 2026
df98ebb
Add copyToHost and resetField methods to OcnToCpl
andrewdnolan Jul 2, 2026
fd24a41
Add exportToCoupler method
andrewdnolan Jul 2, 2026
9c86c65
Used `isApprox` for comparison
andrewdnolan Jul 2, 2026
b6068e0
Add first pass at documentation
andrewdnolan Jul 2, 2026
75f4903
Fix up comments
andrewdnolan Jul 2, 2026
a60dd31
Fix bug where NImportFields was passed twice
andrewdnolan Jul 2, 2026
50bb8ba
Add test for non-default name and erasing
andrewdnolan Jul 2, 2026
39f8e49
Temp. conversion once per cpl interval on device
andrewdnolan Jul 3, 2026
4205708
Rename upate method and fix spelling errors
andrewdnolan Jul 3, 2026
b82337a
Fix typos found in code review
andrewdnolan Jul 6, 2026
1e8058c
Apply suggestions from code review
andrewdnolan Jul 6, 2026
089f50d
Fix "being" / "begin" typo
andrewdnolan Jul 6, 2026
ada2701
Access `MinLayerCell` on host in manual for loops
andrewdnolan Jul 7, 2026
d0ac984
Apply suggestions from code review
andrewdnolan Jul 8, 2026
c48126f
Switch to 8 tasks (from 1) for SFCOUPLING CTEST
andrewdnolan Jul 9, 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, ImportIdxMap, ExportIdxMap,
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
Loading