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

how to define the flux by CG and DG function in UnitInterval

–2 votes

hi
how could one define the flux in DG while the advection speed is defined in CG space for unitInterval case?

asked Sep 23, 2013 by waynezw0618 FEniCS Novice (450 points)

1 Answer

+1 vote

Your question is not specific enough to get answers. You can look at demos to see implementations of the numerical flux (e.g., the DG advection-diffusion demo). If you have a particular flux in mind you need to be specific.

answered Sep 25, 2013 by Garth N. Wells FEniCS Expert (35,930 points)

sorry for I didn't describe the question clearly. I am reading dg-advection-diffusion-demo now, since I want to try a time dependent problem in 1D domain.as I mentioned by Logg, a simple way to write upwind flux is

flux = dot(jump(Ct), jump(up*C))

my question are:
1) I can't understand why it can be write in such manner, since it use the 'exterior' test function. while for me, the flux is integrate over surface, so there is only 'interior' part of test function.

2) how could one define 1D flux? for simpler I have a only constant advect velocity inside 1D domain. then I do things as :

from dolfin import *
u0=Expression('1')
mesh=UnitInterval(3)
V_cg=FunctionSpace(mesh,'CG',1)
V_dg=FunctionSpace(mesh,'DG',1)

U=Function(V_cg)
n=FacetNormal(mesh)
un=U*n
up=(un+abs(un))/2.0

U.interpolate(u0)

c=TrialFunction(V_dg)
v=TestFunction(V_dg)

flux=jump(v)*jump(up*c)*dS

print assemble(flux).array()

but it gives error message as:

Trying to integrate expression of rank 1 with free indices ().
Traceback (most recent call last):
File "/media/ZHANGWEI/Fenics/1D_DG_upwind_flux.py", line 17, in
flux=jump(v)jump(upc)dS
File "/usr/lib/python2.7/dist-packages/ufl/integral.py", line 269, in rmul
% (integrand.rank(), integrand.free_indices()))
File "/usr/lib/python2.7/dist-packages/ufl/log.py", line 154, in error
raise self._exception_type(self._format_raw(
message))
UFLException: Trying to integrate expression of rank 1 with free indices ().

thanks in advance!

...