The following function takes three dolfin.Functions (with size mod 3 = 0) and manipulates the third input vector in every DOF-entry including if-statements:
def mani(func1, func2, out_func):
vec1 = func1.vector().get_local()
vec2 = func2.vector().get_local()
mask = vec1<0.5
IF_vals = vec3.reshape(-1,3)*vec1[:,None]
ELSE_vals = np.array([1,1,1])
out_func.vector().set_local() = np.where(mask[:,None],IF_vals,ELSE_vals).ravel()
Would there be a significant increase in the computational speed if this function would be implemented in c++? If so, could you give me some references on how to implement this in c++? Thanks.