-
Notifications
You must be signed in to change notification settings - Fork 13
Horizontal & vertical splitting of advective transport terms, and a DG_Upwind version #616
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
af8f604
Split HV added. Works for cartesian
atb1995 13e2eb9
Testing spherical nature
atb1995 1d8decd
Merge to main + some changes
atb1995 20c3846
Intermediate commit
atb1995 4ba7c2f
merge to main
atb1995 154048e
Merge to main
atb1995 8354245
Tidy of code, exceptions added, test added
atb1995 9491af0
Merge branch 'hv_advective_split' of https://github.com/firedrakeproj…
atb1995 04bf441
Merge branch 'main' into hv_advective_split
tommbendall de6ad38
Merge branch 'main' into hv_advective_split
atb1995 6273920
Changes in response to TB review
atb1995 b22afa8
Lint fix
atb1995 4d3dcdc
Tidy of common forms and fix to spatial methods
atb1995 df562ad
More fixes to code..
atb1995 f58d7b7
Spherical test + fixes added
atb1995 9f10f4d
Lint fix
atb1995 e045287
pytest fix
atb1995 c362d33
lint fix
atb1995 9f15d8d
Fix error for check
atb1995 39e74f1
Source term fix
atb1995 0e669f2
Changes in response to review
atb1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| """ | ||
|
|
||
| from firedrake import split | ||
| from firedrake.fml import Term, keep, drop | ||
| from firedrake.fml import Term, keep, drop, all_terms | ||
| from gusto.core.labels import prognostic | ||
|
|
||
| __all__ = ['SpatialMethod'] | ||
|
|
@@ -15,19 +15,20 @@ class SpatialMethod(object): | |
| The base object for describing a spatial discretisation of some term. | ||
| """ | ||
|
|
||
| def __init__(self, equation, variable, term_label): | ||
| def __init__(self, equation, variable, term_labels): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed this offline but putting it here for posterity: could we avoid some of the complicated logic below by using Can we still enforce that the original labelled form still only has one valid term to be replaced? |
||
| """ | ||
| Args: | ||
| equation (:class:`PrognosticEquation`): the equation, which includes | ||
| the original type of this term. | ||
| variable (str): name of the variable to set the method for | ||
| term_label (:class:`Label`): the label specifying which type of term | ||
| to be discretised. | ||
| term_labels (list of :class:`Label`): list of the labels specifying | ||
| which type of term to be discretised. | ||
| """ | ||
| self.equation = equation | ||
| self.variable = variable | ||
| self.domain = self.equation.domain | ||
| self.term_label = term_label | ||
| # Most schemes have only one term label | ||
| self.term_label = term_labels[0] | ||
|
|
||
| if hasattr(equation, "field_names"): | ||
| # Equation with multiple prognostic variables | ||
|
|
@@ -38,14 +39,26 @@ def __init__(self, equation, variable, term_label): | |
| self.field = equation.X | ||
| self.test = equation.test | ||
|
|
||
| # Find the original term to be used | ||
| # Find the original terms to be used | ||
| self.original_form = equation.residual.label_map( | ||
| lambda t: t.has_label(term_label) and t.get(prognostic) == variable, | ||
| map_if_true=keep, map_if_false=drop) | ||
| all_terms, | ||
| map_if_true=drop | ||
| ) | ||
| for term in term_labels: | ||
| self.original_form += equation.residual.label_map( | ||
| lambda t: t.has_label(term) and t.get(prognostic) == variable, | ||
| map_if_true=keep, | ||
| map_if_false=drop | ||
| ) | ||
|
|
||
| num_terms = len(self.original_form.terms) | ||
| assert num_terms == 1, f'Unable to find {term_label.label} term ' \ | ||
| + f'for {variable}. {num_terms} found' | ||
| num_terms_per_label = len(self.original_form.terms) // len(term_labels) | ||
| assert len(self.original_form.terms) % len(term_labels) == 0, ( | ||
| "The terms do not divide evenly into labels." | ||
| ) | ||
| assert num_terms_per_label == 1, ( | ||
| f"Unable to find terms {[term.label for term in term_labels]} for " | ||
| f"{variable}. {num_terms_per_label} terms per expected term found" | ||
| ) | ||
|
|
||
| def replace_form(self, equation): | ||
| """ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this all looks correct. It's very cumbersome having to go through the whole of this process -- do you think there are any shortcuts we can take, e.g. in adding the linearisations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to tidy it a bit by splitting out the advection forms, hopefully this helps!