diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d9da68c7387f35caff1537248ed3f9b229ae46dc..f52a06db113728f2b80f48b8c1726f4ecf7ed0ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,6 @@ dune_symlink_to_source_files(FILES foreach(_dim 2 3) set(_target sand-wedge-${_dim}D) add_executable(${_target} ${SOURCE_FILES}) - add_dune_pythonlibs_flags(${_target}) add_dune_ug_flags(${_target}) set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}) diff --git a/src/sand-wedge-data/bc.hh b/src/sand-wedge-data/bc.hh new file mode 100644 index 0000000000000000000000000000000000000000..0d14feabe7456271d9fcdc6fbb9ebdaa6f7bbd07 --- /dev/null +++ b/src/sand-wedge-data/bc.hh @@ -0,0 +1,18 @@ +#ifndef SRC_SAND_WEDGE_DATA_BC_HH +#define SRC_SAND_WEDGE_DATA_BC_HH + +class VelocityDirichletCondition + : public Dune::VirtualFunction<double, double> { + void evaluate(double const &relativeTime, double &y) const { + // Assumed to vanish at time zero + double const finalVelocity = -5e-5; + y = (relativeTime <= 0.1) + ? finalVelocity * (1.0 - std::cos(relativeTime * M_PI / 0.1)) / 2.0 + : finalVelocity; + } +}; + +class NeumannCondition : public Dune::VirtualFunction<double, double> { + void evaluate(double const &relativeTime, double &y) const { y = 0.0; } +}; +#endif diff --git a/src/sand-wedge-data/boundaryconditions.py b/src/sand-wedge-data/boundaryconditions.py deleted file mode 100644 index 8db53fe0cc92c884357304bb854ac4be72e10ff0..0000000000000000000000000000000000000000 --- a/src/sand-wedge-data/boundaryconditions.py +++ /dev/null @@ -1,18 +0,0 @@ -import math - -class neumannCondition: - def __call__(self, relativeTime): - return 0 - -class velocityDirichletCondition: - def __call__(self, relativeTime): - # Assumed to vanish at time zero - finalVelocity = -5e-5 - if relativeTime <= 0.1: - return finalVelocity * ( 1.0 - math.cos(relativeTime * math.pi / 0.1) ) / 2.0 - return finalVelocity - -Functions = { - 'neumannCondition' : neumannCondition(), - 'velocityDirichletCondition' : velocityDirichletCondition() -} diff --git a/src/sand-wedge.cc b/src/sand-wedge.cc index 6fcc699a629cdafaf76f3ef92b4f0a78f6c27027..403986b33b8d9005d848ae41d6f5d49adf117ad3 100644 --- a/src/sand-wedge.cc +++ b/src/sand-wedge.cc @@ -1,13 +1,7 @@ -#include <Python.h> - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifndef HAVE_PYTHON -#error Python is required -#endif - #ifdef HAVE_IPOPT #undef HAVE_IPOPT #endif @@ -39,8 +33,6 @@ #include <dune/fufem/boundarypatch.hh> #pragma clang diagnostic pop -#include <dune/fufem/dunepython.hh> -#include <dune/fufem/sharedpointermap.hh> #include <dune/solvers/norms/energynorm.hh> #include <dune/solvers/solvers/loopsolver.hh> #include <dune/solvers/solvers/solver.hh> @@ -60,6 +52,7 @@ #include "hdf5/restart-io.hh" #include "matrices.hh" #include "program_state.hh" +#include "sand-wedge-data/bc.hh" #include "sand-wedge-data/mybody.hh" #include "sand-wedge-data/mygeometry.hh" #include "sand-wedge-data/myglobalfrictiondata.hh" @@ -75,14 +68,6 @@ size_t const dims = MY_DIM; namespace fs = boost::filesystem; -void initPython(fs::path const &dataDirectory) { - Python::start(); - - Python::run("import sys"); - Python::run( - str(boost::format("sys.path.append('%s')") % dataDirectory.string())); -} - Dune::ParameterTree getParameters(int argc, char *argv[], fs::path const &dataDirectory) { Dune::ParameterTree parset; @@ -167,17 +152,8 @@ int main(int argc, char *argv[]) { // Set up functions for time-dependent boundary conditions using Function = Dune::VirtualFunction<double, double>; - using FunctionMap = SharedPointerMap<std::string, Function>; - FunctionMap functions; - { - initPython(dataDirectory); - Python::import("boundaryconditions") - .get("Functions") - .toC<typename FunctionMap::Base>(functions); - } - auto const &velocityDirichletFunction = - functions.get("velocityDirichletCondition"), - &neumannFunction = functions.get("neumannCondition"); + Function const &velocityDirichletFunction = VelocityDirichletCondition(); + Function const &neumannFunction = NeumannCondition(); MyAssembler const myAssembler(leafView); @@ -327,7 +303,6 @@ int main(int argc, char *argv[]) { report(); } - Python::stop(); } catch (Dune::Exception &e) { Dune::derr << "Dune reported error: " << e << std::endl; } catch (std::exception &e) {