- Thank you received: 0
How to calculate the error on the skeleton of mesh
5 years 1 week ago #2131
by Yongbin
How to calculate the error on the skeleton of mesh was created by Yongbin
#mesh
from netgen.geom2d import SplineGeometry
geo = SplineGeometry()
geo.AddRectangle( (0, 0), (1, 1))
mesh = Mesh( geo.GenerateMesh(maxh=1/16))
#
velocity = CoefficientFunction(UN.components[0:2])
err_u = sqrt (Integrate ( (velocity-exact_u)*(velocity-exact_u), mesh))
#
Now,I want to calculate the error on the skeleton of mesh, namely ,the L^2 error of mass flux jump [v_h] \cdot n
#tex
[tex] \sum_{F \in \mathcal{F}_{h}} \frac{1}{h_{F}}\left\| \llbracket {v}_{h} \rrbracket \cdot {n}_{F}\|_{L^{2}(F)}^{2}[/tex]
#\mathcal{F}_{h} stand for all facets of mesh
from netgen.geom2d import SplineGeometry
geo = SplineGeometry()
geo.AddRectangle( (0, 0), (1, 1))
mesh = Mesh( geo.GenerateMesh(maxh=1/16))
#
velocity = CoefficientFunction(UN.components[0:2])
err_u = sqrt (Integrate ( (velocity-exact_u)*(velocity-exact_u), mesh))
#
Now,I want to calculate the error on the skeleton of mesh, namely ,the L^2 error of mass flux jump [v_h] \cdot n
#tex
[tex] \sum_{F \in \mathcal{F}_{h}} \frac{1}{h_{F}}\left\| \llbracket {v}_{h} \rrbracket \cdot {n}_{F}\|_{L^{2}(F)}^{2}[/tex]
#\mathcal{F}_{h} stand for all facets of mesh
5 years 1 week ago #2132
by schruste
Replied by schruste on topic How to calculate the error on the skeleton of mesh
Hi Yongbin,
The simplest way to compute this quantity is by defining a bilinear form a so that a(u,u) coincides with your (sum of) integral(s). Then you Apply the bilinear form to your discrete solution u and take the inner product of the result with u again.
Best,
Christoph
The simplest way to compute this quantity is by defining a bilinear form a so that a(u,u) coincides with your (sum of) integral(s). Then you Apply the bilinear form to your discrete solution u and take the inner product of the result with u again.
Best,
Christoph
The following user(s) said Thank You: Yongbin
5 years 1 week ago #2133
by Yongbin
Replied by Yongbin on topic How to calculate the error on the skeleton of mesh
Hi,Christoph,
Thank you very much for your reply. Sorry,I may not fully understand what you mean. This is my code for Stokes . I don't know how to calculate in my code. In addition,I also wonder, is there other way to calculate?
Thank you again!
Yongbin
Thank you very much for your reply. Sorry,I may not fully understand what you mean. This is my code for Stokes . I don't know how to calculate in my code. In addition,I also wonder, is there other way to calculate?
Thank you again!
Yongbin
5 years 1 week ago #2134
by schruste
Replied by schruste on topic How to calculate the error on the skeleton of mesh
Hi Yongbin,
Here is the code fitting your script. I use hybrid dg jumps here as you use a hybrid DG formulation:
Alternatively, if you are interested in the standard DG jumps the code looks as follows:
Alternatives? I think this is the most straight-forward way to do it. As of now there is no "Integrate" equivalent that would allow you to integrate the skeleton-terms directly. However, I think the above approach is also very natural.
Best,
Christoph
Here is the code fitting your script. I use hybrid dg jumps here as you use a hybrid DG formulation:
Code:
a_jumps = BilinearForm(X)
a_jumps += (ubar-uu)*(vbar-vv) * dx(element_boundary = True)
AUNvec = UN.vec.CreateVector()
a_jumps.Apply(UN.vec,AUNvec)
jump_norm = sqrt(InnerProduct(AUNvec,UN.vec))
print(jump_norm)
Code:
uuOther = CoefficientFunction((ux.Other(), uy.Other()))
vvOther = CoefficientFunction((vx.Other(), vy.Other()))
a_jumps = BilinearForm(X)
a_jumps += (uuOther-uu)*(vvOther-vv) * dx(skeleton = True)
AUNvec = UN.vec.CreateVector()
a_jumps.Apply(UN.vec,AUNvec)
jump_norm = sqrt(InnerProduct(AUNvec,UN.vec))
print(jump_norm)
Best,
Christoph
The following user(s) said Thank You: Yongbin
5 years 1 week ago #2135
by Yongbin
Replied by Yongbin on topic How to calculate the error on the skeleton of mesh
I have successfully solved this problem according to your reply, thank you very much for your reply!
Yongbin Han
Yongbin Han
5 years 1 week ago #2136
by joachim
Replied by joachim on topic How to calculate the error on the skeleton of mesh
Hi Yongbin,
often one needs these terms in residual-type error estimators. Then you need them element by element.
This is now also supported:
full example is attached.
You can integrate elementwise, on every element boundary, and use also values from the neighbouring elements.
This is a quite new feature and needs some more testing. Faces at the domain boundary are skipped, at the moment.
Joachim
often one needs these terms in residual-type error estimators. Then you need them element by element.
This is now also supported:
Code:
h = specialcf.mesh_size
n = specialcf.normal(mesh.dim)
elerr = Integrate ( h*(n*(lam*grad(gfu)-(lam*grad(gfu)).Other()))**2*dx(element_boundary=True), mesh, element_wise=True)
You can integrate elementwise, on every element boundary, and use also values from the neighbouring elements.
This is a quite new feature and needs some more testing. Faces at the domain boundary are skipped, at the moment.
Joachim
Attachments:
The following user(s) said Thank You: Yongbin
Time to create page: 0.132 seconds