Cast to float of Function(R) fails with 64-bit PETSc

Issue #431 resolved
Prof Garth Wells created an issue

Tests in test/unit/python/function/test_function.py of the form

def test_real_function_float_conversion1(R):
    c = Function(R)
    assert float(c) == 0.0

seg fault when PETSc is compiled with 64-bit integers. Last line is the problem.

Comments (12)

  1. Martin Sandve Alnæs

    site-packages/dolfin/functions/function.py

    line 493

    the dtype='intc' is probably the cause.

  2. Prof Garth Wells reporter

    OK. How should we fix it? The NumPy wrapping is really confusing to me. Would it be better to just use copies for integer arrays?

  3. Prof Garth Wells reporter

    @johanhake Doesn't seem to work with 64-bit PETSc. I get

    function/test_function.py:270: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >       values = vec.gather(indices)
    E       TypeError: (1) numpy array of 'intc' expected. Make sure that the numpy array use dtype=intc.
            # Gather value directly from vector in a parallell safe way
            vec = self.vector()
            indices = numpy.zeros(1, dtype=cpp.la_index_dtype())
    >       values = vec.gather(indices)
    

    Buildbot also reports this error (http://fenicsproject.org:8010/builders/dolfin-master-full-mpich/builds/1345/steps/make%20run_unittests_py/logs/stdio)

  4. Johan Hake

    There wasn't any sizeof(dolfin::la_index)==8 typemap for const std::vector<dolfin::la_index>&. I have pushed a fix for this to next. Let see how that works out.

  5. Log in to comment