How to set coefficients for finite element?

Hello, I have been scratching my head trying to find this through the tutorials but can’t seem to find it. I essentially have a functionspace, which as far as I understood represents a mesh with its corresponding Lagrange polynomials. I am trying to obtain evaluations of it on points inside the domain with certain coefficients that I want to impose.

I have included a short code block of my code. Essentially I am trying to approximate the continuous Dirichlet-to Neumman operator by using an eigendecomposition of a discretized DtN operator.


    def compute_eigenfunctions(self):

        eigenvalues, eigenvectors = self.eigendecomposition()
        V = fem.functionspace(self.domain, ("Lagrange", self.order))
        
        eigenfunctions = []
        for i in range(eigenvectors.shape[1]):
            eigenvector = eigenvectors[i, :]
            eigenfunction = fem.Function(V, x = eigenvector)
            eigenfunctions.append(eigenfunction)

        return eigenfunctions
    

I tried this by inspecting the source code for fem.Function but the x argument doesn’t seem to be in the right format as an np.ndarray.

Thanks!

I would change this to

eigenfunction= fem.Function(V)
eigenfunction.x.array[:] = eigenvector