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, WellsNext, we initialize the pair of bilinear and linear forms that we have previouslycompiled with FFC:Poisson::BilinearForm a;Poisson::LinearForm L(f);We may now define a PDE from the pair of forms, the mesh and the boundaryconditions:PDE pde(a, L, mesh, bc);To solve the PDE, we now just need to call the solve function as follows:Function U = pde.solve();Finally, we export the solution u to a file for visualization. Here, we chooseto save the solution in VTK format for visualization in ParaView or MayaVi,which we do by specifying a file name with extension .pvd:File file(‘‘poisson.pvd’’);file

DOLFIN User ManualHoffman, Jansson, Logg, Wellsclass : public Function{real eval(const Point& p, unsigned int i){return p.x*sin(p.y);}} f;// Boundary conditionclass : public BoundaryCondition{void eval(BoundaryValue& value, const Point& p, unsigned int i){if ( std::abs(p.x - 1.0) < DOLFIN_EPS )value = 0.0;}} bc;// Set up problemUnitSquare mesh(16, 16);Poisson::BilinearForm a;Poisson::LinearForm L(f);PDE pde(a, L, mesh, bc);// Compute solutionFunction U = pde.solve();// Save solution to fileFile file("poisson.pvd");file

<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, WellsNext, we initialize the pair of bilinear and linear forms that we have previouslycompiled with FFC:Poisson::BilinearForm a;Poisson::LinearForm L(f);We may now define a PDE from the pair of forms, the mesh and the boundaryconditions:PDE pde(a, L, mesh, bc);To solve the PDE, we now just need to call the solve function as follows:Function U = pde.solve();Finally, we export the solution u to a file for visualization. Here, we chooseto save the solution in VTK format for visualization in ParaView or MayaVi,which we do by specifying a file name with extension .pvd:File file(‘‘poisson.pvd’’);file

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

Saved successfully!

Ooh no, something went wrong!