Keywords

1 Introduction

Matrix methods are widely known and used today for static calculation of structures typically used in construction [1, 2] and, through the finite element method, of arbitrary pieces in two or three dimensions [7]. With this work we intend to fill a niche in the open-source software of the field of computational mechanics in relation to said matrix methods, providing a C++ library and a set of associated tools to ease computational structural analysis. The software is design emphasizing a didactic aiming by means of, among other features, parameterization of structures, the presentation of force diagrams, and the creation of animations of the deformed structures.

The availability of versatile, open-source and universally free matrix calculation tools for structures would have multiple applications. Firstly, as a reusable block (programming language library) in the creation of static analysis tools for engineering projects. In the educational field, it would allow the automation of tasks such as the creation of graphics and animations of different structures, including the parametric generation of structures and the automatic calculation of static solutions (reactions, deformations, and stresses), thus facilitating the creation of teaching material, including randomized exercises and exams. Carrying all this out online, from a web browser, minimizes the access threshold to the tool.

At present there are numerous software for structural calculation using the matrix method and/or by the finite element method, but most are proprietary software. This work presents an open-source software that, in addition, in its offline form is compatible with all major operating systems (Windows, Mac, and GNU/Linux), and in its online form works from any computer or modern mobile device. Another of its noteworthy feature is its ability to define nodal coordinates not concordant with the global coordinate axis [10], allowing the definition of sliders with arbitrary orientations.

The presented software is written in C++ 17 [11] and makes use of the well-known Eigen3 library [3] for calculations with dense and sparse matrices. Documentation and online tools are available on the project website [4] and the Git repositoryFootnote 1.

The rest of this article is organized as follows. Section 2 exposes the materials and methods, Sect. 3 presents the results of the work, and finally the conclusions are summarized in Sect. 4.

2 Methods

2.1 Direct Stiffness Matrix Method

This matrix method is not limited by the type of structure as other classical calculation methods are, by means of organizing all the information about the structure in the form of matrices. In addition, a greater number of unknowns can be solved compared to classic resolution methods in Strength of Materials [5] and with the benefit of being able to automate it. To be able to apply it to a continuous structure, it is necessary to model it through a discrete and finite set of variables. There is some freedom on the part of the engineer when choosing: (i) the way in which continuous bodies are divided into a discrete series of elements, and (ii) how many degrees of freedom (dof) each of these elements will have at the joints (or nodes). It should be noted that the use of the stiffness method is motivated by the greater ease of automation, allowing to define a library of predefined elements with stiffness matrices with known expressions from an earlier theoretical analysis [1, 7, 10].

2.2 Distributed Loads

The study of discretized problems implies that: (i) results are obtained only for the state vector dof, and (ii) only point loads can be defined. Therefore, any distributed loads must be converted into equivalent concentrated loads, for which the well-known methods in matrix calculus [10] are used using the Strength of Materials equations [5, 8, 9]. Regarding the axial, shear, bending and torsion moments, in our work we have opted to mesh the structures in sufficiently small elements, so that, by calculating the stresses at the ends of each element in a rigorous manner, linear piecewise stress diagrams are obtained. The following distributed loads have been implemented: uniform, trapezoidal, temperature variation, and non-nodal point.

2.3 Meshing

Meshing is the step in which a continuous solid is divided into a multitude of finite elements [7]. In our work, only basic meshing of linear elements (rods or beams) into smaller, also linear elements has been necessary, so the connectivity between elements after meshing is trivial as it is purely linear. There are two noteworthy aspects: (i) An element of a particular type (see Fig. 1), when meshed, can be converted into several elements of different types according to the degrees of freedom defined at its ends (e.g. when meshing a bi-articulated bar, an articulated-rigid element, several rigid-rigid elements, and finally a rigid-articulated element will be obtained), and (ii) distributed loads along a beam or bar must also be “meshed” to be distributed among the finite elements, which are the ones that are finally calculated.

2.4 Eigen3 Library

Eigen (version 3) is one of the most widely used C++ libraries in multiple engineering fields to represent and manipulate matrices, vectors, and tensors [3]. It allows two representation modes for matrices: dense and sparse. The formers are used in our work to represent the stiffness submatrices of finite elements, as well as generalized coordinate vectors. Sparse matrices are suited for stiffness matrices of very large structures, especially after meshing, since each element is typically only connected to a few neighboring elements. Once sparse matrices are represented, the resolution of canonical linear systems Ax = b, as required in our work, demands specifically algorithms to exploit the matrix sparsity and solve them in typically almost linear time O(N) instead of cubic O(N3), with N the number of degrees of freedom. Two algorithms have been implemented in the library to solve this linear system: (i) the Cholesky decomposition (LLT) algorithm for the \({K}_{ff}\), converted to a dense matrix, and (ii) Cholesky for the pure sparse matrix case [3]. By default, the dense matrix version is used, since most of the structures analyzed will be of a size small enough for the sparse method to not be computationally advantageous.

2.5 MRPT-opengl Library

MRPT (“Mobile Robot Programming Toolkit”) is an open-software project that offers C++ libraries with algorithms and tools for mobile robot programming [12]. Its mrpt-opengl module offers a library for the generation of 3D graphics in a modular way through assembly and composition of basic visual primitives (lines, points, cylinders, etc.), chosen to generate and dynamically update the visualizations of structures.

Fig. 1.
figure 1

A few of the available types of finite elements implemented in libopenbeam, together with their short names as specified in the structure definition files.

2.6 Emscripten

Emscripten [13] is a project, presented in 2011 and in active development, which provides a modified version of the clang compiler capable of cross-compiling from various languages (including C++) to JavaScript and WebAsm. By compiling MRPT, Eigen3, and OpenBeam all with Emscripten, web applications in Javascript have been developed that make use of all the high-level functions exposed in OpenBeam, such as analyzing a structure definition file, performing static analysis, or generating and updating its graphical representation in an html5 WebGL canvas [14].

3 Results

3.1 The Openbeam C++ Library

The main functionality developed in this work is integrated into a C++ library, which is used by the applications themselves, and which can be used by users interested in creating their own projects.

3.2 Implemented Finite Elements

At present, implemented elements are eminently planar: rods, beams, and springs. Figure 1 illustrates a few of the implemented elements. As can be seen, they are all binary (connecting only two nodes) and each one makes use of a variable number of degrees of freedom at each of its two ends.

3.3 YAML Structure Definition Language

An example in Fig. 2 illustrates how users can describe the structure to analyze by means of our custom structure definition language in YAML [6], with all syntax details available online. Note that, whenever a numerical value is needed, mathematical expressions (algebraic operations, trigonometric functions, etc.) can be used at any point, as well as more complex constructions such as “if… Then… Else” if the user requires it (e.g. to define that a load only exists if a length meets certain criteria), allowing easy parameterization of structures.

Fig. 2.
figure 2

(a) Example of the YAML structure definition language used in OpenBeam. Visual representation of the structure in (b) its original state, and (c) deformed under loads.

3.4 Applications

A command-line off-line program called “ob-solve” has been developed, with more than thirty arguments and flags to: load a structure from a YAML file, show the results of the static analysis to the console or to an HTML file, show the stiffness matrices, generate visualizations of the structure in its original or deformed states, etc. Examples of the results of this program are provided in an online repositoryFootnote 2. The on-line version of this program is more interactive and is designed to be used by students and professors in the most intuitive way.

4 Conclusions

Several objectives have been achieved with this work: a new open-source library with a high-level API to define mechanical structures and solve static analysis of them. Two ready-to-use tools are also presented: (i) the command line program with potential for both students and professors, and (ii) the web page with the online tool, which makes it, to the best of the authors’ knowledge, the first application capable of running on the web and mobile devices that allows arbitrarily complex structures to be defined and calculated, completely free of charge and with open-source code.