From f39a9b49d10f452718b3d52e1e24045ed5ed6e29 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Fri, 25 Aug 2017 16:46:09 +0200 Subject: [PATCH] Even more fixups after rebasing --- python/dune/perftool/pdelab/driver/__init__.py | 4 ++++ python/dune/perftool/pdelab/driver/constraints.py | 3 ++- python/dune/perftool/pdelab/driver/interpolate.py | 10 +++++++--- python/dune/perftool/pdelab/driver/solve.py | 6 +++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/python/dune/perftool/pdelab/driver/__init__.py b/python/dune/perftool/pdelab/driver/__init__.py index a7860faf..81ebce1e 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 bc862b70..c0890fd2 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 cc046ae2..3cbef4bd 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 0179fe68..5abbac27 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) -- GitLab