This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

SegFault on MeshFunction.set_value()

0 votes

Running this script returns a segfault and I have no idea why. I just want to set the value of a MeshFunction for a given index, here it's just 0, but obtaining the index from a given cell with cell.index() returns the same error.

from dolfin import *
mesh = UnitSquareMesh(10,10)
history_visit = MeshFunction("bool", mesh, 2) # <--- The segfault was happening because there was no topological dimension (third argument)
history_visit.set_value(0,False)

but I get a segfault from PETSc

[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.
application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0

Thanks

Edit: MeshFunction() needs the topological dimension, in my case it is 2.

closed with the note: Found the problem
asked Jul 18, 2016 by miguelito FEniCS Novice (760 points)
closed Jul 18, 2016 by miguelito
...