DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project DOLFIN User Manual - FEniCS Project

fenicsproject.org
from fenicsproject.org More from this publisher
12.07.2015 Views

DOLFIN User ManualHoffman, 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

DOLFIN User ManualHoffman, Jansson, Logg, Wellswhich generates a file Heat.h when compiled with FFC. To initializationsthe corresponding forms we write:real k;Vector x0;Function U0(x0, mesh);// time step// vector containing dofs for u0// solution at previous time stepHeat::BilinearForm a(k);Heat::LinearForm L(U0, f, k);51

<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!