Skip to content

Commit

Permalink
Advection updates (#245)
Browse files Browse the repository at this point in the history
* Add small offset in box point capture

* Clarifications in nodal swarm

* ddt - allowing discontinuous fields for advected points if required

* Trying to fix semi-lagrange scheme

Major bug (totally my fault) in which I failed to account for particles being reordered after sending and receiving. We now store the node and process for each particle which means we can take small substeps to the sample point and then snap back directly to the launch point.

This includes JC's swarm wormhole teleportation code which is required for long trajectories.

I'm turning off all smoothing for projection operators which was introduced to counter numerical problems which turned out to be related to this bug.

Also, added the possibility to use a sample swarm based on a discontinuous underlying variable. This gives a good spread of points and means that corners / facets where particles may be lost are avoided by particle paths.

* Fix regression / testing

* Fixing one broken test

There are (value related) failures in the advection tests. Of course, advection tests are a bloody nightmare since advection schemes are problematic to validate.

Need to understand this before merging PR

* Julian's review comments

posixpath - not sure why this import is present
epsilon in boxmesh return-coords-... - no need to complicate things

* Make substepping time-criterion consistent with timestep definition

* More minor fixes for adv-diffusion

Arise from convection benchmark models.

* A couple of fixes

* Hackish work around for the PETSc labelling issues with surface integrals

The surface integral code falls over if a label is not present on one of the processes. This is identified in issue #240. This workaround adds element-volumes (all of them) to each boundary label. These are not used in the surface integral code in 2D / 3D so they do not change the result. @knepley - we've discussed this issue in the past ... we should figure out the actual origin of the problem.

* parallel_view fn for mesh labels

Add a parallel_view() function to see the number of labels on each processor. In response to #240

returns something like this:

| Boundary Name            | ID    | Size | Proc ID      |
| ------------------------------------------------------ |
| Bottom                   | 11    | 2        | 0        |
| Top                      | 12    | 2        | 0        |
| Right                    | 13    | 3        | 0        |
| Left                     | 14    | 0        | 0        |
| All_Boundaries           | 1001  | 4        | 0        |
| Bottom                   | 11    | 2        | 1        |
| Top                      | 12    | 2        | 1        |
| Right                    | 13    | 0        | 1        |
| Left                     | 14    | 3        | 1        |
| All_Boundaries           | 1001  | 4        | 1        |
| ------------------------------------------------------ |

* Label points instead

Not a fix, just examining potential workaround choices

* Parallel Test utilises previous mesh

* try this one

* Still just an experiment

* Mostly going to give up on the labelling

Put most stuff back together. Improve the view() a little bit. Fix the problems with expressions (sympy merging expressions with same symbol - FFS!)

Somthing odd with dm re-distribution that should not have been happening.

Also fixing up the object id things that are not being respected by sympy.

* min viscosity - typo in expression definition

* Some changes to the documentation / tidy notebooks

Also adding rendering hints in the notebooks for quarto

* gh-pages workflow - notebooks

* Update publish.yml

* Update publication source path

* Updating /Adding examples in quick-start user guide

8 notebooks added which demonstrate various parts of the uw3 machinery plus the rendering code to put them on github pages as a quickstart guide.

I still need to update the scripts to launch on binder.

* Bug fix - discretisation

Not zapping the kdtree properly when deforming the mesh. I guess this was a problem in free surface models so I am surprised it was not reported before - is there an open issue about particles added to a deforming mesh ?

Minor detail: using invisible hspace in place of the \,\! strings. The width of the hspace is the unique ID / 100 in points. It still looks weird but the code is readable. I tried labels and other things but they break the rendering. There is probably a better way.

* updating examples

Fixes to advection and expressions to make examples and tests work.

* Further fixes

---------

Co-authored-by: Ben Knight <[email protected]>
  • Loading branch information
lmoresi and bknight1 authored Sep 27, 2024
1 parent 275e624 commit 7c5692a
Show file tree
Hide file tree
Showing 65 changed files with 5,620 additions and 31,758 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/build_deploy_jbdoc.yml.disabled

This file was deleted.

16 changes: 8 additions & 8 deletions .github/workflows/build_deploy_pdoc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: API docs / pdoc3
name: API docs / pdoc3

# We should trigger this from an upload event. Note that pdoc requires us to import the
# We should trigger this from an upload event. Note that pdoc requires us to import the
# built code, so this is a building test as well as documentation deployment

on:
push:
push:
branches:
- main # Occurs on protected branch through PR
- development
Expand Down Expand Up @@ -47,15 +47,15 @@ jobs:
VERSION=`python3 setup.py --version`
echo "VERSION=$(echo $VERSION)" >> $GITHUB_ENV
# mkdir -p docs
./docs.sh
./build_api_docs.sh
# There is an action to build the jupyter book to a different directory
# There is an action to build the jupyter book to a different directory
# and then they can be uploaded side by side

- name: Deploy
uses: peaceiris/actions-gh-pages@v3

with:
github_token: ${{ secrets.GITHUB_TOKEN }}
destination_dir: ${{ github.ref_name }}_api # The dest dir is identified by branch
publish_dir: uw3_api_docs # /underworld3
destination_dir: ${{ github.ref_name }}_api # The dest dir is identified by branch
publish_dir: uw3_api_docs # /underworld3
14 changes: 14 additions & 0 deletions .github/workflows/envs/build_quickstart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Conda Environment for python packages running under BINDER
name: emsc_basics
channels:
- conda-forge
dependencies:
- python=3.10
- quarto
- pip
- pip:
- jupyterlab>=4.1
- jupytext>=1.16.1
- pygments>=2.17.0


53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# publish to gh-pages

on:
workflow_dispatch:
push:
branches:
- main # Occurs on protected branch through PR
- development
- advection_updates

name: Quarto Publish

jobs:
build-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Add micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "1.5.6-0" # any version from https://github.com/mamba-org/micromamba-releases
environment-file: .github/workflows/envs/build_quickstart.yml
init-shell: bash
cache-environment: true
post-cleanup: "all"

- name: Render docs with quarto
shell: bash -l {0}
run: |
quarto install tinytex
cd docs/user
quarto render
## Always deploy to version directory
- name: Deploy quarto book
uses: peaceiris/actions-gh-pages@v3

with:
github_token: ${{ secrets.GITHUB_TOKEN }}
destination_dir: ${{ github.ref_name }}/_quickstart
publish_dir: docs/user/_build/book

# - name: Deploy quarto lectures
# uses: peaceiris/actions-gh-pages@v3

# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# destination_dir: lectures # The dest dir is identified by branch
# publish_dir: WebSlides/_slides
30,376 changes: 0 additions & 30,376 deletions Documentation/My Library.bib

This file was deleted.

915 changes: 0 additions & 915 deletions Documentation/UnderworldDocumentation.bib

This file was deleted.

File renamed without changes.
4 changes: 4 additions & 0 deletions docs/user/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/.quarto/

_build

Notebooks/.meshes
26 changes: 0 additions & 26 deletions docs/user/Introduction.qmd

This file was deleted.

42 changes: 42 additions & 0 deletions docs/user/NextSteps.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "Next Steps"
# keywords: []
authors:
- name: Underworld Team

exports:
- format: pdf
- template: arxiv_nips
---


### Underworld Documentation and Examples


### Benchmarks


### The Underworld Community

Sharing codes / fixes

Sharing models

### Parallel Execution

Advise using jupytext to render notebooks at .py files. This is helpful
in shared environments because the files contain no output and play
better with version control.

Not such a good idea if you want to have a tutorial with outputs (like this one)



<!--
```{iframe} https://github.com/underworldcode/underworld3/raw/VEP-preliminary-implementation/Documentation/media/Sinker.html
:width: 100%
:align: center
Caption
```
-->
2 changes: 2 additions & 0 deletions docs/user/Notebooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Example_output/*h5
Example_output/*xdmf
3 changes: 3 additions & 0 deletions docs/user/Notebooks/.jupyter/desktop-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pythonPath": "/Users/lmoresi/mambaforge/envs/underworld3p/bin/python3"
}
Loading

0 comments on commit 7c5692a

Please sign in to comment.