Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advection data storage #787

Open
wants to merge 43 commits into
base: develop
Choose a base branch
from
Open

Advection data storage #787

wants to merge 43 commits into from

Conversation

timspainNERSC
Copy link
Collaborator

@timspainNERSC timspainNERSC commented Feb 5, 2025

Advection data storage

Fixes #782


Change Description

Share data between the column physics and dynamics parts of the module without copying. Tidy up some related classes and code that are no longer used and became a problem as these changes were implemented.

  • Create a distinction between ModelArray::Components (all the DG components at a particular physical location) and a ModelArray::Component (a particular DG component, especially DG0, at all grid locations).
    • A set of Components map to an Eigen::Array::row.
    • A Component maps to a an Eigen::Array::col.
  • Add functions to access a set of Components.
  • Add functions to access a specific Component.
  • Allow a ModelArray to be cast to and from ModelArray::DataType, that is Eigen::Array.
  • Make the ModelComponent ocean mask into an array held in a static function.
  • Move the thickness and concentration arrays with all DG components from the dynamics kernel to PrognosticData.
  • Add a function to PrognosticData to copy all components of one ModelArray to the correct components of another.
  • Update PrognosticData::updatePrognosticData to work correctly with the new full DG arrays.
  • The output from PrognositcData is now all DG components in all cases.
  • Add a complementary function to update the arrays after the dynamics runs.
    • Eventually this function will do nothing and should be removed.
  • Create a map between a type with multiple components and the equivalent type with only one component.
    • For example ModelArray::Type::DG maps to ModelArray::Type::H.
  • Add a const pseudo-Type that is the type that should be used for advected fields. Defined in the relevant ModelArrayDetails.hpp.
  • Add a using typedef that defines an AdvectionField, which is just ModelArray.
  • Remove the function ModelArrayRef::data(). The underlying data array is no longer accessible (this way).
  • Add the four basic arithmetic operators to ModelArrayRef for double and ModelArray arguments.
  • Make ModelArrayRef work only on the 0 component of the array it references.
    • Except for the allComponents() member function which returns a reference to the full array, with all components (also known as the second Eigen dimension).
  • Add TextTags for read-write access to the cell-averaged DG fields.
  • Adjust the dynamics implementations (core/src/modules/DynamicsModule/*.cpp) to work with an external source of data for thickness and concentration.
  • It's not necessary to use ModelArrayRef::data() when passing ModelArrayRefs to the dynamics kernels' setData() functions.
  • Create DGVectorHolder class which can point to a DG ModelArray (or at least its underlying Eigen::Array) and can decay to a DGVector&.
    • Use DGVectorHolders for ice thickness and concentration in the dynamics.
    • Add exception errors if the setData() function is used to try to set thickness or concentration.
    • Add a function that set the DGVectorHolder data.
  • Added a setVelocites function to DGTransport
  • Clean up module functions and features that have never really been used.
    • The Module registry in ModelComponent.
    • The advectionStore in ModelComponent. The pre-existing store works just fine.
    • The hFields (&c.) lists of field names from ModelComponent and derived classes.
    • Deleted from the dynamics source tree:
      • cgParametricMomentum.hpp
      • cgParametricMomentum.cpp
      • BBM.hpp
      • MEB.hpp
      • mevp.hpp

Test Description

  • Added a test for the new DGVectorHolder class.
  • Test the access of ModelArrayRef to only the 0 component.
  • Test the access of ModelArrayRef::allComponents to all components.
  • Test the component(s) functions of ModelArray.
  • Test the direct access of a ModelArray to the underlying data type.
  • Reconfigure the ModelComponent test since there is no longer a Module registry.
  • Add a ModelArray::Type with components to the test ModelArrayDetails.
  • Adjusted the advection tests to use the setVelocities function of DGTransport.
  • Test creating a DGVector directly from Eigen::Matrix and Eigen::Array.
  • The ThermoIntegration test now only checks the DG0 component of the read ice thickness.

Documentation Impact

Added docs/data_storage.rst, which documents how data is shared (after applying this PR) between the column physics and dynamics parts of the model.

timspainNERSC and others added 30 commits January 23, 2025 15:16
@timspainNERSC timspainNERSC self-assigned this Feb 13, 2025
@timspainNERSC timspainNERSC added documentation Improvements or additions to documentation enhancement New feature or request ICCS Tasks or reviews for the ICCS team labels Feb 13, 2025
@timspainNERSC timspainNERSC added this to the 3 Stand-alone model milestone Feb 13, 2025
@timspainNERSC timspainNERSC marked this pull request as ready for review February 13, 2025 09:05
@timspainNERSC
Copy link
Collaborator Author

@winzerle I've added you as a reviewer as this PR changes how the data is passed through the dynamics, and I would like a check that it doesn't break anything. The output of the tests and usual example runs looks fine, at least to me.

Copy link
Collaborator

@winzerle winzerle left a comment

Choose a reason for hiding this comment

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

Looks good although it's a bit difficult since many files are touched. But interface to transport seems ok.

It might be good to do a simple speed-check before and after applying such spaces to see, if there are any efficiency issues.

Copy link
Member

@einola einola left a comment

Choose a reason for hiding this comment

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

Not an in-depth review, but this looks good to me.

I suspect you forgot to update the VP and freedrift modules, and we need to do something about the advection of snow, temperature and damage.

core/src/include/ModelArrayRef.hpp Show resolved Hide resolved
core/src/include/PrognosticData.hpp Outdated Show resolved Hide resolved
core/src/include/PrognosticData.hpp Show resolved Hide resolved
core/src/modules/DynamicsModule/MEVPDynamics.cpp Outdated Show resolved Hide resolved
@timspainNERSC
Copy link
Collaborator Author

I suspect you forgot to update the VP and freedrift modules

Yes, I did!

and we need to do something about the advection of snow, temperature and damage.

Coming soon, as a separate issue and PR.

@timspainNERSC
Copy link
Collaborator Author

Looks good although it's a bit difficult since many files are touched. But interface to transport seems ok.

It might be good to do a simple speed-check before and after applying such spaces to see, if there are any efficiency issues.

It should be (slightly) faster, as there is no longer a copy in each direction when going to and from the dynamics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request ICCS Tasks or reviews for the ICCS team
Projects
Status: Review required
Development

Successfully merging this pull request may close these issues.

Variable data redesign
3 participants