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

how to sum Function objects

+2 votes

Hello everybody,
i've had a problem after last fenics update.

Q=Function(V0)
    for i in range(n):

     current_Q_value=numpy.zeros(i+1)
     disp[i].mark(domains,i)
     if i>0:
        current_Q_value[i]=Q_values[i]
        help = numpy.asarray(domains.array(), dtype=numpy.int32)
        current_Q_value_array=numpy.asarray(current_Q_value)
        Q.vector()[:] += numpy.choose(help, current_Q_value_array)

is the code that run with no problem before the update, but now it gives me
MemoryError, even if the RAM is still empty and the stack memory limit is not reached.
In addiction, if I try to comment this part of the code, i receive another error from another similar instruction:

for i in range(len(primal.domain.array())):
            i_domain=primal.domain.array()[i]
            if i_domain==i_omega:

residual.vector()[i]=T_function.vector()[i]-t_a_function.vector()[i]

TypeError: provide a scalar to set single item

where residual, T_function, t_a_function are all functions defined on the same space.

I need to sum Functions, until last update i do it element by element, but now this syntax doesn't work.
Could you explain me what has been modified please? I cannot find an alternative syntax in python.
Thank you for help in advance.

asked Feb 10, 2015 by soblinsky FEniCS Novice (140 points)
edited Feb 10, 2015 by chris_richardson
...