1 Introduction

1.1 Motivation

The organization of a standard biomechanical deformation analysis pipeline typically proceeds as follows. First, using imaging techniques such as Magnetic Resonance Imaging (MRI) a segmented image of the region of interest is obtained. This segmented image is then meshed so that it can be used as input for a finite-element simulation. The mesh is considered as the initial, undeformed or reference configuration of an elastic body. Then, by applying external forces to this elastic body we can find its deformed (or current) equilibrium configuration.

Conversely, an inverse deformation analysis allows us to find the undeformed configuration of a body knowing its deformed configuration. In the case of an object subject to gravity, the undeformed configuration can be seen as a theoretical gravity-free configuration. Consequently, determining the rest-position of an organ is of interest in many (bio)mechanical problems, as explained in Fig. 1. For example, in abdominal aortic aneurysms to compute the residual stresses [1, 2]or open-configuration [3] or in breast cancer as an intermedial configuration between the imaging and surgical stance [4]. Besides, this approach can also be used in problems of industrial interest, such as tire or turbine blade design [5, 6].

1.2 Problem statement

The objective of inverse deformation analysis is to determine the undeformed configuration of an object such that it attains a known deformed configuration under the action of a known loading. It is important to note the distinction between inverse deformation analysis and common inverse problems. In a typical inverse problem, we might assume we know the applied forces, the initial and deformed configuration, and the goal is to determine the model parameters that minimize some distance (metric) between initial and deformed configurations. In an inverse deformation analysis, we assume we know the applied forces, boundary conditions, model parameters, and the deformed configuration. The objective is to determine the undeformed configuration that would lead to the deformed configuration if the external forces were to be applied.

1.3 Background

Several authors have tackled the problem of inverse deformation analysis using a variety of strategies. To the best of our knowledge, Adkins [7] was the first to propose exchanging the role of the deformed and undeformed configurations, i.e., to express the displacement of the body as a function of the deformed state. The study was limited to plane strain deformations and uniform extension. Schield [8] applied the same formalism to a homogeneous elastic material, without body force. He showed the equivalence of the equilibrium equations if the initial and deformed configurations are interchanged as well as the volumetric strain energies. The results provided by this approach are shown to be commensurate with those of Adkins [7] but are based on dual relations between the initial configuration and the deformed configuration. Carlson [9] used a variational principle to achieve the same as Schield [8] and showed the validity of the approach for different elastic materials. More recently, Carroll [10] mathematically analyzed the Schield transformation and the proven inverse deformation theorem. The theorem states that if a particular deformation is supported without body force for a specific strain energy W, then the inverse deformation is another energy \(W^{*}\), derived from the first: \(W^{*}(\varvec{F})={\text {det}} (\varvec{F}) W\left( \varvec{F}^{-1}\right)\), where \(\varvec{F}\) is the deformation gradient.

Govindjee [11, 12] introduced the reparameterization of the weak form of the forward problem of finite elasticity as a solution method for the inverse problem. This approach only requires \(C_{0}\) continuity and has a direct physical connection to the problem. In addition, the procedure eliminates boundary condition difficulties, can be straightforwardly implemented using standard forward numerical methods, and can deal with both compressible or incompressible materials.

Inspired by Govindjee [12] (Eulerian model) and Yamada [13] (arbitrary Lagrangian–Eulerian (ALE)), Fachinotti [14] rewrote the constitutive equations in terms of Lagrangian variables. In contrast to Eulerian and ALE variables, the Lagrangian formulation requires only a few modifications from the direct to the inverse analysis code (i.e., the computations of the finite-element residual vector and the Jacobian matrix). The formulation is convenient and allows to solve inverse design problems such as finding the unloaded shape of a turbine blade under known loading. However, few drawbacks arise such as the difficulty of deriving and implementing the consistent Jacobian of the finite-element formulation. Despite the usefulness of the approach, to our knowledge, this type of analysis is still not available in any widely used commercial simulation software.

Iterative methods identify the undeformed configuration based on several forward calculations. The algorithm is introduced by Sellier [15] with a fixed-point method for elastostatic problems and then generalizes as the backward displacement method by Bols [16] for patient-specific blood vessel simulations. The iterative algorithm of Sellier has been widely applied to many image-based biomechanical simulations, mainly thanks to its algorithmic simplicity and its ability to use a standard non-linear elasticity simulation software [4]. However, when applied to strongly non-linear problems resulting from material or geometric non-linearity, the algorithm lacks robustness. Furthermore, iterative methods usually require at least one non-linear elasticity problem solution, resulting in higher costs compared with the approach of Fachinotti [14].

In the computer graphics community, Chen [17] used asymptotic numerical methods (ANM) to compute the rest-shape of elastic objects with a neo-Hookean material model. The ANM considers a parametrized version of the static equilibrium: \(f(x, X)+\lambda g=0\), where g is gravity, \(\lambda\) a loading parameter and f are the internal forces with the given deformed configuration x and the unknown rest-configuration X. Then, the algorithm incrementally computes the asymptotic expansion of the curve in (\(X, \lambda\)) space until \(\lambda = 1\), which corresponds to the rest-position. In this study, ANM offers superior performance, robustness, and convergence speed over traditional Newton-type methods for highly nonlinear material models. However, the major drawback of the method is the complexity of changing the model formulation. Indeed, using a different material model implies to establish a different quadratic relationship between Cauchy stresses and the rest-position, then deriving the asymptotic local expansion. More recently, Ly [18] developed an inversion algorithm applicable to geometrically non-linear thin shells, including the effects of contact and dry friction with an external body.

1.4 Contribution

In this paper, we propose to use the Lagrangian formulation of Fachinotti [14] coupled with automatic code generation tools provided by the FEniCS Project finite-element software [19] to compute the rest or undeformed configuration of an object knowing the deformed configuration, the external loads and the material properties. We show experimental validation that the methodology is effective at recovering the undeformed configuration from imaging data. The formulation requires only a few minor modifications of the direct simulations, making it easy to implement. The automated differentiation tools from FEniCS Project provide a great deal of flexibility, for example, permitting users to quickly and easily modify the material model to suit their own problem.

1.5 Outline

This paper is organized as follows; first, we explain the inverse deformation analysis methods as well as the near-incompressible hyperelastic model used for the study. We test our formulation on some simple analytical cases described in [20, 21]. Then, we show in a numerical example how our variational formulation can surpass the iterative algorithm proposed by Sellier [15]. Finally, we demonstrate a relevant real-world application by retrieving the undeformed configuration of a Polydimethylsiloxone (PDMS) beam under the action of gravity from imaging data.

Fig. 1
figure 1

Our pipeline starts with the acquisition of a medical image, in which the organ can be segmented. The organ is observed at equilibrium under the effect of external forces due to its environment (e.g., gravity). In the usual pipeline (1, in red), the segmented geometry is considered as the initial geometry. Then, the external forces are applied until equilibrium to obtain the intermediate geometry used for simulating the procedure. We propose an alternative approach (2, in green), where we constrain the intermediate geometry to be identical to the segmented geometry. It involves the computation of a new geometry (represented by the question mark symbol), which is the organ geometry such that it would deform to the segmented/imaged configuration if external forces were applied. Here, the final result takes into account the undeformed geometry of the organ

2 Inverse finite strain elasticity formulation

This section presents two methods to compute the undeformed configuration knowing the deformed configuration under known loading. We first introduce our methodology derived from Fachinotti [14], then we briefly outline a simple iterative geometric algorithm described in [15].

2.1 Inverse FEM method

2.1.1 Mathematical operators

In this paper, we define the colon operator ( : ) as the inner product between tensors (summed pairwise product of all elements). Let \(\varvec{A}\) and \(\varvec{B}\) be rank-2 tensors, the inner product is then defined as \(\varvec{A}:\varvec{B} = {\text {tr}}(\varvec{A}^{T} \varvec{B}) = A_{ij}B_{ij}\) using the Einstein notation. In a same way, we define the dot product between vectors as \(\varvec{u} \cdot \varvec{v}= u_{i} v_{i}\). Finally, \(\nabla (\bullet )\) denotes the vector differential operator such that \(\nabla \varvec{v} = \frac{\partial v_j}{\partial x_{i}}\).

Consider a deformable body \(\mathcal {B}\). We denote the undeformed configuration \(\varOmega _{0}\). The location of a particle of \(\mathcal {B}\) in \(\varOmega _{0}\) is denoted \(\varvec{X}\). Conversely, the deformed configuration is noted \(\varOmega\), and the location of a particle of \(\mathcal {B}\) in \(\varOmega\) is noted \(\mathrm {\mathbf {x}}\). A one-to-one mapping \(\varvec{\phi }\) maps the position of a particle \(\varvec{X}\) in \(\varOmega _{0}\) to the position of the same particle \(\varvec{x}\) in \(\varOmega\), i.e., \(\varvec{x} = \phi (\varvec{X})\). The configuration \(\varOmega\) can be obtained by \(\varvec{\phi }\left( \varOmega _{0}\right) =\left\{ \varvec{\phi }(\varvec{X}) \; | \; \varvec{X} \in \varOmega _{0}\right\}\).

The weak form of the static equilibrium of the inverse deformation is expressed in the deformed configuration:

$$\begin{aligned} \int _{\varOmega } \varvec{\sigma }: \nabla \varvec{\eta } \; \mathrm {d} \varOmega =\int _{\varOmega } \rho \varvec{b} \cdot \varvec{\eta } d \varOmega +\int _{\Gamma } \varvec{t} \cdot \varvec{\eta } \; \mathrm {d} \Gamma , \end{aligned}$$
(1)

where \(\varvec{\sigma }\) is the Cauchy stress tensor and \(\nabla (\bullet )\) the gradient in \(\varOmega\) with respect to the deformed spatial position of the test function \(\varvec{\eta }\). \(\rho\) is the density of the material in the deformed configuration and \(\varvec{b}\) are the external forces in the deformed configuration. Finally, a traction boundary condition prescribed on a part \(\Gamma\) of the boundary as \(\varvec{\sigma } \cdot \varvec{n} = \varvec{t}\) with \(\varvec{n}\) the outward unit normal at the boundary. On the remaining part of the boundary, we assume that the value of the displacement is given, i.e., a Dirichlet condition.

This approach has the advantage of being based on classical mechanical principles. However, mechanical quantities such as strains or stresses are defined depending on \(\varvec{X}\). Whereas, in the inverse approach, the initial geometry is replaced by the deformed geometry \(\varvec{x}\). We redefine the classical displacement \(\varvec{u} (\varvec{X}) =\varvec{x}-\varvec{X} =\varvec{\phi }(\varvec{X})-\varvec{X}\) as

$$\begin{aligned} \varvec{u}^{\prime }(\varvec{x})=\varvec{X}-\varvec{x}. \end{aligned}$$
(2)

Note that trivially

$$\begin{aligned} \varvec{u}^{\prime } \circ \varvec{\phi } + \varvec{u} =0. \end{aligned}$$
(3)

This redefinition does not modify the classical finite-element pipeline: the unknown position is still the first term in which the known position is subtracted. In addition, as we compute gradients in the deformed configuration, this necessitates the redefinition of the deformation gradient as well:

$$\begin{aligned} \varvec{F}=\frac{\partial \varvec{\phi (\varvec{X})}}{\partial \varvec{X}}= & {} \left( \frac{\partial \varvec{X}}{\partial \varvec{x}}\right) ^{-1} =\left( \frac{\partial \varvec{u'(x)}}{\partial \varvec{x}} + \varvec{I}\right) ^{-1}\nonumber \\= & {} \left( \nabla \varvec{u}^{\prime }+\varvec{I}\right) ^{-1}. \end{aligned}$$
(4)

Henceforth, when performing an inverse deformation analysis, \(\varvec{F}\) and all derived quantities (strain measures, invariants, energy densities, stress measures etc.) are always computed using the above redefinition in terms of \(\varvec{u}^{\prime }\).

This new formulation requires us to only make one change compared to the classical direct finite-element pipeline; rewrite \(\varvec{F}\) in terms of \(\varvec{u}^{\prime }\). This formulation can find the undeformed configuration of an object, knowing only the deformed configuration and the applied forces. The process is not iterative (we perform several Newton–Raphson iterations but only one simulation) and based on the equation of continuum mechanics.

2.2 Nearly-incompressible constitutive model

For many materials, simple elastic models such as the St. Venant Kirchhoff model are not sufficient to describe the observed behavior. More complex hyperelastic models provide a mechanism of modeling the stress–strain behavior of complex materials, such as elastomers or biological tissues. They can be assumed compressible, i.e., the volume may change during deformation or nearly incompressible or even completely incompressible, i.e., the volume is preserved during deformation \({\text {det}} \varvec{F} \sim 1\).

For a hyperelastic material, the strain energy density function describes the stored energy as a function of the isochoric deformation, i.e., shape deformations without volume change. However, using the standard displacement-based finite-element method to describe incompressible material behavior may cause numerical problems typically referred to as locking. Simply put, locking occurs when too many constraints are imposed on the discrete formulation and its overall approximation power is destroyed.

To overcome these difficulties, mixed formulations have been developed. In these formulations, the variational principle is modified by writing the potential energy functional. The strain energy is expressed in terms of the deviatoric component only and the incompressibility constraint is explicitly enforced using a Lagrange multiplier with physical meaning akin to pressure (p). It turns out that the Lagrange multipliers can be expressed as a function of the hydrostatic pressure values f(p) [34]:

$$\begin{aligned} \psi (\varvec{C}, p)= & {} \psi _{\text {deviatoric}}(\varvec{C}) + f(p), \end{aligned}$$
(5)
$$\begin{aligned} f(p)= & {} \psi _{\text {hydrostatic}}(J),\text { with } p= \sigma _{\text {hydro}} \nonumber \\= & {} \frac{1}{3} {\text {tr}}(\varvec{\sigma })=\frac{\partial \psi _{\text {hydrostatic}}(J)}{\partial J}, \end{aligned}$$
(6)

where J is the Jacobian defined as \(J = {\text {det}} \varvec{F}\) and \(\varvec{C}\) is the right Cauchy–Green deformation tensor. Among the hyperelastic materials, we chose to use neo-Hooke [33] and Mooney–Rivlin [31, 32] models, often used for modeling soft object deformations.

Neo-Hookean By calculating f(p), we can deduce the mixed displacement–pressure formulation of a nearly-incompressible neo-Hookean material:

$$\begin{aligned} \psi _{\mathrm {NH}} (\varvec{C},p) =\frac{\mu }{2} (\mathrm {I}_{B}-3) - \mu \ln (J) + p \ln (J) - \frac{1}{2\lambda }p^{2}, \end{aligned}$$
(7)

with

$$\begin{aligned} \psi _{\text {deviatoric}}(\varvec{C}) = \frac{\mu }{2} (\mathrm {I}_{B}-3) - \mu \ln (J), \end{aligned}$$
(8)

and

$$\begin{aligned} \psi _{\text {hydrostatic}}(J) = \frac{\lambda }{2} \ln (J)^{2}, \end{aligned}$$
(9)

where \(\lambda\) and \(\mu\) are material constants called the Lamé parameters.

Mooney–Rivlin By calculating f(p), we can deduce the mixed displacement–pressure formulation of a nearly-incompressible Mooney–Rivlin material:

$$\begin{aligned} \psi _{\mathrm {MR}} (\varvec{C},p)=C_{1}\left( \overline{\mathrm {I}_{C}}-3\right) +C_{2}\left( \overline{\mathrm {I} \mathrm {I}_{C}}-3\right) + p(J-1) - \frac{1}{4D_{1}}p^{2}, \end{aligned}$$
(10)

with \(C_{1}\), \(C_{2}\), \(D_{1}\) material constants, in addition of

$$\begin{aligned} \psi _{\text {deviatoric}}(\varvec{C}) = C_{1}\left( \overline{\mathrm {I}_{C}}-3\right) +C_{2} \left( \overline{\mathrm {II}_{C}}-3\right) , \end{aligned}$$
(11)

and

$$\begin{aligned} \psi _{\text {hydrostatic}}(J) = D_{1}(J-1)^{2}, \end{aligned}$$
(12)

with the modified invariants \(\overline{\mathrm {I}_{C}} = J^{-\frac{2}{3}} \; \mathrm {I}_{C}\), \(\overline{\mathrm {II}_{C}} = J^{-\frac{4}{3}} \; \mathrm {II}_{C}\) and classic invariants \(\mathrm {I}_{\mathrm {\varvec{C}}} ={\text {tr}}(\mathbf {C})\), \(\mathrm {II}_{\mathrm {\varvec{C}}} =\frac{1}{2}\left( ({\text {tr}}(\mathbf {C}))^{2}-{\text {tr}}\left( \mathbf {C}^{2}\right) \right)\). These nearly-incompressible energy densities are used to generate the results from the FEniCS Project presented in this paper.

Finally, the strain energy density can be related to the second Piola–Kirchhoff \(\varvec{S}\) and then to the Cauchy stress tensor by recalling the relation \(\frac{\partial J}{\partial \varvec{C}} = \frac{1}{2}J\varvec{C}^{-1}\):

$$\begin{aligned} \varvec{S}= & {} 2 \frac{\partial \psi }{\partial \varvec{C}} = 2 (f\prime (p) \frac{\partial J}{\partial \varvec{C}} + \frac{\psi _{\text {deviatoric}}}{\partial \varvec{C}}), \end{aligned}$$
(13)
$$\begin{aligned} \varvec{\sigma }= & {} J^{-1}\varvec{FSF}^{T}J = f\prime (p) + 2J^{-1}\varvec{F}\frac{\psi _{\text {deviatoric}}}{\partial \varvec{C}}\varvec{F}^{T}, \end{aligned}$$
(14)

where \(f\prime\) denotes the differentiation of f(p) with respect to p.

2.3 Finite-element solver

We use the FEniCS Project finite-element software [19] to discretise both the standard finite strain elasticity problem and the inverse finite strain elasticity problem that we will outline in the next section. We use a mixed displacement–pressure finite-element formulation with second-order continuous Lagrangian finite elements for displacement \(\mathbf {u}\) and first-order continuous Lagrangian finite elements for pressure p. This pairing is well-known to be \(\inf\)-\(\sup\) stable [36] and relatively robust with respect to numerical locking.

The variational form of the residual Eq. 1 is defined in the unified form language (UFL) [22] and symbolically differentiated to derive an expression for consistent Jacobian. The FEniCS form compiler (FFC) [23] is used to automatically generate low-level C++ code from the high-level UFL description that can calculate the Jacobian and residual cell tensors. The overall solution process is driven by the DOLFIN finite-element library [24]. We use a standard Newton–Raphson algorithm with continuation in the loading parameter. The linear system within the Newton–Raphson algorithm is solved using the direct solver MUMPS via PETSc [25]. To be more precise, inside PETSc we use the direct sparse MUMPS solver as a preconditioner to a single iteration of a Krylov method, leading to convergence in one iteration. The relative tolerance of the solve is in the order of \(1e^{-12}\). The complete implementation of the standard or inverse problem is around 100 lines of Python code that closely follows the mathematical structure of the problem. We refer the reader to the supplementary material [26] for further details.

2.4 Iterative geometric algorithm

Sellier [15] proposed an iterative geometric algorithm (IGA, not to be confused with isogeometric analysis). The algorithm is simple to implement and only requires an existing (standard) forward deformation solver. The algorithm starts with an initial guess for the undeformed configuration (usually chosen, for lack of a better choice, the deformed one) and applies successive displacement fields to it until a convergence criterion is reached. The sequence of displacement fields is obtained from the direct simulations of the current rest-configuration undergoing external forces. The shape of the object after the direct simulation provides an error compared to the exact rest-configuration by measuring the distance to the initial configuration. An updated estimate of the undeformed configuration is calculated by correcting the previous guess with the difference between the computed and deformed configuration. The algorithm stops when the error (computed using the \(l^{2}\)-norm) is below a defined threshold \(\epsilon\) or a maximum number of iterations \(NB^{\mathrm {max}}\) has been reached. The process is outlined in Algorithm 1.

figure a

3 Numerical results

The inverse deformation framework is very similar to the traditional direct framework. To assess the numerical precision of the inverse method, we first applied a serie of tests to verify the soundness of the direct and inverse approaches in which an analytical solution is known. We tested our formulation on some simple analytical cases described in [20, 21], such as simple and generalized shears. Due to the triviality of the tests, they are detailed in the Appendix and can be found in the supplementary material [26].

3.1 Single unit tetrahedron

3.1.1 Part I

Let us consider a mesh with a single unit tetrahedron with a linear Lagrangian finite-element space. Its domain is denoted \(\varOmega ^{T}_{0}\). The nodal coordinates are \([0,0, 0]^T, [1, 0, 0]^T, [0,1, 0]^T\) and \([0,0, 1]^T\). The nodes with \(y = 0\) are fixed, leaving only one free node. A uniform force \(\varvec{f}\) is applied along the y-axis. The tetrahedron is deformed so that the free node moves along the y-axis.

In a first step, we compute the deformation \(\varvec{\phi }\) with the direct method. A displacement \(\varvec{u}\) is computed for the free node. The deformed domain is \(\varOmega ^{T} = \varvec{\phi } (\varOmega ^{T}_{0})\). In a second step, the initial geometry is the deformed geometry \(\varOmega ^{T}\), i.e., a unit tetrahedron with the nodes \(y = 0\) fixed, and the remaining node displaced from \(\varvec{u}\). The same uniform force \(\varvec{f'} = \varvec{f}\) is applied. An inverse simulation is computed so that the displacement of the free node is \(\varvec{u'}\). This example is depicted in Fig. 2a.

3.1.2 Part II

We consider the same unit tetrahedron, with the same boundary conditions. A uniform force \(\varvec{f'}\) is applied along the y-axis.

In the first step, an inverse simulation is computed, leading to a displacement of \(\varvec{u'}\). In the second step, the resulting geometry is deformed with a direct simulation leading to a displacement of \(\varvec{u}\). This part of the example is depicted in Fig. 2b.

Fig. 2
figure 2

Single tetrahedron test, plane view. The two bottom nodes are fixed (\(\varvec{u}= (0,0, 0)^T\) for \(y=0\)). In part I, a force \(\varvec{f}\) is applied on the "free node" (\(y=1\)) generating a displacement \(\varvec{u}\). Then a second force \(\varvec{f'} = \varvec{f}\) (generating \(\varvec{u'}\)) is applied on the same node to retrieve the initial configuration. In part II, we reiterate the same procedure as part I except that we first apply \(\varvec{f'}\) and then \(\varvec{f}\) on the "free node"

The difference with the first part of the test is the order of the successive simulations. In part I, the inverse simulation is performed after the direct simulation. In part II, it is the opposite. In both parts of the test, the goal is to verify that the following relationship: \(\varvec{u'} = -\varvec{u}\).

Furthermore, the inverse simulation is computed with IGA to compare the results and performance with our method. In this test, the error measure is defined as: \(\Vert \varvec{u'}+\varvec{u}\Vert _{l^2}\). We measured this error with different constitutive equations and varying their associated mechanical parameters. In total, we performed 153 tests and provided a statistical analysis in Table 1.

Table 1 Benchmark results on a single tetrahedron simulation

We observe that the accuracy of the iterative algorithm depends on the number of iterations, but it also increases the computational cost, because each iteration calls a direct simulation. Our method provides high accuracy while requiring only the solution of a problem with similar complexity to a single iteration of IGA. Beyond the numerical results, one point is that in 7 tests over the 153 of the part II, the iterative algorithm was not able to reach the accuracy of our method within 50 iterations.

3.2 Sagging block

In Appendix, we applied different displacements on a cube using simple and generalized shears. For the sagging block case, we use the same pipeline as mentioned in Sect. 3.1. Namely, we deform and object by applying a force and recover its initial shape by exercising the opposite force on the deformed object. The geometry is a three-dimensional unit cube of 1 m length, fixed at the bottom (Dirichlet condition \(\varvec{u}=(0, 0, 0)^{T}\) when \(y=0\)) with gravity as a body force applied to the entire object. For the material model, we used the incompressible Neo-Hookean defined in Eq. 7. We performed several Monte Carlo (MC) simulations which to study the error of the recovered initial shape using different material parameters. For the sake of simplicity, we assumed that \(\lambda\) and \(\mu\) were both following an uniform distribution between an acceptable range of values:

$$\begin{aligned} \mu&\sim U(2.0 \times 10^{3}, 2.0\times 10^{5}), \\ \lambda&\sim U(8.0\times 10^{4}, 8.0\times 10^{6}). \end{aligned}$$

We empirically chose those values as lower and upper limits, because we could observe large visible deformations within these bounds. We draw 100 samples of each parameters and make all possible combinations leading to \(100^{2}=10{,}000\) simulations. To study the error, we calculated the mean absolute error (MAE) between the initial shape and the initial shape predicted by our inverse deformation algorithm. The MAE is defined as \(\text {MAE}= \frac{\sum _{i}^{N}\mid e \mid }{N}\), where \(e = x_\mathrm{prediction}-x_\mathrm{initial}\) and N the number of points of the cube.

The result of the MC simulations are shown in the 3D plot in Fig. 3. We observe a small error when the material parameters are on the upper limit of our distribution, e.g., a \(\text {MAE}=1.21 \times 10^{-9}\) m for \(\mu =175 \times 10^{3}\) Pa and \(\lambda =50 \times 10^{5}\) Pa. On the contrary, when moving to smaller values, e.g., \(\mu =20 \times 10^{3}\) Pa and \(\lambda =30 \times 10^{5}\) Pa, the MAE is increasing to \(1.21 \times 10^{-5}\) m. This behavior is expected as choosing smaller values of \(\lambda\) and \(\mu\) induce larger displacements increasing the MAE. Hence, the obtained MAE are more than acceptable and choosing lower values of the material parameters will surely increase the MAE but also create convergence issues for such large deformations. Furthermore, we performed a mesh convergence analysis shown in Fig. 4 proving that refining the mesh leads to a smaller MAE.

Fig. 3
figure 3

Sagging block Monte Carlo simulations using a uniform distribution of Neo-Hookean material parameters. The mean absolute error (MAE) between the initial shape and the predicted shape of the inverse deformation algorithm is calculated for 10,000 simulations

Fig. 4
figure 4

Semilog plot of the mesh convergence analysis of the sagging block simulation. The mean absolute error (MAE) between the initial shape and the predicted shape of the inverse deformation algorithm is calculated for different mesh refinement with fixed parameters (\(\lambda =80 \times 10^{4}\) Pa and \(\mu =25 \times 10^{3}\))

4 Experimental results

In this section, we will demonstrate that our inverse simulation method can match the outcome of a real experiment and, therefore, has value as a predictive modelling tool.

We fixed one extremity of a beam made from Polydimethylsiloxane (PDMS) to a vertical support and allowed it to deform under gravity, slowly accompanied to the equilibrium position by hand and released in that position. The deformed steady state was reached in about 1 min (after vibrations were completely damped) resulting in the configuration displayed in Fig. 5. To conduct the experiment, the room environmental temperature was recorded to \(19^\circ\)C and the humidity at around 50% (the metrology lab is set to keep these temperatures and humidities). It is known that the mechanical properties of the PDMS material are very sensitive to its curing temperature. On the contrary, the material is very stable once it is fully cured and the mechanical properties are constant for a large range of temperatures centered around the \(19^\circ\)C used for testing. This is obviously not the case if the sample is heated up to temperatures in the range of 80–\(90^\circ\)C, but these are not biological values and are out of the scope of the study. Note that the humidity effects are negligible, since the material is quite hydrophobic. To extract the mesh of the deformed configuration from the image, we used the software BlenderFootnote 1 and contoured the beam on 2D images by hand, as shown in Fig. 6. From Blender, we exported a quadrilateral surface mesh as an.obj file. Then, using the CGAL library, we generated tetrahedrons from the surface mesh. A custom code converted the tetrahedra data structure to a dolfin-compatible.xml file. This code is available as a submodule on our Github page [26]. This mesh will be called the "reference" and used as ground-truth for this section.

To run the inverse deformation algorithm, we need three input parameters: the applied force field, the deformed configuration, and the mechanical properties. In this section, the force field is gravity and the deformed configuration was obtained by manual processing. A separate experiment was performed to obtain the mechanical properties and will be detailed in the following section.

Fig. 5
figure 5

Experimental setup: initially a straight PDMS cylindrical beam of 182 mm length and 8.5 mm diameter, clamped on the left side and deformed by gravity

Fig. 6
figure 6

Manual process in Blender to delineate the contours and extract the 3D mesh of the deformed configuration

4.1 Materials

We used a PDMS (Sylgard 184, Ellsworth Adhesives) cylinder of density \(965 {\mathrm{kg/m}^{3}}\) of undeformed dimensions 182 mm and 8.5 mm for length and diameter, respectively.

For the sample preparation the elastomeric part and curing agent were mixed in a 10:1 ratio and cured at room temperature for 24 h before being tested [27]. A surgical knife was used for cutting cylindrical shapes from the second cylinder of PDMS, for compression tests samples (diameter 11 mm, height \(7 \pm 1\) mm).

To characterize the material properties, we used the Mach-1\(^{\mathrm{TM}}\) mechanical testing system (Biomomentum, Canada) as a testing rig for the unconfined compression tests. We used the following protocol:

  • A 1.5 mm single-axis load cell with a resolution of \(75 {\upmu \mathrm{N}}\) was used to measure the vertical force.

  • The vertical displacement was measured by the moving stage of the rig with a resolution of \(0.1 {\upmu \mathrm{N}}\).

  • To minimize friction, paraffin oil was used between the sample and the compression platens.

  • One loading cycle was executed on each specimen. To detect the response of the material at large strains, the samples were compressed at a constant speed of 0.083 mm/s until a displacement corresponding to 30\(\%\) of the measured height was achieved. Particular attention was used to monitor the samples that had uniformly expanded in the radial direction and that their upper and lower faces remained adhered to the moving platen and the fixed platform for the entire duration of the test.

  • The Abaqus evaluation routine was used to fit the true stress–true strain experimental curves with a Mooney–Rivlin model. Abaqus employs a linear least-squares fit for the Mooney–Rivlin form to find the optimal model parameters.

In our case, the optimal parameters are: \(D_{1} = 7.965 \times 10^{-8}\) Pa, \(C_{10} = 101.709\) kPa, \(C_{01} = 151.065\) kPa. The value of \(D_{1}\) is close to 0 which validates our incompressibility hypothesis. The two obtained values of \(C_{10}\) and \(C_{01}\) are the optimal values to describe the behavior of the PDMS using a Mooney–Rivlin material formulation.

4.2 Direct simulation

We run three simulations with identical geometry, material properties, boundary conditions, and material model to verify that these commonly used softwares produce quantitatively similar results. For each software, we used an incompressible Mooney–Rivlin model and boundary conditions imitating the setup shown in Fig. 5. Namely, a Dirichlet boundary condition of \(\varvec{u} = 0\) on the left side of the beam (to imitate the clamping of the beam to the support) and the gravity is applied as a body force on the entire object.)

FEniCS We use the same model as described in Sect. 2.2.

Abaqus We use a static step with a gravity load to solve the beam deformation in Abaqus. Abaqus/Standard uses Newton’s method as a numerical technique for solving the nonlinear equilibrium equations. We employed C3D8RH elements, an 8-node linear brick, hybrid/mixed, constant pressure, reduced integration with hourglass control. Hybrid elements are usually used in Abaqus when the material definition is close to incompressibility to avoid locking. The reduced integration is used to speed up computational time and avoid numerical locking.

SOFA We employ the multiplicative Jacobian energy decomposition method (MJED) which is an optimized algorithm for building the stiffness and tangent stiffness matrices of non-linear hyperelastic materials [28]. An MJED implementation is available in SOFA [29] for finite- element formulation using linear tetrahedral elements. The linear system of equations is solved in every step of quasi-static simulation using a fast in-house linear equation solver based on the Cholesky [35] decomposition.

The visual result of the forward simulations using the 3 softwares are shown in Fig. 7. For each model, we perform a mesh convergence analysis shown in Fig. 8, where we plot the maximum deformation of the beam (located at the tip) for different mesh resolutions.

Fig. 7
figure 7

Comparison of the deformation of the beam for the direct simulation of three different softwares. The three simulations have the same geometry, boundary conditions, material model, and mechanical parameters corresponding to the experiment’s material (PDMS) found in Sect. 4.1. From top to down, in magenta: the experimental data, in blue: the SOFA simulation, in wire-frame green: the FEniCS simulation and in red: the Abaqus simulation

Fig. 8
figure 8

Mesh convergence analysis of the forward simulation. We calculate the maximum deformation of the tip of beam for several level of refinement of the mesh

We observe that the tip displacement for the three software converges to similar solutions (FEniCS: 132.52 mm, Abaqus: 132.71 mm, SOFA: 130.31 mm), while the experimental value is 127.68 mm. We observe a small difference between the numerical solutions and the experiment.

FEniCS and Abaqus give similar results, while SOFA is 2 mm off, compared to the 2 others softwares. We observe in Fig. 8 that FEniCS and Abaqus converged with 60,000 points, while SOFA is still not converged with 160,000 points (due to computational resources limitations). One reason is that SOFA is usually designed for real-time simulation and only uses dynamic solvers which can lead to inaccuracy compared with static solvers from FEniCS and Abaqus. Furthermore, the differences between numerical solutions can be explained by the use of three slightly different formulations of the Mooney–Rivlin law as well as different solvers for solving the equation. Finally, one can note that the ABAQUS simulation converges very quickly. Possibly because ABAQUS is using a hexahedral cell shape with quadratic polynomial interpolation of the displacement field, against tetrahedron cells in FEniCS and SOFA. It is well known, at least in the Engineering community, that finite elements based on hexahedral cells often perform better in practice.

Some factors can explain the difference between the numerical solutions and the experimental value. For instance, the variation may be explained by inadequate constitutive equations or boundary conditions. Then, uncertainties in the mechanical properties measures may also be a factor, especially because the PDMS might exhibit slightly asymmetric behaviour under compression and tension. Finally, we obtained the reference mesh of the undeformed configuration manually based on 2D imaging data, where inaccuracies can be introduced.

4.3 Inverse simulation

In the previous section, we compared the forward simulations of three different software with our experimental solution. In this section, we want to verify the possibility of retrieving the undeformed configuration of our experimental solution knowing only the surface of the deformed configuration, the known applied loads and the material properties.

For this, we converted our experimental surface mesh of the deformed configuration into a volumetric mesh and applied our inverse deformation algorithm implemented using FEniCS. We previously showed a deformation difference of 4.84 mm for the forward simulation in FEniCS. Of course, we do not expect to obtain a perfectly straight beam (the ideal undeformed configuration), but rather an error on the same order as in the forward simulation (i.e., 4.84 mm).

Fig. 9
figure 9

3D plot of the inverse simulation. From down to top, in magenta: the experimental data we wish to retrieve the undeformed configuration, in wire-frame black: the theoretical straight beam, in yellow: the result of the FEniCS inverse simulation

We show in Fig. 9 the result of the inverse deformation algorithm. As expected, the inverse simulation (in yellow) applied to the experimental data (deformed configuration in magenta) is slightly different from the theoretical straight beam that we should obtain (in black). To be more precise, we achieve an error of 5.36 mm compared with the idealized straight beam. As mentioned previously, we expect an error on the order of that for the standard deformation problem (4.84 mm) due to the inherent parametric and modeling uncertainties (material model, material properties, boundary conditions, geometry) already discussed. We, therefore, judge that the proposed methodology has strong potential for prediction of the undeformed configuration of a soft body.

5 Conclusions

In the present paper, we performed two physical experiments and one numerical experiment to address the inverse deformation problem. First an unconfined experiment to find the material properties, and then the cantilever beam problem to find the deformed configuration. The inverse deformation was a computational exercise to see if the undeformed configuration could be recovered.

Our study used the Lagrangian formulation of [14] as a basis for implementing the inverse algorithm in the FEniCS Project finite-element software. We took advantage of the automatic differentiation and code generation capabilities to bypass the difficulties of deriving and implementing the consistent Jacobian. The user must then supply the deformed configuration, the mechanical properties, boundary conditions and the applied forces. The user can easily modify the input mesh, run the code efficiently in parallel, change the constitutive model or change the boundary conditions according to their needs. We have made the code and data available in the supplementary material.

We applied the approach to simple academic examples, where we considered two different incompressible hyperelastic models (neo-Hookean and Mooney–Rivlin) and different boundary conditions. We demonstrated on a simple test case that our method is more efficient in terms of robustness and accuracy than the IGA method of [15]. We have only compared with the classical IGA method of Sellier but other works like [30] have improved on this algorithm. However, we can say that unless an iterative approach requires only one forward model solution, in most circumstances the mechanics-based approach detailed here is likely to be faster and more robust.

Finally, we applied the method to an experiment with a PDMS beam deformed under gravity. We verified and quantified the performance of the direct simulations of three different widely used software (Abaqus, FEniCS, SOFA). Using the inverse deformation algorithm we achieve an error of 5.36 mm for the tip displacement compared to the idealised straight beam.

Despite our progress in providing a flexible inverse deformation algorithm, some work remains to assess its robustness. Our experiments were only focused on using homogeneous nearly incompressible hyperelastic models. Other works such as [14] were interested in more complex behaviors, such as anisotropy. Similarly, our experiments were only based on simple geometries and more complex geometries should be considered.

We showed the validity of our approach for the beam problem by generating a mesh of the deformed configuration from 2D images and recovering the undeformed configuration. In future work we intend to apply this algorithm to segmented 3D geometries to calculate the undeformed configuration of an organ.