Get a vector from field

hi
I wrote this code in julia gridap. h value is a field. i need a vector of values. how can i get that?
∂Hn+1/∂hnj={−1 , if i = j and ψ+n+1(e (ξ i ) )< hn(ξ i )
0 , otherwise

function  dh(hh_in, ψPlusnext_in)
    h_in = hh_in
    if h_in  > ψPlusnext_in
        dh_out = -1.0
    else
        dh_out = 0.0
    end
    dh_out
end

how can i have dh_out as a vector?
Thank you

I also cant define the -1 and 0 in function as vectors because then it can not do the comparison for if condition

You can apply any function to an array by using broadcasting, in your case:

hh_in = rand(10)
ψPlusnext_in = rand(10)
dh_out = dh.(hh_in, ψPlusnext_in)

In this particular case, you could also write

x = rand(10)
y = rand(10)
z = @. (x > y) * -1.0

where the @. makes sure that all following operations are broadcasted, e.g. applied to each component.

Thank you for your response i did what you said but the output is operationcellfield not a vector. Did i miss something?

Oh, sorry, I didn’t read the GridAp.jl specific part. Maybe it would help to see what types exactly you have. You might want to apply it directly to dd_h.cell_dof_values.