Skip to content

Commit

Permalink
remove BaseFormAssembler test
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Dec 19, 2024
1 parent fe30b48 commit 3d49f31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 47 deletions.
2 changes: 0 additions & 2 deletions firedrake/cofunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ def assign(self, expr, subset=None, expr_from_assemble=False):
return self.assign(
assembled_expr, subset=subset,
expr_from_assemble=True)
elif expr == 0:
self.dat.zero(subset=subset)
else:
from firedrake.assign import Assigner
Assigner(self, expr, subset).assign()
Expand Down
48 changes: 3 additions & 45 deletions tests/firedrake/regression/test_assemble_baseform.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import numpy as np
from firedrake import *
from firedrake.assemble import BaseFormAssembler, get_assembler
from firedrake.assemble import get_assembler
from firedrake.utils import ScalarType
import ufl

Expand Down Expand Up @@ -43,39 +43,15 @@ def fs(request, mesh):
@pytest.fixture
def f(fs):
f = Function(fs, name="f")
f_split = f.subfunctions
x = SpatialCoordinate(fs.mesh())[0]

# NOTE: interpolation of UFL expressions into mixed
# function spaces is not yet implemented
for fi in f_split:
fs_i = fi.function_space()
if fs_i.rank == 1:
fi.interpolate(as_vector((x,) * fs_i.value_size))
elif fs_i.rank == 2:
fi.interpolate(as_tensor([[x for i in range(fs_i.mesh().geometric_dimension())]
for j in range(fs_i.rank)]))
else:
fi.interpolate(x)
f.interpolate(as_tensor(np.full(f.ufl_shape, x)))
return f


@pytest.fixture
def one(fs):
one = Function(fs, name="one")
ones = one.subfunctions

# NOTE: interpolation of UFL expressions into mixed
# function spaces is not yet implemented
for fi in ones:
fs_i = fi.function_space()
if fs_i.rank == 1:
fi.interpolate(Constant((1.0,) * fs_i.value_size))
elif fs_i.rank == 2:
fi.interpolate(Constant([[1.0 for i in range(fs_i.mesh().geometric_dimension())]
for j in range(fs_i.rank)]))
else:
fi.interpolate(Constant(1.0))
one.interpolate(Constant(np.ones(one.ufl_shape)))
return one


Expand Down Expand Up @@ -155,24 +131,6 @@ def test_zero_form(M, f, one):
assert abs(zero_form - 0.5 * np.prod(f.ufl_shape)) < 1.0e-12


@pytest.mark.xfail(reason="action(M, M) raises primal-dual TypeError")
def test_preprocess_form(M, a, f):
from ufl.algorithms import expand_indices, expand_derivatives

expr = action(action(M, M), f)
A = BaseFormAssembler.preprocess_base_form(expr)
B = action(expand_derivatives(M), action(M, f))

assert isinstance(A, ufl.Action)
try:
# Need to expand indices to be able to match equal (different MultiIndex used for both).
assert expand_indices(A.left()) == expand_indices(B.left())
assert expand_indices(A.right()) == expand_indices(B.right())
except KeyError:
# Index expansion doesn't seem to play well with tensor elements.
pass


def test_tensor_copy(a, M):

# 1-form tensor
Expand Down

0 comments on commit 3d49f31

Please sign in to comment.