BasicTools: a numerical simulation toolbox

Numerical simulations of physical phenomena can be computed by many (commercial/free) software packages, but despite the apparent variety, all of them rely on a relatively small set of operations during the preparation, exploitation


Statement of need
Industrial design tasks often rely on numerical simulation workflows involving different software packages, each providing its own specific post-processing tools. Common tasks like transferring computed fields from one tool to another must be routinely implemented, with subtle variations. This limits interoperability and increases complexity.
BasicTools is a solution to these concerns. It introduces a data model for meshes and related physical fields that can be populated using different readers and exported using various writers: no new mesh or solution format is forced upon the user. The data-oriented design of BasicTools allows high performance operations using a high-level language (Python with NumPy). BasicTools allows users to convert meshes to other "in-memory" formats (VTK (Schroeder et al., 2006), PyVista (Sullivan & Kaszynski, 2019), MeshIO (Schlömer, 2015present), CGNS (CGNS contributors, 1994-present), and Gmsh (Geuzaine & Remacle, 2009)), enabling mixing (and reusing) the various treatments available in other frameworks. Other features available in BasicTools include various mesh handling routines, field transfer operators, and a flexible finite element engine.

State of the field
In the computational fluid dynamics community, the CFD General Notation System (CGNS) (CGNS contributors, 1994-present) format is a de-facto standard. However, to the authors' knowledge, no such standard exists for solid mechanics. One may consider VTK and MeshIO for mesh manipulation and file format conversion, respectively, but the post-processing of integration point data, a key requirement in solid mechanics, would not be possible. Most available tools implement the simple, but potentially dangerous, approach of extrapolating the integration point values to the nodes of the mesh or averaging in every cell. This can lead to a misinterpretation of the solution and incorrect engineering decisions. Also, only a few finite element engines allow assembling abstract variational formulations on arbitrary geometries, like FreeFem++ (Hecht, 2012) or FEniCS (Alnaes et al., 2015), amongst others.

Overview
The main features of BasicTools are:  1981-present)), VTK, XDMF, SAMCEF, and ABAQUS, and a bridge with MeshIO is provided. Readers for the ABAQUS and SAMCEF proprietary formats are also enabled when properly licensed software is available locally. See BasicTools documentation for more details. • Implicit geometry engine (in the ImplicitGeometry module): Arbitrary subdomains can be defined using implicit geometries (level-set function). Basic shapes (spheres, half-spaces, cylinders, cubes), transformations (symmetry, translation, rotation) and binary operators (union, difference, and intersection) can be used to construct complex shapes. These shapes can be used to select elements (using ElementFilter), or be evaluated on point clouds to explicitly construct iso-zero surfaces. • Linear algebra functions (in the Linalg module): Some common operations on linear systems for finite elements are implemented: penalization, elimination, Lagrange multipliers, and the Ainsworth (Ainsworth, 2001) method to impose essential boundary conditions or linear multi-point constraints. The submodule LinearSolver offers an abstraction layer for sparse linear solvers, including: Cholesky of the sksparse package; factorized, CG, lsqr, gmres, lgmres of the scipy.sparse.linalg module; CG, LU, BiCGSTAB, SPQR of the C++ Eigen library; and the AMG solver of pyamg package.
The large majority of functions are illustrated in the same file where they are defined, in CheckIntegrity functions.

Examples
We present two examples; see BasicTools documentation for complete details.

Pre/post deep learning
Convolution-based deep learning algorithms generally rely on structured data. BasicTools can be used to transfer a field computed on an unstructured mesh using finite elements to a structured grid and vice versa. To validate the operation, the error on the final field is evaluated with respect to the original field.

Mechanical analysis: Thick plate with two inclusions
Consider a thick plate with two inclusions, one softer and the other stiffer than the base material. The plate is clamped on the left side with a constant traction applied on the right side. We compute the strain energy on only one inclusion. The linear elasticity problem is solved using P1 Lagrange finite elements on an unstructured mesh.