From 1ef643a9906ac39bac43ae045e71b121ec4aafcd Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Tue, 30 Oct 2012 12:24:36 +0100 Subject: [PATCH] Move python initialisation to a separate function --- src/one-body-sample.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 4c87a25f..1e2acf3d 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -176,20 +176,23 @@ initStateUpdater(Config::state_model model, } } +template <class FunctionMap> void initPython(FunctionMap &functions) { + Python::start(); + + Python::run("import sys"); + Python::run("sys.path.append('" srcdir "')"); + + Python::import("one-body-sample") + .get("Functions") + .toC<typename FunctionMap::Base>(functions); +} + int main(int argc, char *argv[]) { try { typedef SharedPointerMap<std::string, Dune::VirtualFunction<double, double>> FunctionMap; FunctionMap functions; - { - Python::start(); - - Python::run("import sys"); - Python::run("sys.path.append('" srcdir "')"); - - Python::import("one-body-sample").get("Functions").toC<FunctionMap::Base>( - functions); - } + initPython(functions); Dune::ParameterTree parset; Dune::ParameterTreeParser::readINITree(srcdir "/one-body-sample.parset", -- GitLab