nextsimhub / nextsimdg

neXtSIM_DG : next generation sea-ice model with DG
https://nextsim-dg.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
10 stars 13 forks source link

Add DG components to the restart files #606

Closed timspainNERSC closed 4 months ago

timspainNERSC commented 4 months ago

Add DG components to the restart files

Fixes #592, fixes #595


Change Description

Part of this PR moves the definition of the number of DG components and the CG degree from hard coded values spread between ModelArrayDetails.cpp and the dynamics module and kernel classes. These values are now defined as part of the CMake configuration step, with the CMake command line argument -DDynamicsType= with valid parameter values DG1 and DG2. A value of DG1 sets the advection DG degree to 1 and the number of advection DG components to 3. A value of DG2 sets the advection DG degree to 2 and the number of advection DG components to 6. In both cases the CG degree is set to 2 and the number of DG stress advection components to 8.

These values are implemented as values for preprocessor macros that are applied to all of the source files compiled into the nextsimlib compilation target. This is then used by the model binary and most of the unit tests.

The ModelArrayDetails.cpp file defines the number of components of the DG-related ModelArrays based on these values, but also defines values equivalent to the DG1 option as defaults.

In the dynamics, the number of advection DG components is used as the template parameter in instantiating the relevant dynamics kernel. The CG degree is used in the CGDynamicsKernel class to as the CGdegree template parameter and to calculate the number of DG components for stress. This latter value is calculated using the CG2DGCOMPONENTS function. These two numbers of DG components are used as the template parameters for the DynamicsKernel class. Within these various dynamics kernel classes the template parameters for the underlying dynamics classes such as DGVector and CGVector are set.


Test Description

Added PrognosticDataIO_test.cpp, which tests the writing function PrognosticData::writeRestartFile(). This is currently in a separate source file so that PrognosticData_test can run with MPI enabled, which does not currently allow I/O related tests to pass. Once parallel I/O is fully integrated into the model, these two tests should be combined.