diff --git a/meshmode/interop/firedrake/connection.py b/meshmode/interop/firedrake/connection.py index 4fa6e807f7404855a5e8e4ccc2a08a252a1f4333..1e695e747e04cd0e6df80ac3996fe5c74aa7fd44 100644 --- a/meshmode/interop/firedrake/connection.py +++ b/meshmode/interop/firedrake/connection.py @@ -192,8 +192,8 @@ class FromFiredrakeConnection: ":param:`function` mesh must be the same mesh as used by " \ "``self.from_fspace().mesh()``" - # Get function data as shape [dims][nnodes] or [nnodes] - function_data = function.dat.data.T + # Get function data as shape [nnodes][dims] or [nnodes] + function_data = function.dat.data if out is None: shape = (self.to_discr.nnodes,) @@ -245,12 +245,14 @@ class FromFiredrakeConnection: mm_field = mm_field.reshape(mm_field.shape[1]) # resample from nodes - resampled_view = self.to_discr.groups[0].view(out.dat.data.T) - np.matmul(resampled_view, self._resampling_mat_mm2fd.T, out=resampled_view) + # FIXME : we're still allocating new memory when :param:`out` is supplied + resampled = np.copy(mm_field) + by_cell_view = self.to_discr.groups[0].view(resampled) + np.matmul(by_cell_view, self._resampling_mat_mm2fd.T, out=by_cell_view) # reorder data if len(out.dat.data.shape) == 1: - out.dat.data[:] = out.dat.data[self._reordering_arr_mm2fd] + out.dat.data[:] = resampled[self._reordering_arr_mm2fd] else: - out.dat.data[:] = out.dat.data[self._reordering_arr_mm2fd, :] + out.dat.data[:] = resampled.T[self._reordering_arr_mm2fd, :] return out diff --git a/test/test_firedrake_interop.py b/test/test_firedrake_interop.py index cdd5cf252840a375071dc6a60b0c6213b00ae042..69fffee76a60e47fc525ef9e5a16c74495e9e078 100644 --- a/test/test_firedrake_interop.py +++ b/test/test_firedrake_interop.py @@ -183,7 +183,10 @@ def check_idempotency(fdrake_connection, fdrake_function): """ Make sure fd->mm->fd and mm->fd->mm are identity for DG spaces """ - fdrake_fspace = fdrake_connection.from_fspace() + vdim = None + if len(fdrake_function.dat.data.shape) > 1: + vdim = fdrake_function.dat.data.shape[1] + fdrake_fspace = fdrake_connection.from_fspace(dim=vdim) # Test for idempotency fd->mm->fd mm_field = fdrake_connection.from_firedrake(fdrake_function)