Skip to content

Conversation

@timspainNERSC
Copy link
Collaborator

@timspainNERSC timspainNERSC commented Jan 5, 2024

Dynamics switcher

Fixes #378


Change Description

This PR converts the structure of the code from the original code where the code for all rheologies is mixed in a single file.

The new structure is designed to allow new implementations to be written and included in nextSIM-DG. It also provides separation of all classes using continuous Galerkin (CG) arrays to hold velocity fields.

Modules

The dynamics are modularized so that the dynamics and rheology implementation can be configured at run time, allowing rapid replacement of the rheology mathematics. This modularization is only used in the modules held in the core part of the model. Within the dynamics subdirectory the code is not modularized, but the classes are part of a class hierarchy. The module implementations control the flow of data from the core of the model to the dynamics (and back) and determine which classes are called to act on this data.

Dynamics classes

DynamicsKernel

The new classes in the dynamics subdirectory are part of two class hierarchies. The first is based on the DynamicsKernel class. This is intended to encapsulate all of the dynamics calculations and data. any common data that is based on DG arrays is held here:

  • ice thickness
  • ice concentration
  • strain
  • stress
  • DGTransport instances.

This class is abstract and should not be instantiated.

CGDynamicsKernel

The only current child class is the CGDynamicsKernel class, which defines everything which is common to dynamics classes which use CG velocity fields (currently all of them) and holds the arrays for this data:

  • ice velocity (x,y components)
  • ice thickness interpolated to CG grid
  • ice concentration interpolated to CG grid
  • divergence of stress (x,y components)
  • ocean velocity (x,y components) interpolated to CG grid
  • wind velocity (x,y components) interpolated to CG grid.

The class also holds functions common to dynamics implementation using CG arrays, such as:

  • data transfer
  • interpolation of ice thickness and concentration between DG and CG
  • velocity->strain
  • stress divergence
  • boundary conditions.

Again, the class is abstract and should not be instantiated.

VPCGDynamicsKernel

The implementation of CG-based dynamics for visco-plastic rheologies, a child of the CG dynamics kernel class. The update step is defined at this level, with only the stress update step to be defined by child classes. The main piece of code in this class is the momentum solver. The class also holds the parameters object for the VP calculation.

MEVPDynamicsKernel

This is a child class of the CG VP dynamics kernel. The only definition is that the MEVP stress update step class is to be used to calculate stress from strain. This class is the one instantiated by the MEVP dynamics implementation in the core code.

StressUpdateStep

A class that defines an interface to perform the calculation of stress from strain. By using a generic parameters class, the interface can be common between the MEVP, MEB and BBM rheologies that are the initial targets for nextSIM-DG.

MEVPStressUpdateStep

The child class of the stress update class that is instantiated do the MEVP stress calculation. Used by MEVPDynamicsKernel.


Test Description

Do the outputs of the dynamics benchmark and the yearlong run match for MEVP and BBM? As judged by a human.

  • Kinda?

Documentation Impact

In terms of user documentation, no impact. These changes should be transparent to the user.

Developer documentation should be added.

@timspainNERSC timspainNERSC added the enhancement New feature or request label Jan 5, 2024
@timspainNERSC timspainNERSC added this to the 3 Stand-alone model milestone Jan 5, 2024
@timspainNERSC timspainNERSC self-assigned this Jan 5, 2024
@timspainNERSC timspainNERSC changed the title Dynamics switcher WIP: Dynamics switcher Jan 5, 2024
@timspainNERSC timspainNERSC mentioned this pull request Jan 5, 2024
12 tasks
timspainNERSC and others added 10 commits January 8, 2024 09:09
- added missing functions for DGTransport<8>:

mostly just adding the explicit template definitions such as
  template class DGTransport<8>;

only part where new code was required in DGTransport.cpp
  leftedgeofcell, rightedgeofcell, topedgeofcell, bottomedgeofcell

  these functions restrict an element-DG function to the edge-DG
functions
  by translating the basis functions 1,(x-1/2),(y-1/2),(x-1/2)(y-1/2),
...
  to the corresponding functions on the edges, 1,(t-1/2),(t-1/2)^2-1/12
  Herefore, the cell-edge functions are evaluated for x=0 (left), x=1
(right)
  y=0 (bottom) and y=1 (top) and the corresponding edge basis functions
are
  collected

- added a new DGTransport-Class to DynamicsKernel

   Nextsim::DGTransport<CG2DGSTRESS(CGdegree)>* stresstransport;

   CG2DGSTRESS computes the number of DG-stress unknowns per element
   depending on the CG discretization of the velocity.

   This stresstransport is initialized along with dgtransport (used for
   the advection)

- added first version of stress transport to DynamicsKernel::update

  currently commented out.
I did some minor cleaning of the comments of mEVPStep to make it clearer
 what "pseduo-timestepping" referred to. I also removed extra lines from
  the BBMStep function which seem to have been introduced during a merge
  .
…b/nextsimdg.git into issue378_dynamicsswitcher2
@timspainNERSC timspainNERSC marked this pull request as ready for review March 21, 2024 09:02
@timspainNERSC timspainNERSC changed the title WIP: Dynamics switcher Dynamics switcher Mar 21, 2024
@timspainNERSC timspainNERSC force-pushed the issue378_dynamicsswitcher2 branch from cb23404 to 4ded1b7 Compare March 21, 2024 14:01
@timspainNERSC timspainNERSC force-pushed the issue378_dynamicsswitcher2 branch 3 times, most recently from 43646f0 to 66e648c Compare March 21, 2024 14:48
@timspainNERSC
Copy link
Collaborator Author

Removing the old dynamics source files causes the CI on Mac to fail, not even in the dynamics tests.

The files that have not been removed are

  • dynamics/src/include/cgParametricMomentum.hpp
  • dynamics/src/include/BBM.hpp
  • dynamics/src/include/MEB.hpp
  • dynamics/src/include/mevp.hpp
  • dynamics/src/cgParameticMomentum.cpp

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.

Some minor comments and change requests. You can merge once you've addressed them as you see fit.

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

Labels

enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

Stress advection BBMStep uses the MEB::StressUpdateHighOrder() The BBM rheology exists, but is not usable

5 participants