Local
Tutorial
Reference
Download
Global
GiNaC
Swiginac
Python
SWIG
Simula Research Laboratory

SyFi - Symbolic Finite Elements

News

Release 0.2: Added Bernstein polynomials. The Crouzeix-Raviart, Raviart-Thomas, and Taylor-Hood elements are implemented. Python support is added. Element matrices are computed for the Stokes problem and the mixed Poisson problem. Also, the Jacobian of a nonlinear convection diffusion problem is computed based on symbolic differentiation.
Release 0.1: Lagrangian elements and element matrices for Poisson problem are implemented.

Appetizer

The finite element package SyFi is a C++ library built on top of the symbolic math library GiNaC. The name SyFi stands for Symbolic Finite Elements. The package provides polygonal domains, polynomial spaces, and degrees of freedom as symbolic expressions that are easily manipulated. This makes it easy to define finite elements.

The following example shows the computation of the element matrix for the Poisson problem,

void compute_element_matrix(Polygon& T, int order) { 
  std::map<std::pair<int,int>, ex> A;      // matrix of expression
  std::pair<int,int> index;                // index in matrix
  LagrangeFE fe;                           // Lagrangian element of any order 
  fe.set(order);                           // set the order 
  fe.set(domain);                          // set the polygon 
  fe.compute_basis_functions();            // compute the basis functions
  for (int i=1; i<= fe.nbf() ; i++) {
    index.first = i; 
    for (int j=1; j<= fe.nbf() ; j++) {
      index.second = j; 
      ex nabla = inner(grad(fe.N(i)), grad(fe.N(j)));   // compute the integrands 
      ex Aij = T.integrate(nabla);                      // compute the weak form 
      A[index] = Aij;                                   // update element matrix
    }
  }
}

Requirement

SyFi relies on the symbolic math library GiNaC


Kent-Andre Mardal
Last modified: Mon Nov 15 12:14:16 GMT 2005