-
Notifications
You must be signed in to change notification settings - Fork 13
Gamma plane #707
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
Draft
jshipton
wants to merge
2
commits into
main
Choose a base branch
from
gamma_plane
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Gamma plane #707
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| SpatialCoordinate, Constant, TrialFunctions, TestFunctions, dot, grad, | ||
| interpolate, assemble) | ||
| from firedrake.fml import subject, drop, all_terms | ||
| from gusto.core.coord_transforms import rtheta_from_xy | ||
| from gusto.core.labels import ( | ||
| linearisation, pressure_gradient, coriolis, prognostic | ||
| ) | ||
|
|
@@ -39,6 +40,7 @@ class ShallowWaterEquations(PrognosticEquationSet): | |
| def __init__(self, domain, parameters, | ||
| space_names=None, linearisation_map=all_terms, | ||
| u_transport_option='vector_invariant_form', | ||
| coriolis_trap=None, | ||
| no_normal_flow_bc_ids=None, active_tracers=None): | ||
| """ | ||
| Args: | ||
|
|
@@ -60,6 +62,10 @@ def __init__(self, domain, parameters, | |
| 'vector_invariant_form', 'vector_advection_form', and | ||
| 'circulation_form'. | ||
| Defaults to 'vector_invariant_form'. | ||
| coriolis_trap (tuple, optional): (r_edge, f_trap) specifies a | ||
| distance r_edge and `trap' function f_trap such that the | ||
| Coriolis parameter is set to f_trap(r) for r>r_edge. For use | ||
| with gamma-plane setup only. Defaults to None. | ||
| no_normal_flow_bc_ids (list, optional): a list of IDs of domain | ||
| boundaries at which no normal flow will be enforced. Defaults to | ||
| None. | ||
|
|
@@ -83,6 +89,10 @@ def __init__(self, domain, parameters, | |
| self.domain = domain | ||
| self.active_tracers = active_tracers | ||
|
|
||
| if coriolis_trap is not None: | ||
| assert self.parameters.rotation is CoriolisOptions.gammaplane, "coriolis_trap option is only for use with gamma-plane setup" | ||
| self.coriolis_trap = coriolis_trap | ||
|
|
||
| self._setup_residual(u_transport_option) | ||
|
|
||
| # -------------------------------------------------------------------- # | ||
|
|
@@ -201,7 +211,16 @@ def _setup_residual(self, u_transport_option): | |
| fexpr = self.parameters.f0 | ||
| elif rotation is CoriolisOptions.betaplane: | ||
| xyz = SpatialCoordinate(self.domain.mesh) | ||
| fexpr = self.parameters.f0 + self.parameters.beta * xyz[1] | ||
| fexpr = self.parameters.f0 + self.parameters.beta * ( | ||
| xyz[1] - self.parameters.y0) | ||
| elif rotation is CoriolisOptions.gammaplane: | ||
| x, y = SpatialCoordinate(self.domain.mesh) | ||
| r, _ = rtheta_from_xy(x, y) | ||
|
Collaborator
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. It's also used in here, so currently my gamma plane and trap is centred on a corner of the domain. This will probably be different for different people using it, but I imagine you'd typically want a gamma plane centred in the centre of the mesh? |
||
| Rsq = self.parameters.R**2 | ||
| fexpr = 2*self.parameters.Omega * (1 - 0.5 * r**2 / Rsq) | ||
| if self.coriolis_trap is not None: | ||
| r_edge, f_trap = self.coriolis_trap | ||
| fexpr = conditional(r < r_edge, fexpr, f_trap) | ||
| else: | ||
| raise NotImplementedError('Coriolis option is not implemented') | ||
| self.prescribed_fields('coriolis', CG1).interpolate(fexpr) | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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 requires x,y to be (0,0) on the pole, which is why I previously had x_shift etc although that only works if the pole is in the centre of the mesh. Unless I've missed something, SpatialCoordinate(mesh) always gives x,y as (0,0) in the corner so would then be a different x,y to this?
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.
Would it help to add some input arguments to translate? I can't remember what you use this for...
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.
My original functions had Lx and Ly as input arguments to shift x and y. I use these to define the position of my cyclones, so given it's a polar plane I want to consider the centre of the mesh as (0,0) as that's the pole.