diff --git a/python/dune/perftool/pdelab/function.py b/python/dune/perftool/pdelab/function.py index 564b44479eb1c706d740e4f5e0867d57ef71c7c7..2f2e0292377c662169a1a07d48c0867638e91bb3 100644 --- a/python/dune/perftool/pdelab/function.py +++ b/python/dune/perftool/pdelab/function.py @@ -12,19 +12,6 @@ from dune.perftool.pdelab.localoperator import name_gridfunction_member import pymbolic.primitives as prim -def local_gridfunction(coeff, restriction, diffOrder): - gf = name_gridfunction_member(coeff, diffOrder) - name = "{}_local".format(gf) - define_local_gridfunction(name, gf) - bind_gridfunction_to_element(name, restriction) - return name - - -@preamble -def define_local_gridfunction(name, gf): - return "auto {} = localFunction({});".format(name, gf) - - @preamble def bind_gridfunction_to_element(gf, restriction): element = name_cell(restriction) @@ -42,7 +29,8 @@ def declare_grid_function_range(gridfunction): def pymbolic_evaluate_gridfunction(name, coeff, restriction, grad): diffOrder = 1 if grad else 0 - gridfunction = local_gridfunction(coeff, restriction, diffOrder) + gridfunction = name_gridfunction_member(coeff, diffOrder) + bind_gridfunction_to_element(gridfunction, restriction) temporary_variable(name, shape=(1,) + (world_dimension(),) * diffOrder, diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index 11c302d9744fdc70eb30395f5dcd0697558b6cc2..948356b467e506171aeb8911983a9a76640699fc 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -158,7 +158,7 @@ def localoperator_basename(form_ident): def name_gridfunction_member(coeff, diffOrder=0): - name = "gridfunction_coeff{}_diff{}".format(coeff.count(), diffOrder) + name = "local_gridfunction_coeff{}_diff{}".format(coeff.count(), diffOrder) define_gridfunction_member(name, coeff, diffOrder) return name @@ -175,14 +175,14 @@ def define_gridfunction_member(name, coeff, diffOrder): _type = type_gridfunction_template_parameter(coeff) param = name_gridfunction_constructor_argument(coeff) if diffOrder > 0: - include_file("dune/pdelab/function/discretegridviewfunction.hh", filetag="operatorfile") - newtype = "Dune::PDELab::DiscreteGridViewFunction<typename {0}::GridFunctionSpace, typename {0}::Vector, {1}>".format(_type, diffOrder) - params = ["{}.gridFunctionSpace()".format(param), "{}.dofs()".format(param)] - initializer_list(name, params, classtag="operator") - return "{} {};".format(newtype, name) + other = name_gridfunction_member(coeff, diffOrder - 1) + init = "derivative({})".format(other) + initializer_list(name, [init], classtag="operator") + return "mutable decltype({}) {};".format(init, name) else: - initializer_list(name, [param], classtag="operator") - return "const {}& {};".format(_type, name) + init = "localFunction({})".format(param) + initializer_list(name, [init], classtag="operator") + return "mutable typename {}::LocalFunction {};".format(_type, name) @template_parameter(classtag="operator")