Skip to content
Snippets Groups Projects
Commit e696e4a1 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Simplify Python code by using lambda functions

[[Imported from SVN: r9796]]
parent d220ae3a
No related branches found
No related tags found
No related merge requests found
......@@ -271,16 +271,12 @@ int main (int argc, char *argv[]) try
// Make Python function that computes which vertices are on the Dirichlet boundary,
// based on the vertex positions.
Python::runStream()
<< std::endl << "def dirichletVertices(x):"
<< std::endl << " return " << parameterSet.get<std::string>("dirichletVerticesPredicate");
PythonFunction<FieldVector<double,dim>, int> pythonDirichletVertices(main.get("dirichletVertices"));
std::string lambda = std::string("lambda x: (") + parameterSet.get<std::string>("dirichletVerticesPredicate") + std::string(")");
PythonFunction<FieldVector<double,dim>, int> pythonDirichletVertices(Python::evaluate(lambda));
// Same for the Neumann boundary
Python::runStream()
<< std::endl << "def neumannVertices(x):"
<< std::endl << " return " << parameterSet.get<std::string>("neumannVerticesPredicate", "0");
PythonFunction<FieldVector<double,dim>, int> pythonNeumannVertices(main.get("neumannVertices"));
lambda = std::string("lambda x: (") + parameterSet.get<std::string>("neumannVerticesPredicate", "0") + std::string(")");
PythonFunction<FieldVector<double,dim>, int> pythonNeumannVertices(Python::evaluate(lambda));
for (; vIt!=vEndIt; ++vIt) {
......
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