Skip to content
Snippets Groups Projects
Commit 5f5bce43 authored by graeser's avatar graeser
Browse files

Merge branch 'feature/fix-nonsequence-python-conversion' into 'master'

Feature/fix nonsequence python conversion

See merge request !26
parents 80511cbe 6a8c869d
Branches
No related tags found
1 merge request!26Feature/fix nonsequence python conversion
Pipeline #
......@@ -216,7 +216,7 @@ struct Conversion<Dune::FieldVector<T,n> >
if (n!=1)
DUNE_THROW(Dune::Exception, "cannot convert a non-sequence to a Dune::FieldVector<T,n> with n>1");
Reference(list).toC(v[0]);
Reference(Imp::inc(list)).toC(v[0]);
}
else
{
......@@ -255,7 +255,7 @@ struct Conversion<Dune::FieldMatrix<T,n,m> >
if (n!=1)
DUNE_THROW(Dune::Exception, "cannot convert a non-sequence to a Dune::FieldMatrix<T,n,m> with n>1");
Reference(list).toC(v[0]);
Reference(Imp::inc(list)).toC(v[0]);
}
else
{
......
......@@ -800,6 +800,35 @@ int main(int argc, char** argv)
}
#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.
Python::stop();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment