Skip to content

Commit aa8cdb0

Browse files
committed
Revert "Remove DOF multiplicity parloop"
This reverts commit 436bc44.
1 parent 436bc44 commit aa8cdb0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

firedrake/interpolation.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,12 +1047,16 @@ def _interpolator(tensor, expr, subset, access, bcs=None):
10471047
if needs_weight:
10481048
# Compute the reciprocal of the DOF multiplicity
10491049
W = dual_arg.function_space()
1050-
m_ = get_interp_node_map(source_mesh, target_mesh, W)
1051-
m_indices = W.dof_dset.lgmap.apply(m_.values)
1050+
wsize = W.finat_element.space_dimension() * W.block_size
1051+
kernel_code = f"""
1052+
void multiplicity(PetscScalar *restrict w) {{
1053+
for (PetscInt i=0; i<{wsize}; i++) w[i] += 1;
1054+
}}"""
1055+
kernel = op2.Kernel(kernel_code, "multiplicity", requires_zeroed_output_arguments=False)
10521056
weight = firedrake.Function(W)
1057+
m_ = get_interp_node_map(source_mesh, target_mesh, W)
1058+
op2.par_loop(kernel, cell_set, weight.dat(op2.INC, m_))
10531059
with weight.dat.vec as w:
1054-
w.setValues(m_indices, numpy.ones(m_indices.shape), PETSc.InsertMode.ADD)
1055-
w.assemble()
10561060
w.reciprocal()
10571061

10581062
# Create a buffer for the weighted Cofunction and a callable to apply the weight

0 commit comments

Comments
 (0)