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

RestrictedFunctionSpace(MixedFunctionSpace) #3868

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

pbrubeck
Copy link
Contributor

@pbrubeck pbrubeck commented Nov 18, 2024

Description

This PR enables to construct a RestrictedFunctionSpace from a MixedFunctionSpace.

The boundary_set is the same one for every subspace, but we can do the Right Thing by passing the list of DirichletBCs to infer the individual boundary_sets of each space.

Here we also altered the ordering of the kwargs, to have name as an optional kwarg

This PR also enables interpolation onto mixed spaces, which was not possible before.

Copy link

github-actions bot commented Nov 18, 2024

TestsPassed ✅Skipped ⏭️Failed ❌
Firedrake complex8083 ran6502 passed1521 skipped60 failed

@connorjward
Copy link
Contributor

@pbrubeck FYI I think I may have accidentally broken the CI runners. I am investigating.

Copy link

github-actions bot commented Nov 18, 2024

TestsPassed ✅Skipped ⏭️Failed ❌
Firedrake real8089 ran7300 passed729 skipped60 failed

return super().__new__(cls)

def __init__(self, function_space, boundary_set=frozenset(), name=None):
if all(hasattr(bc, "sub_domain") for bc in boundary_set):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ksagiyam I'm not sure if importing DirichletBC on this file is a good idea

Copy link
Contributor

Choose a reason for hiding this comment

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

DirichletBCs are big objects, so it would be nicer if impl.RestrictedFunctionSpace does not need to handle them, I think.
Though I said it would be good to have RestrictedFunctionSpace(mixed_space, ...) interface, I was not thinking too hard. Given that RestrictedFunctionSpaces are almost the same as regular FunctionSpaces (they basically only have different DoF orderings), they should just be viewed as sisters of regular FunctionSpaces, and we should probably just allow for MixedFunctionSpace([V_regular, V_restrict, V_regular, ...]) interface.
So, instead of changing the impl.RestrictedFunctionSpace constructor, can we simply convert the MixedFunctionSpace object all composed of regular function spaces to one composed of regular and restricted spaces as necessary inspecting bc.function_space in NonlinearVariationalProblem around here https://github.com/firedrakeproject/firedrake/blob/ed826a575a9314b45e8e396d1a2e9da8687f524d/firedrake/variational_solver.py#L91C45-L91C46?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not changing __init__, but just __new__. I think I achieved what you just described but through RestrictedFunctionSpace(MixedFunctionSpace, boundary_set=bcs). The bcs do not live within the RestrictedFunctionSpace, it is just easier to pass a single list as opposed to having to create separate boundary_sets for each mixed component.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest that we do not allow for RestrictedFunctionSpace(MixedFunctionSpace, ...) interface for the reason mentioned in the above. Passing bcs does not sound right either, no matter how we use it, as impl.RestrictedFunctionSpace is topological, while bcs contain geometric information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could follow the same approach we have for FunctionSpace, and implement a user-facing function RestrictedFunctionSpace in functionspace.py that parses the bcs into a boundary_set for each component, and constructs the MixedSpace if a MixedSpace is provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants