Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix expression -Werror #216

Merged
merged 6 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions ffcx/codegeneration/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ def coefficient(self, e, mt, tabledata, num_points):
# cell offset)
idof = begin
return self.symbols.coefficient_dof_access(mt.terminal, idof)
elif ttype == "quadrature":
# Dofmap should be contiguous in this case
assert len(tabledata.dofmap) == end - begin
# f(x_q) = sum_i f_i * delta_iq = f_q, just return direct
# reference to dof array at quadrature point index + begin
iq = self.symbols.quadrature_loop_index()
idof = begin + iq
return self.symbols.coefficient_dof_access(mt.terminal, idof)
else:
# Return symbol, see definitions for computation
return self.symbols.coefficient_value(mt) # , num_points)
Expand Down
4 changes: 0 additions & 4 deletions ffcx/codegeneration/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ def coefficient(self, t, mt, tabledata, num_points, access):
if ttype == "ones" and (end - begin) == 1:
return []

# For quadrature elements we reference the dofs directly, so no definition needed
if ttype == "quadrature":
return []

assert begin < end

# Get access to element table
Expand Down
8 changes: 6 additions & 2 deletions ffcx/codegeneration/evaluatedof.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
# from the old implementation in FFC, although some improvements
# have been made to the generated code.

import logging

from ffcx.codegeneration.jacobian import inverse_jacobian, jacobian
from ufl.permutation import build_component_numbering

logger = logging.getLogger(__name__)
index_type = "int"


Expand Down Expand Up @@ -323,8 +326,9 @@ def generate_transform_values(L, ir):
# Intermediate variable needed for multiple point dofs
needs_temporary = any(dof is not None and len(dof) > 1 for dof in ir.dofs)
if needs_temporary:
result = L.Symbol("result")
code += [L.VariableDecl("double", result)]
logger.warning("Generating code for evaluation of multiple-point dofs not working properly.")
# result = L.Symbol("result")
# code += [L.VariableDecl("double", result)]

if needs_jacobian or needs_inverse_jacobian:
code += jacobian(L, gdim, tdim, cell_shape)
Expand Down
14 changes: 10 additions & 4 deletions ffcx/codegeneration/expressions_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,16 @@ def generate_partition(self, symbol, F, mode, num_points):

def generate_original_coefficient_positions(self):
L = self.backend.language
parts = L.ArrayDecl("static const int", "original_coefficient_positions",
values=self.ir.original_coefficient_positions,
sizes=(len(self.ir.original_coefficient_positions), ))
return parts
num_coeffs = len(self.ir.original_coefficient_positions)
orig_pos = L.Symbol("original_coefficient_positions")
if num_coeffs > 0:
parts = [L.ArrayDecl("static const int", orig_pos,
values=self.ir.original_coefficient_positions,
sizes=(num_coeffs, ))]
parts += [L.Assign("expression->original_coefficient_positions", orig_pos)]
else:
parts = []
return L.StatementList(parts)

def generate_points(self):
L = self.backend.language
Expand Down
4 changes: 2 additions & 2 deletions ffcx/codegeneration/expressions_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
ufc_expression* create_{factory_name}(void)
{{

ufc_expression* expression = malloc(sizeof(*expression));

{original_coefficient_positions}
{points}
{value_shape}

ufc_expression* expression = malloc(sizeof(*expression));
expression->tabulate_expression = tabulate_expression_{factory_name};
expression->original_coefficient_positions = original_coefficient_positions;
expression->num_coefficients = {num_coefficients};
expression->num_points = {num_points};
expression->topological_dimension = {topological_dimension};
Expand Down
8 changes: 4 additions & 4 deletions test/test_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def float_to_type(name):
raise RuntimeError("Unknown C type for: {}".format(name))


def test_matvec():
def test_matvec(compile_args):
"""Test evaluation of linear rank-0 form.

Evaluates expression c * A_ij * f_j where c is a Constant,
Expand All @@ -46,7 +46,7 @@ def test_matvec():
expr = ufl.Constant(mesh) * ufl.dot(a, f)

points = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
obj, module = ffcx.codegeneration.jit.compile_expressions([(expr, points)])
obj, module = ffcx.codegeneration.jit.compile_expressions([(expr, points)], cffi_extra_compile_args=compile_args)

ffi = cffi.FFI()
kernel = obj[0][0]
Expand Down Expand Up @@ -82,7 +82,7 @@ def test_matvec():
assert np.allclose(expr.ufl_shape, value_shape)


def test_rank1():
def test_rank1(compile_args):
"""Tests evaluation of rank-1 form.

Builds a linear operator which takes vector-valued functions in P1 space
Expand All @@ -98,7 +98,7 @@ def test_rank1():
expr = ufl.as_vector([u[1], u[0]]) + ufl.grad(u[0])

points = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
obj, module = ffcx.codegeneration.jit.compile_expressions([(expr, points)])
obj, module = ffcx.codegeneration.jit.compile_expressions([(expr, points)], cffi_extra_compile_args=compile_args)

ffi = cffi.FFI()
kernel = obj[0][0]
Expand Down