-
Notifications
You must be signed in to change notification settings - Fork 13
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
Get SUPG working for MixedFunctionSpace #580
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6270c81
SUPG changes
atb1995 f040279
fix for regular SUPG
atb1995 09510b6
Merge branch 'main' into mixed_fs_supg
atb1995 f744ec3
Small changes
atb1995 08bd4d1
Minor changes
atb1995 c32184d
Merge to main
atb1995 43a4ff8
Intermediate changes
atb1995 994ee9e
SUPG Now working
atb1995 a526884
Tidy up of wrappers
atb1995 eeab6e9
Undo changes to IMEX_RK
atb1995 c161915
Undo changes to supg transport test
atb1995 3d7fe56
Final fix to get everything tidied up in time_disc. Currently testing…
atb1995 e04d3a6
Small tidy. All works at this point, nice results with moist bryan fr…
atb1995 de95167
Update gusto/core/configuration.py
atb1995 faea196
Changes in response to review
atb1995 791eab6
Added a list of term labels to cycle through
atb1995 7b3a337
Small changes to supg test, not yet working
atb1995 fea795e
New test added and passes
atb1995 6ad4849
lint fix
atb1995 4906027
suboptions dict added
atb1995 b511767
Merge to main
atb1995 5e8711c
Switch to None instead of empty dict
atb1995 0af70eb
Lint fix + Improved comments
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 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 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 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 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 |
---|---|---|
|
@@ -91,7 +91,7 @@ def __init__(self, domain, field_name=None, solver_parameters=None, | |
self.wrapper.subwrappers.update({field: RecoveryWrapper(self, suboption)}) | ||
elif suboption.name == "supg": | ||
raise RuntimeError( | ||
'Time discretisation: suboption SUPG is currently not implemented within MixedOptions') | ||
'Time discretisation: suboption SUPG is not implemented within MixedOptions') | ||
else: | ||
raise RuntimeError( | ||
f'Time discretisation: suboption wrapper {suboption.name} not implemented') | ||
|
@@ -101,6 +101,7 @@ def __init__(self, domain, field_name=None, solver_parameters=None, | |
elif self.wrapper_name == "recovered": | ||
self.wrapper = RecoveryWrapper(self, options) | ||
elif self.wrapper_name == "supg": | ||
self.suboptions = options.suboptions | ||
self.wrapper = SUPGWrapper(self, options) | ||
else: | ||
raise RuntimeError( | ||
|
@@ -255,31 +256,47 @@ def setup(self, equation, apply_bcs=True, *active_labels): | |
|
||
else: | ||
if self.wrapper_name == "supg": | ||
self.wrapper.setup() | ||
if self.suboptions is not None: | ||
for field_name, term_labels in self.suboptions.items(): | ||
self.wrapper.setup(field_name) | ||
new_test = self.wrapper.test | ||
if term_labels is not None: | ||
for term_label in term_labels: | ||
self.residual = self.residual.label_map( | ||
lambda t: t.get(prognostic) == field_name and t.has_label(term_label), | ||
map_if_true=replace_test_function(new_test, old_idx=self.wrapper.idx)) | ||
else: | ||
self.residual = self.residual.label_map( | ||
lambda t: t.get(prognostic) == field_name, | ||
map_if_true=replace_test_function(new_test, old_idx=self.wrapper.idx)) | ||
self.residual = self.wrapper.label_terms(self.residual) | ||
else: | ||
self.wrapper.setup(self.field_name) | ||
new_test = self.wrapper.test | ||
self.residual = self.residual.label_map( | ||
all_terms, | ||
map_if_true=replace_test_function(new_test)) | ||
self.residual = self.wrapper.label_terms(self.residual) | ||
else: | ||
self.wrapper.setup(self.fs, wrapper_bcs) | ||
self.fs = self.wrapper.function_space | ||
self.fs = self.wrapper.function_space | ||
new_test = TestFunction(self.wrapper.test_space) | ||
# Replace the original test function with the one from the wrapper | ||
self.residual = self.residual.label_map( | ||
all_terms, | ||
map_if_true=replace_test_function(new_test)) | ||
|
||
self.residual = self.wrapper.label_terms(self.residual) | ||
if self.solver_parameters is None: | ||
self.solver_parameters = self.wrapper.solver_parameters | ||
new_test = TestFunction(self.wrapper.test_space) | ||
# SUPG has a special wrapper | ||
if self.wrapper_name == "supg": | ||
new_test = self.wrapper.test | ||
|
||
# Replace the original test function with the one from the wrapper | ||
self.residual = self.residual.label_map( | ||
all_terms, | ||
map_if_true=replace_test_function(new_test)) | ||
|
||
self.residual = self.wrapper.label_terms(self.residual) | ||
|
||
# -------------------------------------------------------------------- # | ||
# Make boundary conditions | ||
# -------------------------------------------------------------------- # | ||
|
||
if not apply_bcs: | ||
self.bcs = None | ||
elif self.wrapper is not None: | ||
elif self.wrapper is not None and self.wrapper_name != "supg": | ||
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. Is this amendment to the if statement definitely still needed? (I'm happy to keep it if it is) 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. For mixed FS yes |
||
if self.wrapper_name == 'mixed_options': | ||
# Define new Dirichlet BCs on the wrapper-modified | ||
# mixed function space. | ||
|
This file contains 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 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
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.
Just to check, is this a change that should be part of this PR?
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.
Nothing gets past you.. they are required for the parallel preconditioners, so thought I would just get it onto main. Can remove and put in a separate PR?
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.
Nah it's fine