← Back to team overview

ufl team mailing list archive

Re: Upwinding function

 



Martin Sandve Alnæs wrote:
On Fri, Apr 24, 2009 at 1:00 PM, Garth N. Wells <gnw20@xxxxxxxxx> wrote:
To get upwinding in a DG formulation of the advection-diffusion eqn with
the FFC .form language, we used

vector = VectorElement("Lagrange", "triangle", 2)
scalar = FiniteElement("Discontinuous Lagrange", "triangle", 1)
constant = FiniteElement("Discontinuous Lagrange", "triangle", 0)

u  = TrialFunction(scalar)
b  = Function(vector)
of = Function(constant)

def upwind(u, b):
  return [b[i]('+')*(of('+')*u('+') + of('-')*u('-')) for i in range(2)]

to return the product b*u, with u taken from the 'upwind' side. How
should the function 'upwind' look using UFL?

Lets see...

def upwind(u, b):
    s = of('+')*u('+') + of('-')*u('-')
    return [b[i]('+')*s for i in range(2)]

This returns a list, so it's a vector-valued expression?
s is a scalar expression, and b is a vector-valued expression,
so I would simply do

def upwind(u, b):
    s = of('+')*u('+') + of('-')*u('-')
    return b('+')*s

Does that look right?


Yes. Even simpler: return b('+')*(of('+')*u('+') + of('-')*u('-')).

I keep forgetting that simple things are simple with UFL ;).

Garth


Martin




Follow ups

References