Hermes2D  3.0
Hermes2D Documentation

This manual documents the source code of hermes2d. It is intended for the developers of the library. If you are only interested in using hermes2d, please refer to the User's Manual.

This page provides an overview of the structure of the project, in a bottom-up fashion. You can also visit the Class List and the Class Hierarchy pages.

One is also advised to refer to


Mesh Classes

A finite element mesh consists of elements and nodes, defined by the structures Element and Node. Elements can be triangles or quadrilaterals (quads). Each element contains pointers to three or four vertex nodes and to three or four edge nodes. Vertex nodes store the physical coordinates of mesh vertices and edge nodes provide element connectivity across mesh edges. Our meshes can be irregular, i.e., we allow hanging vertex nodes (sometimes called T-junctions). Elements can be active or inactive. Inactive elements are those which have been refined and are no longer part of the actual mesh. Their purpose is to provide pointers to the refined (son) elements.

There are two main classes that define the finite element mesh as a whole, HashTable and Mesh. The first serves as a container for nodes, plus provides node search functions via hashing, the latter contains an Array of elements and various methods.

Except for top-level vertex nodes, all nodes can be reached by providing the id numbers of their "parents". For example, an edge node exists halfway between two vertex nodes, and is created by calling HashTable::get_edge_node() and passing the id's of the two vertex nodes. If the edge node does not exist, it is created first. This greatly simplifies mesh initialization and hanging nodes in general, since one does not have to care whether the edge node already exists and from which element to reach it. The class HashTable achieves this by hashing the id numbers of the parents. The variable "ref" is maintained in each node, specifying the number of elements using the node. This determines when a node should be deleted (ref = 0), but can also be used to tell the type of the node. Standard edge nodes have ref = 2, hanging or boundary edge nodes have ref = 1. Similarly for vertex nodes, where ref can be 2 or 3 (hanging), 4 or 6 (regular) or a large number (top-level vertex node). A detailed description of these mechanisms can be found in Chapter 5 of the thesis of Jakub Cerveny.

The code supports elements with curved edges defined by NURBS curves. If an element is curvilinear, its member "cm" points to the structure CurvMap, which in turn defines the curvature of the edges using the structures Nurbs. Since NURBS curves are non-polynomial, the curvilinear reference mapping has to be projected to a polynomial one (see curved.h). Once this is done, the curvilinear mapping is defined by adding edge and bubble shape functions to the standard affine reference mapping.

Throughout the code, the macros for_all_active_elements(), for_all_vertex_nodes(), etc. (see mesh.h), are used to iterate through elements and nodes of the mesh.

Relevant files are located in the mesh directory (see directory list)

Shapeset Classes

In higher-order FEM, shapeset is a collection of the so-called shape functions, which are polynomials that can be used to construct higher-order basis functions. There are three types of shape functions: vertex, edge and bubble functions. Vertex functions are standard linear functions for the construction of the well-known pyramid basis functions. By gluing together two edge shape functions, one obtains edge basis functions, which generate higher-order solutions along edges. Finally, bubble functions complete the higher-order approximation on individual elements. For more information, refer to Chapter 3 of Jakub's thesis. Hermes2D uses hierarchic functions exclusively.

Shapeset is a base class for all shapesets, both Scalar (H1) and vector-valued (H(curl)). It defines the interface (basically it is just a bunch of tables) and the functionality for constrained shape functions.

The actual shapesets are H1ShapesetOrtho, H1ShapesetJacobi, HcurlShapesetLegendre and HcurlShapesetGradLeg. The other ("eigen") shapesets are experimental and not recommended for normal use.

Relevant files are located in the shapeset directory (see directory list)

Space Classes

The Space class corresponds to the mathematical notion of a finite element space over a 2D domain. Given a mesh and a shapeset, the Space class constructs a specific higher-order FE space. Currently, four space types are defined: H1Space, HcurlSpace, HdivSpace and L2Space. These represent their respective mathematical counterparts.

The main purpose of these classes is (1) to hold polynomial degrees of mesh elements, (2) to construct and enumerate the basis functions of the space and (3) to return assembly lists (see AsmList<Scalar>), which are used in the stiffness matrix assembly.

Multiple spaces can share the same mesh. This is used when solving systems of PDEs. In multi-mesh computations, each space usually has its own mesh, but all meshes must descend from a single master mesh.

All of the three spaces are able to construct higher-order basis functions on irregular meshes. For details, see the documentation for the Space class.

Relevant files are located in the space directory (see directory list)

Quadrature Classes

Classes holding quadrature formulas.

Relevant files are located in the quadrature directory (see directory list)

Functions in Hermes

Types of functions representations in Hermes.

MeshFunction class and its descendants

Relevant files are located in the function directory, except for hermes_function.h (see directory list)



Relevant file is hermes_function.h in function directory (see directory list)

RefMap Class

Describes reference mapping of an actual physical Element onto the reference one.

Relevant file is refmap.h in mesh directory (see directory list)

Multi-mesh Assembling

Class facilitates monolithic multi-mesh traversing.


Relevant file is traverse.h in mesh directory (see directory list)

Visualization Classes

View classes

Relevant files are located in the views directory (see directory list)

Linearizer classes

Relevant files are located in the views directory (see directory list)