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

[WIP] Wet/dry capabilities for 2D shallow water equations #1340

Merged
merged 145 commits into from
Jul 6, 2023

Conversation

svengoldberg
Copy link
Contributor

This implements the hydrostatic reconstruction technique of Chen & Noelle that is able to handle wet/dry transitions and remain well-balanced. Blending factors for the DG / FV scheme are added / modified to ensure well-balancedness in partially wet elements. The indicators accurately track the wet/dry front as well for evolving flows. The positivity preservation limiter is modified to avoid limiting of the bottom topography variable.

Two (constant) threshold quantities are added to the shallow water equations such that the wet/dry capabilities are easier to use and adjust for different simulation setups.

The calculation of the lake-at-rest-error was modified to return meaningful results when dry areas come into action. The old one would produce not useful values, imagine e.g. a dry hill being higher than the water level.

Tests are added to exercise the new features.

Copy link
Member

@andrewwinters5000 andrewwinters5000 left a comment

Choose a reason for hiding this comment

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

Overall great work @svengoldberg ! This is an excellent addition to the shallow wter capabilities of Trixi.

I left a fair number of comments and/or suggestions. most of them are for spacing and docstring changes (similar to my 1D review).

Also here there are new elixirs but no new tests with reference values have been added, e.g., to the file test/test_tree_2d_shallowwater.jl. Feel free to ping me if you need help concerning how to add new tests that exercise the new features you implemented.

src/solvers/dgsem_structured/dg_2d.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/dg_2d.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/indicators_2d.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/indicators_2d.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/indicators_2d.jl Outdated Show resolved Hide resolved
Copy link
Member

@andrewwinters5000 andrewwinters5000 left a comment

Choose a reason for hiding this comment

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

Overall great work @svengoldberg ! This is an excellent addition to the shallow wter capabilities of Trixi.

I left a fair number of comments and/or suggestions. most of them are for spacing and docstring changes (similar to my 1D review).

Also here there are new elixirs but no new tests with reference values have been added, e.g., to the file test/test_tree_2d_shallowwater.jl. Feel free to ping me if you need help concerning how to add new tests that exercise the new features you implemented.

@andrewwinters5000
Copy link
Member

CI fails. When this is fixed and @andrewwinters5000 approves the PR, it should be ready to merge into dev

This should be fixed now.

@ranocha
Copy link
Member

ranocha commented Jul 5, 2023

CI looks good 👍

@andrewwinters5000
Copy link
Member

CI looks good 👍

Great! I will update the dev branch and then do the merge today. Then I can tackle the 1D PR, but this should be much easier now that all the 2D stuff is done and dusted.

Many thanks to everyone (@svengoldberg @ranocha @sloede ) getting this new powerful and useful feature mergable!

@andrewwinters5000
Copy link
Member

Due to issues I had with pushing to the PR for the 1D branch, I give my revised plan for this PR below:

  1. Merge the functionality from 'sg/wet-dry-swe-1d' this PR (done).
  2. Once CI passes with the combined functionality, I will merge this PR to dev.
  3. We can then iterate in dev and fix any small inconsistencies.
  4. Once things are good to go in dev we can merge to main.

What do you think of this @ranocha @sloede ?

@sloede
Copy link
Member

sloede commented Jul 6, 2023

Due to issues I had with pushing to the PR for the 1D branch, I give my revised plan for this PR below:

1. Merge the functionality from 'sg/wet-dry-swe-1d' this PR (done).

2. Once CI passes with the combined functionality, I will merge this PR to `dev`.

3. We can then iterate in `dev` and fix any small inconsistencies.

4. Once things are good to go in `dev` we can merge to `main`.

What do you think of this @ranocha @sloede ?

Just so I get it right: instead of merging 1d into dev and then 2d into dev, 1d is merged here (i.e., to 2d), and then 2d to dev?

@andrewwinters5000
Copy link
Member

Just so I get it right: instead of merging 1d into dev and then 2d into dev, 1d is merged here (i.e., to 2d), and then 2d to dev?

Yes, the 1d has already been merged into the 2d and I have fixed all the conflicts, duplicate code and removed the TODOs. So the next step would be to merge this 2d into dev

@sloede
Copy link
Member

sloede commented Jul 6, 2023

OK for me :-)

@andrewwinters5000
Copy link
Member

OK for me :-)

Great! My other motivation is that the conversation here is already quite involved. So I wanted to "restart" the conversation and review process fresh inside dev :)

Copy link
Member

@andrewwinters5000 andrewwinters5000 left a comment

Choose a reason for hiding this comment

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

This can merge to dev. There are some edits needed but it is mainly to docstrings and so on.

@andrewwinters5000 andrewwinters5000 merged commit 112fffd into trixi-framework:dev Jul 6, 2023
29 of 31 checks passed
andrewwinters5000 added a commit that referenced this pull request Jul 14, 2023
* add dummy commit in order to open a dev to main PR

* [WIP] Wet/dry capabilities for 2D shallow water equations (#1340)

* HR of Chen and Noelle (1D) and edit SWE struct

* Overload limiter (SWE 1D) to cut off waterheight

* New indicatorHG (SWE 1D) to apply FV on dry cells

* Threshold in rhs! before calculation (SWE 1D)

* New lake_at_rest_error for SWE 1D

* New wet/dry elixirs for testing scheme for SWE 1D

* HR of Chen and Noelle (2D) and edit SWE struct

* Overload limiter (SWE 2D) to cut off waterheight

* New indicatorHG (SWE 2D) to apply FV on dry cells

* Threshold in rhs! before calculation (SWE 2D)

* New lake_at_rest_error for SWE 2D

* New wet/dry elixirs for testing scheme for SWE 2D

* Elixir SWE 2D: 3 mounds, problem with boundaries

* Fixed MethodError; apply_thresholds! too strict

* Fixed MethodError; apply_thresholds! too strict

* Move threshold on volume integral in stage_limiter

* Indentation, spacing and comments adjustment

* Renaming numerical HLL type flux (SWE 1D)

* Move threshold on volume integral in stage_limiter

* Renaming numerical HLL type flux (SWE 2D)

* Indentation, spacing and comments adjustment

* Describing docs for Chen and Noelle HR (SWE 1D)

* Edit SWE 1D elixirs, error-based solver and docs

* Including tests on new SWE 1D elixirs

* Describing docs for Chen and Noelle HR (SWE 2D)

* Edit SWE 2D elixirs, error-based solver and docs

* Including tests on new SWE 2D elixirs

* New/reorganize positivity limiter (SWE 2D)

* New/reorganize positivity limiter (SWE 1D)

* Editing docs SWE 1D

* Editing docs SWE 2D

* Rearrange cut off at interfaces, edit tests SWE 1D

* Edit docs, add Ref

* Edit docs and indenting (SWE 2D)

* Rearrange cut off at interfaces, edit tests SWE 2D

* Remove tree/structured mesh elixir from repo SWE2D

* Create unstructured mesh elixir SWE 2D

* Add 1D lake-at-rest-error logic to pass 1D tests

* Add 2D lake-at-rest-error logic to pass 2D tests

* Fixed typo. Confusing name, but correct math

* Correction of comments and docstrings

* Correction of comments and docstrings

* Rename mesh file in elixir for UnstructuredMesh

* Update test_unstructured_2d.jl

forgot an end statement for the new test

* Fixing typos

* fix dispatching error on new lake-at-rest error calculation. See if this fixes broken tests

* Editing initial condition in parabolic bowl elixir

* Delete unnecessary variable in elixir

* adjust lake-at-rest error computation strategy. move specialized version of error into the wet-dry elixir as the new functionality was only needed in this speacial case. update corresponding test values as the bottom is now truly discontinuous

* update structured mesh version of the wet-dry well-balancedness test

* fix typos

* update values in parabolic bowl test on StructuredMesh

* update parabolic bowl test on TreeMesh

* revert the 1D computation of the lake-at-rest error to the standard way. This will change once the 1D wet/dry merges

* Reset lake-at-rest error computation strategy.
New version of error only in wet-dry elixir (special case)
Update test values as the bottom is now truly discontinuous

* Fix typo

* Shorten test run for parabolic bowl 1D

* Choose lower resolution for parabolic bowl
and update test values

* Further reduce resolution for parabolic bowl
and update test values

* adjust special initial conditions and well-balancedness error routines to avoid the need of element IDs

* Remove MPI from well-balanced test

* simplify workaround to set discontinuous initial data

* Simplify workaround to set discontinuity

* Change structure of Chen&Noelle flux

* Fix typos and indenting

* Adjust call of solve and use ode_default_options

* Edit docstring

* Replace boolean with if, remove set_node_vars
Shorten test runs on TreeMesh and UnstructuredMesh

* Change structure of Chen&Noelle flux

* Fix typos and indenting

* Adjust call of solve and use ode_default_options

* Edit docstring

* Replace boolean with if, remove set_node_vars
Shorten test runs on TreeMesh and UnstructuredMesh

* Update comment regarding H0 for lake-at-rest error

* Add the original source to the parabolic bowl test

* Update comment regarding H0 for lake-at-rest error

* Add the original source to the parabolic bowl test

* New sc indicator especially for SWE

* Remove threshold parameter from SWE limiter call

* update some docstrings

* remove type instability in positivty limiter

* typo fix

* move safety check for dry state in the new positivity limiter into the same element loop

* more docstring updates

* remove dummy comment added in the dev initial commit

* adjust default threshold values to be precision agnostic

* update comment on the default threshold value in the new TreeMesh elixirs

* update comments for the three new TreeMesh examples

* update IC comment for three mound test

* update IC comments for new StructuredMesh2D tests

* update comment on shallow water constructor

* adjust comments in the shallow_water_2d file

* adjust comment regarding threshold_limiter in the new elixirs

* fix typos found by SpellCheck

* Edit docs

* Import Printf macros for printing wb error

* Remove type instability in Chen & Noelle HR

* Change logic for setting SC indicator to one

* Change logic for default values of SWE struct

* Outsource HG shock capturing indicator for SWE
Create different function to compute indicator
Edit comments
Change wet/dry clipping to if-else logic

* Move limiterthreshold into function & edit docs
Threshold was a passed variable in elixir before.
Now, it is taken right from the SWE struct in the limiter
Edit docs

* Move new limiter safety check in same element loop

* Adjust default threshold values

* Remove type instability

* Import Printf package for terminal output

* Edit docs

* Add Printf package to the test/Project.toml
Used for printing lake-at-rest error in well-balancedness test

* Add Printf package to the test/Project.toml
Used for printing lake-at-rest error in well-balancedness test

* Typo fix in elixir_shallowwater_well_balanced_wet_dry.jl

* Typo fix in elixir_shallowwater_well_balanced_wet_dry.jl

* unify new code with required formatting

* fix weird formatting and add 'format: noindent' where missing. fix crashing structured mesh run

* add unit test for new show routine

* apply JuliaFormatter

* simplify elixir as we can set discontinuous ICs in 1D. Also update beach test values

* dummy commit to check push access

* remove dummy comment

* typo fix

---------

Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se>
Co-authored-by: Michael Schlottke-Lakemper <michael@sloede.com>

* adjust comments and remove duplicate code

* add TODOs for code pieces that should move to TrixiShallowWater package

* remove accidentally added file

* apply formatter to avoid errors with new comments

* move TODO comments to avoid errors in Documentation build

* Apply suggestions from code review

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>

* remove unnecessary analysis quantities from several new elixirs

* rename local threshold variable in new indicator to avoid confusion

* update NEWS.md with wetting and drying feature

* fix fomartting issue from conflict resolution

---------

Co-authored-by: svengoldberg <102215246+svengoldberg@users.noreply.github.com>
Co-authored-by: Michael Schlottke-Lakemper <michael@sloede.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
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.

None yet

4 participants