Skip to content
Snippets Groups Projects
Commit 6917da50 authored by René Heß's avatar René Heß
Browse files

Some small improvements and bugfixes

parent f23ded13
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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()
......
......@@ -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):
......
......@@ -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):
......
......@@ -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__
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment