RestrictedFunctionSpace(MixedFunctionSpace) #6489
8083 tests run, 6502 passed, 1521 skipped, 60 failed.
Annotations
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[interval-mesh-0-coords-TensorFunctionSpace(CG2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(1), np.int64(1), np.int64(1)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(1), np.int64(1), np.int64(1)), 'Cells'), Set((np.int64(3), np.int64(3), np.int64(3)), 'set... 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'set_#x7f94f27988c0'), 2, None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: 879824267735639143
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 3282)
vertexcoords = array([], shape=(0, 1), dtype=complex128)
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f33bcbc0>
name = None
maps_ = (MixedMap((Map(Set((np.int64(1), np.int64(1), np.int64(1)), 'Cells'), Set((np.int64(3), np.int64(3), np.int64(3)), 'se...p.int64(0)), 'Cells'), Set((np.int64(1), np.int64(1), np.int64(1)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(1), np.int64(1), np.int64(1)), 'Cells'), Set((np.int64(3), np.int64(3), np.int64(3)), 'set... 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'set_#x7f94f27988c0'), 2, None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(1), np.int64(1), np.int64(1)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[interval-mesh-1-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([0.+0.j]), array([[[0.35715804+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([0.+0.j]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2fa41a0'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3311[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2fa41a0'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3311[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f868bad0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(1, 1), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=1), 3302)), 5951).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 3299)
vertexcoords = array([[0.59762701+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([0.+0.j]), array([[[0.35715804+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([0.+0.j]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2fa41a0'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3311[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2fa41a0'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3311[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f868bad0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(1, 1), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=1), 3302)), 5951).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[interval-mesh-100-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]), array([[[3.57158041e-01+0.j]],\n\n [[8.65604586e-01+0.j]],\n\n [[4.97767998e-01+0.j]],\n\n [[3.47824366e-01+0.j]],\n\n [[1.20623957e-01+0.j]],\n\n [[6.26928595e-01+0.j]],\n\n [[1.40755847e-01+0.j]],\n\n [[1.64749034e+00+0.j]],\n\n [[2.03725814e+00+0.j]],\n\n [[7.12265558e-02+0.j]],\n\n [[1.17386407e+00+0.j]],\n\n [[3.11129505e-01+0.j]],\n\n [[4.04609371e-01+0.j]],\n\n [[1.82572327e+00+0.j]],\n\n [[1.28112370e-01-0.j]],\n\n [[1.06107460e-01-0.j]],\n\n [[2.11198339e-01-0.j]],\n\n [[1.35778354e+00+0.j]],\n\n [[1.11579821e+00+0.j]],\n\n [[1.53766026e+00+0.j]],\n\n [[2.12353875e+00+0.j]],\n\n [[1.20630051e+00+0.j]],\n\n [[1.78894083e-01+0.j]],\n\n [[1.12584483e+00+0.j]],\n\n [[6.94065075e-02-0.j]],\n\n [[6.08153611e-01+0.j]],\n\n [[4.54940852e-02-0.j]],\n\n [[1.93025962e+00+0.j]],\n\n [[2.95606040e-01+0.j]],\n\n [[1.08454218e-01+0.j]],\n\n [[8.47463375e-04+0.j]],\n\n [[1.09928384e+00+0.j]],\n\n [[1.69991838e-01+0.j]],\n\n [[4.05600719e-01+0.j]],\n\n [[2.13832626e-01-0.j]],\n\n [[5.40623435e-01+0.j]],\n\n [[5.24453250e-01+0.j]],\n\n [[5.385...941e-01+0.j]],\n\n [[5.00122095e-02-0.j]],\n\n [[1.14137763e-02-0.j]],\n\n [[5.63826646e-02+0.j]],\n\n [[1.30413307e+00+0.j]],\n\n [[9.35120795e-02-0.j]],\n\n [[1.38271686e+00+0.j]],\n\n [[9.47428002e-02-0.j]],\n\n [[2.11097342e+00+0.j]],\n\n [[1.91233392e-01+0.j]],\n\n [[2.11272672e+00+0.j]],\n\n [[5.03661372e-01+0.j]],\n\n [[9.57515401e-01+0.j]],\n\n [[1.77767148e-01-0.j]],\n\n [[4.30518717e-03+0.j]],\n\n [[6.73957309e-02-0.j]],\n\n [[8.51567131e-03+0.j]],\n\n [[6.89296471e-02-0.j]],\n\n [[1.84868507e-02+0.j]],\n\n [[1.07929325e-01+0.j]],\n\n [[1.38164612e-01-0.j]],\n\n [[7.83126306e-01+0.j]],\n\n [[4.00945923e-01+0.j]],\n\n [[9.47345726e-04+0.j]],\n\n [[2.98657995e-01+0.j]],\n\n [[9.74182567e-02-0.j]],\n\n [[4.24964472e-01+0.j]],\n\n [[1.84577330e+00+0.j]],\n\n [[1.88068050e-02+0.j]],\n\n [[6.96925701e-01+0.j]],\n\n [[5.58869813e-02-0.j]],\n\n [[8.69844245e-01+0.j]],\n\n [[6.21136065e-03+0.j]],\n\n [[1.78535764e-02-0.j]],\n\n [[4.52963821e-01+0.j]],\n\n [[2.11402161e-01-0.j]],\n\n [[1.34068623e+00+0.j]],\n\n [[2.40697238e-01-0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]) = Dat(DataSet(Set((np.int64(100), np.int64(100), np.int64(100)), 'set_#x7f94f29ec980'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3328[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(100), np.int64(100), np.int64(100)), 'set_#x7f94f29ec980'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3328[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2ff3ec0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(1, 1), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=1), 3319)), 5979).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 3316)
vertexcoords = array([[ 0.59762701+0.j],
[ 0.93037873+0.j],
[ 0.70552675+0.j],
[ 0.58976637+0.j],
[ 0.347...13361728+0.j],
[ 0.67302587+0.j],
[-0.45978491+0.j],
[ 1.15788006+0.j],
[-0.49060905+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]), array([[[3.57158041e-01+0.j]],\n\n [[8.65604586e-01+0.j]],\n\n [[4.97767998e-01+0.j]],\n\n [[3.47824366e-01+0.j]],\n\n [[1.20623957e-01+0.j]],\n\n [[6.26928595e-01+0.j]],\n\n [[1.40755847e-01+0.j]],\n\n [[1.64749034e+00+0.j]],\n\n [[2.03725814e+00+0.j]],\n\n [[7.12265558e-02+0.j]],\n\n [[1.17386407e+00+0.j]],\n\n [[3.11129505e-01+0.j]],\n\n [[4.04609371e-01+0.j]],\n\n [[1.82572327e+00+0.j]],\n\n [[1.28112370e-01-0.j]],\n\n [[1.06107460e-01-0.j]],\n\n [[2.11198339e-01-0.j]],\n\n [[1.35778354e+00+0.j]],\n\n [[1.11579821e+00+0.j]],\n\n [[1.53766026e+00+0.j]],\n\n [[2.12353875e+00+0.j]],\n\n [[1.20630051e+00+0.j]],\n\n [[1.78894083e-01+0.j]],\n\n [[1.12584483e+00+0.j]],\n\n [[6.94065075e-02-0.j]],\n\n [[6.08153611e-01+0.j]],\n\n [[4.54940852e-02-0.j]],\n\n [[1.93025962e+00+0.j]],\n\n [[2.95606040e-01+0.j]],\n\n [[1.08454218e-01+0.j]],\n\n [[8.47463375e-04+0.j]],\n\n [[1.09928384e+00+0.j]],\n\n [[1.69991838e-01+0.j]],\n\n [[4.05600719e-01+0.j]],\n\n [[2.13832626e-01-0.j]],\n\n [[5.40623435e-01+0.j]],\n\n [[5.24453250e-01+0.j]],\n\n [[5.385...941e-01+0.j]],\n\n [[5.00122095e-02-0.j]],\n\n [[1.14137763e-02-0.j]],\n\n [[5.63826646e-02+0.j]],\n\n [[1.30413307e+00+0.j]],\n\n [[9.35120795e-02-0.j]],\n\n [[1.38271686e+00+0.j]],\n\n [[9.47428002e-02-0.j]],\n\n [[2.11097342e+00+0.j]],\n\n [[1.91233392e-01+0.j]],\n\n [[2.11272672e+00+0.j]],\n\n [[5.03661372e-01+0.j]],\n\n [[9.57515401e-01+0.j]],\n\n [[1.77767148e-01-0.j]],\n\n [[4.30518717e-03+0.j]],\n\n [[6.73957309e-02-0.j]],\n\n [[8.51567131e-03+0.j]],\n\n [[6.89296471e-02-0.j]],\n\n [[1.84868507e-02+0.j]],\n\n [[1.07929325e-01+0.j]],\n\n [[1.38164612e-01-0.j]],\n\n [[7.83126306e-01+0.j]],\n\n [[4.00945923e-01+0.j]],\n\n [[9.47345726e-04+0.j]],\n\n [[2.98657995e-01+0.j]],\n\n [[9.74182567e-02-0.j]],\n\n [[4.24964472e-01+0.j]],\n\n [[1.84577330e+00+0.j]],\n\n [[1.88068050e-02+0.j]],\n\n [[6.96925701e-01+0.j]],\n\n [[5.58869813e-02-0.j]],\n\n [[8.69844245e-01+0.j]],\n\n [[6.21136065e-03+0.j]],\n\n [[1.78535764e-02-0.j]],\n\n [[4.52963821e-01+0.j]],\n\n [[2.11402161e-01-0.j]],\n\n [[1.34068623e+00+0.j]],\n\n [[2.40697238e-01-0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j,\n 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]) = Dat(DataSet(Set((np.int64(100), np.int64(100), np.int64(100)), 'set_#x7f94f29ec980'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3328[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(100), np.int64(100), np.int64(100)), 'set_#x7f94f29ec980'), (1, 1), 'None_nodes_dset'), None, dtype('complex128'), 'function_3328[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2ff3ec0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(1, 1), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=1), 3319)), 5979).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-0-coords-TensorFunctionSpace(CG2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(9), np.int64(9), np.int64(9)), 'set... 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'set_#x7f94f2b47350'), 3, None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: 3521107982910022300
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3333)
vertexcoords = array([], shape=(0, 2), dtype=complex128)
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f309e300>
name = None
maps_ = (MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(9), np.int64(9), np.int64(9)), 'se...p.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(9), np.int64(9), np.int64(9)), 'set... 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'set_#x7f94f2b47350'), 3, None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-0-coords-VectorFunctionSpace(BDM2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(21), np.int64(21), np.int64(21)), '... 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'set_#x7f94f2a91310'), 3, None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: 1981441192393448743
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3351)
vertexcoords = array([], shape=(0, 2), dtype=complex128)
tfs = ('BDM', 2, <cyfunction VectorFunctionSpace at 0x7f951f06e740>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f200d070>
name = None
maps_ = (MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(21), np.int64(21), np.int64(21)), ...p.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(21), np.int64(21), np.int64(21)), '... 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'set_#x7f94f2a91310'), 3, None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-0-coords-FunctionSpace(Regge2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(33), np.int64(33), np.int64(33)), '... 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'set_#x7f94f2d29310'), 3, None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: 6879067337027424329
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3369)
vertexcoords = array([], shape=(0, 2), dtype=complex128)
tfs = ('Regge', 2, <cyfunction FunctionSpace at 0x7f951f06e5a0>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f32e3980>
name = None
maps_ = (MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(33), np.int64(33), np.int64(33)), ...p.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), Set((np.int64(33), np.int64(33), np.int64(33)), '... 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'set_#x7f94f2d29310'), 3, None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(2), np.int64(2), np.int64(2)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-1-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f36a6690'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3402[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f36a6690'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3402[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2d28b30>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3393)), 6131).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3387)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f36a6690'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3402[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f36a6690'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3402[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2d28b30>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3393)), 6131).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-1-coords-VectorFunctionSpace(BDM2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f28d8c50'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3420[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f28d8c50'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3420[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1d3d640>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3411)), 6165).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3405)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j]])
tfs = ('BDM', 2, <cyfunction VectorFunctionSpace at 0x7f951f06e740>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f28d8c50'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3420[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f28d8c50'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3420[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1d3d640>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3411)), 6165).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-1-coords-FunctionSpace(Regge2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2a9a870'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3438[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2a9a870'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3438[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1d09970>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3429)), 6199).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3423)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j]])
tfs = ('Regge', 2, <cyfunction FunctionSpace at 0x7f951f06e5a0>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2a9a870'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3438[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2a9a870'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3438[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1d09970>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3429)), 6199).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-100-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 3.57158041e-01+0.j, 5.56019458e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j]],\n\n [[ 4.97767998e-01+0.j, 4.16095949e-01+0.j],\n [ 4.16095949e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.20623957e-01+0.j, 2.74995651e-01+0.j],\n [ 2.74995651e-01+0.j, 6.26928595e-01+0.j]],\n\n [[ 1.40755847e-01+0.j, 4.81553630e-01+0.j],\n [ 4.81553630e-01+0.j, 1.64749034e+00+0.j]],\n\n [[ 2.03725814e+00+0.j, 3.80928971e-01+0.j],\n [ 3.80928971e-01+0.j, 7.12265558e-02+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 4.04609371e-01+0.j, 8.59479345e-01+0.j],\n [ 8.59479345e-01+0.j, 1.82572327e+00+0.j]],\n\n [[ 1.11579821e+00+0.j, 1.30985441e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j]],\n\n [[ 1.78894083e-01+0.j, 4.48783887e-01+0.j],\n [ 4.48783887e-01+0.j, 1.12584483e+00+0.j]],\n\n [[ 4.54940852e-02-0.j, -2.96336625e-01+0.j],\n [-2.96336625e-01+0.j, 1.93025962e+00+0.j]],\n\n [[ 8.47463375e-04+0.j, 3.05221689e-02+0.j],\n [ 3.05221689e-02+0.j, 1.09928384e+00+0.j]],\n\n [[ 1.69991838e-01+0.j, 2...e-01+0.j, 5.34535180e-01+0.j]],\n\n [[ 6.36855869e-02-0.j, -3.01826755e-01+0.j],\n [-3.01826755e-01+0.j, 1.43045537e+00+0.j]],\n\n [[ 9.88263557e-02+0.j, -1.13695712e-01+0.j],\n [-1.13695712e-01+0.j, 1.30802302e-01-0.j]],\n\n [[ 2.27120711e-01-0.j, -1.04824895e-01+0.j],\n [-1.04824895e-01+0.j, 4.83806987e-02+0.j]],\n\n [[ 9.21563760e-01+0.j, -1.50468061e-01+0.j],\n [-1.50468061e-01+0.j, 2.45676299e-02-0.j]],\n\n [[ 2.93843368e-01+0.j, -2.12126270e-01+0.j],\n [-2.12126270e-01+0.j, 1.53134491e-01-0.j]],\n\n [[ 8.25969795e-01+0.j, -3.96542129e-01+0.j],\n [-3.96542129e-01+0.j, 1.90377011e-01-0.j]],\n\n [[ 2.91083477e-02-0.j, -1.26757114e-01+0.j],\n [-1.26757114e-01+0.j, 5.51984811e-01+0.j]],\n\n [[ 4.28314197e-01+0.j, -1.58472599e-02+0.j],\n [-1.58472599e-02+0.j, 5.86335097e-04-0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.47411213e-01-0.j, -1.41610458e-01+0.j],\n [-1.41610458e-01+0.j, 1.36037967e-01+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e65eb0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3456[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e65eb0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3456[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f32e0500>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3447)), 6233).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3441)
vertexcoords = array([[ 0.59762701+0.j, 0.93037873+0.j],
[ 0.70552675+0.j, 0.58976637+0.j],
[ 0.3473096 +0.j, 0.7917....29644212+0.j, -0.0803125 +0.j],
[-0.04517074+0.j, 0.00871296+0.j],
[-0.38394168+0.j, 0.36883325+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 3.57158041e-01+0.j, 5.56019458e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j]],\n\n [[ 4.97767998e-01+0.j, 4.16095949e-01+0.j],\n [ 4.16095949e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.20623957e-01+0.j, 2.74995651e-01+0.j],\n [ 2.74995651e-01+0.j, 6.26928595e-01+0.j]],\n\n [[ 1.40755847e-01+0.j, 4.81553630e-01+0.j],\n [ 4.81553630e-01+0.j, 1.64749034e+00+0.j]],\n\n [[ 2.03725814e+00+0.j, 3.80928971e-01+0.j],\n [ 3.80928971e-01+0.j, 7.12265558e-02+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 4.04609371e-01+0.j, 8.59479345e-01+0.j],\n [ 8.59479345e-01+0.j, 1.82572327e+00+0.j]],\n\n [[ 1.11579821e+00+0.j, 1.30985441e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j]],\n\n [[ 1.78894083e-01+0.j, 4.48783887e-01+0.j],\n [ 4.48783887e-01+0.j, 1.12584483e+00+0.j]],\n\n [[ 4.54940852e-02-0.j, -2.96336625e-01+0.j],\n [-2.96336625e-01+0.j, 1.93025962e+00+0.j]],\n\n [[ 8.47463375e-04+0.j, 3.05221689e-02+0.j],\n [ 3.05221689e-02+0.j, 1.09928384e+00+0.j]],\n\n [[ 1.69991838e-01+0.j, 2...e-01+0.j, 5.34535180e-01+0.j]],\n\n [[ 6.36855869e-02-0.j, -3.01826755e-01+0.j],\n [-3.01826755e-01+0.j, 1.43045537e+00+0.j]],\n\n [[ 9.88263557e-02+0.j, -1.13695712e-01+0.j],\n [-1.13695712e-01+0.j, 1.30802302e-01-0.j]],\n\n [[ 2.27120711e-01-0.j, -1.04824895e-01+0.j],\n [-1.04824895e-01+0.j, 4.83806987e-02+0.j]],\n\n [[ 9.21563760e-01+0.j, -1.50468061e-01+0.j],\n [-1.50468061e-01+0.j, 2.45676299e-02-0.j]],\n\n [[ 2.93843368e-01+0.j, -2.12126270e-01+0.j],\n [-2.12126270e-01+0.j, 1.53134491e-01-0.j]],\n\n [[ 8.25969795e-01+0.j, -3.96542129e-01+0.j],\n [-3.96542129e-01+0.j, 1.90377011e-01-0.j]],\n\n [[ 2.91083477e-02-0.j, -1.26757114e-01+0.j],\n [-1.26757114e-01+0.j, 5.51984811e-01+0.j]],\n\n [[ 4.28314197e-01+0.j, -1.58472599e-02+0.j],\n [-1.58472599e-02+0.j, 5.86335097e-04-0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.47411213e-01-0.j, -1.41610458e-01+0.j],\n [-1.41610458e-01+0.j, 1.36037967e-01+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e65eb0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3456[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e65eb0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3456[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f32e0500>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3447)), 6233).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-100-coords-VectorFunctionSpace(BDM2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 3.57158041e-01+0.j, 5.56019458e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j]],\n\n [[ 4.97767998e-01+0.j, 4.16095949e-01+0.j],\n [ 4.16095949e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.20623957e-01+0.j, 2.74995651e-01+0.j],\n [ 2.74995651e-01+0.j, 6.26928595e-01+0.j]],\n\n [[ 1.40755847e-01+0.j, 4.81553630e-01+0.j],\n [ 4.81553630e-01+0.j, 1.64749034e+00+0.j]],\n\n [[ 2.03725814e+00+0.j, 3.80928971e-01+0.j],\n [ 3.80928971e-01+0.j, 7.12265558e-02+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 4.04609371e-01+0.j, 8.59479345e-01+0.j],\n [ 8.59479345e-01+0.j, 1.82572327e+00+0.j]],\n\n [[ 1.11579821e+00+0.j, 1.30985441e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j]],\n\n [[ 1.78894083e-01+0.j, 4.48783887e-01+0.j],\n [ 4.48783887e-01+0.j, 1.12584483e+00+0.j]],\n\n [[ 4.54940852e-02-0.j, -2.96336625e-01+0.j],\n [-2.96336625e-01+0.j, 1.93025962e+00+0.j]],\n\n [[ 8.47463375e-04+0.j, 3.05221689e-02+0.j],\n [ 3.05221689e-02+0.j, 1.09928384e+00+0.j]],\n\n [[ 1.69991838e-01+0.j, 2...e-01+0.j, 5.34535180e-01+0.j]],\n\n [[ 6.36855869e-02-0.j, -3.01826755e-01+0.j],\n [-3.01826755e-01+0.j, 1.43045537e+00+0.j]],\n\n [[ 9.88263557e-02+0.j, -1.13695712e-01+0.j],\n [-1.13695712e-01+0.j, 1.30802302e-01-0.j]],\n\n [[ 2.27120711e-01-0.j, -1.04824895e-01+0.j],\n [-1.04824895e-01+0.j, 4.83806987e-02+0.j]],\n\n [[ 9.21563760e-01+0.j, -1.50468061e-01+0.j],\n [-1.50468061e-01+0.j, 2.45676299e-02-0.j]],\n\n [[ 2.93843368e-01+0.j, -2.12126270e-01+0.j],\n [-2.12126270e-01+0.j, 1.53134491e-01-0.j]],\n\n [[ 8.25969795e-01+0.j, -3.96542129e-01+0.j],\n [-3.96542129e-01+0.j, 1.90377011e-01-0.j]],\n\n [[ 2.91083477e-02-0.j, -1.26757114e-01+0.j],\n [-1.26757114e-01+0.j, 5.51984811e-01+0.j]],\n\n [[ 4.28314197e-01+0.j, -1.58472599e-02+0.j],\n [-1.58472599e-02+0.j, 5.86335097e-04-0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.47411213e-01-0.j, -1.41610458e-01+0.j],\n [-1.41610458e-01+0.j, 1.36037967e-01+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f23add30'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3474[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f23add30'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3474[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f337eba0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3465)), 6267).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3459)
vertexcoords = array([[ 0.59762701+0.j, 0.93037873+0.j],
[ 0.70552675+0.j, 0.58976637+0.j],
[ 0.3473096 +0.j, 0.7917....29644212+0.j, -0.0803125 +0.j],
[-0.04517074+0.j, 0.00871296+0.j],
[-0.38394168+0.j, 0.36883325+0.j]])
tfs = ('BDM', 2, <cyfunction VectorFunctionSpace at 0x7f951f06e740>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 3.57158041e-01+0.j, 5.56019458e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j]],\n\n [[ 4.97767998e-01+0.j, 4.16095949e-01+0.j],\n [ 4.16095949e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.20623957e-01+0.j, 2.74995651e-01+0.j],\n [ 2.74995651e-01+0.j, 6.26928595e-01+0.j]],\n\n [[ 1.40755847e-01+0.j, 4.81553630e-01+0.j],\n [ 4.81553630e-01+0.j, 1.64749034e+00+0.j]],\n\n [[ 2.03725814e+00+0.j, 3.80928971e-01+0.j],\n [ 3.80928971e-01+0.j, 7.12265558e-02+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 4.04609371e-01+0.j, 8.59479345e-01+0.j],\n [ 8.59479345e-01+0.j, 1.82572327e+00+0.j]],\n\n [[ 1.11579821e+00+0.j, 1.30985441e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j]],\n\n [[ 1.78894083e-01+0.j, 4.48783887e-01+0.j],\n [ 4.48783887e-01+0.j, 1.12584483e+00+0.j]],\n\n [[ 4.54940852e-02-0.j, -2.96336625e-01+0.j],\n [-2.96336625e-01+0.j, 1.93025962e+00+0.j]],\n\n [[ 8.47463375e-04+0.j, 3.05221689e-02+0.j],\n [ 3.05221689e-02+0.j, 1.09928384e+00+0.j]],\n\n [[ 1.69991838e-01+0.j, 2...e-01+0.j, 5.34535180e-01+0.j]],\n\n [[ 6.36855869e-02-0.j, -3.01826755e-01+0.j],\n [-3.01826755e-01+0.j, 1.43045537e+00+0.j]],\n\n [[ 9.88263557e-02+0.j, -1.13695712e-01+0.j],\n [-1.13695712e-01+0.j, 1.30802302e-01-0.j]],\n\n [[ 2.27120711e-01-0.j, -1.04824895e-01+0.j],\n [-1.04824895e-01+0.j, 4.83806987e-02+0.j]],\n\n [[ 9.21563760e-01+0.j, -1.50468061e-01+0.j],\n [-1.50468061e-01+0.j, 2.45676299e-02-0.j]],\n\n [[ 2.93843368e-01+0.j, -2.12126270e-01+0.j],\n [-2.12126270e-01+0.j, 1.53134491e-01-0.j]],\n\n [[ 8.25969795e-01+0.j, -3.96542129e-01+0.j],\n [-3.96542129e-01+0.j, 1.90377011e-01-0.j]],\n\n [[ 2.91083477e-02-0.j, -1.26757114e-01+0.j],\n [-1.26757114e-01+0.j, 5.51984811e-01+0.j]],\n\n [[ 4.28314197e-01+0.j, -1.58472599e-02+0.j],\n [-1.58472599e-02+0.j, 5.86335097e-04-0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.47411213e-01-0.j, -1.41610458e-01+0.j],\n [-1.41610458e-01+0.j, 1.36037967e-01+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0.-0.j, 0.+0.j],\n [0.-0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f23add30'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3474[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f23add30'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3474[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f337eba0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3465)), 6267).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[square-mesh-100-coords-FunctionSpace(Regge2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 3.57158041e-01+0.j, 5.56019458e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j]],\n\n [[ 4.97767998e-01+0.j, 4.16095949e-01+0.j],\n [ 4.16095949e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.20623957e-01+0.j, 2.74995651e-01+0.j],\n [ 2.74995651e-01+0.j, 6.26928595e-01+0.j]],\n\n [[ 1.40755847e-01+0.j, 4.81553630e-01+0.j],\n [ 4.81553630e-01+0.j, 1.64749034e+00+0.j]],\n\n [[ 2.03725814e+00+0.j, 3.80928971e-01+0.j],\n [ 3.80928971e-01+0.j, 7.12265558e-02+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 4.04609371e-01+0.j, 8.59479345e-01+0.j],\n [ 8.59479345e-01+0.j, 1.82572327e+00+0.j]],\n\n [[ 1.11579821e+00+0.j, 1.30985441e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j]],\n\n [[ 1.78894083e-01+0.j, 4.48783887e-01+0.j],\n [ 4.48783887e-01+0.j, 1.12584483e+00+0.j]],\n\n [[ 4.54940852e-02-0.j, -2.96336625e-01+0.j],\n [-2.96336625e-01+0.j, 1.93025962e+00+0.j]],\n\n [[ 8.47463375e-04+0.j, 3.05221689e-02+0.j],\n [ 3.05221689e-02+0.j, 1.09928384e+00+0.j]],\n\n [[ 1.69991838e-01+0.j, 2...e-01+0.j, 5.34535180e-01+0.j]],\n\n [[ 6.36855869e-02-0.j, -3.01826755e-01+0.j],\n [-3.01826755e-01+0.j, 1.43045537e+00+0.j]],\n\n [[ 9.88263557e-02+0.j, -1.13695712e-01+0.j],\n [-1.13695712e-01+0.j, 1.30802302e-01-0.j]],\n\n [[ 2.27120711e-01-0.j, -1.04824895e-01+0.j],\n [-1.04824895e-01+0.j, 4.83806987e-02+0.j]],\n\n [[ 9.21563760e-01+0.j, -1.50468061e-01+0.j],\n [-1.50468061e-01+0.j, 2.45676299e-02-0.j]],\n\n [[ 2.93843368e-01+0.j, -2.12126270e-01+0.j],\n [-2.12126270e-01+0.j, 1.53134491e-01-0.j]],\n\n [[ 8.25969795e-01+0.j, -3.96542129e-01+0.j],\n [-3.96542129e-01+0.j, 1.90377011e-01-0.j]],\n\n [[ 2.91083477e-02-0.j, -1.26757114e-01+0.j],\n [-1.26757114e-01+0.j, 5.51984811e-01+0.j]],\n\n [[ 4.28314197e-01+0.j, -1.58472599e-02+0.j],\n [-1.58472599e-02+0.j, 5.86335097e-04-0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.47411213e-01-0.j, -1.41610458e-01+0.j],\n [-1.41610458e-01+0.j, 1.36037967e-01+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e771d0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3492[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e771d0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3492[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1ba5310>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3483)), 6301).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 3477)
vertexcoords = array([[ 0.59762701+0.j, 0.93037873+0.j],
[ 0.70552675+0.j, 0.58976637+0.j],
[ 0.3473096 +0.j, 0.7917....29644212+0.j, -0.0803125 +0.j],
[-0.04517074+0.j, 0.00871296+0.j],
[-0.38394168+0.j, 0.36883325+0.j]])
tfs = ('Regge', 2, <cyfunction FunctionSpace at 0x7f951f06e5a0>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 3.57158041e-01+0.j, 5.56019458e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j]],\n\n [[ 4.97767998e-01+0.j, 4.16095949e-01+0.j],\n [ 4.16095949e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.20623957e-01+0.j, 2.74995651e-01+0.j],\n [ 2.74995651e-01+0.j, 6.26928595e-01+0.j]],\n\n [[ 1.40755847e-01+0.j, 4.81553630e-01+0.j],\n [ 4.81553630e-01+0.j, 1.64749034e+00+0.j]],\n\n [[ 2.03725814e+00+0.j, 3.80928971e-01+0.j],\n [ 3.80928971e-01+0.j, 7.12265558e-02+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 4.04609371e-01+0.j, 8.59479345e-01+0.j],\n [ 8.59479345e-01+0.j, 1.82572327e+00+0.j]],\n\n [[ 1.11579821e+00+0.j, 1.30985441e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j]],\n\n [[ 1.78894083e-01+0.j, 4.48783887e-01+0.j],\n [ 4.48783887e-01+0.j, 1.12584483e+00+0.j]],\n\n [[ 4.54940852e-02-0.j, -2.96336625e-01+0.j],\n [-2.96336625e-01+0.j, 1.93025962e+00+0.j]],\n\n [[ 8.47463375e-04+0.j, 3.05221689e-02+0.j],\n [ 3.05221689e-02+0.j, 1.09928384e+00+0.j]],\n\n [[ 1.69991838e-01+0.j, 2...e-01+0.j, 5.34535180e-01+0.j]],\n\n [[ 6.36855869e-02-0.j, -3.01826755e-01+0.j],\n [-3.01826755e-01+0.j, 1.43045537e+00+0.j]],\n\n [[ 9.88263557e-02+0.j, -1.13695712e-01+0.j],\n [-1.13695712e-01+0.j, 1.30802302e-01-0.j]],\n\n [[ 2.27120711e-01-0.j, -1.04824895e-01+0.j],\n [-1.04824895e-01+0.j, 4.83806987e-02+0.j]],\n\n [[ 9.21563760e-01+0.j, -1.50468061e-01+0.j],\n [-1.50468061e-01+0.j, 2.45676299e-02-0.j]],\n\n [[ 2.93843368e-01+0.j, -2.12126270e-01+0.j],\n [-2.12126270e-01+0.j, 1.53134491e-01-0.j]],\n\n [[ 8.25969795e-01+0.j, -3.96542129e-01+0.j],\n [-3.96542129e-01+0.j, 1.90377011e-01-0.j]],\n\n [[ 2.91083477e-02-0.j, -1.26757114e-01+0.j],\n [-1.26757114e-01+0.j, 5.51984811e-01+0.j]],\n\n [[ 4.28314197e-01+0.j, -1.58472599e-02+0.j],\n [-1.58472599e-02+0.j, 5.86335097e-04-0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.47411213e-01-0.j, -1.41610458e-01+0.j],\n [-1.41610458e-01+0.j, 1.36037967e-01+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e771d0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3492[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(96), np.int64(96), np.int64(96)), 'set_#x7f94f2e771d0'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3492[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1ba5310>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3483)), 6301).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[squarequads-mesh-0-coords-TensorFunctionSpace(CG2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(4), np.int64(4), np.int64(4)), 'Cells'), Set((np.int64(25), np.int64(25), np.int64(25)), '... Set((np.int64(9), np.int64(9), np.int64(9)), 'set_#x7f94f2e67650'), np.int64(4), None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: 8165101443776799037
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Q', quadrilateral, 1), dim=2), 3495)
vertexcoords = array([], shape=(0, 2), dtype=complex128)
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f1b86de0>
name = None
maps_ = (MixedMap((Map(Set((np.int64(4), np.int64(4), np.int64(4)), 'Cells'), Set((np.int64(25), np.int64(25), np.int64(25)), ...p.int64(0)), 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(4), np.int64(4), np.int64(4)), 'Cells'), Set((np.int64(25), np.int64(25), np.int64(25)), '... Set((np.int64(9), np.int64(9), np.int64(9)), 'set_#x7f94f2e67650'), np.int64(4), None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(4), np.int64(4), np.int64(4)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[squarequads-mesh-1-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f27ad370'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3530[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f27ad370'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3530[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f3fbffb0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3521)), 6373).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Q', quadrilateral, 1), dim=2), 3515)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j],\n [0.55601946+0.j, 0.86560459+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f27ad370'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3530[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f27ad370'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3530[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f3fbffb0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3521)), 6373).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[squarequads-mesh-100-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 4.79679212e-02+0.j, 8.19259064e-02+0.j],\n [ 8.19259064e-02+0.j, 1.39923807e-01+0.j]],\n\n [[ 1.71234764e-02+0.j, 2.97596329e-02+0.j],\n [ 2.97596329e-02+0.j, 5.17205577e-02+0.j]],\n\n [[ 1.87161402e-01+0.j, -4.82321801e-03+0.j],\n [-4.82321801e-03+0.j, 1.24296098e-04-0.j]],\n\n [[ 1.14137763e-02-0.j, -2.53680729e-02+0.j],\n [-2.53680729e-02+0.j, 5.63826646e-02+0.j]],\n\n [[ 1.84868507e-02+0.j, 4.46684825e-02+0.j],\n [ 4.46684825e-02+0.j, 1.07929325e-01+0.j]],\n\n [[ 6.21136065e-03+0.j, -1.05306696e-02+0.j],\n [-1.05306696e-02+0.j, 1.78535764e-02-0.j]],\n\n [[ 5.24647599e-02-0.j, -2.21183142e-02+0.j],\n [-2.21183142e-02+0.j, 9.32473200e-03+0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 2.95606040e-01+0.j, 1.79052288e-01+0.j],\n [ 1.79052288e-01+0.j, 1.08454218e-01+0.j]],\n\n [[ 4.10103887e-01+0.j, 2.41558382e-01+0.j],\n [ 2.41558382e-01+0.j, 1.42282124e-01+0.j]],\n\n [[ 6.49985288e-01+0.j, 5...e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 5.24453250e-01+0.j, 5.31460923e-01+0.j],\n [ 5.31460923e-01+0.j, 5.38562232e-01+0.j]],\n\n [[ 6.94777980e-01+0.j, 7.01231453e-01+0.j],\n [ 7.01231453e-01+0.j, 7.07744869e-01+0.j]],\n\n [[ 4.67970731e-01+0.j, 4.40894657e-01+0.j],\n [ 4.40894657e-01+0.j, 4.15385163e-01+0.j]],\n\n [[ 9.03466522e-01+0.j, 4.77771953e-01+0.j],\n [ 4.77771953e-01+0.j, 2.52655780e-01+0.j]],\n\n [[ 4.09510176e-01+0.j, 4.36269290e-01+0.j],\n [ 4.36269290e-01+0.j, 4.64776957e-01+0.j]],\n\n [[ 4.20747468e-01+0.j, 5.23072825e-01+0.j],\n [ 5.23072825e-01+0.j, 6.50283605e-01+0.j]],\n\n [[ 1.23740701e+00+0.j, 1.00980041e+00+0.j],\n [ 1.00980041e+00+0.j, 8.24059385e-01+0.j]],\n\n [[ 1.24241769e+00+0.j, 7.11363565e-01+0.j],\n [ 7.11363565e-01+0.j, 4.07301126e-01+0.j]],\n\n [[ 8.91345956e-01+0.j, 1.16386691e+00+0.j],\n [ 1.16386691e+00+0.j, 1.51970869e+00+0.j]],\n\n [[ 3.26344393e-01+0.j, 3.88357757e-01+0.j],\n [ 3.88357757e-01+0.j, 4.62155168e-01+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(50), np.int64(50), np.int64(50)), 'set_#x7f94f32c2180'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3550[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(50), np.int64(50), np.int64(50)), 'set_#x7f94f32c2180'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3550[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f81feb10>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3541)), 6407).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Q', quadrilateral, 1), dim=2), 3535)
vertexcoords = array([[ 0.2190158 +0.j, 0.37406391+0.j],
[ 0.1308567 +0.j, 0.22742154+0.j],
[ 0.43262155+0.j, -0.0111....11463792+0.j, 0.63820148+0.j],
[ 0.9441112 +0.j, 1.23276465+0.j],
[ 0.57126561+0.j, 0.67981995+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]), array([[[ 4.79679212e-02+0.j, 8.19259064e-02+0.j],\n [ 8.19259064e-02+0.j, 1.39923807e-01+0.j]],\n\n [[ 1.71234764e-02+0.j, 2.97596329e-02+0.j],\n [ 2.97596329e-02+0.j, 5.17205577e-02+0.j]],\n\n [[ 1.87161402e-01+0.j, -4.82321801e-03+0.j],\n [-4.82321801e-03+0.j, 1.24296098e-04-0.j]],\n\n [[ 1.14137763e-02-0.j, -2.53680729e-02+0.j],\n [-2.53680729e-02+0.j, 5.63826646e-02+0.j]],\n\n [[ 1.84868507e-02+0.j, 4.46684825e-02+0.j],\n [ 4.46684825e-02+0.j, 1.07929325e-01+0.j]],\n\n [[ 6.21136065e-03+0.j, -1.05306696e-02+0.j],\n [-1.05306696e-02+0.j, 1.78535764e-02-0.j]],\n\n [[ 5.24647599e-02-0.j, -2.21183142e-02+0.j],\n [-2.21183142e-02+0.j, 9.32473200e-03+0.j]],\n\n [[ 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [-3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 2.95606040e-01+0.j, 1.79052288e-01+0.j],\n [ 1.79052288e-01+0.j, 1.08454218e-01+0.j]],\n\n [[ 4.10103887e-01+0.j, 2.41558382e-01+0.j],\n [ 2.41558382e-01+0.j, 1.42282124e-01+0.j]],\n\n [[ 6.49985288e-01+0.j, 5...e-01+0.j, 3.47824366e-01+0.j]],\n\n [[ 1.17386407e+00+0.j, 6.04337444e-01+0.j],\n [ 6.04337444e-01+0.j, 3.11129505e-01+0.j]],\n\n [[ 5.24453250e-01+0.j, 5.31460923e-01+0.j],\n [ 5.31460923e-01+0.j, 5.38562232e-01+0.j]],\n\n [[ 6.94777980e-01+0.j, 7.01231453e-01+0.j],\n [ 7.01231453e-01+0.j, 7.07744869e-01+0.j]],\n\n [[ 4.67970731e-01+0.j, 4.40894657e-01+0.j],\n [ 4.40894657e-01+0.j, 4.15385163e-01+0.j]],\n\n [[ 9.03466522e-01+0.j, 4.77771953e-01+0.j],\n [ 4.77771953e-01+0.j, 2.52655780e-01+0.j]],\n\n [[ 4.09510176e-01+0.j, 4.36269290e-01+0.j],\n [ 4.36269290e-01+0.j, 4.64776957e-01+0.j]],\n\n [[ 4.20747468e-01+0.j, 5.23072825e-01+0.j],\n [ 5.23072825e-01+0.j, 6.50283605e-01+0.j]],\n\n [[ 1.23740701e+00+0.j, 1.00980041e+00+0.j],\n [ 1.00980041e+00+0.j, 8.24059385e-01+0.j]],\n\n [[ 1.24241769e+00+0.j, 7.11363565e-01+0.j],\n [ 7.11363565e-01+0.j, 4.07301126e-01+0.j]],\n\n [[ 8.91345956e-01+0.j, 1.16386691e+00+0.j],\n [ 1.16386691e+00+0.j, 1.51970869e+00+0.j]],\n\n [[ 3.26344393e-01+0.j, 3.88357757e-01+0.j],\n [ 3.88357757e-01+0.j, 4.62155168e-01+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0... 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(50), np.int64(50), np.int64(50)), 'set_#x7f94f32c2180'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3550[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(50), np.int64(50), np.int64(50)), 'set_#x7f94f32c2180'), (2, 2), 'None_nodes_dset'), None, dtype('complex128'), 'function_3550[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f81feb10>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(2, 2), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=2), 3541)), 6407).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[extruded-mesh-0-coords-TensorFunctionSpace(CG2)]
AttributeError: 'tuple' object has no attribute 'shape'
Raw output
parentmesh = Mesh(VectorElement(TensorProductElement(FiniteElement('Lagrange', triangle, 1), FiniteElement('Lagrange', interval, 1), cell=TensorProductCell(triangle, interval)), dim=3), 3558)
vertexcoords = array([], shape=(0, 3), dtype=complex128)
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:932: in make_interpolator
argfs_map = vom_cell_parent_node_map_extruded(target_mesh, argfs_map)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
vertex_only_mesh = Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3563)
extruded_cell_node_map = MixedMap((Map(ExtrudedSet(Set((np.int64(8), np.int64(8), np.int64(8)), 'Cells'), array([[0, 4]], dtype=int32)), Set((n...int64(36)), 'set_#x7f94f32d2690'), np.int64(6), None, 'None_cell_node', array([1, 1, 1, 1, 1, 1], dtype=int32), None)))
def vom_cell_parent_node_map_extruded(vertex_only_mesh, extruded_cell_node_map):
"""Build a map from the cells of a vertex only mesh to the nodes of the
nodes on the source mesh where the source mesh is extruded.
Parameters
----------
vertex_only_mesh : :class:`mesh.MeshGeometry`
The ``mesh.VertexOnlyMesh`` whose cells we iterate over.
extruded_cell_node_map : :class:`pyop2.Map`
The cell node map of the function space on the extruded mesh within
which the ``mesh.VertexOnlyMesh`` is immersed.
Returns
-------
:class:`pyop2.Map`
The map from the cells of the vertex only mesh to the nodes of the
source mesh's cell node map. The map iterset is the
``vertex_only_mesh.cell_set`` and the map toset is the
``extruded_cell_node_map.toset``.
Notes
-----
For an extruded mesh the cell node map is a map from a
:class:`pyop2.ExtrudedSet` (the cells of the extruded mesh) to a
:class:`pyop2.Set` (the nodes of the extruded mesh).
Take for example
``mx = ExtrudedMesh(UnitIntervalMesh(2), 3)`` with
``mx.layers = 4``
which looks like
.. code-block:: text
-------------------layer 4-------------------
| parent_cell_num = 2 | parent_cell_num = 5 |
| | |
| extrusion_height = 2 | extrusion_height = 2 |
-------------------layer 3-------------------
| parent_cell_num = 1 | parent_cell_num = 4 |
| | |
| extrusion_height = 1 | extrusion_height = 1 |
-------------------layer 2-------------------
| parent_cell_num = 0 | parent_cell_num = 3 |
| | |
| extrusion_height = 0 | extrusion_height = 0 |
-------------------layer 1-------------------
base_cell_num = 0 base_cell_num = 1
If we declare ``FunctionSpace(mx, "CG", 2)`` then the node numbering (i.e.
Degree of Freedom/DoF numbering) is
.. code-block:: text
6 ---------13----------20---------27---------34
| | |
5 12 19 26 33
| | |
4 ---------11----------18---------25---------32
| | |
3 10 17 24 31
| | |
2 ---------9-----------16---------23---------30
| | |
1 8 15 22 29
| | |
0 ---------7-----------14---------21---------28
base_cell_num = 0 base_cell_num = 1
Cell node map values for an extruded mesh are indexed by the base cell
number (rows) and the degree of freedom (DoF) index (columns). So
``extruded_cell_node_map.values[0] = [14, 15, 16, 0, 1, 2, 7, 8, 9]``
are all the DoF/node numbers for the ``base_cell_num = 0``.
Similarly
``extruded_cell_node_map.values[1] = [28, 29, 30, 21, 22, 23, 14, 15, 16]``
contain all 9 of the DoFs for ``base_cell_num = 1``.
To get the DoFs/nodes for the rest of the cells we need to include the
``extruded_cell_node_map.offset``, which tells us how far each cell's
DoFs/nodes are translated up from the first layer to the second, and
multiply these by the the given ``extrusion_height``. So in our example
``extruded_cell_node_map.offset = [2, 2, 2, 2, 2, 2, 2, 2, 2]`` (we index
this with the DoF/node index - it's an array because each DoF/node in the
extruded mesh cell, in principal, can be offset upwards by a different
amount).
For ``base_cell_num = 0`` with ``extrusion_height = 1``
(``parent_cell_num = 1``) we add ``1*2 = 2`` to each of the DoFs/nodes in
``extruded_cell_node_map.values[0]`` to get
``extruded_cell_node_map.values[0] + 1 * extruded_cell_node_map.offset[0] =
[16, 17, 18, 2, 3, 4, 9, 10, 11]`` where ``0`` is the DoF/node index.
For each cell (vertex) of a vertex only mesh immersed in a parent
extruded mesh, we can can get the corresponding ``base_cell_num`` and
``extrusion_height`` of the parent extruded mesh. Armed with this
information we use the above to work out the corresponding DoFs/nodes on
the parent extruded mesh.
"""
if not isinstance(vertex_only_mesh.topology, firedrake.mesh.VertexOnlyMeshTopology):
raise TypeError("The input mesh must be a VertexOnlyMesh")
cnm = extruded_cell_node_map
vmx = vertex_only_mesh
dofs_per_target_cell = cnm.arity
base_cells = vmx.cell_parent_base_cell_list
heights = vmx.cell_parent_extrusion_height_list
> assert cnm.values_with_halo.shape[1] == dofs_per_target_cell
E AttributeError: 'tuple' object has no attribute 'shape'
firedrake/interpolation.py:1415: AttributeError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[extruded-mesh-1-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f32ace30'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3600[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f32ace30'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3600[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2717aa0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3591)), 6485).dat
Raw output
parentmesh = Mesh(VectorElement(TensorProductElement(FiniteElement('Lagrange', triangle, 1), FiniteElement('Lagrange', interval, 1), cell=TensorProductCell(triangle, interval)), dim=3), 3586)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j, 0.70552675+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f32ace30'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3600[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f32ace30'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3600[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2717aa0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3591)), 6485).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[extruded-mesh-100-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[ 1.71234764e-02+0.j, 2.97596329e-02+0.j, 8.37997866e-02+0.j],\n [ 2.97596329e-02+0.j, 5.17205577e-02+0.j, 1.45639286e-01+0.j],\n [ 8.37997866e-02+0.j, 1.45639286e-01+0.j, 4.10103887e-01+0.j]],\n\n [[ 4.33385891e-05+0.j, 2.84803636e-03+0.j, -7.33949421e-05+0.j],\n [ 2.84803636e-03+0.j, 1.87161402e-01+0.j, -4.82321801e-03+0.j],\n [-7.33949421e-05+0.j, -4.82321801e-03+0.j, 1.24296098e-04-0.j]],\n\n [[ 5.24647599e-02-0.j, -2.21183142e-02+0.j, -1.46577123e-01+0.j],\n [-2.21183142e-02+0.j, 9.32473200e-03+0.j, 6.17946005e-02+0.j],\n [-1.46577123e-01+0.j, 6.17946005e-02+0.j, 4.09510176e-01+0.j]],\n\n [[ 1.53487299e-02+0.j, 3.67262121e-02+0.j, -9.94991515e-03+0.j],\n [ 3.67262121e-02+0.j, 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-9.94991515e-03+0.j, -2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.31281755e-01+0.j, -2.17234066e-02+0.j, 4.19021767e-03+0.j],\n [-2.17234066e-02+0.j, 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [ 4.19021767e-03+0.j, -3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.96096056e-02+0.j, 3.73790464e-02+0.j, 9.47520015e-02+0.j],\n [ 3.73790464....23072825e-01+0.j],\n [ 5.49760707e-01+0.j, 5.23072825e-01+0.j, 6.50283605e-01+0.j]],\n\n [[ 3.26344393e-01+0.j, 3.88357757e-01+0.j, 5.48554404e-01+0.j],\n [ 3.88357757e-01+0.j, 4.62155168e-01+0.j, 6.52793071e-01+0.j],\n [ 5.48554404e-01+0.j, 6.52793071e-01+0.j, 9.22068653e-01+0.j]],\n\n [[ 3.57158041e-01+0.j, 5.56019458e-01+0.j, 4.21641842e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j, 6.56407086e-01+0.j],\n [ 4.21641842e-01+0.j, 6.56407086e-01+0.j, 4.97767998e-01+0.j]],\n\n [[ 1.42281322e+00+0.j, 1.07229335e+00+0.j, 1.13167236e-01+0.j],\n [ 1.07229335e+00+0.j, 8.08126476e-01+0.j, 8.52877052e-02+0.j],\n [ 1.13167236e-01+0.j, 8.52877052e-02+0.j, 9.00105723e-03+0.j]],\n\n [[ 1.24241769e+00+0.j, 7.11363565e-01+0.j, 3.50404926e-01+0.j],\n [ 7.11363565e-01+0.j, 4.07301126e-01+0.j, 2.00629225e-01+0.j],\n [ 3.50404926e-01+0.j, 2.00629225e-01+0.j, 9.88263557e-02+0.j]],\n\n [[ 7.05319624e-01+0.j, 8.98878251e-01+0.j, 5.32959857e-02+0.j],\n [ 8.98878251e-01+0.j, 1.14555456e+00+0.j, 6.79218340e-02+0.j],\n [ 5.32959857e-02+0.j, 6.79218340e-02+0.j, 4.02719844e-03+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(30), np.int64(30), np.int64(30)), 'set_#x7f94f234ed50'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3628[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(30), np.int64(30), np.int64(30)), 'set_#x7f94f234ed50'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3628[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f37c9fd0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3619)), 6524).dat
Raw output
parentmesh = Mesh(VectorElement(TensorProductElement(FiniteElement('Lagrange', triangle, 1), FiniteElement('Lagrange', interval, 1), cell=TensorProductCell(triangle, interval)), dim=3), 3614)
vertexcoords = array([[ 0.1308567 +0.j, 0.22742154+0.j, 0.64039354+0.j],
[ 0.00658321+0.j, 0.43262155+0.j, -0.01114882+0.j]... [ 1.11463792+0.j, 0.63820148+0.j, 0.31436659+0.j],
[ 0.83983309+0.j, 1.07030582+0.j, 0.06346021+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[ 1.71234764e-02+0.j, 2.97596329e-02+0.j, 8.37997866e-02+0.j],\n [ 2.97596329e-02+0.j, 5.17205577e-02+0.j, 1.45639286e-01+0.j],\n [ 8.37997866e-02+0.j, 1.45639286e-01+0.j, 4.10103887e-01+0.j]],\n\n [[ 4.33385891e-05+0.j, 2.84803636e-03+0.j, -7.33949421e-05+0.j],\n [ 2.84803636e-03+0.j, 1.87161402e-01+0.j, -4.82321801e-03+0.j],\n [-7.33949421e-05+0.j, -4.82321801e-03+0.j, 1.24296098e-04-0.j]],\n\n [[ 5.24647599e-02-0.j, -2.21183142e-02+0.j, -1.46577123e-01+0.j],\n [-2.21183142e-02+0.j, 9.32473200e-03+0.j, 6.17946005e-02+0.j],\n [-1.46577123e-01+0.j, 6.17946005e-02+0.j, 4.09510176e-01+0.j]],\n\n [[ 1.53487299e-02+0.j, 3.67262121e-02+0.j, -9.94991515e-03+0.j],\n [ 3.67262121e-02+0.j, 8.78779331e-02+0.j, -2.38080087e-02+0.j],\n [-9.94991515e-03+0.j, -2.38080087e-02+0.j, 6.45009799e-03-0.j]],\n\n [[ 2.31281755e-01+0.j, -2.17234066e-02+0.j, 4.19021767e-03+0.j],\n [-2.17234066e-02+0.j, 2.04039612e-03-0.j, -3.93571046e-04+0.j],\n [ 4.19021767e-03+0.j, -3.93571046e-04+0.j, 7.59157337e-05+0.j]],\n\n [[ 1.96096056e-02+0.j, 3.73790464e-02+0.j, 9.47520015e-02+0.j],\n [ 3.73790464....23072825e-01+0.j],\n [ 5.49760707e-01+0.j, 5.23072825e-01+0.j, 6.50283605e-01+0.j]],\n\n [[ 3.26344393e-01+0.j, 3.88357757e-01+0.j, 5.48554404e-01+0.j],\n [ 3.88357757e-01+0.j, 4.62155168e-01+0.j, 6.52793071e-01+0.j],\n [ 5.48554404e-01+0.j, 6.52793071e-01+0.j, 9.22068653e-01+0.j]],\n\n [[ 3.57158041e-01+0.j, 5.56019458e-01+0.j, 4.21641842e-01+0.j],\n [ 5.56019458e-01+0.j, 8.65604586e-01+0.j, 6.56407086e-01+0.j],\n [ 4.21641842e-01+0.j, 6.56407086e-01+0.j, 4.97767998e-01+0.j]],\n\n [[ 1.42281322e+00+0.j, 1.07229335e+00+0.j, 1.13167236e-01+0.j],\n [ 1.07229335e+00+0.j, 8.08126476e-01+0.j, 8.52877052e-02+0.j],\n [ 1.13167236e-01+0.j, 8.52877052e-02+0.j, 9.00105723e-03+0.j]],\n\n [[ 1.24241769e+00+0.j, 7.11363565e-01+0.j, 3.50404926e-01+0.j],\n [ 7.11363565e-01+0.j, 4.07301126e-01+0.j, 2.00629225e-01+0.j],\n [ 3.50404926e-01+0.j, 2.00629225e-01+0.j, 9.88263557e-02+0.j]],\n\n [[ 7.05319624e-01+0.j, 8.98878251e-01+0.j, 5.32959857e-02+0.j],\n [ 8.98878251e-01+0.j, 1.14555456e+00+0.j, 6.79218340e-02+0.j],\n [ 5.32959857e-02+0.j, 6.79218340e-02+0.j, 4.02719844e-03+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(30), np.int64(30), np.int64(30)), 'set_#x7f94f234ed50'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3628[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(30), np.int64(30), np.int64(30)), 'set_#x7f94f234ed50'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3628[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f37c9fd0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3619)), 6524).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[cube-mesh-0-coords-TensorFunctionSpace(CG2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(27), np.int64(27), np.int64(27)), '... 'Cells'), Set((np.int64(8), np.int64(8), np.int64(8)), 'set_#x7f94f2e892b0'), 4, None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: 5306185372414121251
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 3639)
vertexcoords = array([], shape=(0, 3), dtype=complex128)
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f1a095b0>
name = None
maps_ = (MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(27), np.int64(27), np.int64(27)), ...p.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(27), np.int64(27), np.int64(27)), '... 'Cells'), Set((np.int64(8), np.int64(8), np.int64(8)), 'set_#x7f94f2e892b0'), 4, None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[cube-mesh-0-coords-VectorFunctionSpace(BDM2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(144), np.int64(144), np.int64(144))... 'Cells'), Set((np.int64(8), np.int64(8), np.int64(8)), 'set_#x7f94f1a71f70'), 4, None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: -8266814318282116930
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 3657)
vertexcoords = array([], shape=(0, 3), dtype=complex128)
tfs = ('BDM', 2, <cyfunction VectorFunctionSpace at 0x7f951f06e740>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f86621b0>
name = None
maps_ = (MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(144), np.int64(144), np.int64(144)...p.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(144), np.int64(144), np.int64(144))... 'Cells'), Set((np.int64(8), np.int64(8), np.int64(8)), 'set_#x7f94f1a71f70'), 4, None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 330 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[cube-mesh-0-coords-FunctionSpace(Regge2)]
AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
Raw output
map1 = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
map2 = MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(255), np.int64(255), np.int64(255))... 'Cells'), Set((np.int64(8), np.int64(8), np.int64(8)), 'set_#x7f94f3a09940'), 4, None, 'None_cell_node', None, None)))
def compose_map_and_cache(map1, map2):
"""
Retrieve a :class:`pyop2.ComposedMap` map from the cache of map1
using map2 as the cache key. The composed map maps from the iterset
of map1 to the toset of map2. Makes :class:`pyop2.ComposedMap` and
caches the result on map1 if the composed map is not found.
:arg map1: The map with the desired iterset from which the result is
retrieved or cached
:arg map2: The map with the desired toset
:returns: The composed map
"""
cache_key = hash((map2, "composed"))
try:
> cmap = map1._cache[cache_key]
E KeyError: 454939907757791803
firedrake/interpolation.py:1300: KeyError
During handling of the above exception, another exception occurred:
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 3675)
vertexcoords = array([], shape=(0, 3), dtype=complex128)
tfs = ('Regge', 2, <cyfunction FunctionSpace at 0x7f951f06e5a0>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
assert np.allclose(w_v1.dat.data_ro, result1)
assert np.allclose(w_v2.dat.data_ro, result2)
# try and make reusable Interpolator from V to W
> A_w = Interpolator(TestFunction(V), W)
tests/vertexonly/test_interpolation_from_parent.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../firedrake_venv/src/pyadjoint/pyadjoint/tape.py:110: in wrapper
return function(*args, **kwargs)
firedrake/interpolation.py:819: in __init__
self.callable, arguments = make_interpolator(expr, V, subset, access, bcs=bcs)
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
???
firedrake/interpolation.py:934: in make_interpolator
argfs_map = compose_map_and_cache(target_mesh.cell_parent_cell_map, argfs_map)
firedrake/interpolation.py:1303: in compose_map_and_cache
cmap = None if map2 is None else op2.ComposedMap(map2, map1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'ComposedMap' object has no attribute 'maps_'") raised in repr()] ComposedMap object at 0x7f94f3126030>
name = None
maps_ = (MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(255), np.int64(255), np.int64(255)...p.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None))
tomap = MixedMap((Map(Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), Set((np.int64(255), np.int64(255), np.int64(255))... 'Cells'), Set((np.int64(8), np.int64(8), np.int64(8)), 'set_#x7f94f3a09940'), 4, None, 'None_cell_node', None, None)))
frommap = Map(Set((np.int64(0), np.int64(0), np.int64(0)), 'Cells'), Set((np.int64(6), np.int64(6), np.int64(6)), 'Cells'), 1, None, 'cell_parent_cell', None, None)
def __init__(self, *maps_, name=None):
if not all(isinstance(m, Map) for m in maps_):
raise TypeError("All maps must be Map instances")
for tomap, frommap in zip(maps_[:-1], maps_[1:]):
if tomap.iterset is not frommap.toset:
raise ex.MapTypeError("tomap.iterset must match frommap.toset")
if tomap.comm is not frommap.comm:
raise ex.MapTypeError("All maps needs to share a communicator")
if frommap.arity != 1:
raise ex.MapTypeError("frommap.arity must be 1")
self._iterset = maps_[-1].iterset
self._toset = maps_[0].toset
self.comm = mpi.internal_comm(self._toset.comm, self)
self._arity = maps_[0].arity
# Don't call super().__init__() to avoid calling verify_reshape()
self._values = None
self.shape = (self._iterset.total_size, self._arity)
self._name = name or "cmap_#x%x" % id(self)
> self._offset = maps_[0]._offset
E AttributeError: 'MixedMap' object has no attribute '_offset'. Did you mean: 'offset'?
../firedrake_venv/src/PyOP2/pyop2/types/map.py:256: AttributeError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[cube-mesh-1-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2addf40'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3708[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2addf40'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3708[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2341550>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3699)), 6680).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 3693)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j, 0.70552675+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2addf40'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3708[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f2addf40'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3708[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2341550>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3699)), 6680).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[cube-mesh-1-coords-VectorFunctionSpace(BDM2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f9500542570'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3726[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f9500542570'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3726[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1670cb0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3717)), 6714).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 3711)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j, 0.70552675+0.j]])
tfs = ('BDM', 2, <cyfunction VectorFunctionSpace at 0x7f951f06e740>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f9500542570'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3726[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f9500542570'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3726[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f1670cb0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3717)), 6714).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[cube-mesh-1-coords-FunctionSpace(Regge2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f38f08f0'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3744[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f38f08f0'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3744[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2e894f0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3735)), 6748).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 3729)
vertexcoords = array([[0.59762701+0.j, 0.93037873+0.j, 0.70552675+0.j]])
tfs = ('Regge', 2, <cyfunction FunctionSpace at 0x7f951f06e5a0>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[0.35715804+0.j, 0.55601946+0.j, 0.42164184+0.j],\n [0.55601946+0.j, 0.86560459+0.j, 0.65640709+0.j],\n [0.42164184+0.j, 0.65640709+0.j, 0.497768 +0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f38f08f0'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3744[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(1), np.int64(1), np.int64(1)), 'set_#x7f94f38f08f0'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3744[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f2e894f0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3735)), 6748).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError
Check failure on line 327 in tests/vertexonly/test_interpolation_from_parent.py
github-actions / Firedrake complex
test_interpolation_from_parent.test_mixed_function_interpolation[cube-mesh-100-coords-TensorFunctionSpace(CG2)]
AssertionError: assert False
+ where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[ 1.11579821e+00+0.j, 1.30985441e+00+0.j, 1.53929879e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j, 1.80700889e+00+0.j],\n [ 1.53929879e+00+0.j, 1.80700889e+00+0.j, 2.12353875e+00+0.j]],\n\n [[ 1.93025962e+00+0.j, 7.55378317e-01+0.j, 4.57542126e-01+0.j],\n [ 7.55378317e-01+0.j, 2.95606040e-01+0.j, 1.79052288e-01+0.j],\n [ 4.57542126e-01+0.j, 1.79052288e-01+0.j, 1.08454218e-01+0.j]],\n\n [[ 7.07744869e-01+0.j, -6.66583804e-02+0.j, -2.03712737e-01+0.j],\n [-6.66583804e-02+0.j, 6.27816587e-03-0.j, 1.91865200e-02-0.j],\n [-2.03712737e-01+0.j, 1.91865200e-02-0.j, 5.86353656e-02-0.j]],\n\n [[ 8.69844245e-01+0.j, 7.35045326e-02+0.j, -1.24618741e-01+0.j],\n [ 7.35045326e-02+0.j, 6.21136065e-03+0.j, -1.05306696e-02+0.j],\n [-1.24618741e-01+0.j, -1.05306696e-02+0.j, 1.78535764e-02-0.j]],\n\n [[ 1.42281322e+00+0.j, 1.07229335e+00+0.j, 1.13167236e-01+0.j],\n [ 1.07229335e+00+0.j, 8.08126476e-01+0.j, 8.52877052e-02+0.j],\n [ 1.13167236e-01+0.j, 8.52877052e-02+0.j, 9.00105723e-03+0.j]],\n\n [[ 1.23740701e+00+0.j, 1.00980041e+00+0.j, -3.33211620e-01+0.j],\n [ 1.00980041....17946005e-02+0.j],\n [-1.46577123e-01+0.j, 6.17946005e-02+0.j, 4.09510176e-01+0.j]],\n\n [[ 5.52831732e-02+0.j, 8.74025128e-02+0.j, 3.01862840e-01+0.j],\n [ 8.74025128e-02+0.j, 1.38183082e-01+0.j, 4.77244146e-01+0.j],\n [ 3.01862840e-01+0.j, 4.77244146e-01+0.j, 1.64826237e+00+0.j]],\n\n [[ 3.26344393e-01+0.j, 3.88357757e-01+0.j, 5.48554404e-01+0.j],\n [ 3.88357757e-01+0.j, 4.62155168e-01+0.j, 6.52793071e-01+0.j],\n [ 5.48554404e-01+0.j, 6.52793071e-01+0.j, 9.22068653e-01+0.j]],\n\n [[ 1.65969618e-01+0.j, 2.33501124e-01+0.j, 5.26899607e-01+0.j],\n [ 2.33501124e-01+0.j, 3.28510577e-01+0.j, 7.41290196e-01+0.j],\n [ 5.26899607e-01+0.j, 7.41290196e-01+0.j, 1.67273504e+00+0.j]],\n\n [[ 1.96096056e-02+0.j, 3.73790464e-02+0.j, 9.47520015e-02+0.j],\n [ 3.73790464e-02+0.j, 7.12504442e-02+0.j, 1.80612478e-01+0.j],\n [ 9.47520015e-02+0.j, 1.80612478e-01+0.j, 4.57833877e-01+0.j]],\n\n [[ 1.10992340e-01-0.j, -2.01353943e-01+0.j, -2.22864836e-01+0.j],\n [-2.01353943e-01+0.j, 3.65281156e-01+0.j, 4.04304598e-01+0.j],\n [-2.22864836e-01+0.j, 4.04304598e-01+0.j, 4.47496963e-01+0.j]]]))
+ where <function allclose at 0x7f952c92f1b0> = np.allclose
+ and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(88), np.int64(88), np.int64(88)), 'set_#x7f94f17fbb60'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3762[cmpt-0]').data_ro
+ where Dat(DataSet(Set((np.int64(88), np.int64(88), np.int64(88)), 'set_#x7f94f17fbb60'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3762[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f19174a0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3753)), 6782).dat
Raw output
parentmesh = Mesh(VectorElement(FiniteElement('Lagrange', tetrahedron, 1), dim=3), 3747)
vertexcoords = array([[ 1.0563135 +0.j, 1.2400243 +0.j, 1.45723668+0.j],
[ 1.38933783+0.j, 0.54369664+0.j, 0.32932388+0.j]... [ 0.1400343 +0.j, 0.26692779+0.j, 0.67663423+0.j],
[-0.33315513+0.j, 0.60438494+0.j, 0.66895214+0.j]])
tfs = ('CG', 2, <cyfunction TensorFunctionSpace at 0x7f951f06e810>)
@pytest.mark.xfail(raises=NotImplementedError, reason="Interpolation of UFL expressions into mixed functions not supported")
def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs):
if parentmesh.name == "immersedsphere":
vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords)
tfs_fam, tfs_deg, tfs_typ = tfs
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour=None)
vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension())
V1 = tfs_typ(parentmesh, tfs_fam, tfs_deg)
V2 = FunctionSpace(parentmesh, "CG", 1)
V = V1 * V2
W1 = TensorFunctionSpace(vm, "DG", 0)
W2 = FunctionSpace(vm, "DG", 0)
W = W1 * W2
x = SpatialCoordinate(parentmesh)
v = Function(V)
v1, v2 = v.subfunctions
# Get Function in V1
# use outer product to check Regge works
expr1 = outer(x, x)
assert W1.shape == expr1.ufl_shape
assemble(interpolate(expr1, v1))
result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))])
if len(result1) == 0:
result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),))
# Get Function in V2
expr2 = reduce(add, SpatialCoordinate(parentmesh))
assemble(interpolate(expr2, v2))
result2 = np.sum(vertexcoords, axis=1)
# Interpolate Function in V into W
w_v = assemble(interpolate(v, W))
# Split result and check
w_v1, w_v2 = w_v.subfunctions
> assert np.allclose(w_v1.dat.data_ro, result1)
E AssertionError: assert False
E + where False = <function allclose at 0x7f952c92f1b0>(array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]), array([[[ 1.11579821e+00+0.j, 1.30985441e+00+0.j, 1.53929879e+00+0.j],\n [ 1.30985441e+00+0.j, 1.53766026e+00+0.j, 1.80700889e+00+0.j],\n [ 1.53929879e+00+0.j, 1.80700889e+00+0.j, 2.12353875e+00+0.j]],\n\n [[ 1.93025962e+00+0.j, 7.55378317e-01+0.j, 4.57542126e-01+0.j],\n [ 7.55378317e-01+0.j, 2.95606040e-01+0.j, 1.79052288e-01+0.j],\n [ 4.57542126e-01+0.j, 1.79052288e-01+0.j, 1.08454218e-01+0.j]],\n\n [[ 7.07744869e-01+0.j, -6.66583804e-02+0.j, -2.03712737e-01+0.j],\n [-6.66583804e-02+0.j, 6.27816587e-03-0.j, 1.91865200e-02-0.j],\n [-2.03712737e-01+0.j, 1.91865200e-02-0.j, 5.86353656e-02-0.j]],\n\n [[ 8.69844245e-01+0.j, 7.35045326e-02+0.j, -1.24618741e-01+0.j],\n [ 7.35045326e-02+0.j, 6.21136065e-03+0.j, -1.05306696e-02+0.j],\n [-1.24618741e-01+0.j, -1.05306696e-02+0.j, 1.78535764e-02-0.j]],\n\n [[ 1.42281322e+00+0.j, 1.07229335e+00+0.j, 1.13167236e-01+0.j],\n [ 1.07229335e+00+0.j, 8.08126476e-01+0.j, 8.52877052e-02+0.j],\n [ 1.13167236e-01+0.j, 8.52877052e-02+0.j, 9.00105723e-03+0.j]],\n\n [[ 1.23740701e+00+0.j, 1.00980041e+00+0.j, -3.33211620e-01+0.j],\n [ 1.00980041....17946005e-02+0.j],\n [-1.46577123e-01+0.j, 6.17946005e-02+0.j, 4.09510176e-01+0.j]],\n\n [[ 5.52831732e-02+0.j, 8.74025128e-02+0.j, 3.01862840e-01+0.j],\n [ 8.74025128e-02+0.j, 1.38183082e-01+0.j, 4.77244146e-01+0.j],\n [ 3.01862840e-01+0.j, 4.77244146e-01+0.j, 1.64826237e+00+0.j]],\n\n [[ 3.26344393e-01+0.j, 3.88357757e-01+0.j, 5.48554404e-01+0.j],\n [ 3.88357757e-01+0.j, 4.62155168e-01+0.j, 6.52793071e-01+0.j],\n [ 5.48554404e-01+0.j, 6.52793071e-01+0.j, 9.22068653e-01+0.j]],\n\n [[ 1.65969618e-01+0.j, 2.33501124e-01+0.j, 5.26899607e-01+0.j],\n [ 2.33501124e-01+0.j, 3.28510577e-01+0.j, 7.41290196e-01+0.j],\n [ 5.26899607e-01+0.j, 7.41290196e-01+0.j, 1.67273504e+00+0.j]],\n\n [[ 1.96096056e-02+0.j, 3.73790464e-02+0.j, 9.47520015e-02+0.j],\n [ 3.73790464e-02+0.j, 7.12504442e-02+0.j, 1.80612478e-01+0.j],\n [ 9.47520015e-02+0.j, 1.80612478e-01+0.j, 4.57833877e-01+0.j]],\n\n [[ 1.10992340e-01-0.j, -2.01353943e-01+0.j, -2.22864836e-01+0.j],\n [-2.01353943e-01+0.j, 3.65281156e-01+0.j, 4.04304598e-01+0.j],\n [-2.22864836e-01+0.j, 4.04304598e-01+0.j, 4.47496963e-01+0.j]]]))
E + where <function allclose at 0x7f952c92f1b0> = np.allclose
E + and array([[[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+...j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]],\n\n [[0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j],\n [0.+0.j, 0.+0.j, 0.+0.j]]]) = Dat(DataSet(Set((np.int64(88), np.int64(88), np.int64(88)), 'set_#x7f94f17fbb60'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3762[cmpt-0]').data_ro
E + where Dat(DataSet(Set((np.int64(88), np.int64(88), np.int64(88)), 'set_#x7f94f17fbb60'), (3, 3), 'None_nodes_dset'), None, dtype('complex128'), 'function_3762[cmpt-0]') = Coefficient(WithGeometry(IndexedProxyFunctionSpace(<firedrake.mesh.VertexOnlyMeshTopology object at 0x7f94f19174a0>, TensorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), shape=(3, 3), symmetry={}), name=None, index=0, component=None), Mesh(VectorElement(FiniteElement('Discontinuous Lagrange', vertex, 0), dim=3), 3753)), 6782).dat
tests/vertexonly/test_interpolation_from_parent.py:327: AssertionError