Calling components of a solution in CompoundFESpaces

More
4 years 1 month ago - 4 years 1 month ago #3258 by P. Sh
Hi,

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.

Best,
D
Last edit: 4 years 1 month ago by P. Sh.
More
4 years 1 month ago #3259 by joachim
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


Code:
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")
More
4 years 1 month ago - 4 years 1 month ago #3260 by P. Sh
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.

Best,
D
Last edit: 4 years 1 month ago by P. Sh.
Time to create page: 0.096 seconds