- Thank you received: 0

2 years 1 month ago #3555
by pde
*DG jumps over boundary faces in periodic square* was created by *pde*

This is a question concerning the implementation of jump terms in DG methods for periodic problems (2D unit square with periodic boundary conditions). I am new to ngsolve and would appreciate any help. I am working in the space L2(mesh, order=choose_poly_degree, dgjumps=True), where I use the discretization

periodic = SplineGeometry()

pnums = [periodic.AppendPoint(*p) for p in [ (0,0), (1,0), (1,1), (0,1) ]]

lright = periodic.Append ( ["line", pnums[0], pnums[1]],bc="periodic")

btop = periodic.Append ( ["line", pnums[1], pnums[2]], bc="periodic")

periodic.Append ( ["line", pnums[3], pnums[2]], leftdomain=0, rightdomain=1, copy=lright, bc="periodic")

periodic.Append ( ["line", pnums[0], pnums[3]], leftdomain=0, rightdomain=1, copy=btop, bc="periodic")

mesh = Mesh(periodic.GenerateMesh(maxh=choose_discretization_size))

Say we would like to have a bilinear form a(u,v) containing the integral of jump(u)*jump(v) over all faces, where the jump for boundary faces is defined in a periodic way.

While jumps over interior faces can be implemented using jump(u)=u-u.Other(), it is not clear to me how to do this for boundary faces. Ideally, this would be something like u-u.Otherbdry() with .Otherbdry() now accessing the periodic neighbour of a boundary element, i.e., the element on the opposite side of the square sharing the same boundary face upon periodic identification. Many thanks in advance for suggestions.

periodic = SplineGeometry()

pnums = [periodic.AppendPoint(*p) for p in [ (0,0), (1,0), (1,1), (0,1) ]]

lright = periodic.Append ( ["line", pnums[0], pnums[1]],bc="periodic")

btop = periodic.Append ( ["line", pnums[1], pnums[2]], bc="periodic")

periodic.Append ( ["line", pnums[3], pnums[2]], leftdomain=0, rightdomain=1, copy=lright, bc="periodic")

periodic.Append ( ["line", pnums[0], pnums[3]], leftdomain=0, rightdomain=1, copy=btop, bc="periodic")

mesh = Mesh(periodic.GenerateMesh(maxh=choose_discretization_size))

Say we would like to have a bilinear form a(u,v) containing the integral of jump(u)*jump(v) over all faces, where the jump for boundary faces is defined in a periodic way.

While jumps over interior faces can be implemented using jump(u)=u-u.Other(), it is not clear to me how to do this for boundary faces. Ideally, this would be something like u-u.Otherbdry() with .Otherbdry() now accessing the periodic neighbour of a boundary element, i.e., the element on the opposite side of the square sharing the same boundary face upon periodic identification. Many thanks in advance for suggestions.

Please Log in or Create an account to join the conversation.

2 years 3 weeks ago #3556
by cwinters

Replied by *cwinters* on topic *DG jumps over boundary faces in periodic square*

Hi,

did you test if "jump(u)=u-u.Other()" does what you expect?

The periodicity is built into the "Apply(...)" and "Assemble()" member function of the BilinearForm. The boundary facets are handled like interior facets, using the periodic neighbouring elements. Thus you should be fine using "u.Other()" in any case.

See also "py_tutorials/DG/periodic.py" in the sources of NGSolve.

Best,

Christoph

did you test if "jump(u)=u-u.Other()" does what you expect?

The periodicity is built into the "Apply(...)" and "Assemble()" member function of the BilinearForm. The boundary facets are handled like interior facets, using the periodic neighbouring elements. Thus you should be fine using "u.Other()" in any case.

See also "py_tutorials/DG/periodic.py" in the sources of NGSolve.

Best,

Christoph

The following user(s) said Thank You: pde

Please Log in or Create an account to join the conversation.

2 years 3 weeks ago #3558
by pde
##### Attachments:

Replied by *pde* on topic *DG jumps over boundary faces in periodic square*

Many thanks Christoph!

The reason I was asking is that I am observing some strange behaviour for the error under uniform mesh refinement in a DG scheme for a linear toy problem $u-\Delta u = f$ with periodic boundary conditions on the unit cell (L2 error is increasing from e.g. 1/h=128 to 256), and wanted to make sure that the bilinear form is actually doing what I had in mind (i.e., that it also contains an integral over boundary faces involving the periodic jump). I have attached a code in case this is helpful.

The reason I was asking is that I am observing some strange behaviour for the error under uniform mesh refinement in a DG scheme for a linear toy problem $u-\Delta u = f$ with periodic boundary conditions on the unit cell (L2 error is increasing from e.g. 1/h=128 to 256), and wanted to make sure that the bilinear form is actually doing what I had in mind (i.e., that it also contains an integral over boundary faces involving the periodic jump). I have attached a code in case this is helpful.

Please Log in or Create an account to join the conversation.

2 years 3 weeks ago #3562
by cwinters

Replied by *cwinters* on topic *DG jumps over boundary faces in periodic square*

Hi,

since the convergence is fine before you reach h=1/256, I'm pretty sure that the periodicity is handled correctly. The number of "inner facets" during the assembly also corresponds to the total number of facets (mesh.nedges), including the ones on the boundary.

There must be another reason limiting the $L_2$ error. The result of "Integrate((uh-U)*(uh-U),mesh)" is around 1e-12~1e-13 before you apply the sqrt. Could it be that you already see some approximation effects?

Best,

Christoph

since the convergence is fine before you reach h=1/256, I'm pretty sure that the periodicity is handled correctly. The number of "inner facets" during the assembly also corresponds to the total number of facets (mesh.nedges), including the ones on the boundary.

There must be another reason limiting the $L_2$ error. The result of "Integrate((uh-U)*(uh-U),mesh)" is around 1e-12~1e-13 before you apply the sqrt. Could it be that you already see some approximation effects?

Best,

Christoph

Please Log in or Create an account to join the conversation.

Time to create page: 0.147 seconds