12.07.2015 Views

DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - 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.

<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, Wellsclass : public Function{real eval(const Point& p, unsigned int i){return p.x*sin(p.y);}} f;The boundary condition is specified similarly, by overloading the eval()function for a subclass of BoundaryCondition:class : public BoundaryCondition{void eval(BoundaryValue& value, const Point& p, unsigned int i){if ( std::abs(p.x - 1.0) < <strong>DOLFIN</strong>_EPS )value = 0.0;}} bc;We only need to specify the boundary condition explicitly on the Dirichletboundary. On the remaining part of the boundary, <strong>DOLFIN</strong> assumeshomogeneous Neumann boundary conditions by default.Note that there is currently no easy way to impose non-homogeneous Neumannboundary conditions or other combinations of boundary conditions.This will most certainly be added to a future release of <strong>DOLFIN</strong>.Next, we need to create a mesh. <strong>DOLFIN</strong> relies on external programs formesh generation, and imports meshes in <strong>DOLFIN</strong> XML format. However,for simple domains like the unit square or unit cube, <strong>DOLFIN</strong> provides abuilt-in mesh generator. To generate a uniform mesh of the unit square withmesh size 1/16 (with a total of 2 · 16 2 = 512 triangles), we can just typeUnitSquare mesh(16, 16);19

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

Saved successfully!

Ooh no, something went wrong!