Skip to content
Snippets Groups Projects
Commit afca8d2d authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Merge branch 'stop-using-pythonfunction' into 'master'

Stop using deprecated class PythonFunction

See merge request !55
parents 942fc339 c7ae343e
Branches
Tags
1 merge request!55Stop using deprecated class PythonFunction
Pipeline #34332 failed
...@@ -160,21 +160,16 @@ int main (int argc, char *argv[]) try ...@@ -160,21 +160,16 @@ int main (int argc, char *argv[]) try
// Make Python function that computes which vertices are on the Dirichlet boundary, // Make Python function that computes which vertices are on the Dirichlet boundary,
// based on the vertex positions. // based on the vertex positions.
std::string lambda = std::string("lambda x: (") + parameterSet.get<std::string>("dirichletVerticesPredicate") + std::string(")"); std::string lambda = std::string("lambda x: (") + parameterSet.get<std::string>("dirichletVerticesPredicate") + std::string(")");
PythonFunction<FieldVector<double,dim>, bool> pythonDirichletVertices(Python::evaluate(lambda)); auto pythonDirichletVertices = Python::make_function<bool>(Python::evaluate(lambda));
// Same for the Neumann boundary // Same for the Neumann boundary
lambda = std::string("lambda x: (") + parameterSet.get<std::string>("neumannVerticesPredicate", "0") + std::string(")"); lambda = std::string("lambda x: (") + parameterSet.get<std::string>("neumannVerticesPredicate", "0") + std::string(")");
PythonFunction<FieldVector<double,dim>, bool> pythonNeumannVertices(Python::evaluate(lambda)); auto pythonNeumannVertices = Python::make_function<bool>(Python::evaluate(lambda));
for (auto&& v : vertices(gridView)) for (auto&& v : vertices(gridView))
{ {
bool isDirichlet; dirichletVertices[indexSet.index(v)] = pythonDirichletVertices(v.geometry().corner(0));
pythonDirichletVertices.evaluate(v.geometry().corner(0), isDirichlet); neumannVertices[indexSet.index(v)] = pythonNeumannVertices(v.geometry().corner(0));
dirichletVertices[indexSet.index(v)] = isDirichlet;
bool isNeumann;
pythonNeumannVertices.evaluate(v.geometry().corner(0), isNeumann);
neumannVertices[indexSet.index(v)] = isNeumann;
} }
BoundaryPatch<GridView> dirichletBoundary(gridView, dirichletVertices); BoundaryPatch<GridView> dirichletBoundary(gridView, dirichletVertices);
...@@ -202,7 +197,7 @@ int main (int argc, char *argv[]) try ...@@ -202,7 +197,7 @@ int main (int argc, char *argv[]) try
SolutionType x(basis.size()); SolutionType x(basis.size());
lambda = std::string("lambda x: (") + parameterSet.get<std::string>("initialDeformation") + std::string(")"); lambda = std::string("lambda x: (") + parameterSet.get<std::string>("initialDeformation") + std::string(")");
PythonFunction<FieldVector<double,dim>, FieldVector<double,dim> > pythonInitialDeformation(Python::evaluate(lambda)); auto pythonInitialDeformation = Python::make_function<FieldVector<double,dim> >(Python::evaluate(lambda));
Dune::Functions::interpolate(basis, x, pythonInitialDeformation); Dune::Functions::interpolate(basis, x, pythonInitialDeformation);
...@@ -328,7 +323,7 @@ int main (int argc, char *argv[]) try ...@@ -328,7 +323,7 @@ int main (int argc, char *argv[]) try
Python::Reference dirichletValuesPythonObject = C(homotopyParameter); Python::Reference dirichletValuesPythonObject = C(homotopyParameter);
// Extract object member functions as Dune functions // Extract object member functions as Dune functions
PythonFunction<FieldVector<double,dim>, FieldVector<double,dim> > dirichletValues(dirichletValuesPythonObject.get("dirichletValues")); auto dirichletValues = Python::make_function<FieldVector<double, dim> >(dirichletValuesPythonObject.get("dirichletValues"));
Dune::Functions::interpolate(basis, x, dirichletValues, dirichletDofs); Dune::Functions::interpolate(basis, x, dirichletValues, dirichletDofs);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment