Is there a straightforward way of calculating individual jumps?


59
views
0
25 days ago by
Hello all,

I need to calculate the quantity, for element K,
\[
\sum_{e\in \varepsilon_K} h_e ||[\![u]\!]||_e
\]
where \(\varepsilon_K\) is the set of faces (or edges in 2D) of element \(K\), \(h_e\) is the diameter/length of face/edge \(e\), and \(u\) is a function in a (possibly vector) non-conforming finite element space.

The norms are taken over each face individually, as are the jumps, \([\![u]\!]\). I am aware that the jump operator is implemented as jump(u), however I am not sure how to use it in this context, i.e. if \(u \in V_h\), does jump(u) return the jumps across every facet in the mesh of \(V_h\)? How can I access each of these values if I am iterating through \(\varepsilon_K\), for example?

Any help would be greatly appreciated!

Thanks in advance.
Community: FEniCS Project

1 Answer


2
19 days ago by
I think I have solved this problem using the 'assemble' function over a sub-domain, with the help of: https://fenicsproject.org/qa/13073/integrate-along-single-facet/.

Here it is just in case anyone else needs it:
from fenics import *

mesh = UnitSquareMesh(10,10)
V = FunctionSpace(mesh, 'CR', 1)
u = Function(V)

## do something with 'u' here ##
# boring example: u = interpolate(Expression('x[0]*x[1]', degree=1), V)

mf = MeshFunctionSizet(mesh, 1, 0) #create a MeshFunction of dimension 1, where all 
                                   #values default to 0
for K in cells(mesh):
    jumpSum = 0.
    for e in edges(K):
        # mark edge e as domain to integrate over 
        mf.set_value(e.mesh_id(), 1)
        # squared L2 norm of jump along edge, multiplied by its length
        jumpSum += assemble(jump(u)*jump(u)*dS(subdomain_data=mf)) * e.length()
        # un-mark domain, ready for next iteration
        mf.set_value(e.mesh_id(), 0)
    print(str(jumpSum))

This example simply calculates and prints the sum defined in the OP for every cell.
Please login to add an answer/comment or follow this question.

Similar posts:
Search »