Example: Poisson Equation
The essential steps in the numerical solution of the Poisson equation as considered in the previous example using ViennFEM is shown here. Aside from a few technical type definitions, all user code is shown. Moreover, the code is essentially unchanged for 1d, 2d, and 3d. At the end of the page you will know all the high-level code required for solving the Poisson equation on an interconnect and be able reproduce the following result:
The first step is to read the mesh from file to a ViennaGrid domain object:
Here, a sample mesh included in the release package is used.
The next step is to supply Dirichlet boundary conditions to the boundary vertices. It is possible to use separate boundary conditions for many different PDEs on the same mesh. For demonstration purposes the simplest form is considered:
Next, the Poisson equation is set up and the linear system is instantiated. 'MatrixType' and 'VectorType' are generic types, in our case from Boost.uBLAS.
Now everything is ready for the assembly. For that purpose an assembly functor is instantiated and called:
The assembled system is now solved using the conjugate gradient solver provided with ViennaCL and then written to a VTK file for further processing in e.g. ParaView.