Hello,
I am currently translating a code originally developed in FEniCS (legacy) to FEniCSx.
In the legacy version, I used the following function:
def Heaviside(H_, sigma, subspace_number, sigma_min, sigma_max):
fsub = sigma.sub(subspace_number, deepcopy=True)
tmp = fsub.vector().get_local()
tmp1 = tmp - sigma_min
tmp2 = (tmp1 + np.abs(tmp1)) * 0.5
tmp3 = tmp2 + sigma_min
tmp4 = sigma_max - tmp3
tmp5 = (tmp4 + np.abs(tmp4)) * 0.5
tmp6 = (-1.tmp5) + sigma_max
h = 0.5 - 0.5np.cos(np.pi*(tmp6 - sigma_min)/(sigma_max - sigma_min))
H_.vector()[:] = h
return H_
In FEniCSx, I’m having trouble with the line fsub.vector().get_local()
. When trying to implement it, I couldn’t find a direct equivalent of .get_local
in dolfinx. From reading forum discussions, I found references to .vector.getArray()
or .vector.getArray(readonly=False)
, but these only return empty arrays rather than containing the values of my solution sigma
.
Thank you, regards.