This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Trace values in one dimension

0 votes

For discontinuous function spaces, we can get trace values on interior faces of a function u by u('+') and u('-').

In one dimension, is it the case that u('+') gives the left limit and u('-') gives the right limit on each face ?

Thanks

asked Jan 28, 2014 by praveen FEniCS User (2,760 points)

Hi, the code below suggests that u("+") is the left value and u("-") is the right one

from dolfin import *                                                             

N = 10                                                                           
mesh = UnitIntervalMesh(N)                                                       
V = FunctionSpace(mesh, "DG", 1)                                                 
u = Function(V)                                                                  
u_v = u.vector()                                                                 

dofmap = V.dofmap()                                                              
for cell in cells(mesh):                                                         
  x = cell.midpoint().x()                                                        
  u_v[dofmap.cell_dofs(cell.index())] = int(x*N)                                 

print u_v.array()                                                                


facet_f = FacetFunction("size_t", mesh, 0)                                       
for facet in facets(mesh):                                                       
  x = facet.midpoint().x()                                                       
  facet_f[facet] = int(x*N)                                                      

print facet_f.array()                                                            

# minus -> left, plus -> right should give value(-) < value(+)                   
dS = Measure("dS")[facet_f]                                                      
for i in range(1, N):                                                            
  print "at facet", i, assemble(u("-")*dS(i)), assemble(u("+")*dS(i))   

In the UFL manual I haven't found how the positive/negative sides are chosen.

Thanks MiroK. I used your basic idea to check the left/right-ness if the traces. It seems that u("+") is the left value and u("-") is the right one. But as Garth Wells writes below, this is not a guaranteed behaviour, so one has to be careful to use this assumption, and better to avoid making such an assumption.

1 Answer

0 votes
 
Best answer

The restriction '+' and '-' do not necessarily correspond the left or right side in 1D. The only guarantee is that they are from opposite sides of a facet.

answered Jan 28, 2014 by Garth N. Wells FEniCS Expert (35,930 points)
selected Jan 29, 2014 by praveen
...