BCs for cross-mesh interpolation#5165
Conversation
| row_mask = self._bc_mask(row_arg.function_space(), bcs) | ||
| col_mask = self._bc_mask(col_arg.function_space(), bcs) | ||
| with row_mask.dat.vec_ro as r, col_mask.dat.vec_ro as c: | ||
| mat.diagonalScale(r, c) |
There was a problem hiding this comment.
Use mat.zeroRowsColumnsLocal() instead.
| def _bc_mask(self, space: WithGeometry, bcs: Iterable[DirichletBC]) -> Function: | ||
| """Return a 0/1 mask over `space` which is zero at boundary condition nodes | ||
| """ | ||
| space = space.dual() if is_dual(space) else space | ||
| f = Function(space).assign(1.0) | ||
| for bc in bcs: | ||
| if bc.function_space() == space: | ||
| bc.zero(f) | ||
| return f |
There was a problem hiding this comment.
This is reinventing the wheel. We have some functions that do similar things scattered all over the place. My recommendation is to move bcdofs from preconditioners/patch.py to bcs.py and use it instead.
| if self.ufl_interpolate.is_adjoint: | ||
| I = Matrix(interpolate(TestFunction(source_space), self.target_space), res) | ||
| return assemble(action(I, self._interpolate_from_quadrature)).petscmat | ||
| res = assemble(action(I, self._interpolate_from_quadrature)).petscmat |
There was a problem hiding this comment.
Wouldn't the right thing be to reuse the support that assemble has for bcs?
| res = assemble(action(I, self._interpolate_from_quadrature)).petscmat | |
| res = assemble(action(I, self._interpolate_from_quadrature), bcs=bcs).petscmat |
There was a problem hiding this comment.
VomOntoVomInterpolator doesn't support BCs. I suppose we could do what this PR is doing for VomOntoVom and then it should work.
There was a problem hiding this comment.
But the BCs that the user provided are not defined on a VOM FunctionSpace. Why do we need to support BCs for VomOntoVom?
There was a problem hiding this comment.
If I do res = assemble(interp_expr, mat_type=mat_type, bcs=bcs).petscmat then the BCs get passed through to VomOntoVomInterpolator
There was a problem hiding this comment.
This seems like a bug, we should only set BCs on the final matrix-matrix product
Support BCs for cross-mesh interpolation matrices