Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #156 from firedrakeproject/value-packing-pr
Browse files Browse the repository at this point in the history
* value-packing-pr:
  change to value packing
  • Loading branch information
wence- committed Dec 15, 2017
2 parents 3869116 + dd85165 commit d7da9dc
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions tsfc/kernel_interface/firedrake.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from gem.node import traversal
from gem.optimise import remove_componenttensors as prune

from finat import TensorFiniteElement

from tsfc.finatinterface import create_element
from tsfc.kernel_interface.common import KernelBuilderBase as _KernelBuilderBase
from tsfc.coffee import SCALAR_TYPE
Expand Down Expand Up @@ -61,12 +59,12 @@ def __init__(self, interior_facet=False):

# Cell orientation
if self.interior_facet:
cell_orientations = gem.Variable("cell_orientations", (2, 1))
self._cell_orientations = (gem.Indexed(cell_orientations, (0, 0)),
gem.Indexed(cell_orientations, (1, 0)))
cell_orientations = gem.Variable("cell_orientations", (2,))
self._cell_orientations = (gem.Indexed(cell_orientations, (0,)),
gem.Indexed(cell_orientations, (1,)))
else:
cell_orientations = gem.Variable("cell_orientations", (1, 1))
self._cell_orientations = (gem.Indexed(cell_orientations, (0, 0)),)
cell_orientations = gem.Variable("cell_orientations", (1,))
self._cell_orientations = (gem.Indexed(cell_orientations, (0,)),)

def _coefficient(self, coefficient, name):
"""Prepare a coefficient. Adds glue code for the coefficient
Expand Down Expand Up @@ -284,31 +282,21 @@ def prepare_coefficient(coefficient, name, interior_facet=False):
return funarg, expression

finat_element = create_element(coefficient.ufl_element())

if isinstance(finat_element, TensorFiniteElement):
scalar_shape = finat_element.base_element.index_shape
tensor_shape = finat_element.index_shape[len(scalar_shape):]
else:
scalar_shape = finat_element.index_shape
tensor_shape = ()
scalar_size = numpy.prod(scalar_shape, dtype=int)
tensor_size = numpy.prod(tensor_shape, dtype=int)
shape = finat_element.index_shape
size = numpy.prod(shape, dtype=int)

funarg = coffee.Decl(SCALAR_TYPE, coffee.Symbol(name),
pointers=[("const", "restrict"), ("restrict",)],
pointers=[("restrict",)],
qualifiers=["const"])

if not interior_facet:
expression = gem.reshape(
gem.Variable(name, (scalar_size, tensor_size)),
scalar_shape, tensor_shape
)
expression = gem.reshape(gem.Variable(name, (size,)), shape)
else:
varexp = gem.Variable(name, (2 * scalar_size, tensor_size))
plus = gem.view(varexp, slice(scalar_size), slice(tensor_size))
minus = gem.view(varexp, slice(scalar_size, 2 * scalar_size), slice(tensor_size))
expression = (gem.reshape(plus, scalar_shape, tensor_shape),
gem.reshape(minus, scalar_shape, tensor_shape))
varexp = gem.Variable(name, (2 * size,))
plus = gem.view(varexp, slice(size))
minus = gem.view(varexp, slice(size, 2 * size))
expression = (gem.reshape(plus, shape),
gem.reshape(minus, shape))
return funarg, expression


Expand Down Expand Up @@ -358,6 +346,6 @@ def expression(restricted):


cell_orientations_coffee_arg = coffee.Decl("int", coffee.Symbol("cell_orientations"),
pointers=[("restrict", "const"), ("restrict",)],
pointers=[("restrict",)],
qualifiers=["const"])
"""COFFEE function argument for cell orientations"""

0 comments on commit d7da9dc

Please sign in to comment.