12.07.2015 Views

DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, WellsThe right-hand side f of (7.1) is similarly specified by defining a new subclassof Function, which we here will name MyFunction, and overloading theevaluation operator:class MyFunction : public Function{real operator() (const Point& p) const{return p.x*p.z*sin(p.y);}};with the source f(x, y, z) = xz sin(y).7.8 Initial value problemsA time dependent problem has to be discretized in time manually, and theresulting variational form is then discretized in space using FFC similarly toa stationary problem, with the solution at previous time steps provided asdata to the form file.For example, the form file Heat.form for the heat equation discretized intime with the implicit Euler method, takes the form:v = BasisFunction(scalar) # test functionU1 = BasisFunction(scalar) # value at next time stepU0 = Function(scalar) # value at previous time stepf = Function(scalar) # source termk = Constant() # time stepa = v*U1*dx + k*v.dx(i)*U1.dx(i)*dxL = v*U0*dx + v*f*dx50

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

Saved successfully!

Ooh no, something went wrong!