From be233e54805177eeab68763488f9bbfb3bba76ab Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.r.kempf@gmail.com> Date: Wed, 9 Sep 2015 18:32:23 +0200 Subject: [PATCH] Put the code for numerical jacobian into a separate function --- python/dune/perftool/pdelab/localoperator.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index 7af8a8a5..357711b7 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -25,17 +25,21 @@ def measure_specific_details(measure): # The return dictionary that this memoized method will grant direct access to. ret = {} - if measure == "cell": - base_class('Dune::PDELab::FullVolumePattern') + def numerical_jacobian(which): if get_option("numerical_jacobian"): # Add a base class from dune.perftool.pdelab.driver import type_localoperator loptype = type_localoperator() - base_class("Dune::PDELab::NumericalJacobianVolume<{}>".format(loptype)) + base_class("Dune::PDELab::NumericalJacobian{}<{}>".format(which, loptype)) # Add the initializer list for that base class ini = name_initree_constructor() - initializer_list("Dune::PDELab::NumericalJacobianVolume<{}>({}.get(\"numerical_epsilon.volume\", 1e-9))".format(loptype, ini)) + initializer_list("Dune::PDELab::NumericalJacobian{}<{}>({}.get(\"numerical_epsilon.{}\", 1e-9))".format(which, loptype, ini, which.lower())) + + + if measure == "cell": + base_class('Dune::PDELab::FullVolumePattern') + numerical_jacobian("Volume") ret["residual_signature"] = ['template<typename EG, typename LFSV0, typename X, typename LFSV1, typename R>', 'void alpha_volume(const EG& eg, const LFSV0& lfsv0, const X& x, const LFSV1& lfsv1, R& r) const'] @@ -44,6 +48,7 @@ def measure_specific_details(measure): if measure == "exterior_facet": base_class('Dune::PDELab::FullBoundaryPattern') + numerical_jacobian("Boundary") ret["residual_signature"] = ['template<typename IG, typename LFSV0, typename X, typename LFSV1, typename R>', 'void alpha_boundary(const IG& ig, const LFSV0& lfsv0, const X& x, const LFSV1& lfsv1, R& r) const'] @@ -52,6 +57,7 @@ def measure_specific_details(measure): if measure == "interior_facet": base_class('Dune::PDELab::FullSkeletonPattern') + numerical_jacobian("Skeleton") ret["residual_signature"] = ['template<typename IG, typename LFSV0_S, typename X, typename LFSV1_S, typename LFSV0_N, typename R, typename LFSV1_N>', 'void alpha_skeleton(const IG& ig, const LFSV0_S& lfsv0_s, const X& x_s, const LFSV1_S& lfsv1_s, const LFSV0_N& lfsv0_n, const X& x_n, const LFSV1_N& lfsv1_n, R& r_s, R& r_n) const'] -- GitLab