Hi, again.
As known, the external force vector can be obtained from the following codes:
dU_ext = dot(load, u_test)*ds(1) # reference external energy functional due to external load imposed on the boundary ds(1)
f_ext = assemble(dU_ext) # assembled external forces
Now, I want to calculate a similar external force vector as the product of a stiffness matrix K and a vector u_p containing prescribed displacements.
K = assemble(a) # stiffness matrix
bc.apply(u_p.vector()) # u_p contains the prescribed displacements
# the reference external forces
f_ext = inner(K, u_p) # does not work
f_ext = numpy.matmul(K.array(), u_p.vector.array()) # works, but yields an array rather than a Vector as the external forces given above
I want to arrive at an external force vector f_ext of the same type obtained by assemble().
Can someone give me any idea? Thank you!