Repository navigation
Add Clement interpolation on domain interior - #12
Conversation
628f8df to
23bab3b
Compare
stephankramer
left a comment
There was a problem hiding this comment.
Nice. Just some queries, also fine with it as is. Given the parloops depend on a correct halo exchange (I think it should do the right thing already) maybe add a parallel test?
| patch_vol = fd.Function(fd.FunctionSpace(mesh, "Lagrange", 1)) | ||
| domain = "{[i]: 0 <= i < patch.dofs}" | ||
| instructions = "patch[i, 0] = patch[i, 0] + vol[0, 0]" | ||
| keys = {"vol": (cell_volume(mesh), fd.READ), "patch": (patch_vol, fd.RW)} | ||
| fd.par_loop((domain, instructions), ufl.dx(domain=mesh), keys) |
There was a problem hiding this comment.
If you want to avoid a parloop you could also do patch_vol.interpolate(CellVolume(mesh), access=fd.INC)
There was a problem hiding this comment.
Oh, nice! I wasn't aware of that. Done in a6d3b8e.
| # Take the weighted average of the source function over the neighbouring cells | ||
| block_size = getattr(Vs, "block_size", 1) | ||
| domain = f"{{[i, j]: 0 <= i < out.dofs and 0 <= j < {block_size}}}" | ||
| instructions = "out[i, j] = out[i, j] + vol[0, 0] * f[0, j]" | ||
| keys = { | ||
| "f": (source, fd.READ), | ||
| "vol": (cell_volume(mesh), fd.READ), | ||
| "out": (target, fd.RW), | ||
| } | ||
| fd.par_loop((domain, instructions), ufl.dx(domain=mesh), keys) |
There was a problem hiding this comment.
Similarly here I think you could do: target.interpolate(CellVolume(mesh)*source, access=fd.INC)
| def clement_interpolant(source, target=None): | ||
| r"""Compute the Clement interpolant of a :math:`\mathbb P0` source field. | ||
|
|
||
| i.e. take the volume average over neighbouring cells at each vertex. See |
There was a problem hiding this comment.
Out of interest: is this the same as a lumped P0 - P1 projection? (i.e. with a lumped mass matrix) ?
There was a problem hiding this comment.
Yes, you're right, it does. Added a note in 3fd7cfd.
23bab3b to
302710f
Compare
Functionality here is now duplicated in `adapt_common` following merging mesh-adaptation/adapt_common#12 and mesh-adaptation/adapt_common#21, so can be removed from Animate.
Closes #10.
Merges into #19
This PR ports the interior Clement interpolation functionality of Animate over to adapt_common.
Edit: I'll do the boundary case in a follow-up PR.
Checklist
get_function_spaceutilget_function_space