-
Notifications
You must be signed in to change notification settings - Fork 172
RieszMap
fixes/suggestions
#4568
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,6 +426,13 @@ def __init__(self, function_space_or_inner_product=None, | |
sobolev_space, u, v | ||
) | ||
|
||
if bcs is None: | ||
bcs = () | ||
else: | ||
bcs = tuple(bcs) | ||
if len(bcs) > 0 and inner_product == "l2": | ||
raise ValueError("Cannot supply boundary conditions with an l2 Riesz map") | ||
|
||
self._function_space = function_space | ||
self._inner_product = inner_product | ||
self._bcs = bcs | ||
|
@@ -478,8 +485,8 @@ def __call__(self, value): | |
else: | ||
solve, rhs, soln = self._solver | ||
rhs.assign(value) | ||
soln.zero() | ||
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. Doesn't PETSc always use a zero initial guess unless you pass 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. This might be ignored due to #4142. I'd need to check for this use case, but I think it's still safer to zero here. 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.
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. Setting the initial guess explicitly outside PETSc is the only way with SNES. |
||
solve() | ||
output = Function(self._function_space) | ||
output.assign(soln) | ||
elif ufl.duals.is_primal(value): | ||
if value.function_space() != self._function_space: | ||
|
@@ -490,8 +497,13 @@ def __call__(self, value): | |
for o, c in zip(output.subfunctions, value.subfunctions): | ||
o.dat.data[:] = c.dat.data_ro[:] | ||
else: | ||
if len(self._bcs) > 0: | ||
value = value.copy(deepcopy=True) | ||
for bc in self._bcs: | ||
bc.apply(value) | ||
output = firedrake.assemble( | ||
firedrake.action(self._inner_product, value) | ||
firedrake.action(self._inner_product, value), | ||
bcs=self._bcs, zero_bc_nodes=True, | ||
pbrubeck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
else: | ||
raise ValueError( | ||
|
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 curious here. Does this lead to the wrong results in optimization?
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.
Does "l2" here means that we are imposing the wrong inner-product between two primal objects, or does it mean that we are pairing a primal with a dual?
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.
For$l_2$ the bcs are ignored. They could probably be applied, but I'm not sure it would be that useful.
Yes, it's the basis dependent map defined by dof assignment. I'm not sure if there's a case to remove this now (Firedrake code at least doesn't seem to use it much?) but maybe not for this PR?
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.
This close to a major release I'd say lets keep this PR to fixes, then we can think about API changes after.