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, Wells7.7 Specifying boundary conditions and dataThe boundary conditions are specified by defining a new subclass of the classBoundaryCondition, which we here will name MyBC:class MyBC : public BoundaryCondition{const BoundaryValue operator() (const Point& p){BoundaryValue value;if ( std::abs(p.x - 0.0) < <strong>DOLFIN</strong>_EPS ) value = 0.0;if ( std::abs(p.x - 1.0) < <strong>DOLFIN</strong>_EPS ) value = 0.0;if ( std::abs(p.y - 0.0) < <strong>DOLFIN</strong>_EPS ) value = 0.0;if ( std::abs(p.y - 1.0) < <strong>DOLFIN</strong>_EPS ) value = 0.0;if ( std::abs(p.z - 0.0) < <strong>DOLFIN</strong>_EPS ) value = 0.0;if ( std::abs(p.z - 1.0) < <strong>DOLFIN</strong>_EPS ) value = 0.0;return value;}};where we have assumed homogeneous Dirichlet boundary conditions for theunit cube. We only need to specify the boundary conditions explicitly onthe Dirichlet boundary. On the remaining part of the boundary, homogeneousNeumann boundary conditions are automatically imposed weakly bythe variational form.The boundary conditions are then imposed as an argument to the assemble()function:MyBC bc;FEM::assemble(a,L,A,b,mesh,bc);There is currently no easy way to impose non-homogeneous Neumann boundaryconditions or other combinations of boundary conditions. This will beadded to a future release of <strong>DOLFIN</strong>.49

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

Saved successfully!

Ooh no, something went wrong!