From 6c45d61b9efd61780188c8c77ac6c6aeb97591d1 Mon Sep 17 00:00:00 2001 From: benSepanski Date: Sun, 28 Jun 2020 11:31:35 -0500 Subject: [PATCH] get function transfer to pass tests --- meshmode/interop/firedrake/connection.py | 14 ++++++++------ test/test_firedrake_interop.py | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/meshmode/interop/firedrake/connection.py b/meshmode/interop/firedrake/connection.py index 4fa6e807..1e695e74 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 cdd5cf25..69fffee7 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) -- GitLab