Skip to content
Snippets Groups Projects
Commit ff30d3c6 authored by Elias Pipping's avatar Elias Pipping
Browse files

[Noise] Remove support for dune-python BC

parent 1fc22690
No related branches found
No related tags found
No related merge requests found
......@@ -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})
......
#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
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()
}
#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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment