- Thank you received: 0
Question regarding 1d HDG
6 years 7 months ago #431
by janfp
Question regarding 1d HDG was created by janfp
Dear all,
usingmake_seg_mesh from ngsolve-src/py_tutorials/TensorProduct/make_seg_mesh.py, I tried the following example:
To my understanding, I am creating an L^2-Space of order one with 10 elements, so each element has two degrees of freedom (1d), one on the left, one on the right. Thus u.vec.size is 20.
However, I would expect that every second entry in this vector corresponds to the same (physical) vertex point and thus, calling u.Set(x), i would expect a result like, e.g.
0
0.05
0.05
0.15
0.15
...
however, instead I get
0.05
0.15
0.25
0.35
0.45
0.55
0.65
0.75
0.85
0.95
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05
I this a misunderstanding or is there something wrong with .Set(x) in 1d?
thanks,
Jan
usingmake_seg_mesh from ngsolve-src/py_tutorials/TensorProduct/make_seg_mesh.py, I tried the following example:
Code:
from make_seg_mesh import *
import numpy as np
import matplotlib as mpl
from ngsolve import *
ngsglobals.msg_level = 0
m2 = SegMesh(10,0,1,0)
m2.dim = 1
mesh = Mesh(m2)
Y = L2(mesh, order=1) # space can be fixed for the whole routine
#Z = FacetFESpace(mesh, order=0,dirichlet = [1,2])
#X = FESpace([Y,Z])
u = GridFunction(Y)
print("Size of u.vec = " + str(u.vec.size)) # returns 20, each element has two degrees of freedom
u.Set(x)
print(u.vec) # Strange result
To my understanding, I am creating an L^2-Space of order one with 10 elements, so each element has two degrees of freedom (1d), one on the left, one on the right. Thus u.vec.size is 20.
However, I would expect that every second entry in this vector corresponds to the same (physical) vertex point and thus, calling u.Set(x), i would expect a result like, e.g.
0
0.05
0.05
0.15
0.15
...
however, instead I get
0.05
0.15
0.25
0.35
0.45
0.55
0.65
0.75
0.85
0.95
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05
I this a misunderstanding or is there something wrong with .Set(x) in 1d?
thanks,
Jan
Attachments:
6 years 7 months ago #432
by schruste
Replied by schruste on topic Question regarding 1d HDG
hi jan,
it seems that you are just expecting a different basis (and numbering). The L2 space has an L2 orthogonal basis (not the hat function basis!). Moreover, lowest order dofs are numbered first (unless you use a flag not to do that). the lowest order dofs are the mean values, which fits your values. The second dof per element corresponds to the second legrende polynomial. This is the same coefficient for all elements if you set a linear function.
Btw.: you can also visualize the basis functions by setting a gridfunctions vector to the unit vector.
Best,
Christoph
it seems that you are just expecting a different basis (and numbering). The L2 space has an L2 orthogonal basis (not the hat function basis!). Moreover, lowest order dofs are numbered first (unless you use a flag not to do that). the lowest order dofs are the mean values, which fits your values. The second dof per element corresponds to the second legrende polynomial. This is the same coefficient for all elements if you set a linear function.
Btw.: you can also visualize the basis functions by setting a gridfunctions vector to the unit vector.
Best,
Christoph
Time to create page: 0.097 seconds