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

Get SUPG working for MixedFunctionSpace #580

Merged
merged 23 commits into from
Dec 5, 2024
Merged

Conversation

atb1995
Copy link
Collaborator

@atb1995 atb1995 commented Nov 28, 2024

Currently SUPG does not work for mixed function spaces. Here I have allowed for the altering of multiple test functions.

Note that MixedFSWrapper is not used, as altering a single test function in the tuple of test functions for a MixedFunctionSpace was difficult to do.

There is scope in future to not use SUPG as a wrapper, but this is not addressed in this pull request.
moist_bf_theta_e_-1
moist_bf_theta_e_supg3_-1

@atb1995 atb1995 self-assigned this Nov 28, 2024
@tommbendall tommbendall added the enhancement Involves adding a new capability label Dec 2, 2024
@@ -163,9 +163,9 @@ def __init__(self, base_scheme, domain, M, maxk, quad_type, node_type, qdelta_im

# Get Q_delta matrices
self.Qdelta_imp = genQDeltaCoeffs(qdelta_imp, form=formulation,
nodes=self.nodes, Q=self.Q)
nodes=self.nodes, Q=self.Q, nNodes=M, nodeType=node_type, quadType=quad_type)
Copy link
Contributor

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?

Copy link
Collaborator Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah it's fine

self.wrapper.setup(field_name)
new_test = self.wrapper.test
self.residual = self.residual.label_map(
lambda t: t.get(prognostic) == field_name and t.has_label(transport),
Copy link
Contributor

Choose a reason for hiding this comment

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

I generally don't like specific terms appearing in this file because I think the time_discretisation should be agnostic to the type of term being solved...

... if we need to specifically only replace the test function in the transport terms, could the SUPGOptions object contain a list of labels for the terms that need replacing? Then the user can specify which terms are going to be adjusted

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay agreed, I have added a list of term labels to cycle through. I need to add a test for this so hang fire for that


# -------------------------------------------------------------------- #
# 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":
Copy link
Contributor

Choose a reason for hiding this comment

The 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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For mixed FS yes

@@ -381,9 +387,13 @@ def setup(self):
# -------------------------------------------------------------------- #
# Set up test function
# -------------------------------------------------------------------- #
if self.time_discretisation.wrapper_field_names is not None:
uadv = Function(domain.spaces('HDiv'))
Copy link
Contributor

Choose a reason for hiding this comment

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

could this line be above the if statement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, put it below

@@ -101,6 +101,10 @@ 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":
if options.field_names:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be if options.field_names is not None:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've instead just done it as self.wrapper_field_names = options.field_names and the None check is now further down

ibp = IntegrateByParts.TWICE
field_names = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@tommbendall tommbendall marked this pull request as ready for review December 5, 2024 16:30
@@ -202,6 +202,7 @@ class SUPGOptions(WrapperOptions):
tau = None
default = 1/sqrt(15)
ibp = IntegrateByParts.TWICE
suboptions = None # Dictionary containing field_name and term_labels
Copy link
Contributor

Choose a reason for hiding this comment

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

As well as fixing the lint, can you expand on this comment just to make it a bit clearer what suboptions should be, i.e. the keys of the dictionary should be strings for the names of the fields, and the values should be a list of terms to apply the SUPG test function to

Copy link
Contributor

@tommbendall tommbendall left a comment

Choose a reason for hiding this comment

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

Thanks Alex!

@tommbendall tommbendall merged commit e253e14 into main Dec 5, 2024
4 checks passed
@tommbendall tommbendall deleted the mixed_fs_supg_new branch December 5, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Involves adding a new capability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants