-
Notifications
You must be signed in to change notification settings - Fork 160
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
base: master
Are you sure you want to change the base?
Conversation
|
@pbrubeck FYI I think I may have accidentally broken the CI runners. I am investigating. |
|
firedrake/functionspaceimpl.py
Outdated
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): |
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.
@ksagiyam I'm not sure if importing DirichletBC on this file is a good idea
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.
DirichletBC
s 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 RestrictedFunctionSpace
s are almost the same as regular FunctionSpace
s (they basically only have different DoF orderings), they should just be viewed as sisters of regular FunctionSpace
s, 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?
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'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.
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 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.
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 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.
33efcd0
to
cfff93c
Compare
Description
This PR enables to construct a
RestrictedFunctionSpace
from aMixedFunctionSpace
.The
boundary_set
is the same one for every subspace, but we can do the Right Thing by passing the list ofDirichletBC
s to infer the individualboundary_sets
of each space.Here we also altered the ordering of the kwargs, to have
name
as an optional kwargThis PR also enables interpolation onto mixed spaces, which was not possible before.