13.07.2015 Views

UFL Specification and User Manual 0.3 - FEniCS Project

UFL Specification and User Manual 0.3 - FEniCS Project

UFL Specification and User Manual 0.3 - FEniCS Project

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

<strong>UFL</strong> <strong>Specification</strong> <strong>and</strong> <strong>User</strong> <strong>Manual</strong> <strong>0.3</strong>Martin S. Alnæs, Anders Logga = v[i]*w[j]*u[i].dx(j)*dxThis example is implemented in the file navier stokes.ufl in the collectionof demonstration forms included with the <strong>UFL</strong> source distribution.3.6 The heat equationDiscretizing the heat equation,˙u−∇·(c∇u) = f, (3.9)in time using the dG(0) method (backward Euler), we obtain the followingvariationalproblemforthediscretesolutionu h = u h (x,t): Findu n h = u h(·,t n )with u n−1h= u h (·,t n−1 ) given such that∫ ∫1v(u n h −u n−1h)dx+ c∇v ·∇u n hdx = vf n dx (3.10)k n∫ΩΩfor all test functions v, where k = t n − t n−1 denotes the time step . In theexample below, we implement this variational problem with piecewise lineartest <strong>and</strong> trial functions, but other choices are possible (just choose anotherfinite element).Rewriting the variational problem in the st<strong>and</strong>ard form a(v,u h ) = L(v) forall v, we obtain the following pair of bilinear <strong>and</strong> linear forms:∫ ∫a(v,u n h;c,k) = vu n hdx+k n c∇v ·∇u n hdx, (3.11)∫ΩΩ∫L(v;u n−1h,f,k) = vu n−1hdx+k n vf n dx, (3.12)which can be implemented as follows:ΩΩΩelement = FiniteElement("Lagrange", triangle, 1)66

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

Saved successfully!

Ooh no, something went wrong!