Calling components of a solution in CompoundFESpaces


In the Mixed formulation for second order equations, with the following FESpace

fesm = FESpace([V,Q])

if the solution is defined as

gfm = ng.GridFunction(fesm, multidim=15) # array of eigenfunctions

How can one call components of the solution gfm?

Any help, would be appreciated.


Hi D,

in the 20.08 release we brought in the gf.MDComponent function for that,
and allow also a gf.Set (…) for individual components, here an example.

Best, Joachim

from ngsolve import *
from netgen.geom2d import unit_square

mesh = Mesh(unit_square.GenerateMesh(maxh=0.1))

fes = H1(mesh, order=2)

gfu = GridFunction(fes, multidim=3)

gfu.Set (x*x, mdcomp=0)
gfu.Set (sqrt(2)*x*y, mdcomp=1)
gfu.Set (y*y, mdcomp=2)

Draw (gfu)

gfusum = sum( [gfu.MDComponent(i)**2 for i in range(len(gfu.vecs))] )
Draw (gfusum, mesh, "gfusum")

Hi Joachim,

Thank you for your helpful response.
In my example, gfm is an array with length of 15 which each component is defined in the dual function space fesm. Let’s say gfm = (sigma, u) ; one can say the answer is gfm = [gfm1, gfm2, . . . , gfm15 ] where gfm1 = (sigma1, u1) ;

when the mulitidim =1, the following command works.
gfsigma = gfm.components[0]
gfu = gfm.components[1]

but when gfm is an array, how to call the sigma1? Thanks.