- Thank you received: 0
Calling components of a solution in CompoundFESpaces
3 years 10 months ago - 3 years 10 months ago #3258
by P. Sh
Calling components of a solution in CompoundFESpaces was created 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
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: 3 years 10 months ago by P. Sh.
3 years 10 months ago #3259
by joachim
Replied by joachim on topic Calling components of a solution in CompoundFESpaces
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
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")
3 years 10 months ago - 3 years 10 months ago #3260
by P. Sh
Replied by P. Sh on topic Calling components of a solution in CompoundFESpaces
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
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: 3 years 10 months ago by P. Sh.
Time to create page: 0.099 seconds