fo Sparselizard finite element c++ library
  • sparselizard

    FINITE ELEMENT C++ LIBRARY

  • sparselizard

    OPEN SOURCE

  • sparselizard

    USER FRIENDLY

  • sparselizard

    MULTI PHYSICS

  • sparselizard

    NONLINEAR

  • sparselizard

    BUILT-IN GEOMETRY DEFINITION

  • sparselizard

    BUILT-IN MESHER

  • sparselizard

    NONLINEAR HARMONIC ANALYSIS

OVERVIEW

Sparselizard (Copyright (C) 2017-2018 Alexandre Halbach and Christophe Geuzaine, University of Liege, Belgium) is a rather general, multiphysics, open source C++ finite element library meant to be user friendly, fast and parallel. It can handle a rather general set of problems in 1D, 2D and 3D such as mechanical, acoustic, thermal, electric, magnetic, fluid, electromagnetic, piezoelectric,... 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. Some built-in geometry definition and meshing tools are also provided. A working example that solves an electrostatic problem on a grounded 3D disk with electric volume charges can be found below:

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

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 built-in geometry definition and mesher can be used for now for rather simple 2D or extruded 3D geometries. For general geometries and advanced meshing the .msh format of the widely-used open-source GMSH meshing software is supported. 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.

EXAMPLES

ELECTROMAGNETIC WAVEGUIDE


Electromagnetic waveguide

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

MAGNETIC INDUCTION AND SKIN EFFECT


Fluid flow in a microvalve

An AC voltage is applied to a coil surrounding an aluminium tube in which currents are induced. In the current density image displayed the skin effect in the thick copper wire of the coil is also visible.

SEE EXAMPLE

MAGNETIC SHIELDING OF A DC CURRENT


MEMS with fluid coupling

A 3D steel cylinder is placed nearby a wire with a given static current density. The magnetic vector potential formulation is used. A gauge condition is added in combination with a spanning tree to remove the singular matrix problem associated with the formulation.

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

FLUID FLOW IN A MICROVALVE


Fluid flow in a microvalve

The flow speed magnitude (top) and the pressure field (bottom, 100 Pa at left inlet and 0 Pa at right outlet) are computed for a low Reynolds (Stokes) flow in a microvalve.

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

CONDUCTOR HEATING DUE TO DC CURRENT


Conductor heating due to DC current

A voltage is applied across a 3D tungsten conductor in vacuum. The (strong) DC current flow as well as the induced thermal heating (displayed) is simulated. The influence of the temperature on the material properties is taken into account with a nonlinear loop.

SEE EXAMPLE

GEOMETRY DEFINITION AND MESHING


Geometry definition and meshing

The sparselizard geometry builder and mesher are used to create and mesh this simple 3D mechanical structure (top view above). The deformation of the structure subject to a torsion force is then simulated.

SEE EXAMPLE

POTENTIAL AIR FLOW AROUND AN AIRFOIL


Potential air flow around an airfoil

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

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 (TUTORIAL VIDEO)
  • Watch the tutorial video
  • 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.

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