diff --git a/python/dune/perftool/loopy/transformer.py b/python/dune/perftool/loopy/transformer.py index 3cad73b4eb16076948c536db2951ea486916c4b2..630ed6e871963f0f2483282865586550ed955946 100644 --- a/python/dune/perftool/loopy/transformer.py +++ b/python/dune/perftool/loopy/transformer.py @@ -51,8 +51,8 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker, UFL2PymbolicMapper, GeometryMapp # We therefore gather a list of modified trial functions too. from dune.perftool.ufl.modified_terminals import extract_modified_arguments test_ma = extract_modified_arguments(o,) - trial_ma = extract_modified_arguments(o, testfunction=False, trialfunction=True) - apply_ma = extract_modified_arguments(o, testfunction=False, applyfunction=True) + trial_ma = extract_modified_arguments(o, coeffcount=0) + apply_ma = extract_modified_arguments(o, coeffcount=1) # All test and trial functions on boundary integrals are technically restricted import itertools diff --git a/python/dune/perftool/pdelab/driver.py b/python/dune/perftool/pdelab/driver.py index 8f3fb65597e04e623d6b4f4f3045fee7ef7bdc1a..ff87bd114c7ee54107f25ece4e5d0d83531e3c87 100644 --- a/python/dune/perftool/pdelab/driver.py +++ b/python/dune/perftool/pdelab/driver.py @@ -907,7 +907,7 @@ def dune_solve(): if get_option("matrix_free"): go = name_gridoperator() x = name_vector() - include_file("dune/perftool/matrixfree.hh", filetag="drive") + include_file("dune/perftool/matrixfree.hh", filetag="driver") return "solveMatrixFree({},{});".format(go, x) else: slp = name_stationarylinearproblemsolver() diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index 1c027044108f33a2bf47183a77e6a1f907317613..b539e14fdce6942cf288968e47cc2effc7928a65 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -379,11 +379,15 @@ def generate_localoperator_kernels(formdata, data): # Jacobian apply methods for matrix-free computations if get_option("matrix_free"): - from dune.perftool.ufl.execution import ApplyCoefficient - apply_coefficient = ApplyCoefficient(form.coefficients()[0]. ufl_element(), 1) + # The apply vector has reserved index 1 so we directly use Coefficient class from ufl + from ufl import Coefficient + apply_coefficient = Coefficient(form.coefficients()[0].ufl_element(), 1) + + # Create application of jacobian on vector from ufl import action - jac_apply_form = action(expand_derivatives(derivative(form, form.coefficients()[0])), apply_coefficient) + jac_apply_form = action(jacform, apply_coefficient) + # Create kernel for jacobian application with global_context(form_type="jacobian_apply"): for measure in set(i.integral_type() for i in jac_apply_form.integrals()): with global_context(integral_type=measure): diff --git a/python/dune/perftool/ufl/execution.py b/python/dune/perftool/ufl/execution.py index 981471d019aae19222fe9535c7197e154c80eb5e..5fe6975b233a73a2629186489742f5e897b6d7f2 100644 --- a/python/dune/perftool/ufl/execution.py +++ b/python/dune/perftool/ufl/execution.py @@ -26,14 +26,6 @@ class TrialFunction(ufl.Coefficient): ufl.Coefficient.__init__(self, element, count=0) -class ApplyCoefficient(ufl.Coefficient): - """ A coefficient that always takes the reserved index 1 """ - def __init__(self, element, count=None): - if count and count is not 1: - raise ValueError("The jacobian apply coefficient must be of index 1 in uflpdelab") - ufl.Coefficient.__init__(self, element, count=1) - - class Coefficient(ufl.Coefficient): """ A coefficient that honors the reserved index 0. """ def __init__(self, element, count=None): diff --git a/python/dune/perftool/ufl/modified_terminals.py b/python/dune/perftool/ufl/modified_terminals.py index 88eed9589636b1fcbd40e163b7889bcc98b1dc05..82bb8eee94b2c0ec9e3a46835faae0e0dc610e70 100644 --- a/python/dune/perftool/ufl/modified_terminals.py +++ b/python/dune/perftool/ufl/modified_terminals.py @@ -103,11 +103,9 @@ class ModifiedArgumentDescriptor(MultiFunction): class _ModifiedArgumentExtractor(MultiFunction): """ A multifunction that extracts and returns the set of modified arguments """ - def __call__(self, o, argnumber=None, testfunction=True, trialfunction=False, applyfunction=False): + def __call__(self, o, argnumber=None, coeffcount=None): self.argnumber = argnumber - self.trialfunction = trialfunction - self.testfunction = testfunction - self.applyfunction = applyfunction + self.coeffcount = coeffcount self.modified_arguments = set() ret = self.call(o) if ret: @@ -133,17 +131,12 @@ class _ModifiedArgumentExtractor(MultiFunction): function_view = pass_on def argument(self, o): - if self.testfunction: - if self.argnumber is None or o.number() == self.argnumber: - return o + if self.argnumber is None or o.number() == self.argnumber: + return o def coefficient(self, o): - if self.trialfunction: - if o.count() == 0: - return o - if self.applyfunction: - if o.count() == 1: - return o + if o.count() == self.coeffcount: + return o call = MultiFunction.__call__