diff --git a/python/dune/perftool/pdelab/driver/__init__.py b/python/dune/perftool/pdelab/driver/__init__.py index a7860faf9ad0b1c31def0a284e34b070e9cd6e90..81ebce1ea48efc25b88d9e3863df15535afc96db 100644 --- a/python/dune/perftool/pdelab/driver/__init__.py +++ b/python/dune/perftool/pdelab/driver/__init__.py @@ -63,6 +63,10 @@ def get_formdata(): return _driver_data['formdata'] +def get_mass_formdata(): + return _driver_data["mass_formdata"] + + def is_stationary(): return 'mass_form' not in _driver_data diff --git a/python/dune/perftool/pdelab/driver/constraints.py b/python/dune/perftool/pdelab/driver/constraints.py index bc862b7065b74b49a5c118567e87b114a92ae639..c0890fd22eb03f54ba69e7497f60f11d6967d0a4 100644 --- a/python/dune/perftool/pdelab/driver/constraints.py +++ b/python/dune/perftool/pdelab/driver/constraints.py @@ -1,4 +1,5 @@ -from dune.perftool.generation import (include_file, +from dune.perftool.generation import (global_context, + include_file, preamble, ) from dune.perftool.pdelab.driver import (FEM_name_mangling, diff --git a/python/dune/perftool/pdelab/driver/interpolate.py b/python/dune/perftool/pdelab/driver/interpolate.py index cc046ae26270aa65cbe14bbbd23bb659231e3a89..3cbef4bdbfdeecc7fd149d4255a531b586b2c000 100644 --- a/python/dune/perftool/pdelab/driver/interpolate.py +++ b/python/dune/perftool/pdelab/driver/interpolate.py @@ -52,7 +52,7 @@ def name_boundary_function(element, func): childs.append(name_boundary_function(subel, func[k:k + subel.value_size()])) k = k + subel.value_size() name = "_".join(childs) - define_composite_boundary_function(name, tuple(childs)) + define_composite_parameterfunction(name, tuple(childs)) return name else: assert isinstance(element, FiniteElement) @@ -95,9 +95,11 @@ def name_boundary_lambda(boundary): @preamble def define_boundary_lambda(name, boundary): - from ufl.classes import Expr if boundary is None: - return "auto {} = [&](const auto& x){{ return 0.0; }};".format(name) + boundary = 0.0 + from ufl.classes import Expr + if isinstance(boundary, (int, float)): + return "auto {} = [&](const auto& x){{ return {}; }};".format(name, float(boundary)) elif isinstance(boundary, Expr): # Set up a visitor with global_context(integral_type="exterior_facet", formdata=get_formdata(), driver=True): @@ -112,3 +114,5 @@ def define_boundary_lambda(name, boundary): return "auto {} = [&](const auto& x){{ return ({}){}; }};".format(name, numpy_to_cpp_dtype("float64"), ccm(expr)) + else: + raise NotImplementedError("What is this?") diff --git a/python/dune/perftool/pdelab/driver/solve.py b/python/dune/perftool/pdelab/driver/solve.py index 0179fe68905f6c1890a517657d345c35b235a845..5abbac27c46deb00169f3787b9283c93db9f94a6 100644 --- a/python/dune/perftool/pdelab/driver/solve.py +++ b/python/dune/perftool/pdelab/driver/solve.py @@ -40,8 +40,8 @@ def dune_solve(): include_file("dune/perftool/matrixfree.hh", filetag="driver") solve = "solveNonlinearMatrixFree({},{});".format(go, x) elif not linear and not matrix_free: - go_type = type_gridoperator(_driver_data['formdata']) - go = name_gridoperator(_driver_data['formdata']) + go_type = type_gridoperator(get_formdata()) + go = name_gridoperator(get_formdata()) snp = name_stationarynonlinearproblemsolver(go_type, go) solve = "{}.apply();".format(snp) @@ -172,7 +172,7 @@ def name_stationarylinearproblemsolver(): def typedef_stationarynonlinearproblemsolver(name, go_type): include_file("dune/pdelab/newton/newton.hh", filetag="driver") ls_type = type_linearsolver() - x_type = type_vector(_driver_data['formdata']) + x_type = type_vector(get_formdata()) return "using {} = Dune::PDELab::Newton<{}, {}, {}>;".format(name, go_type, ls_type, x_type)