CliMA / Oceananigans.jl

🌊 Julia software for fast, friendly, flexible, ocean-flavored fluid dynamics on CPUs and GPUs
https://clima.github.io/OceananigansDocumentation/stable
MIT License
931 stars 189 forks source link

Implementing a `CutCellBottom` immersed boundary #3123

Open siddharthabishnu opened 1 year ago

siddharthabishnu commented 1 year ago

Cut cells use piecewise linear representations of bathymetry (as opposed to full or partial cells which use piecewise constant ones).

Here’s a tentative work plan for implementing cut cells:

  1. Develop the following test cases:

    (a) Tracer advection with no momentum on a seamount (Adcroft or Schär configuration); (b) Internal wave or overflow with momentum;

    Run these test cases for full and partial cells. As suggested by @jm-c, compare a simulation using low vertical resolution (~10 vertical layers) and partial cells with one using high vertical resolution (~500 vertical layers) and full cells at the same horizontal resolution (to verify the effectiveness of partial cells). To ensure that a stratified ocean remains at rest, implement the technique in Lin for partial cells.

  2. Implement two-dimensional cut cells in the y-z plane:

    (a) Implement CutCellBottom in ImmersedBoundary module similar to PartialCellBottom; (b) Implement a special compute_w_from_continuity for CutCellBottom. https://github.com/CliMA/Oceananigans.jl/blob/8e6b5cd540b7a710955edf9846959966efbb6ea0/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl#L15-L16

    (c) Implement the "algorithm" for partial cells to compute the hydrostatic pressure for CutCellBottom. https://github.com/CliMA/Oceananigans.jl/blob/8e6b5cd540b7a710955edf9846959966efbb6ea0/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl#L24

  3. Extend the cut cell implementation to 3D and consider improving the pressure gradient calculation.

References

Advection on Cut-Cell Grids for an Idealized Mountain of Constant Slope A finite-volume integration method for computing pressure gradient force in general vertical coordinates A fourth-order Cartesian grid embedded boundary method for Poisson's equation A New Terrain-Following Vertical Coordinate Formulation for Atmospheric Prediction Models Comparison of Terrain-Following and Cut-Cell Grids Using a Nonhydrostatic Model Large-eddy simulations with ClimateMachine v0.2.0: a new open-source code for atmospheric simulations on GPUs and CPUs Medium range forecasts using cut-cells: a sensitivity study On methods for solving the oceanic equations of motion in generalized vertical coordinates Representation of topography by porous barriers and objective interpolation of topographic data Representation of Topography by Shaved Cells in a Height Coordinate Ocean Model Rescaled height coordinates for accurate representation of free-surface flows in ocean circulation models Sliding or stumbling on the staircase: numerics of ocean circulation along piecewise-constant coastlines

### Tasks
- [ ] Tracer advection over seamount test case
- [ ] Two-dimensional implementation of `CutCellBottom`
- [ ] Three-dimensional implementation of `CutCellBottom`
- [ ] Merging of cells with small area (2D) or volume (3D) for cut cells
glwagner commented 1 year ago

This validation test essentially implements the tracer advection test:

https://github.com/CliMA/Oceananigans.jl/blob/main/validation/immersed_boundaries/tracer_advection_over_bump.jl

but we should take care to make sure the boundary conditions are correct.

glwagner commented 1 year ago

@siddharthabishnu @simone-silvestri can you document the progress we discussed yesterday on this issue?

glwagner commented 1 year ago

Also, if there has been work do you think we can open a draft PR to track the progress?

glwagner commented 1 year ago

(Possibly a PR that updates the tracer advection case is all we need for now to complete the first task. I don't think the tracer advection case works on main currently.)

siddharthabishnu commented 1 year ago

@glwagner I have opened a PR with the branch sb/cut-cells-experiment, on which I have been working on implementing the cut cells. To summarize the progress:

So, tasks 1 (a) and 2 (b) have been completed so far. Tasks 2(b) and 2(c) are being worked on right now, after completion of which tasks 1 (b) and 3 will be initiated.

glwagner commented 1 year ago

Nice! Do you have an image that illustrates the problems at low resolution, ie a plot that reproduces the Adcroft result?

siddharthabishnu commented 1 year ago

Nice! Do you have an image that illustrates the problems at low resolution, ie a plot that reproduces the Adcroft result?

Yes. Here they are. I improved the visualization on the latest commit and pushed it right now. The types of immersed boundary and plot are included in the filenames. The discrete version of the topography (i.e. the Gaussian bump for this test case) is detectable only for the heatmaps.

https://github.com/CliMA/Oceananigans.jl/assets/12926768/f94a6b92-cb5e-4197-9e5b-bd8ea1bad42a

https://github.com/CliMA/Oceananigans.jl/assets/12926768/c2d37eb9-931e-4efa-aa99-c113e38bf393

https://github.com/CliMA/Oceananigans.jl/assets/12926768/38771b36-e030-4877-8c9f-61944cd9aefc

https://github.com/CliMA/Oceananigans.jl/assets/12926768/baf6c24b-3fc1-4f4e-aec7-17826bd4da61

glwagner commented 1 year ago

This paper describes a "cell merging" technique that can help reduce problems with very small cells: https://journals.ametsoc.org/view/journals/mwre/138/10/2010mwr3252.1.xml?tab_body=abstract-display

There are also some citations in there about an alternative method that they call the "thin wall" method.