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

NetCDF outputs for 2D fields #255

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

NetCDF outputs for 2D fields #255

wants to merge 8 commits into from

Conversation

tkarna
Copy link
Contributor

@tkarna tkarna commented Jul 23, 2021

Adds netCDF outputs for 2d fields. Usage via the new option:

options.fields_to_export_netcdf = ['uv_2d', 'elev_2d']

Supports:

  • 2D fields (also in the 3D model)
  • P0, P1, and P1DG function spaces
    • all other functions will be interpolated to P1DG space prior to exporting
  • triangular and quad meshes
  • scalar and vector fields
  • output only (netcdf files cannot be read back in)

Benefits:

  • portable output format (unlike vtk)
  • smaller files (mesh stored only once)

Outputs will be stored in files outputs/nc/Elevation2d/Elevation2d.nc. All time steps will be appended in the same file. NetCDF header looks like this

netcdf Elevation2d {
dimensions:
        face = 800 ;
        face_nb_nodes = 3 ;
        vertex = 2400 ;
        time = UNLIMITED ; // (99 currently)
variables:
        uint64 Mesh_face_nodes(face, face_nb_nodes) ;
                Mesh_face_nodes:start_index = 0LL ;
        float Mesh_node_x(vertex) ;
        float Mesh_node_y(vertex) ;
        float time(time) ;
                time:standard_name = "time" ;
                time:units = "s" ;
        float elev_2d(time, vertex) ;
}

The stored mesh and data are defined as follows:

P0 fields:

  • connectivity and mesh coordinates: P1
  • data: P0 (a.k.a. "cells")

P1 fields:

  • connectivity and mesh coordinates: P1
  • data: P1 (a.k.a. "vertices")

P1DG fields:

  • connectivity and mesh coordinates: P1DG
  • data: P1DG (a.k.a. "vertices")

To enable netcdf outputs firedrake must be installed with:
PETSC_CONFIGURE_OPTIONS="--download-netcdf-configure-arguments=--enable-parallel"
In addition, netCDF4-python package has to be installed manually because its default configuration fails to detect parallel netcdf4 capability. setup.py needs to be modified to set has_parallel4_support = True.

tkarna added 6 commits July 22, 2021 12:51
- add time dimension to netcdf output files
- add time variable to netcdf output files
- propagate simulation time to export method
Currently only 2d fields can be exported
tkarna added 2 commits July 23, 2021 12:28
We need to find a way to automatically build parallel netcdf support
Use time=0 for adjoint variable exports. Presently the adjoint model only supports
vtk outputs where the time value is not used. Outputs should be generalized later on
to support adjoint model iteration index metadata.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant