Skip to content

Commit 1bd729a

Browse files
authored
Real x extruded fixes (#4970)
* Fixes for Real x extruded following firedrakeproject/fiat#237 * Don't special case Real so much
1 parent c3b1325 commit 1bd729a

5 files changed

Lines changed: 12 additions & 25 deletions

File tree

firedrake/functionspace.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def make_scalar_element(mesh, family, degree, vfamily, vdegree, variant, quad_sc
3131
family :
3232
The finite element family.
3333
degree :
34-
The degree of the finite element.
34+
The degree of the finite element. If unspecified this will default
35+
to the lowest degree available for the given family.
3536
vfamily :
3637
The finite element in the vertical dimension (extruded meshes
3738
only).
@@ -86,7 +87,8 @@ def FunctionSpace(mesh, family, degree=None, name=None,
8687
family :
8788
The finite element family.
8889
degree :
89-
The degree of the finite element.
90+
The degree of the finite element. If unspecified this will default
91+
to the lowest degree available for the given family.
9092
name:
9193
An optional name for the function space.
9294
vfamily :
@@ -125,7 +127,8 @@ def DualSpace(mesh, family, degree=None, name=None,
125127
family :
126128
The finite element family.
127129
degree :
128-
The degree of the finite element.
130+
The degree of the finite element. If unspecified this will default
131+
to the lowest degree available for the given family.
129132
name :
130133
An optional name for the function space.
131134
vfamily:
@@ -164,7 +167,8 @@ def VectorFunctionSpace(mesh, family, degree=None, dim=None, name=None,
164167
family :
165168
The finite element family.
166169
degree :
167-
The degree of the finite element.
170+
The degree of the finite element. If unspecified this will default
171+
to the lowest degree available for the given family.
168172
dim :
169173
An optional number of degrees of freedom per function space
170174
node (defaults to the geometric dimension of the mesh).
@@ -216,7 +220,8 @@ def TensorFunctionSpace(mesh, family, degree=None, shape=None,
216220
family :
217221
The finite element family.
218222
degree :
219-
The degree of the finite element.
223+
The degree of the finite element. If unspecified this will default
224+
to the lowest degree available for the given family.
220225
shape :
221226
An optional shape for the tensor-valued degrees of freedom at
222227
each function space node (defaults to a square tensor using the

tests/firedrake/vertexonly/test_interpolation_from_parent.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,6 @@ def test_scalar_real_interpolation(parentmesh, vertexcoords):
310310
vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour="ignore")
311311
W = FunctionSpace(vm, "DG", 0)
312312
V = FunctionSpace(parentmesh, "Real", 0)
313-
# Remove below when interpolating constant onto Real works for extruded
314-
if type(parentmesh.topology) is mesh.ExtrudedMeshTopology:
315-
with pytest.raises(ValueError):
316-
assemble(interpolate(Constant(1), V))
317-
return
318313
v = assemble(interpolate(Constant(1), V))
319314
w_v = assemble(interpolate(v, W))
320315
assert np.allclose(w_v.dat.data_ro, 1.)

tests/firedrake/vertexonly/test_vertex_only_fs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def vectorfunctionspace_tests(vm):
194194
# num_vertices (globally) times. Note that we get a vertex cell for
195195
# each geometric dimension so we have to sum over geometric
196196
# dimension too.
197-
R = VectorFunctionSpace(vm, "R", dim=gdim)
197+
R = VectorFunctionSpace(vm, "R", 0, dim=gdim)
198198
ones = Function(R).assign(1)
199199
f.interpolate(ones)
200200
assert np.isclose(assemble(inner(f, f)*dx), num_cells_mpi_global*gdim)

tsfc/fem.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,6 @@ def translate_constant_value(terminal, mt, ctx):
743743
def translate_coefficient(terminal, mt, ctx):
744744
domain = extract_unique_domain(terminal)
745745
vec = ctx.coefficient(terminal, mt.restriction)
746-
747-
if terminal.ufl_element().family() == 'Real':
748-
assert mt.local_derivatives == 0
749-
return vec
750-
751746
element = ctx.create_element(terminal.ufl_element(), restriction=mt.restriction)
752747

753748
# Collect FInAT tabulation for all entities

tsfc/kernel_interface/common.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ def coefficient(self, ufl_coefficient, restriction):
5858
kernel_arg = self.coefficient_map[ufl_coefficient]
5959
domain = extract_unique_domain(ufl_coefficient)
6060
assert self._domain_integral_type_map[domain] is not None
61-
if ufl_coefficient.ufl_element().family() == 'Real':
62-
return kernel_arg
63-
elif not self._domain_integral_type_map[domain].startswith("interior_facet"):
61+
if not self._domain_integral_type_map[domain].startswith("interior_facet"):
6462
return kernel_arg
6563
else:
6664
return kernel_arg[{'+': 0, '-': 1}[restriction]]
@@ -495,12 +493,6 @@ def prepare_coefficient(coefficient, name, domain_integral_type_map):
495493
GEM expression referring to the Coefficient values.
496494
497495
"""
498-
if coefficient.ufl_element().family() == 'Real':
499-
# Constant
500-
value_size = coefficient.ufl_function_space().value_size
501-
expression = gem.reshape(gem.Variable(name, (value_size,)),
502-
coefficient.ufl_shape)
503-
return expression
504496
finat_element = create_element(coefficient.ufl_element())
505497
shape = finat_element.index_shape
506498
size = numpy.prod(shape, dtype=int)

0 commit comments

Comments
 (0)