13.07.2015 Views

Part II Implementation - FEniCS Project

Part II Implementation - FEniCS Project

Part II Implementation - FEniCS Project

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Martin Sandve Alnæsg = sin(cell.x[0])v = variable(g)f = exp(v**2)h = diff(f, v)Try running this code in a Python session and print the expressions. The resultis>>> print vvar0(sin((x)[0]))>>> print hd/d[var0(sin((x)[0]))] (exp((var0(sin((x)[0]))) ** 2))Note that the variable has a label 0 (“var0”), and that h still represents the abstractderivative. Section 19.7 explains how derivatives are computed.19.4.5 Other operatorsA few operators are provided for the implementation of discontinuous Galerkinmethods. The basic concept is restricting an expression to the positive or negativeside of an interior facet, which is expressed simply as v(’+’) or v(’-’)respectively. On top of this, the operators avg and jump are implemented, definedasavg(v) = 1 2 (v+ + v − ), (19.41)jump(v) = v + − v − . (19.42)Theseoperatorscan onlybe usedwhenintegratingovertheinteriorfacets(*dS).The only control flow construct included in UFL is conditional expressions. Aconditional expression takes on one of two values depending on the result of aboolean logic expression. The syntax for this isf = conditional(condition, true_value, false_value)which is interpreted asf ={t, if condition is true,f, otherwise.(19.43)The condition can be one of167

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!