• sparselizard

    FINITE ELEMENT C++ LIBRARY

  • sparselizard

    OPEN SOURCE

  • sparselizard

    USER FRIENDLY

  • sparselizard

    MULTI PHYSICS

  • sparselizard

    NON LINEAR

  • sparselizard

    MULTI HARMONICS

OVERVIEW

Sparselizard (Copyright (C) 2017-2018 Alexandre Halbach and Christophe Geuzaine, University of Liege, Belgium) is an open source C++ finite element library meant to be user friendly, fast and parallel. Example code to solve an electrostatic problem on a grounded 3D disk with electric volume charges:

int vol = 1, sur = 2;             // Disk volume and boundary as set in ’disk.geo’
mesh mymesh("disk.msh");

field v("h1");                    // Nodal shape functions for the electric potential
v.setorder(vol, 4);               // Interpolation order 4 on the whole domain
v.setconstraint(sur, 0);          // Force 0 V on the disk boundary

formulation elec;                 // Electrostatics with 1 nC/m^3 charge density
elec += integral(vol, -8.85e-12 * grad(dof(v)) * grad(tf(v)) + 1e-9 * tf(v));
elec.generate();
vec solv = solve(elec.A(), elec.b());

v.setdata(vol, solv);             // Transfer data from solution vector to v field
(-grad(v)).write(vol, "E.pos");   // Write the electric field

Sparselizard can handle a rather general set of problems in 1D, 2D and 3D such as mechanical, acoustic, thermal, electric, fluid and electromagnetic problems (provided in form of a weak formulation as detailed in this wikipedia page ). Problems with several hundreds of thousands of unknowns in 3D and several millions of unknowns in 2D can be treated on classical laptops. To give an idea of the performance you can expect here are a couple of timings.
On a standard 2013 laptop (dual core, 16 GB of RAM):
  • 2D electrostatics: 13.509.602 triangles | 6.760.000 unknowns | 130 seconds
  • 3D electrostatics: 3.556.224 tetrahedra | 614.125 unknowns | 220 seconds
  • 2D linear elasticity: 2.042.041 quadrangles | 2.044.900 unknowns | 105 seconds
  • 3D linear elasticity: 117.649 hexahedra | 125.000 unknowns | 240 seconds
Multiphysics problems, nonlinear problems or nonlinear multiphysics problems can be simulated as well. The problems can be readily solved in time with a time-stepping resolution or with the natively supported multiharmonic resolution method. In the latter case the steady-state solution of a time-periodic problem can be obtained in a single step, for linear as well as for general nonlinear problems.
The library comes with hierarchical high order shape functions so that high order interpolations can be used with an interpolation order adapted to every unknown field and geometrical region.

The widely-used open-source GMSH meshing software is required to mesh the geometry and generate the .msh file required in the finite element simulation. Points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms or any combination thereof is accepted in the mesh. The result files output by sparselizard are in .pos format supported by GMSH.

DOWNLOAD

For now sparselizard has been successfully tested on Linux and Mac. If you use Windows install a virtual Ubuntu Linux using VirtualBox. This is a quick and easy step. Follow online tutorials for help. After that simply follow the instructions for Linux.

The easiest way to get the sparselizard c++ finite element library running is to use its static library, even though better performances will be obtained when compiled on your computer.

Static library for Linux 64 bits
  • Download the static library here (or here if no AVX support) and open the folder in a terminal.
  • Run 'g++ -O3 -std=c++11 main.cpp -L ./ -l sparselizard -pthread -l dl -I headers -o slexe;'
  • Run './slexe'
  • Visualise the output .pos files with GMSH as detailed in the third section of the documentation.

Alternatively, if you wish to compile yourself the latest version of the sparselizard library, download the source code here. In case you do so the step by step installation detailed in the documentation might be for you.

Take a look at the examples in the 'examples' folder and at the documentation for a smooth introduction.

EXAMPLES

ELECTROMAGNETIC WAVEGUIDE


Electromagnetic waveguide 3D

A cross shaped perfectly conducting 3D waveguide is excited with an imposed electric field at one end. Follow this link for a transient time resolution video.

SEE EXAMPLE

MECHANICAL DISK VIBRATION MODES


Mechanical disk eigenmodes

The eigenmodes and eigenfrequencies are obtained for a 3D disk clamped at its boundary.

SEE EXAMPLE

MEMS WITH FLUID COUPLING


MEMS with fluid coupling

A micromembrane is electrically actuated and outputs pressure waves in a water medium. The electromechanical coupling is nonlinear. The steady state is obtained with the multiharmonic method. Follow this link for a time visualisation video.

SEE EXAMPLE

TOPOLOGY OPTIMIZATION


Topology optimisation

This mechanical steel structure is automatically optimized to withstand a given force with the minimum possible steel volume. This was obtained with a third-party c++ topology optimization code developed using the sparselizard library for all finite element calculations.

PIEZOELECTRIC MICRO-BILAYER


Piezoelectric micro-bilayer

A micro-sized bilayer is made up of a piezoelectric PZT layer and a polysilicon layer. The piezo is sandwiched between two electrically actuated electrodes. The harmonic actuation creates a harmonic deflection of the bilayer. Follow this link for a time visualisation video.

SEE EXAMPLE

NONLINEAR AIR FLOW AROUND AN AIRFOIL


MEMS with fluid coupling

A NACA0012 airfoil is put in a subsonic air flow. The problem is nonlinear because the air density is a function of the air speed. The picture shows the Mach number everywhere around the airfoil.

SEE EXAMPLE

CITE US

If you like this library do not hesitate to cite the following reference:
"Sparselizard - the user friendly finite element c++ library"
Alexandre Halbach, University of Liege, Belgium

CONTACT

It would be a pleasure to answer any of your questions or to get your bug reports.
In the latter case please provide a minimal code including the bug.

ALEXANDRE HALBACH


PhD - Electrical Engineering

alexandre.halbach at gmail.com