Skip to content
Snippets Groups Projects
Commit 6a8c869d authored by Daniel Kienle's avatar Daniel Kienle Committed by Carsten Gräser
Browse files

add test case for python fix

parent 2e102b60
Branches
No related tags found
1 merge request!26Feature/fix nonsequence python conversion
Pipeline #
...@@ -800,6 +800,35 @@ int main(int argc, char** argv) ...@@ -800,6 +800,35 @@ int main(int argc, char** argv)
} }
#endif #endif
std::cout << std::endl;
std::cout << "Example 18: calling functions with Fieldvector multiple times ******************" << std::endl;
{
using Vec3D = Dune::FieldVector<double, 3>;
using Vec2D = Dune::FieldVector<double, 2>;
using Vec1D = Dune::FieldVector<double, 1>;
Vec3D a{0.5,0.5,0.5};
Vec2D b{0.5,0.5};
Vec1D c{0.5};
auto test3d = Python::make_function<Vec3D>(Python::evaluate("lambda x: (0.0, 0.0, 0.0)"));
auto test2d = Python::make_function<Vec2D>(Python::evaluate("lambda x: (0.0, 0.0)"));
auto test1d = Python::make_function<Vec1D>(Python::evaluate("lambda x: (0.0)"));
int nloop=2;
std::cout << "multiple calls with 3d Fieldvector... "<< std::endl;
for (int i=0; i<nloop; ++i)
std::cout << i << ". call "<< test3d(a) << " should be (0,0,0)" << std::endl;
std::cout << "multiple calls with 2d Fieldvector... "<< std::endl;
for (int i=0; i<nloop; ++i)
std::cout << i << ". call "<< test2d(b) << " should be (0,0)" << std::endl;
std::cout << "multiple calls with 1d Fieldvector... "<< std::endl;
for (int i=0; i<nloop; ++i)
std::cout << i << ". call "<< test1d(c) << " should be (0)" << std::endl;
}
// Before exiting you should stop the python interpreter. // Before exiting you should stop the python interpreter.
Python::stop(); Python::stop();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment