선정목록으로
Fast MATLAB evaluation of nonlinear energies using FEM in 2D and 3D: nodal elements
간접 관련 엔지니어링 플라스틱 · (23) 컴파운드 (3) 자동차 인테리어 소재(4) 카시트 모듈(9) 타이어코드
기본 정보
- 저자
- DOI
- 10.48550/arxiv.2109.01158
- 저널
- arXiv (Cornell University)
- 발행년도
- 2022
- 발행기관
- Cornell University
- 피인용수
- 0
- 라이선스
- cc-by
- 논문 유형
- –
- 언어
- –
- 원문 페이지
- https://doi.org/10.48550/arxiv.2109.01158
- 토픽
- Electrostatics and Colloid Interactions
- OpenAlex ID
- W6891994939
평가 내용
- 관련도
- 간접 관련
- 사업분야
- 엔지니어링 플라스틱 · (23) 컴파운드
- 부 분야
- (3) 자동차 인테리어 소재, (4) 카시트 모듈, (9) 타이어코드
- R&D 측면
- 분석·모델링
- 확신도
- 0.70
- 근거 용어
- finite element method, hyperelasticity, nonlinear elasticity, Neo-Hookean density, deformation mapping
- 판단 근거
- 이 논문은 유한요소법(FEM)을 이용해 초탄성(hyperelasticity) 소재의 비선형 에너지 함수를 빠르게 계산하는 수치 해석 알고리즘을 다룹니다. 이는 코오롱인더스트리의 컴파운드(23)나 자동차 시트(3), 타이어코드(9) 등 고분자 소재의 변형 및 기계적 거동을 시뮬레이션하는 R&D 공정에 간접적으로 활용될 수 있습니다.
- R&D 활용 포인트
- 고분자 컴파운드 및 산업용 섬유 소재의 구조적 변형, 응력 분포, 비선형 탄성 거동을 예측하는 CAE(Computer-Aided Engineering) 시뮬레이션 모델의 정확도 및 계산 효율성을 높이는 데 활용 가능합니다.
- 평가 입력
- 본문 80,121자 중 30,032자 발췌
초록
Nonlinear energy functionals appearing in the calculus of variations can be discretized by the finite element (FE) method and formulated as a sum of energy contributions from local elements. A fast evaluation of energy functionals containing the first order gradient terms is a central part of this contribution. We describe a vectorized implementation using the simplest linear nodal (P1) elements in which all energy contributions are evaluated all at once without the loop over triangular or tetrahedral elements. Furthermore, in connection to the first-order optimization methods, the discrete gradient of energy functional is assembled in a way that the gradient components are evaluated over all degrees of freedom all at once. The key ingredient is the vectorization of exact or approximate energy gradients over nodal patches. It leads to a time-efficient implementation at higher memory-cost. Provided codes in MATLAB related to 2D/3D hyperelasticity and 2D p-Laplacian problem are available for download and structured in a way it can be easily extended to other types of vector or scalar forms of energies.
본문 80,121자
본문 펼치기
## Fast MATLAB evaluation of nonlinear energies using FEM in 2D and 3D: Nodal elements
Alexej Moskovka <sup>1</sup> and Jan Valdman <sup>2,3</sup>
1Department of Mathematics, Faculty of Applied Sciences, University of West
Bohemia, Technick´a 8, 30100 Plzeˇn, Czechia
2Institute of Information Theory and Automation, Czech Academy of Sciences,
Pod vod´arenskou vˇeˇz´ı 4, 18200 Praha 8, Czechia
3Department of Computer Science, Faculty of Science, University of South
Bohemia, Braniˇsovsk´a 1760, 37005 Cesk´e <sup>ˇ</sup> Budˇejovice, Czechia
Abstract
Nonlinear energy functionals appearing in the calculus of variations can be discretized
by the finite element (FE) method and formulated as a sum of energy contributions from
local elements. A fast evaluation of energy functionals containing the first order gradient
terms is a central part of this contribution. We describe a vectorized implementation using
the simplest linear nodal (P1) elements in which all energy contributions are evaluated all at
once without the loop over triangular or tetrahedral elements. Furthermore, in connection to
the first-order optimization methods, the discrete gradient of energy functional is assembled
in a way that the gradient components are evaluated over all degrees of freedom all at once.
The key ingredient is the vectorization of exact or approximate energy gradients over nodal
patches. It leads to a time-efficient implementation at higher memory-cost. Provided codes
in MATLAB related to 2D/3D hyperelasticity and 2D p-Laplacian problem are available
for download and structured in a way it can be easily extended to other types of vector or
scalar forms of energies.
### 1 Introduction
Given a domain Ω _∈_ R <sup>_dim_</sup>, where _dim_ _∈{_ 1 _,_ 2 _,_ 3 _}_ is the space-dimension, we consider a minimization problem
_J_ ( u ) = min v _∈V_ <sup>_J_</sup> <sup>(</sup> <sup>v</sup> <sup>)</sup> <sup>_,_</sup> (1)
where _V_ is a space of trial functions and _J_ : _V_ _→_ R represents an energy functional in the form
_J_ ( v ) = _Jgrad_ ( v ) + _Jlin_ ( v ) _,_ (2)
where _Jgrad_ ( v ) denotes its first-gradient part and _Jlin_ ( v ) its linear part. Examples of such
minimization problems are numerous and their study is a general subject of the Calculus of
variations. There are models with higher order derivatives (such as plate problems with the
second derivative in their formulation) available but not considered in this contribution.
1
As the main example we recall a class of vector nonlinear elasticity problems represented by
minimizations of energies of hyperelastic materials [10, 12]. The trial space is chosen as
_V_ = _WD_ <sup>1</sup> <sup>_,p_</sup> <sup>(Ω</sup> <sup>_,_</sup> <sup>R</sup> <sup>_dim_</sup> <sup>)</sup>
i.e., the (vector) Sobolev space of _L_ <sup>_p_</sup> (Ω) integrable functions with the first weak derivative
being also _L_ <sup>_p_</sup> (Ω) integrable and satisfying (in the sense of traces) Dirichlet boundary conditions
v ( x ) = u _D_ ( x ) at the domain boundary x _∈_ _∂_ Ωfor a prescribed function u _D_ : _∂_ Ω _→_ R <sup>_dim_</sup> .
A primal variable is the deformation mapping v _∈_ _V_ describing the relocation of any point x _∈_ Ω
during the deformation process. Then the gradient deformation tensor F _∈_ _L_ <sup>_p_</sup> (Ω _,_ R <sup>_dim×dim_</sup> ) is
defined as
_<u>∂v</u>_ <sup>(1)</sup>
_<u>∂v</u>_ <sup>(1)</sup> _<u>∂v</u>_ <sup>(1)</sup>
_. . ._
_∂x_ 1 _∂xdim_
... ...
_<u>∂v</u>_ <sup>(</sup> <sup>_dim_</sup> <sup>)</sup> _<u>∂v</u>_ <sup>(</sup> <sup>_dim_</sup> <sup>)</sup>
<sup>(</sup> <sup>_dim_</sup> <sup>)</sup> _<u>∂v</u>_ <sup>(</sup> <sup>_dim_</sup> <sup>)</sup>
_. . ._
_∂x_ 1 _∂xdim_
F ( v ) = _∇_ v =
_._ (3)
_∂xdim_
The first-gradient and the linear parts of the energy functional (2) read
Ω
_Jgrad_ ( v ) =
Ω
_W_
- F ( v ( x ))� d x _,_ _Jlin_ ( v ) = _−_
f ( x ) _·_ v ( x ) d x _,_
where _W_ : R <sup>_dim×dim_</sup> _→_ R defines a strain-energy density function and f : Ω _→_ R <sup>_dim_</sup> a loading
functional. We assume the compressible Neo-Hookean density
_W_ ( F ) = _C_ 1� _I_ 1( F ) _−_ _dim −_ 2 log(det F )� + _D_ 1(det F _−_ 1) <sup>2</sup> _,_ (4)
where _I_ 1( F ) = _|_ F _|_ <sup>2</sup> uses the Frobenius norm _| · |_, and det( _·_ ) is the matrix determinant operator.
An extension to other gradient densities as the St. Venant Kirchhoff is possible.
As the second example we recall a scalar p-Laplacian problem [7] with the energy functional
defined as
_|∇v_ ( x ) _|_ <sup>_p_</sup> d x _−_
_J_ ( _v_ ) = <sup><u>1</u></sup>
_f_ ( x ) _v_ ( x ) d x _,_ (5)
_p_
Ω
Ω
where _V_ = _WD_ <sup>1</sup> <sup>_,p_</sup> <sup>(Ω</sup> <sup>_,_</sup> <sup>R).</sup> The functional _J_ ( _v_ ) is then known to be strictly convex in _V_ for
_p ∈_ (1 _, ∞_ ) and it has therefore a unique minimizer _u_ ( x ) _∈_ _V_ .
The main motivation of this contribution is to describe how nonlinear energy functionals
can be efficiently and automatically evaluated by the finite element method (FE). We provide
vectorization concepts and MATLAB implementation for
- evaluations of the value _J_ ( v ),
- evaluations of the gradient vector _∇J_ ( v )
expressed for a trial function v _∈_ _V_ . These two objects can be passed to an external optimization
method of the first order to find a minima of the energy u _∈_ _V_ and the corresponding minimal
energy value _J_ ( u ). We utilize the trust-region optimization method [4] available in the MATLAB
Optimization Toolbox for benchmarking. Our implementation is built on the top of our own
vectorized codes [3, 6, 15] developed primarily for assemblies of finite element matrices. There
are no explicit loops over mesh elements in evaluations of _J_ ( v ) and _∇J_ ( v ), all necessary data
such as gradients of basis functions and energy densities are computed all at once. It leads
to a significant computational speedup, but also it is memory intensive. Practically, the user
specifies the form of the energy _J_ ( v ) and the corresponding gradient vector _∇J_ ( v ) is evaluated
2
approximately by a central difference scheme. Alternatively, if the user is willing to apply some
differential calculus to a particular form of the energy, then the exact gradient can be assembled.
This exact gradient approach is not versatile, but leads to the further performance speedup in
our tests. We set up a set of six benchmarks as a base for future tests and improvements:
- The mesh and the nodal patches data are preprocessed in Benchmark 1.
- Evaluations of _J_ ( v ) and _∇J_ ( v ) for a given v _∈_ _V_ are provided in Benchmarks 2 and 3.
- The full minimizations of 2D/3D hyperelasticity and 2D p-Laplacian energies are shown in
Benchmarks 4, 5 and 6.
Authors are not aware of any similar MATLAB implementation. This is also our first attempt in
this direction apart from our own contribution [13] focusing on p-Laplacian energy minimization.
There is a growing number of MATLAB vectorized implementations of the second order linear
partial differential equations eg. [9, 17] or particular nonlinear partial differential equations
[6, 16].
The paper is structured in the following way: Section 2 summarizes useful notation and Section 3 basics of FEM. Section 4 includes implementation of two structures: mesh and (nodal)
patches. Section 5 is focused on implementation of energy evaluation and Section 6 on implementation of the gradient of energy. The final Section 7 reports on the solutions of particular
minimization problems.
### 2 Notation
Index mappings in the construction of FEM:
_ILG_ : N _→_ N - (local to global) mapping which for a local basis function on an element returns
the index of the corresponding global basis function
_IDN_ : N _→_ N - (degree to node) mapping which for the _n_ -th degree of freedom returns the
index _i_ of the corresponding node, see (22)
Domain triangulations are described by the following parameters:
_T, N_ - a set of elements, a set of nodes
_M ⊂N_ - a set of (at least partially) free nodes
_T_ <sup>_i_</sup> _, T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> - the _i_ -th nodal patch, the
- _IDN_ ( _n_ )�-th nodal patch
_|T |, |N|, |M|, |T_ <sup>_i_</sup> _|, |T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_ - the sizes of sets _T, N_ _, M, T_ <sup>_i_</sup> _, T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>
Both scalar and vector problems are treated together as a vector problem with _d_ components,
where _d_ = 1 for scalar problems, _d_ = _dim_ for vector problems and _dim_ is the space dimension.
The following indices are frequently used:
_i_ - the index of a node ( _i ∈{_ 1 _, . . ., nb}_, also _i ∈{_ 1 _, . . ., |N|}_ or _i ∈{_ 1 _, . . ., |M|}_ )
_j_ - the index of a vector component ( _j_ _∈{_ 1 _, . . ., d}_ )
_k_ - the index of an element ( _k_ _∈{_ 1 _, . . ., |T |}_ ), also ( _k_ _∈{_ 1 _, . . ., |T_ <sup>_i_</sup> _|_ ) or ( _k_ _∈{_ 1 _, . . ., |T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_ )
_ℓ_ - the index of a local basis function ( _ℓ_ _∈{_ 1 _, . . ., dim_ + 1 _}_ )
3
_m_ - the index of a spatial component ( _m ∈{_ 1 _, . . ., dim}_ )
_n_ - the index of a global degree of freedom ( _n_ _∈{_ 1 _, . . ., d|N|}_ ) or an active degree of freedom
( _n ∈{_ 1 _, . . ., d|M|}_ )
_r_ - the index of a global patches matrix row ( _r_ _∈{_ 1 _, . . ., |M|}_ )
Nodal basis functions are used in several ways:
_ϕi_ ( x ) _,_ _ϕ_ _i_ ( x ) - a scalar global nodal basis function, a vector global nodal basis function
_ϕ_ _k,ℓ_ ( x ) - the _ℓ−_ th local basis function on the _k−_ th element
A trial vector function is addressed in several ways:
v ( x ) _,_ _v_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> ( x ) - a trial vector function and its _j_ -th component
V - a matrix of the coefficients of v ( x ) in the nodal finite element basis
v _i,_ v <sup>(</sup> <sup>_j_</sup> <sup>)</sup> _,_ _vi_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> - the _i_ -th row of V, the _j_ -th column of V, the (i,j) element of V
v - a vector reshaped from V
v ˆ - the restriction of v to free nodes
Given matrices A _,_ B _∈_ R <sup>_p×q_</sup> _,_ the following operators are used:
tr( A ) - the trace of matrix (for _p_ = _q_ )
det( A ) - the determinant of matrix (for _p_ = _q_ )
A _⊙_ B - the elementwise (Hadamard) product defined as a matrix C _∈_ R <sup>_p×q_</sup>, where _ci,j_ = _ai,j bi,j_
- _q_
_j_ =1
- _q_
_j_ =1
A : B - the scalar product defined as A : B =
- _p_
_i_ =1
_ai,jbi,j_ =
- _p_
_i_ =1
A _⊙_ B
### 3 Finite element discretization
The finite element method [5] is applied for the discretization of (1). We assume a trial function
and a trial space of the form
v ( x ) = ( _v_ <sup>(1)</sup> ( x ) _, . . ., v_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup> ( x )) _,_ _V_ = _V_ <sup>(1)</sup> _× . . . × V_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup>
and approximate v ( x ) _∈_ _V_ in the finite-dimensional subspace
_Vh_ = _Vh_ <sup>(1)</sup>
_h_ <sup>(1)</sup> _× . . . × Vh_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup>
_h_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup> _⊂_ _V,_
where _Vh_ <sup>(1)</sup>
_h_ <sup>(1)</sup> = _. . ._ = _Vh_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup>
_h_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup> := _Vh_ <sup>_s_</sup>
_h_ <sup>_s_</sup> <sup>and</sup> <sup>the</sup> <sup>scalar</sup> <sup>basis</sup> <sup>space</sup> <sup>_V_</sup> _h_ <sup>_s_</sup>
where _Vh_ <sup>(1)</sup> = _. . ._ = _Vh_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup> := _Vh_ <sup>_s_</sup> <sup>and</sup> <sup>the</sup> <sup>scalar</sup> <sup>basis</sup> <sup>space</sup> <sup>_V_</sup> _h_ <sup>_s_</sup> <sup>is</sup> <sup>generated</sup> <sup>from</sup> <sup>the</sup> <sup>scalar</sup> <sup>basis</sup>
functions
_ϕi_ ( x ) _∈_ _Vh_ <sup>_s,_</sup> _i ∈{_ 1 _, . . ., nb},_
where _nb_ denotes their number. Hence, any component of v ( x ) is given by a linear combination
_vi_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> _ϕi_ ( x ) _,_ x _∈_ Ω _,_ _j_ _∈{_ 1 _, . . ., d}._ (6)
4
_v_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> ( x ) =
_nb_
_i_ =1
The coefficients _vi_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> from (6) are assembled in a matrix V _∈_ R <sup>_nb×d_</sup> given as
1 1
... ...
... ...
_vn_ <sup>(1)</sup> _b_ _. . ._ _vn_ <sup>(</sup>
_n_ <sup>(1)</sup> _b_ _. . ._ _vn_ <sup>(</sup> <sup>_d_</sup> _b_ <sup>)</sup>
1 <sup>(1)</sup> _. . ._ _v_ 1 <sup>(</sup> <sup>_d_</sup> <sup>)</sup>
_v_ 1 <sup>(1)</sup>
v 1
...
...
v _nb_
=
- v <sup>(1)</sup> _. . ._ v <sup>(</sup> <sup>_d_</sup> <sup>)�</sup>
(7)
V =
=
_nb_
and latter two equivalent forms assume a row vector v _i_ = ( _vi_ <sup>(1)</sup>
_i_ <sup>(1)</sup> _, . . ., vi_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup>
and latter two equivalent forms assume a row vector v _i_ = ( _vi_ <sup>(1)</sup> _, . . ., vi_ <sup>(</sup> <sup>_d_</sup> <sup>)</sup> ) _,_ _i ∈{_ 1 _, . . ., nb}_, and a
column vector v <sup>(</sup> <sup>_j_</sup> <sup>)</sup> = ( _v_ 1 <sup>(</sup> <sup>_j_</sup> <sup>)</sup> <sup>_, . . ., v_</sup> _n_ <sup>(</sup> <sup>_j_</sup> _b_ <sup>))</sup> <sup>_T,_</sup> <sup>_j_</sup> <sup>_∈{_</sup> <sup>1</sup> <sup>_, . . ., d}_</sup> <sup>.</sup> <sup>Using</sup> <sup>a</sup> <sup>row</sup> <sup>vector</sup> <sup>basis</sup> <sup>function</sup>
1 <sup>(</sup> <sup>_j_</sup> <sup>)</sup> <sup>_, . . ., v_</sup> _n_ <sup>(</sup> <sup>_j_</sup> _b_ <sup>))</sup> <sup>_T,_</sup> <sup>_j_</sup> <sup>_∈{_</sup> <sup>1</sup> <sup>_, . . ., d}_</sup> <sup>.</sup> <sup>Using</sup> <sup>a</sup> <sup>row</sup> <sup>vector</sup> <sup>basis</sup> <sup>function</sup>
_,_ _i ∈{_ 1 _, . . ., nb}_
_ϕ_ _i_ ( x ) = ( _ϕi_ ( x ) _, . . ., ϕi_ ( x ))
<u>�</u> <u>��</u> <u>�</u>
_d −_ times
one can rewrite (6) in a compact way for all components _j_ _∈{_ 1 _, . . ., d}_ as
v ( x ) =
_nb_
_i_ =1
v _i ⊙_ _ϕ_ _i_ ( x ) _,_ _x ∈_ Ω _,_ (8)
where the symbol _⊙_ represents an elementwise (or Hadamard) multiplication (here multiplication
of components with the same index _j_ ). Formula (8) is the key tool for a vectorized implementation, since MATLAB provides the elementwise multiplication.
The domain Ωis then approximated by its triangulation _T_ into closed elements in the sense
of Ciarlet [5]. The simplest possible elements are considered, i.e., triangles for _dim_ = 2 and
tetrahedra for _dim_ = 3. The elements are geometrically specified by their nodes (or vertices)
belonging to the set of nodes _N_ . The nodes are also clustered into elements edges (for _dim ≥_ 2)
and faces (for _dim_ = 3). The numbers of elements and nodes are denoted as _|T |_ and _|N|_ .
Given a node _Ni_ _∈N_ _, i ∈{_ 1 _, . . ., |N|}_, we define a nodal patch _T_ <sup>_i_</sup> by
_T_ <sup>_i_</sup> = _{T_ _∈T_ : _Ni_ _∈_ _T_ _}_
and the number of its elements by _|T_ <sup>_i_</sup> _|_ . The nodal patch _T_ <sup>_i_</sup> consists of elements denoted as
_Tk_ <sup>_i_</sup> <sup>_,_</sup> <sup>_k_</sup> <sup>_∈{_</sup> <sup>1</sup> <sup>_, . . ., |T_</sup> <sup>_i|}_</sup> <sup>,</sup> <sup>which</sup> <sup>are</sup> <sup>adjacent</sup> <sup>to</sup> <sup>the</sup> <sup>node</sup> <sup>_Ni_</sup> <sup>.</sup> <sup>The</sup> <sup>same</sup> <sup>nodal</sup> <sup>patch</sup> <sup>_T_</sup> <sup>_i_</sup> <sup>can</sup> <sup>be</sup>
alternatively denoted by _T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>, where _i_ = _IDN_ ( _n_ ) and _n_ is the index of one of the corresponding
degrees of freedom.
We consider only the case where _Vh_ <sup>_s_</sup> <sup>=</sup> <sup>_P_</sup> <sup>1(</sup> <sup>_T_</sup> <sup>)</sup> <sup>is</sup> <sup>the</sup> <sup>space</sup> <sup>of</sup> <sup>nodal,</sup> <sup>elementwise</sup> <sup>linear</sup> <sup>and</sup>
globally continuous scalar basis functions. Then the number of basis functions is equal to the
number of nodes
_nb_ = _|N|,_
but some coefficients of the trial function v ( x ) are known due to the Dirichlet boundary conditions.
Example 1 _One_ _regular_ _triangulation_ _T_ _of_ _an_ _L-shape_ _domain_ Ω _is_ _shown_ _in_ _Fig._ _1._ _The_
_triangulation_ _is_ _specified_ _by_ _|T |_ = 24 _and_ _|N|_ = 21 _._ _The_ _graph_ _of_ _the_ _global_ _scalar_ _basis_ _function_
_ϕ_ 10( _x_ ) _is_ _displayed._ _The_ _function_ _has_ _a_ _hexagonal_ _pyramid_ _shape_ _and_ _the_ _support_ _on_ _the_ _nodal_
_patch_
_T_ <sup>10</sup> = _{T_ 1 _, T_ 2 _, T_ 7 _, T_ 8 _, T_ 19 _, T_ 20 _}._
_The_ _restrictions_ _of_ _ϕ_ 10( _x_ ) _to_ _its_ _six_ _supporting_ _triangles_ _in_ _T_ <sup>10</sup> _are_ _given_ _as_ _linear_ _functions_ _with_
_values_ _1_ _at_ _the_ _node_ _N_ 10 _and_ _values_ _0_ _at_ _the_ _two_ _remaining_ _nodes._
5
Figure 1: Example of a scalar nodal basis function for _dim_ = 2.
_Additionally,_ _for_ _the_ _scalar_ _case_ _(d_ = 1 _)_ _the_ _node_ _N_ 10 _has_ _only_ _one_ _corresponding_ _degree_ _of_
_freedom_ _with_ _index_ 10 _and,_ _therefore,_ _T_ <sup>(10)</sup> = _T_ <sup>10</sup> _as_ _long_ _as_ _IDN_ (10) = 10 _._ _For_ _the_ _vector_ _case_
_(d_ = 2 _)_ _the_ _same_ _node_ _N_ 10 _has_ _two_ _corresponding_ _degrees_ _of_ _freedom_ _with_ _indices_ 19 _,_ 20 _,_ _hence,_
_T_ <sup>(19)</sup> = _T_ <sup>(20)</sup> = _T_ <sup>10</sup> _as_ _long_ _as_ _IDN_ (19) = _IDN_ (20) = 10 _._ _This_ _alternative_ _notation_ _is_ _essential_
_in_ _Section_ _6._
3.1 The first-gradient energy term _Jgrad_ ( v )
Since the first gradient of any scalar basis function _ϕi_ ( x ) _∈_ _P_ <sup>1</sup> ( _T_ ) _,_ _i ∈{_ 1 _, . . ., |N|}_, is a piecewise
constant function on each element, the gradient part of the discrete energy can be written as a
sum over the elements
_|T |_
_k_ =1
_|Tk| W_
_|T |_
_k_ =1
_Tk_
- _∇_ v ( x )�� _Tk_
- _,_ (9)
- _∇_ v ( x )� d x =
_Jgrad_ ( v ) =
Ω
_W_
- F ( v ( x ))� d x =
_W_
and _|Tk|_ denotes the size of the element _Tk,_ _k_ _∈{_ 1 _, . . ., |T |}_ (equal to its length in 1D, its area
in 2D or its volume in 3D). In order to evaluate (9), we need to assemble the gradient v ( x ) _|Tk_ on
every element. To do it, we define a (local-global) mapping _ILG_ : N _×_ N _→_ N which for the _k_ -th
element and its _ℓ_ -th node returns the global index _i_ of this node. Then a local basis function is
given as
_ϕ_ _k,ℓ_ ( _x_ ) = _ϕ_ _i_
�� _Tk_ <sup>(</sup> <sup>_x_</sup> <sup>)</sup> <sup>_,_</sup> where _i_ = _ILG_ ( _k, ℓ_ ) (10)
for _k_ _∈{_ 1 _, . . ., |T |},_ _ℓ_ _∈{_ 1 _, . . ., dim_ + 1 _}_ . Hence, any partial derivative of v ( x ) with respect to
_xm_ reads
_<u>∂</u>_ <u>v</u> <u>(</u> <u>x</u> <u>)</u>
_∂xm_
���� _Tk_
=
_dim_ +1
_ℓ_ =1
v _k,ℓ_ _⊙_ <sup>_∂_</sup> <sup>_ϕ_</sup> <sup>_<u>k,ℓ</u>_</sup> <sup>(</sup> <sup>x</sup> <sup>)</sup>
_∂xm_
_,_ _m ∈{_ 1 _, . . ., dim},_ (11)
where v _k,ℓ_ = v _ILG_ ( _k,ℓ_ ) represents the values of v in the _ℓ_ -th node of the _k_ -th element.
6
3.2 The linear energy term _Jlin_
Furthermore, if f ( x ) _∈_ _Vh_, then the linear term of the energy (2) rewrites as
_fi_ <sup>(</sup> 1 <sup>_j_</sup> <sup>)</sup>
_i_ <sup>(</sup> 1 <sup>_j_</sup> <sup>)</sup> <sup>_v_</sup> _i_ <sup>(</sup> 2 <sup>_j_</sup> <sup>)</sup>
_d_
_j_ =1
Ω
_f_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> ( x ) _v_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> ( x ) d x =
_Jlin_ ( v ) =
Ω
=
=
f ( x ) _·_ v ( x ) d x =
_d_
_j_ =1
_d_
_j_ =1
_|N|_ _|N |_
-
_i_ 1=1 _i_ 2=1
(12)
Ω
- _|N |_
_i_ 1=1
_f_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup>
_i_ 1 <sup>_ϕi_</sup> 1 <sup>(</sup> <sup>x</sup> <sup>)</sup>
_f_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup>
_i_ 1
_|N |_
_i_ 2=1
_v_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup>
_i_ 2
<sup>(</sup> <sup>_j_</sup> <sup>)</sup>
_i_ 2 <sup>_ϕi_</sup> 2 <sup>(</sup> <sup>x</sup> <sup>)</sup>
d x =
_i_ 2
- _ϕi_ 1( x ) _ϕi_ 2( x ) d x _._
Ω
All integral terms in the formula above can be assembled in a sparse and symmetric mass matrix
M _∈_ R <sup>_|N|×|N |_</sup> with entries
M _i_ 1 _,i_ 2 =
Ω
_ϕi_ 1( x ) _ϕi_ 2( x ) d x _,_ _i_ 1 _, i_ 2 _∈{_ 1 _,_ 2 _, . . ., |N|}._ (13)
Then we can define vectors b <sup>(</sup> <sup>_j_</sup> <sup>)</sup> = M f <sup>(</sup> <sup>_j_</sup> <sup>)</sup> _∈_ R <sup>_|N |_</sup> _,_ where f <sup>(</sup> <sup>_j_</sup> <sup>)</sup> = ( _f_ 1 <sup>(</sup> <sup>_j_</sup> <sup>)</sup> <sup>_, . . ., f_</sup> _|N |_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> <sup>)</sup> <sup>_T_</sup> <sup>_∈_</sup> <sup>R</sup> <sup>_|N |,_</sup> <sup>_j_</sup> <sup>_∈_</sup>
_{_ 1 _, . . ., d}_ and it is easy to check the exact formula
_d_
_j_ =1
_Jlin_ ( v ) =
f ( x ) _·_ v ( x ) d x =
Ω
b <sup>(</sup> <sup>_j_</sup> <sup>)</sup> _·_ v <sup>(</sup> <sup>_j_</sup> <sup>)</sup> (14)
which allows us to represent the linear part of the discrete energy _J_ ( v ) as a linear function.
### 4 Implementation: Mesh and nodal patches
We describe the typical properties of meshes and nodal patches needed in our computational
techniques. Considered finite element meshes consist of triangles (in 2D) and tetrahedra (in 3D),
however detailed explanations of Sections 4, 5, 6 address 3D version only.
Figure 2: Example: A tetrahedral mesh of a 3D bar domain with red boundary nodes.
4.1 The ’mesh’ structure
The topology and important attributes of the computational domain are stored in the structuretype data object ’ mesh ’. For the example of a tetrahedral mesh displayed in Fig. 2, a vector
energy model and full Dirichlet boundary conditions (specified in all three directions and indicated by the nodes in red circles) it provides the following information:
7
```
mesh =
struct with fields:
dim: 3
level: 1
nn: 729
ne: 1920
elems2nodes: [1920×4 double]
nodes2coord: [729×3 double]
volumes: [1920×1 double]
dphi: {[1920×4 double] [1920×4 double] [1920×4 double]}
nodesDirichlet: [18×1 double]
nodesMinim: [711×1 double]
dofsDirichlet: [54×1 double]
dofsMinim: [2133×1 double]
```
Parameter dim represents the domain dimension (here _dim_ = 3) of the problem and level the
level of a uniform refinement. Higher levels of refinement lead to finer uniformly refined meshes
with more elements. The numbers of mesh nodes and elements are provided in nn and ne . Mesh
nodes belonging to each tetrahedron are collected in a matrix ’ elems2nodes ’ and the Cartesian
coordinates of mesh nodes in a matrix ’ nodes2coord ’.
Once the last two matrices are given, the codes of [15] generate the ’ volumes ’ of all tetrahedra
together with the restrictions of the partial derivatives (gradients) of all P1-basis functions to
tetrahedra stored in a cell ’ dphi ’ whose components are matrices corresponding to the partial
derivates with respect to every _xm,_ _m ∈{_ 1 _, . . ., dim}_ .
The indices of Dirichlet boundary nodes are stored in a vector ’ nodesDirichlet ’ and the
remaining free nodes in a vector ’ nodesMinim ’. Vectors ’ dofsDirichlet ’ and ’ dofsMinim ’
denote the indices of the degrees of freedom corresponding to Dirichlet and free nodes.
Remark 1 _Vectors_ _’_ _dofsDirichlet_ _’_ _and_ _’_ _dofsMinim_ _’_ _are_ _equal_ _to_ _vectors_ _’_ _nodesDirichlet_ _’_
_and_ _’_ _nodesMinim_ _’_ _in_ _case_ _of_ _a_ _scalar_ _energy_ _formulation._
4.2 The ’patches’ structure
This object is only relevant if the knowledge of gradient _∇J_ ( v ) is required, e.g. as an input of
the trust-region method of Section 7. Then, the additional structure-type data object ’ patches ’
is constructed for the evaluation of its gradient part given by (9).
Remark 2 _Only_ _the_ _components_ _of_ _∇J_ ( _v_ ) _corresponding_ _to_ _free_ _nodes_ _are_ _evaluated_ _in_ _our_ _im-_
_plementation,_ _and_ _the_ _remaining_ _components_ _belonging_ _to_ _the_ _full_ _Dirichlet_ _boundary_ _conditions_
_are_ _omitted._ _Thus,_ _the_ _nodes_ _with_ _at_ _least_ _one_ _free_ _degree_ _of_ _freedom_ _also_ _belong_ _to_ _the_ _set_ _of_
_free_ _nodes_ _and_ _the_ _gradient_ _is_ _evaluated_ _in_ _all_ _of_ _their_ _components_ _and_ _finally_ _restricted_ _to_ _free_
_degrees_ _of_ _freedom._
We denote by _M_ a set of all free nodes and by _|M|_ their number. Then, the node index
_i, i ∈{_ 1 _, . . ., |M|}_, goes exclusively through the free nodes. A nodal patch _T_ <sup>_i_</sup> _,_ _i ∈{_ 1 _, . . ., |M|}_
is implemented as a vector of elements indices ’ elems _~~i~~_ ’, a vector of their volumes ’ volumes _~~i~~_ ’,
8
a matrix of the corresponding elements nodes stored as ’ elems2nodes _~~i~~_ ’, values of the gradients of local basis functions stores as a cell ’ dphi _~~i~~_ ’ with matrices components dphi _~~i~~_ _{_ 1 _}_,
_. . ._, dphi _i_ _{dim}_ . All these matrices and vectors are of size _|T_ <sup>_i_</sup> _|_ _×_ ( _dim_ + 1) and _|T_ <sup>_i_</sup> _|_ _×_ 1,
respectively.
The data of all nodal patches _T_ <sup>_i_</sup> _,_ _i_ _∈{_ 1 _, . . ., |M|}_ are then collected in the corresponding
long global matrices or vectors with the number of rows equal to
_∥T ∥_ =
For _i ∈{_ 1 _, . . ., |M|}_ we define the indices
_|M|_
_i_ =1
_|T_ <sup>_i_</sup> _| ._
_pi_ =
_i_
_r_ =1
_|T_ <sup>_r_</sup> _|,_ (15)
and additionally _p_ 0 = 0. Then the submatrix or subvector extracted from rows ( _pi−_ 1+1) _, . . ., pi_ of
the global matrices or vector above corresponds to the _i_ -th nodal patch. It is shown schematically
in Fig. 3.
1
_|T_ <sup>1</sup> _|_ rows
_p_ 1
_p|M_ _|−_ 1 + 1
_|T_ <sup>_|M_</sup> <sup>_|_</sup> _|_ rows
_p|M_ _|_
_∥T ∥_ rows
_T_ <sup>1</sup>
...
_T_ <sup>_|M_</sup> <sup>_|_</sup>
Figure 3: All data from nodal patches are stored in long matrices or vectors.
Thus we obtain the global vectors ’ elems ’, ’ volumes ’ of size _∥T ∥×_ 1 and the global matrices
’ elems2nodes ’, dphi _{_ 1 _}_, _. . ._, dphi _{dim}_, of size _∥T ∥×_ ( _dim_ + 1).
Remark 3 _For_ _the_ _gradient_ _evaluation_ _of_ _Section_ _6_ _we_ _will_ _need_ _to_ _extend_ _a_ _set_ _of_ _pi,_ _i_ _∈_
_{_ 0 _, . . ., |M|},_ _indices_ _up_ _to_ _{_ 0 _, . . ., d|M|}._ _Thus,_ _we_ _additionally_ _define_
_pn_ = _pn −|M|_ + _∥T ∥_ _,_ _n ∈{_ _|M|_ + 1 _, . . .,_ 2 _|M|}_
(16)
_pn_ = _pn−_ 2 _|M|_ + 2 _∥T ∥_ _,_ _n ∈{_ 2 _|M|_ + 1 _, . . .,_ 3 _|M|} ._
9
In order to maintain the right ordering of the local basis functions within each nodal patch, an
additional logical-type matrix of zeros and ones ’ logical ’ is provided. If the _n_ -th row corresponds
to the _i_ -th patch, then logical ( _n, ℓ_ ) = 1 means that elems2nodes ( _n, ℓ_ ) = _i_ . Therefore, in every
row of ’ logical ’ matrix the value ’1’ has exactly one single occurrence.
Below we provide an example of the ’ patches ’ structure along with the same ’ mesh ’ one
introduced in Subsection 4.1 and corresponding to the domain in Fig. 2.
```
patches =
struct with fields:
lengths: [711×1 double]
elems: [7584×1 double]
volumes: [7584×1 double]
elems2nodes: [7584×4 double]
dphi: {[7584×4 double] [7584×4 double] [7584×4 double]}
logical: [7584×4 logical]
```
The first vector ’ lengths ’ is of size _|M| ×_ 1 with entries lengths ( _i_ ) = _|T_ <sup>_i_</sup> _|,_ _i_ _∈{_ 1 _, . . ., |M|}_ .
Here, its size is equal to 711 = 729 _−_ 18, where _|N|_ = 729 is the number of mesh nodes and 18
is the number of nodes with full Dirichlet boundary conditions.
Benchmark 1 _The_ _script_ _`benchmark1_start.m`_ _generates_ _a_ _sequence_ _of_ _the_ _structures_ _`mesh`_ _and_
_`patches`_ _corresponding_ _to_ _each_ _of_ _the_ _uniform_ _mesh_ _refinements._ _Table_ _1_ _provides_ _the_ _assembly_
_times_ _and_ _the_ _memory_ _requirements_ _of_ _both_ _objects._
number
of elems.
number
of free
mesh
patches
patches
mesh
level
number
of nodes
of nodes of elems. of free setup setup memory memory
_<u>|N|</u>_ _<u>|T |</u>_ <u>dofs</u> <u>time</u> <u>[s]</u> <u>time</u> <u>[s]</u> <u>size</u> <u>[MB]</u> <u>size</u> <u>[MB]</u>
1 729 1920 2133 0.01 0.01 0.30 1.13
2 4025 15360 11925 0.02 0.02 2.32 9.07
3 26001 122880 77517 0.06 0.13 18.17 72.73
4 185249 983040 554013 0.51 0.98 144.07 582.53
5 1395009 7864320 4178493 5.56 10.62 1147.67 4663.18
setup
<u>time</u> <u>[s]</u>
mesh
memory
<u>size</u> <u>[MB]</u>
_<u>|N|</u>_
_<u>|T |</u>_
<u>dofs</u>
setup
<u>time</u> <u>[s]</u>
Table 1: Benchmark 1 - setup times and memory consumption in 3D.
_Note_ _that_ _the_ _most_ _memory_ _consuming_ _part_ _of_ _both_ _structures_ _is_ _given_ _by_ _substructures_ _’_ _dphi_ _’_
_containing_ _the_ _values_ _of_ _the_ _precomputed_ _gradients_ _of_ _basis_ _functions._
### 5 Implementation: energy evaluation
The following matrix-vector transformation is frequently used: matrices B _,_ V _∈_ R <sup>_|N |×d_</sup> are
stretched to the isomorphic vectors
b _,_ v _∈_ R <sup>_d|N|_</sup> : b _n_ = B _i,j,_ v _n_ = V _i,j,_ _n ∈{_ 1 _, . . ., d|N|},_ (17)
where _i_ = ( _n −_ 1) _/d_ + 1 and _j_ = ( _n −_ 1)% _d_ + 1. Here, _/_ symbol is the integer division operator
and % is the modulo operator. Put simply, for any _i ∈{_ 1 _, . . ., |N|}_ the elements of v with indices
10
_d_ ( _i −_ 1) + 1 _, . . ., d_ ( _i −_ 1) + _d_ corresponds to the values of the trial function v ( x ) in the _i_ -th node
in the directions 1 _, . . ., d_ .
5.1 The linear energy term _Jlin_
The linear part of the energy (14) rewrites equivalently as
_Jlin_ ( v ) =
f ( x ) _·_ v ( x ) d x = B : V = b _·_ v _,_ (18)
Ω
where : denotes the scalar product of matrices.
5.2 The first-gradient energy term _Jgrad_
The gradient part of the discrete energy (9) is given as a sum of the energy contributions from
every element _Tk,_ _k_ _∈{_ 1 _, . . ., |T |}_ and its evaluation in MATLAB is performed effectively by
using operations with vectors and matrices only. The energy evaluation for a trial vector v _∈_
R <sup>_d|N|_</sup> is performed by the main function:
1 <mark>f u n c t i o n</mark> <mark>[ e,</mark> <mark>d e n s i t i e s</mark> <mark>]</mark> <mark>=</mark> <mark>energy ( v, mesh, params )</mark>
2 <mark>%</mark> <mark>components</mark> <mark>of</mark> <mark>deformation</mark>
3 <mark>v</mark> <mark>c e l l</mark> <mark>=</mark> <mark>createCellFromVector ( v, mesh . dim ) ;</mark>
4
5 <mark>%</mark> <mark>components</mark> <mark>of</mark> <mark>deformation</mark> <mark>on</mark> <mark>elements</mark>
6 <mark>v</mark> <mark>elems</mark> <mark>=</mark> <mark>C e l l A t M a t r i x O f I n d i c e s ( v</mark> <mark>c e l l</mark> <mark>, mesh . elems2nodes ) ;</mark>
7
8 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>on</mark> <mark>elements</mark>
9 <mark>F</mark> <mark>elems</mark> <mark>=</mark> <mark>e v a l u a t e</mark> <mark>F ( mesh,</mark> <mark>v</mark> <mark>elems ) ;</mark>
10
11 <mark>%</mark> <mark>g r a d i e n t</mark> <mark>d e n s i t i e s</mark> <mark>on</mark> <mark>elements</mark>
12 <mark>d e n s i t i e s</mark> <mark>.</mark> <mark>Gradient</mark> <mark>=</mark> <mark>densityGradientVector</mark> <mark>3D ( F</mark> <mark>elems</mark> <mark>, params ) ;</mark>
13
14 <mark>%</mark> <mark>t o t a l</mark> <mark>g r a d i e n t</mark> <mark>energy</mark>
15 <mark>e</mark> <mark>=</mark> <mark>sum</mark> <mark>( mesh . volumes .</mark> <mark>∗</mark> <mark>d e n s i t i e s</mark> <mark>.</mark> <mark>Gradient ) ;</mark>
16 <mark>end</mark>
The structure ’ mesh ’ is described in Section 5 and the ’ params ’ contains material parameters
apart from some other parameters (e.g. visualization parameters). The code above is vectorized
and generates the objects:
A cell ’ v ~~e~~ lems ’ containing matrices v ~~e~~ lems _{_ 1 _}_, v ~~e~~ lems _{_ 2 _}_, v ~~e~~ lems _{_ 3 _}_ of size _|T |_ _×_ 4
providing the restrictions of nodal deformations to all elements.
A cell ’ F elems ’ of size _dim×dim_ storing the deformation gradients (see (3)) in all elements. In
particular, F elems _{d}{m}_ is then a vector of size _|T |×_ 1 evaluating the partial derivatives
of the _d_ -th component of deformation with respect to the _m_ -th variable in all elements.
A vector ’ densities.Gradient ’ of size _|T | ×_ 1 containing gradient densities in all elements.
The energy e is given as a sum of the gradient energy contributions over the elements (the
gradient part _Jgrad_ ( v ) given by (9)) subtracted by the linear energy term _Jlin_ ( v ) (given
by (14)).
The Neo-Hookean density function _W_ = _W_ ( _F_ ) from (4) is implemented as
11
1 <mark>f u n c t i o n</mark> <mark>d e n s i t i e s=densityGradientVector</mark> <mark>3D (F, params )</mark>
2 <mark>%</mark> <mark>determinant</mark> <mark>term</mark>
3 <mark>DET</mark> <mark>=</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,1</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,2</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,3</mark> _<mark>}</mark>_ <mark>+</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,3</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,1</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,2</mark> _<mark>}</mark>_ <mark>+</mark> <mark>. . .</mark>
4 <mark>F</mark> _<mark>{</mark>_ <mark>1,2</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,3</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,1</mark> _<mark>}</mark>_ <mark>−</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,3</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,2</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,1</mark> _<mark>}</mark>_ <mark>−</mark> <mark>. . .</mark>
5 <mark>F</mark> _<mark>{</mark>_ <mark>1,2</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,1</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,3</mark> _<mark>}</mark>_ <mark>−</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,1</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,3</mark> _<mark>}</mark>_ <mark>.</mark> <mark>∗</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,2</mark> _<mark>}</mark>_ <mark>;</mark>
6
7 <mark>%</mark> <mark>I1</mark> <mark>term</mark> <mark>( Frobenius</mark> <mark>norm</mark> <mark>squared )</mark>
8 <mark>I1</mark> <mark>=</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,1</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,2</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,3</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>. . .</mark>
9 <mark>F</mark> _<mark>{</mark>_ <mark>2,1</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,2</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2,3</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>. . .</mark>
10 <mark>F</mark> _<mark>{</mark>_ <mark>3,1</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,2</mark> _<mark>}</mark>_ <mark>.ˆ2</mark> <mark>+</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,3</mark> _<mark>}</mark>_ <mark>.ˆ2;</mark>
11
12 <mark>%</mark> <mark>g r a d i e n t</mark> <mark>d e n s i t i e s</mark>
13 <mark>d e n s i t i e s</mark> <mark>=</mark> <mark>params . C1</mark> <mark>∗</mark> <mark>( I1 −3−2∗</mark> <mark>log (DET) )</mark> <mark>+</mark> <mark>params . D1∗</mark> <mark>(DET−1) . ˆ 2 ;</mark>
14 <mark>end</mark>
Benchmark 2 _Assume_ _a_ _bar_ _domain_ Ω= (0 _, lx_ ) _×_ ( _−_ <sup>_<u>l</u>_</sup> 2 <sup>_<u>y</u>_</sup> <sup>_,_</sup> <sup>_<u>l</u>_</sup> 2 <sup>_<u>y</u>_</sup> <sup>)</sup> <sup>_×_</sup> <sup>(</sup> <sup>_−_</sup> <sup>_<u>l</u>_</sup> 2 <sup>_<u>z</u>_</sup> <sup>_,_</sup> <sup>_<u>l</u>_</sup> 2 <sup>_<u>z</u>_</sup> <sup>)</sup> <sup>_,_</sup> <sup>_where_</sup> <sup>_lx_</sup> <sup>=</sup> <sup>0</sup> <sup>_._</sup> <sup>4</sup> <sup>_, ly_</sup> <sup>=</sup>
_lz_ = 0 _._ 01 _,_ _specified_ _by_ _the_ _material_ _parameters_ _E_ = 2 _·_ 10 <sup>8</sup> _(Young’s_ _modulus)_ _and_ _ν_ = 0 _._ 3
_(Poisson’s_ _ratio)_ _and_ _deformed_ _by_ _the_ _prescribed_ _deformation_ _v_ ( _x_ ) = _v_ ( _x, y, z_ ) _given_ _by_
_v_ <sup>(1)</sup> ( _x, y, z_ ) = _x,_
_v_ <sup>(2)</sup> ( _x, y, z_ ) = cos( _α_ <sup>_<u>x</u>_</sup>
_lx_
_v_ <sup>(2)</sup> ( _x, y, z_ ) = cos( _α_ <sup>_<u>x</u>_</sup>
_lx_
_v_ <sup>(3)</sup> ( _x, y, z_ ) = _−_ sin( _α_ <sup>_<u>x</u>_</sup>
_lx_
(19)
_v_ <sup>(3)</sup> ( _x, y, z_ ) = _−_ sin( _α_ <sup>_<u>x</u>_</sup>
) _y_ + sin( _α_ <sup>_<u>x</u>_</sup>
_lx_
) _y_ + cos( _α_ <sup>_<u>x</u>_</sup>
_lx_
) _z,_
) _z,_
_or,_ _equivalently,_ _using_ _matrix_ _operations_
_v_ <sup>(1)</sup> ( _x, y, z_ )
_v_ <sup>(2)</sup> ( _x, y, z_ )
_v_ <sup>(3)</sup> ( _x, y, z_ )
_l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup>
_x_
_y_
_z_
1 0 0
0 cos( _α_ _l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup> sin( _α_
0 cos( _α_ _l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup> sin( _α_ _l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup>
0 _−_ sin( _α_ _l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup> cos( _α_ _l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup>
=
_l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup> sin( _α_ _l_ <sup>_<u>x</u>_</sup> _x_
_l_ <sup>_<u>x</u>_</sup> _x_ <sup>)</sup> cos( _α_ _l_ <sup>_<u>x</u>_</sup> _x_
_._ (20)
_Here,_ _α_ = 2 _π_ _means_ _that_ _the_ _right_ _Dirichlet_ _wall_ _is_ _twisted_ _once_ _around_ _the_ _x-axes_ _(Fig._ _4)._
_Constants_ _C_ 1 _, D_ 1 _are_ _transformed_ _according_ _to_ _the_ _formulas_ _C_ 1 = <sup>_<u>µ</u>_</sup> 2 <sup>_, D_</sup> <sup>1</sup> <sup>=</sup> <sup>_<u>K</u>_</sup> 2 <sup>_,_</sup> <sup>_where_</sup> <sup>_µ_</sup> <sup>=</sup> 2(1+ _<u>E</u>_ _ν_ )
_is_ _the_ _shear_ _modulus_ _and_ _K_ = 3(1 _−E_ 2 _ν_ ) <sup>_is_</sup> <sup>_the_</sup> <sup>_bulk_</sup> <sup>_modulus._</sup> <sup>_The_</sup> <sup>_exact_</sup> <sup>_evaluation_</sup> <sup>_shows_</sup> <sup>_that_</sup> <sup>_the_</sup>
_corresponding_ _gradient_ _energy_ _using_ _the_ _Neo-Hookean_ _density_ _function_ (4) _reads_
_Jgrad_ ( _v_ ) = <sup>_α_</sup> <sup>2</sup> <sup>_C_</sup> <sup>1</sup> <sup>_ly_</sup> <sup>_lz_</sup> <sup>(</sup> <sup>_l_</sup> _<u>y</u>_ <sup>2</sup>
_<u>y</u>_ <sup>2</sup> <sup>+</sup> <sup>_l_</sup> _<u>z</u>_ <sup>2</sup>
_<u>y</u>_ <sup>+</sup> <sup>_l_</sup> _<u>z</u>_ <sup>2)</sup>
<sup>_y_</sup> <sup>_lz_</sup> <sup>(</sup> <sup>_l_</sup> <sup>2</sup> _≈_ 6 _._ 326670 _._
12 _lx_
_The_ _script_ _`benchmark2_start.m`_ _evaluates_ _an_ _approximation_ _of_ _Jgrad_ ( _v_ ) _on_ _the_ _sequence_ _of_ _the_
_uniform_ _mesh_ _refinements_ _defined_ _in_ _Benchmark_ _1._ _In_ _order_ _to_ _provide_ _higher_ _accuracy_ _of_ _the_
_evaluation_ _times,_ _the_ _energies_ _are_ _recomputed_ _10_ _times._ _Table_ _2_ _provides_ _evaluation_ _times_ _and_
_values_ _of_ _the_ _energy_ _approximations_ _(times_ _for_ _setting_ _up_ _the_ _’_ _mesh_ _’_ _structure_ _are_ _not_ _included)._
Figure 4: A bar domain twisted by the prescribed deformation (19).
12
mesh
<u>level</u>
number of free dofs evaluation (10x) of
_<u>Jgrad</u>_ <u>(</u> <u>v</u> <u>):</u> <u>time</u> <u>[s]</u>
value of _Jgrad_ ( v )
1 2133 0.01 12.6623
2 11925 0.02 7.9083
3 77517 0.08 6.7219
4 554013 0.76 6.4255
5 4178493 12.82 6.3514
Table 2: Benchmark 2 - energy evaluation times in 3D.
### 6 Implementation: energy gradient evaluation
Evaluation of the full gradient _∇J_ ( v ) _,_ where v = ( _v_ 1 _, . . ., vd|N |_ ) _∈_ R <sup>_d|N |_</sup>, requires in general
computation of all partial derivatives <sup>_<u>∂J</u>_</sup> _∂v_ <sup><u>(</u></sup> _n_ <sup><u>v</u></sup> <sup><u>)</u></sup> <sup>,</sup> <sup>_n_</sup> <sup>_∈{_</sup> <sup>1</sup> <sup>_, . . ., d|N|}_</sup> <sup>.</sup> <sup>Some</sup> <sup>minimization</sup> <sup>methods</sup>
(e.g. trust-region mentioned applied in Section 7) require the knowledge of gradient, but only
restricted to free degrees of freedom.
The gradient _∇Jlin_ ( v ) easily reads using (18)
_∇Jlin_ ( v ) = b _,_ (21)
where b is of size _d|N|_, given by (17) and its restriction to free degrees of freedom is then trivial.
The evaluation of _∇Jgrad_ ( v ) is technically more involved. Firstly, it is evaluated with respect
to Remark 2 for all degrees of freedom belonging to all (at least partially) free nodes. Secondly,
it is restricted to free degrees of freedom only. In order to determine to which node the _n_ -th
active degree of freedom belongs we define the index mapping
_IDN_ : _{_ 1 _, . . ., d|M|} →{_ 1 _, . . ., |M|},_ _IDN_ ( _n_ ) = ( _n −_ 1) _/d_ + 1 (22)
which for the _n_ -th active degree of freedom returns the corresponding _i_ -th free node (here _/_ is
an integer division operator). By
_T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _,_ _n ∈{_ 1 _, . . ., d|M|},_
we denote the set of elements adjacent to node _NIDN_ ( _n_ ) belonging to the _n_ -th active degree
of freedom and by _|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_ their number. The gradient of the nonlinear part _Jgrad_ ( v ) can be
computed in two different ways:
1. numerically, where the partial derivatives are computed approximately by using a difference
scheme.
2. exactly by taking the explicit partial derivatives.
Deriving the exact partial derivatives can be demanding and it depends on the particular problem. On the contrary, the numerical approach is more general and is feasible regardless of
the complexity of the function representing the corresponding discrete energy. Hence, we first
describe the numerical approach by using the central difference scheme and then explain the
gradient evaluation by deriving the explicit form of the partial derivatives.
13
6.1 Numerical approach to evaluate _∇Jgrad_ ( v )
By using the central difference scheme, one can write
_<u>∂</u>_
_Jgrad_ ( v ) _≈_ <sup>_<u>Jgrad</u>_</sup> <sup><u>(</u></sup> <sup><u>v</u></sup> <sup><u>+</u></sup> <sup>_<u>ε</u>_</sup> <sup><u>e</u></sup> <sup>_<u>n</u>_</sup> <sup><u>)</u></sup> <sup>_<u>−</u>_</sup> <sup>_<u>Jgrad</u>_</sup> <sup><u>(</u></sup> <sup><u>v</u></sup> <sup>_<u>−</u>_</sup> <sup>_<u>ε</u>_</sup> <sup><u>e</u></sup> <sup>_<u>n</u>_</sup> <sup><u>)</u></sup> _,_ (23)
_∂vn_ 2 _ε_
where e _n_ is the _n_ -th canonical vector in R <sup>_d|M|_</sup> and _ε_ is a small positive number. Both summands
in the numerator above can be directly evaluated by taking the energy evaluation procedure
introduced in the previous subsection as
_Jgrad_ ( v + _ε_ e _n_ ) _−_ _Jgrad_ ( v _−_ _ε_ e _n_ ) =
_|T |_
_k_ =1 _Tk_
_W_ ( _∇_ ( v _−_ _ε_ e _n_ )) d x _._
=
_|T |_
_k_ =1 _Tk_
_W_ ( _∇_ ( v + _ε_ e _n_ )) d x _−_
However, this approach is ineffective as long as the step of the central difference scheme _ε_ occurs
only in a few summands of the sums representing _Jgrad_ ( v + _ε_ e _n_ ) and _Jgrad_ ( v _−_ _ε_ e _n_ ) given by
(9), while the remaining summands are the same and therefore vanish. Hence, we can further
simplify
_Jgrad_ ( v + _ε_ e _n_ ) _−_ _Jgrad_ ( v _−_ _ε_ e _n_ ) =
_|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_
_k_ =1
_Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>
=
=
_|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_
_k_ =1
_|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_
_k_ =1
_Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>
_|Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|W_
_W_ ( _∇_ ( v + _ε_ e _n_ )) d x _−_
- _∇_ ( v + _ε_ e _n_ )
_W_ ( _∇_ ( v _−_ _ε_ e _n_ )) d x =
�� _Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>
_k_
�� _Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>
_k_
- _−_
_|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_
_k_ =1
_|Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|W_
- _∇_ ( v _−_ _ε_ e _n_ )
- _._
By using the substitutions
_Jgrad_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,−_</sup>
<sup>(</sup> _k_ <sup>_n_</sup> <sup>)</sup> _|W_
- _∇_ ( v _−_ _ε_ e _n_ )
_grad_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,−_</sup> <sup>(</sup> <sup>v</sup> <sup>) =</sup> <sup>_|T_</sup> <sup>(</sup> _k_ <sup>_n_</sup> <sup>)</sup>
<sup>(</sup> _k_ <sup>_n_</sup> <sup>)</sup> _|W_
_grad_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,_</sup> <sup>+(</sup> <sup>v</sup> <sup>) =</sup> <sup>_|T_</sup> <sup>(</sup> _k_ <sup>_n_</sup> <sup>)</sup>
(24)
- _,_ (25)
- _,_ _Jgrad_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,_</sup> <sup>+</sup>
�� _Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>
_k_
- _∇_ ( v + _ε_ e _n_ )
�� _Tk_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup>
_k_
one can rewrite (24)
_Jgrad_ ( v + _ε_ e _n_ ) _−_ _Jgrad_ ( v _−_ _ε_ e _n_ ) =
_|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_
_k_ =1
_Jgrad_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,_</sup> <sup>+(</sup> <sup>v</sup> <sup>)</sup> <sup>_−_</sup>
_|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_
_k_ =1
_Jgrad_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,−_</sup> <sup>(</sup> <sup>v</sup> <sup>)</sup> (26)
and evaluate the whole _∇Jgrad_ ( v ) via the simple for-loop over its components.
Remark 4 _The_ _energy_ _evaluation_ _procedure_ _has_ _to_ _be_ _called_ _in_ _every_ _loop_ _over_ _the_ _vector_ _com-_
_ponents_ _n_ _∈{_ 1 _, . . ., d|M|}_ _and_ _it_ _turned_ _out_ _to_ _cause_ _multiple_ _self_ _built-in_ _times_ _that_ _slowed_
_down_ _performance._ _To_ _avoid_ _that,_ _the_ _original_ _energy_ _evaluation_ _procedure_ _is_ _modified_ _so_ _that_
_the_ _multiple_ _input_ _vectors_ _can_ _be_ _processed_ _simultaneously_ _and_ _the_ _energy_ _evaluation_ _procedure_
_be_ _called_ _only_ _once._
The outer gradient evaluation procedure is simple:
1 <mark>eps</mark> <mark>=</mark> <mark>1e −8;</mark> <mark>%</mark> <mark>f i n i t e</mark> <mark>d i f f e r e n c e</mark> <mark>step</mark> <mark>s i z e</mark>
2
3 <mark>%</mark> <mark>l o c a l</mark> <mark>patch</mark> <mark>e n e r g i e s</mark> <mark>f o r</mark> <mark>+eps</mark> <mark>and</mark> <mark>−eps</mark>
4 <mark>e s</mark> <mark>m i n s p l u s</mark> <mark>=</mark> <mark>e n e r g i e s ( v,[ −</mark> <mark>eps</mark> <mark>eps ]</mark> <mark>, mesh, patches</mark> <mark>, params</mark> <mark>,</mark> <mark>indx ) ;</mark>
5
6 <mark>%</mark> <mark>the</mark> <mark>g r a d i e n t</mark> <mark>v e c t o r</mark> <mark>by</mark> <mark>the</mark> <mark>c e n t r a l</mark> <mark>d i f f e r e n c e</mark> <mark>scheme</mark>
7 <mark>g</mark> <mark>=</mark> <mark>d i f f</mark> <mark>( es</mark> <mark>minsplus</mark> <mark>, 1</mark> <mark>, 2 ) / eps /2;</mark>
14
Here ’ es ~~m~~ insplus ’ is a matrix of size 3 _∥T ∥×_ 2 with the components given by (25):
es ~~m~~ insplus ( _n,_ 1) = _J_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,−_</sup>
_grad_
<sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,_</sup> <sup>+</sup>
_grad_ <sup>(</sup> <sup>v</sup> <sup>)</sup> <sup>.</sup>
<sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,−_</sup> es ~~m~~ insplus ( _n,_ 2) = _J_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> <sup>_,_</sup> <sup>+</sup>
_grad_ <sup>(</sup> <sup>v</sup> <sup>)</sup> <sup>,</sup> _grad_
The gradient vector g is then assembled by using the central difference scheme (23) with a
constant central difference step size _ε_ for all _n_ _∈{_ 1 _, . . ., d|M|}_ . Obviously, a generalization of
the above code to higher accuracy difference schemes is possible.
We recall a cell ’ v ~~e~~ lems ’ containing matrices
v ~~e~~ lems _{_ 1 _}_, v elems _{_ 2 _}_, v ~~e~~ lems _{_ 3 _}_ of size _|T | ×_ 4
is assembled in the energy evaluation procedure energy from Subsection 5.2. For the evaluation
of (23) by using (26) we need to assemble a cell-structure ’ v ~~p~~ atches ’ containing matrices
v ~~p~~ atches _{_ 1 _}_, v ~~p~~ atches _{_ 2 _}_, v ~~p~~ atches _{_ 3 _}_ of size _∥T ∥×_ 4
that provide the restrictions of nodal deformations to all patches. In fact, the structure ’ v ~~p~~ atches ’
copies parts of ’ v ~~e~~ lems ’ to the particular positions.
The extended procedure energies evaluates all _ε_ -perturbed values of energies:
1 <mark>f u n c t i o n</mark> <mark>e</mark> <mark>=</mark> <mark>e n e r g i e s ( v, eps</mark> <mark>, mesh, patches</mark> <mark>, params</mark> <mark>,</mark> <mark>indx )</mark>
2 <mark>%</mark> <mark>components</mark> <mark>of</mark> <mark>deformation</mark>
3 <mark>v</mark> <mark>c e l l</mark> <mark>=</mark> <mark>createCellFromVector ( v, mesh . dim ) ;</mark>
4 <mark>%</mark> <mark>components</mark> <mark>of</mark> <mark>deformation</mark> <mark>on</mark> <mark>elements</mark>
5 <mark>v</mark> <mark>elems</mark> <mark>=</mark> <mark>C e l l A t M a t r i x O f I n d i c e s ( v</mark> <mark>c e l l</mark> <mark>, mesh . elems2nodes ) ;</mark>
6 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>on</mark> <mark>elements</mark>
7 <mark>F</mark> <mark>elems</mark> <mark>=</mark> <mark>e v a l u a t e</mark> <mark>F ( mesh,</mark> <mark>v</mark> <mark>elems ) ;</mark>
8
9 <mark>%</mark> <mark>deformations</mark> <mark>on</mark> <mark>patches</mark>
10 <mark>v</mark> <mark>patches</mark> <mark>=</mark> <mark>C e l l A t M a t r i x O f I n d i c e s ( v</mark> <mark>c e l l</mark> <mark>,</mark> <mark>patches</mark> <mark>. elems2nodes ) ;</mark>
11 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>on</mark> <mark>patches</mark>
12 <mark>F</mark> <mark>patches</mark> <mark>=</mark> <mark>C e l l A t M a t r i x O f I n d i c e s ( F</mark> <mark>elems</mark> <mark>,</mark> <mark>patches</mark> <mark>. elems ) ;</mark>
13
14 <mark>v</mark> <mark>p a t c h e s</mark> <mark>e p s</mark> <mark>=</mark> <mark>c e l l</mark> <mark>(3,1)</mark> <mark>;</mark>
15 <mark>e</mark> <mark>=</mark> <mark>z e r o s (3</mark> <mark>∗</mark> <mark>numel ( mesh . nodesMinim )</mark> <mark>, s i z e ( eps</mark> <mark>, 2 ) ) ;</mark>
16 <mark>f o r</mark> <mark>comp=1: s i z e ( eps</mark> <mark>, 2 )</mark> <mark>%</mark> <mark>loop</mark> <mark>over</mark> <mark>e p s i l o n</mark> <mark>p e r t u r b a t i o n s</mark>
17 <mark>%</mark> <mark>p e r t u r b a t i o n s</mark> <mark>of</mark> <mark>deformations</mark> <mark>on</mark> <mark>patches</mark>
18 <mark>v</mark> <mark>p a t c h e s</mark> <mark>e p s</mark> _<mark>{</mark>_ <mark>1</mark> _<mark>}</mark>_ <mark>=</mark> <mark>v</mark> <mark>patches</mark> _<mark>{</mark>_ <mark>1</mark> _<mark>}</mark>_ <mark>+</mark> <mark>eps (comp) ∗</mark> <mark>patches</mark> <mark>.</mark> <mark>l o g i c a l</mark> <mark>;</mark>
19 <mark>v</mark> <mark>p a t c h e s</mark> <mark>e p s</mark> _<mark>{</mark>_ <mark>2</mark> _<mark>}</mark>_ <mark>=</mark> <mark>v</mark> <mark>patches</mark> _<mark>{</mark>_ <mark>2</mark> _<mark>}</mark>_ <mark>+</mark> <mark>eps (comp) ∗</mark> <mark>patches</mark> <mark>.</mark> <mark>l o g i c a l</mark> <mark>;</mark>
20 <mark>v</mark> <mark>p a t c h e s</mark> <mark>e p s</mark> _<mark>{</mark>_ <mark>3</mark> _<mark>}</mark>_ <mark>=</mark> <mark>v</mark> <mark>patches</mark> _<mark>{</mark>_ <mark>3</mark> _<mark>}</mark>_ <mark>+</mark> <mark>eps (comp) ∗</mark> <mark>patches</mark> <mark>.</mark> <mark>l o g i c a l</mark> <mark>;</mark>
21
22 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>of</mark> <mark>p e r t u r b a t i o n</mark>
23 <mark>GG</mark> <mark>=</mark> <mark>evaluate</mark> <mark>GG ( patches</mark> <mark>,</mark> <mark>v</mark> <mark>patches</mark> <mark>eps</mark> <mark>,</mark> <mark>F</mark> <mark>patches ) ;</mark>
24
25 <mark>%</mark> <mark>d e n s i t i e s</mark>
26 <mark>d e n s i t i e s</mark> <mark>p a t c h e s</mark> <mark>=</mark> <mark>densityGradientVector</mark> <mark>3D (GG, params ) ;</mark>
27 <mark>%</mark> <mark>e n e r g i e s</mark>
28 <mark>e</mark> <mark>patches</mark> <mark>=</mark> <mark>[ patches</mark> <mark>. volumes ;</mark> <mark>patches</mark> <mark>. volumes ;</mark> <mark>patches</mark> <mark>. volumes ] . ∗</mark>
<mark>d e n s i t i e s</mark> <mark>p a t c h e s</mark> <mark>;</mark>
29 <mark>%</mark> <mark>f i n a l</mark> <mark>energy</mark> <mark>v a l u e s</mark> <mark>on</mark> <mark>patches</mark>
30 <mark>csep</mark> <mark>=</mark> <mark>cumsum</mark> <mark>( e</mark> <mark>patches ) ;</mark>
31 <mark>e ( [ 1 : 3 : end</mark> <mark>2 : 3 : end</mark> <mark>3 : 3 : end ]</mark> <mark>, comp)</mark> <mark>=</mark> <mark>[ csep ( indx (1) ) ;</mark> <mark>d i f f</mark> <mark>( csep ( indx ) )</mark> <mark>] ;</mark>
32 <mark>end</mark>
33 <mark>e</mark> <mark>=</mark> <mark>e ( mesh .</mark> <mark>dofsMinim</mark> <mark>local</mark> <mark>, : )</mark> <mark>;</mark> <mark>%</mark> <mark>dropping</mark> <mark>out</mark> <mark>the</mark> <mark>D i r i c h l e t</mark> <mark>dofs</mark>
34 <mark>end</mark>
15
The cells ’ v ~~e~~ lems ’ and ’ F elems ’ are the same as in the first-gradient energy evaluation procedure from Subsection 5.2. The cell ’ v ~~p~~ atches ~~e~~ ps ’ contains matrices
v patches eps _{_ 1 _}_, v patches ~~e~~ ps _{_ 2 _}_, v ~~p~~ atches ~~e~~ ps _{_ 3 _}_ of size _∥T ∥×_ 4
that provide the restrictions of nodal deformations to all patches, but here these deformations
are perturbed by the value of the central difference step _ε_ . This cell is used for the construction
of the key cell ’ GG ’ of size _dim × dim_ containing vectors
GG _{j, m}_ of length _dim ∥T ∥_
storing the partial derivatives of deformations of the _j_ -th component with respect to the _m_ -th
variable. The structure of ’ GG ’ is in details displayed in Fig. 5.
3 _∥T ∥_
the 1st layer of vector
indices
_{_ 1 _, . . ., ∥T ∥}_
the 2nd layer of vector
indices
_{∥T ∥_ + 1 _, . . .,_ 2 _∥T ∥}_
the 3rd layer of vector
indices
_{_ 2 _∥T ∥_ + 1 _, . . .,_ 3 _∥T ∥}_
Figure 5: The ’ GG ’ structure.
All three layers of vector indices have the same size of _∥T ∥_ entries and the following meaning:
- the 1st layer corresponds to the _ε_ -perturbation of the component v <sup>(1)</sup>,
- the 2nd layer corresponds to the _ε_ -perturbation of the component v <sup>(2)</sup>,
- the 3rd layer corresponds to the _ε_ -perturbation of the component v <sup>(3)</sup> .
The cell ’ G ’ has the same size as ’ F ’, but contains deformation gradient matrices corresponding
to the deformations perturbed by _ε_ . The most important feature is using the values of the
16
precomputed input cell ’ F ’ for the efficient construction of the ’ GG ’ cell. Note that if the
numeric difference step _ε_ is added or subtracted from the first component of displacements, the
deformation gradients of the rest two components remain the same and their values are already
stored in the ’ F ’ cell.
A vector ’ csep ’ of length _d∥T ∥_ contains the cumulative sums of ’ e ~~p~~ atches ’ with elements
csep ( _n_ ) =
_n_
_r_ =1
e ~~p~~ atches ( _r_ ) _._
An output matrix e of size 3 _|M| ×_ 2 contains all energy contributions and for any _comp ∈{_ 1 _,_ 2 _}_
e ( _n, comp_ ) =
_pn_
_r_ = _pn−_ 1+1
e ~~p~~ atches ( _r_ ) = csep ( _pn_ ) _−_ csep ( _pn −_ 1) _._ (27)
Note that vector ’ e patches ’ changes its value inside the loop over the components _comp_ . Therefore, the whole vector e is evaluated at once using the Matlab difference function diff with the
input vector ’ indx ’ of length 3 _|M|_, where indx ( _n_ ) = _pn, n ∈{_ 1 _, . . ., d|M|}_, with _pn_ defined in
(15) and additionally in (16).
The procedure for the construction of ’ GG ’ is listed below:
1 <mark>f u n c t i o n</mark> <mark>GG</mark> <mark>=</mark> <mark>evaluate</mark> <mark>GG ( patches</mark> <mark>, v</mark> <mark>patches</mark> <mark>, F)</mark>
2 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>on</mark> <mark>patches</mark>
3 <mark>G</mark> <mark>=</mark> <mark>e v a l u a t e</mark> <mark>F ( patches</mark> <mark>,</mark> <mark>v</mark> <mark>patches ) ;</mark>
4
5 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t</mark> <mark>on</mark> <mark>patches</mark> <mark>and</mark> <mark>on</mark> <mark>3</mark> <mark>components</mark>
6 <mark>GG</mark> <mark>=</mark> <mark>c e l l</mark> <mark>(3,3)</mark> <mark>;</mark>
7 <mark>GG</mark> _<mark>{</mark>_ <mark>1,1</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[G</mark> _<mark>{</mark>_ <mark>1,1</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,1</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1</mark> <mark>, 1</mark> _<mark>}</mark>_ <mark>] ;</mark>
8 <mark>GG</mark> _<mark>{</mark>_ <mark>1,2</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[G</mark> _<mark>{</mark>_ <mark>1,2</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,2</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1</mark> <mark>, 2</mark> _<mark>}</mark>_ <mark>] ;</mark>
9 <mark>GG</mark> _<mark>{</mark>_ <mark>1,3</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[G</mark> _<mark>{</mark>_ <mark>1,3</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1,3</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>1</mark> <mark>, 3</mark> _<mark>}</mark>_ <mark>] ;</mark>
10 <mark>GG</mark> _<mark>{</mark>_ <mark>2,1</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[ F</mark> _<mark>{</mark>_ <mark>2,1</mark> _<mark>}</mark>_ <mark>;</mark> <mark>G</mark> _<mark>{</mark>_ <mark>2,1</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2</mark> <mark>, 1</mark> _<mark>}</mark>_ <mark>] ;</mark>
11 <mark>GG</mark> _<mark>{</mark>_ <mark>2,2</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[ F</mark> _<mark>{</mark>_ <mark>2,2</mark> _<mark>}</mark>_ <mark>;</mark> <mark>G</mark> _<mark>{</mark>_ <mark>2,2</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2</mark> <mark>, 2</mark> _<mark>}</mark>_ <mark>] ;</mark>
12 <mark>GG</mark> _<mark>{</mark>_ <mark>2,3</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[ F</mark> _<mark>{</mark>_ <mark>2,3</mark> _<mark>}</mark>_ <mark>;</mark> <mark>G</mark> _<mark>{</mark>_ <mark>2,3</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>2</mark> <mark>, 3</mark> _<mark>}</mark>_ <mark>] ;</mark>
13 <mark>GG</mark> _<mark>{</mark>_ <mark>3,1</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[ F</mark> _<mark>{</mark>_ <mark>3,1</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,1</mark> _<mark>}</mark>_ <mark>;</mark> <mark>G</mark> _<mark>{</mark>_ <mark>3</mark> <mark>, 1</mark> _<mark>}</mark>_ <mark>] ;</mark>
14 <mark>GG</mark> _<mark>{</mark>_ <mark>3,2</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[ F</mark> _<mark>{</mark>_ <mark>3,2</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,2</mark> _<mark>}</mark>_ <mark>;</mark> <mark>G</mark> _<mark>{</mark>_ <mark>3</mark> <mark>, 2</mark> _<mark>}</mark>_ <mark>] ;</mark>
15 <mark>GG</mark> _<mark>{</mark>_ <mark>3,3</mark> _<mark>}</mark>_ <mark>=</mark> <mark>[ F</mark> _<mark>{</mark>_ <mark>3,3</mark> _<mark>}</mark>_ <mark>;</mark> <mark>F</mark> _<mark>{</mark>_ <mark>3,3</mark> _<mark>}</mark>_ <mark>;</mark> <mark>G</mark> _<mark>{</mark>_ <mark>3</mark> <mark>, 3</mark> _<mark>}</mark>_ <mark>] ;</mark>
16 <mark>end</mark>
6.2 Exact approach to evaluate _∇Jgrad_ ( v )
Evaluation of the exact _∇J_ ( v ) requires an explicit deriving of every <sup>_<u>∂J</u>_</sup> _∂v_ <sup><u>(</u></sup> _n_ <sup><u>v</u></sup> <sup><u>)</u></sup> <sup>_, n_</sup> <sup>_∈{_</sup> <sup>1</sup> <sup>_, . . ., d|M|}_</sup> <sup>.</sup>
The gradient of the linear part is trivial and is given by (18). Using (9) one can write
_<u>∂Jgrad</u>_ <u>(</u> <u>v</u> <u>)</u>
_∂vn_
=
_|T |_
_k_ =1
_<u>∂</u>_
_|Tk|_
_∂vn_
_W_
- F ( v ) _|Tk_
- _._ (28)
Note that the only elements whose energy contributions depend on _vn_ are those belonging to
the _i_ -th patch, where _i_ = _IDN_ ( _n_ ). Therefore, we can simplify the equation above as
_<u>∂</u>_
_|Tk|_
_∂vn_
17
_<u>∂Jgrad</u>_ <u>(</u> <u>v</u> <u>)</u>
_∂vn_
- _._ (29)
=
_|T_ <sup>(</sup> <sup>_n_</sup> <sup>)</sup> _|_
_k_ =1
_W_
- F ( v ) _|Tk_
By using the chain rule one can write
_dim_
_m_ =1
_<u>∂</u>_
_∂vn_
- F ( v )� _<u>∂</u>_ <u>F</u> _<u>j,m</u>_
_∂vn_
- F ( v )� =
- F ( v )
_d_
_j_ =1
_<u>∂W</u>_
_∂_ F _j,m_
( v ) _,_ (30)
_W_
where assuming the Neo-Hookean density from (4)
_<u>∂W</u>_ <u>(</u> <u>F</u> <u>)</u>
_∂_ F _j,m_
<u>2</u>
_−_
det( F )
_<u>∂</u>_ <u>det(</u> <u>F</u> <u>)</u>
_∂_ F _j,m_
- _<u>∂</u>_ <u>det(</u> <u>F</u> <u>)</u>
_∂_ F _j,m_
= _C_ 1
- _<u>∂</u>_ <u>I</u> <u>1(</u> <u>F</u> <u>)</u>
_∂_ F _j,m_
- + 2 _D_ 1� det( F ) _−_ 1
_._ (31)
Using the row or the column expansion rule for calculating the determinant of a 3 _×_ 3 matrix,
one can express
_<u>∂</u>_ <u>det(</u> <u>F</u> <u>)</u>
_∂_ F _j,m_
= ( _−_ 1) <sup>_j_</sup> <sup>+</sup> <sup>_m_</sup> det( F <sup>_sub_</sup> _j,m_ <sup>)</sup> <sup>_,_</sup> (32)
where F <sup>_sub_</sup> _j,m_ <sup>is</sup> <sup>the</sup> <sup>2</sup> <sup>_×_</sup> <sup>2</sup> <sup>submatrix</sup> <sup>of</sup> <sup>F</sup> <sup>given</sup> <sup>by</sup> <sup>dropping</sup> <sup>the</sup> <sup>_j_</sup> <sup>-th</sup> <sup>row</sup> <sup>and</sup> <sup>the</sup> <sup>_m_</sup> <sup>-th</sup> <sup>column</sup> <sup>of</sup>
F . Futhermore, _∂_ F _<u>∂</u>_ <u>I</u> _j,m_ <u>1</u> <sup>can</sup> <sup>be</sup> <sup>also</sup> <sup>simplified</sup> <sup>by</sup>
_<u>∂</u>_ <u>I</u> <u>1(</u> <u>F</u> <u>)</u>
_∂_ F _j,m_
= 2 F _j,m ._ (33)
From Subsection 6.1 we already know how to assemble v _|Tk_ and F ( v ) _|Tk_ . Here, in addition, we
need to express <sup>_<u>∂</u>_</sup> <sup><u>I</u></sup> _∂_ <sup><u>1</u></sup> F <sup><u>(</u></sup> <sup><u>F</u></sup> <sup><u>)</u></sup> _,_ <sup>_<u>∂</u>_</sup> <sup><u>det(</u></sup> _∂_ F <sup><u>F</u></sup> <sup><u>)</u></sup> and _∂v∂_ <u>F</u> _n_ <sup>.</sup>
_∂_ <sup><u>1</u></sup> F <sup><u>(</u></sup> <sup><u>F</u></sup> <sup><u>)</u></sup> _,_ <sup>_<u>∂</u>_</sup> <sup><u>det(</u></sup> _∂_ F <sup><u>F</u></sup> <sup><u>)</u></sup>
need to express <sup>_<u>∂</u>_</sup> <sup><u>I</u></sup> _∂_ <sup><u>1</u></sup> F <sup><u>(</u></sup> <sup><u>F</u></sup> <sup><u>)</u></sup> _,_ <sup>_<u>∂</u>_</sup> <sup><u>det(</u></sup> _∂_ F <sup><u>F</u></sup> <sup><u>)</u></sup> and _∂v∂_ <u>F</u> _n_ <sup>.</sup>
Similarly to the numeric gradient evaluation, the exact gradient evaluation procedure uses
the same precomputed structures ’ v ~~c~~ ell ’, ’ v ~~e~~ lems ’ and ’ F ~~e~~ lems ’.
1 <mark>%</mark> <mark>components</mark> <mark>of</mark> <mark>deformation</mark>
2 <mark>v</mark> <mark>c e l l</mark> <mark>=</mark> <mark>createCellFromVector ( v, mesh . dim ) ;</mark>
3 <mark>%</mark> <mark>components</mark> <mark>of</mark> <mark>deformation</mark> <mark>on</mark> <mark>elements</mark>
4 <mark>v</mark> <mark>elems</mark> <mark>=</mark> <mark>C e l l A t M a t r i x O f I n d i c e s ( v</mark> <mark>c e l l</mark> <mark>, mesh . elems2nodes ) ;</mark>
5 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>on</mark> <mark>elements</mark>
6 <mark>F</mark> <mark>elems</mark> <mark>=</mark> <mark>e v a l u a t e</mark> <mark>F ( mesh,</mark> <mark>v</mark> <mark>elems ) ;</mark>
The main procedure for the exact gradient evaluation is provided below:
1 <mark>%</mark> <mark>deformations</mark> <mark>on</mark> <mark>patches</mark>
2 <mark>v</mark> <mark>patches</mark> <mark>=</mark> <mark>C e l l A t M a t r i x O f I n d i c e s ( v</mark> <mark>c e l l</mark> <mark>,</mark> <mark>patches</mark> <mark>. elems2nodes ) ;</mark>
3 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>on</mark> <mark>patches</mark>
4 <mark>F</mark> <mark>patches</mark> <mark>=</mark> <mark>C e l l A t M a t r i x O f I n d i c e s ( F</mark> <mark>elems</mark> <mark>,</mark> <mark>patches</mark> <mark>. elems ) ;</mark>
5
6 <mark>%</mark> <mark>deformation</mark> <mark>g r a d i e n t s</mark> <mark>of</mark> <mark>p e r t u r b a t i o n</mark>
7 <mark>GG</mark> <mark>=</mark> <mark>evaluate</mark> <mark>GG ( patches</mark> <mark>,</mark> <mark>v</mark> <mark>patches</mark> <mark>,</mark> <mark>F</mark> <mark>patches ) ;</mark>
8
9 <mark>%</mark> <mark>d e n s i t i e s</mark>
10 <mark>D</mark> <mark>d e n s i t i e s</mark> <mark>p a t c h e s</mark> <mark>=</mark> <mark>density</mark> <mark>D</mark> <mark>GradientVector</mark> <mark>3D (GG, D</mark> <mark>F, params ) ;</mark>
11 <mark>%</mark> <mark>e n e r g i e s</mark>
12 <mark>D</mark> <mark>e</mark> <mark>patches</mark> <mark>=</mark> <mark>[ patches</mark> <mark>. volumes ;</mark> <mark>patches</mark> <mark>. volumes ;</mark> <mark>patches</mark> <mark>. volumes ] . ∗</mark>
<mark>D</mark> <mark>d e n s i t i e s</mark> <mark>p a t c h e s</mark> <mark>;</mark>
13 <mark>%</mark> <mark>f i n a l</mark> <mark>energy</mark> <mark>v a l u e s</mark> <mark>on</mark> <mark>patches</mark>
14 <mark>csDep</mark> <mark>=</mark> <mark>cumsum</mark> <mark>( D</mark> <mark>e</mark> <mark>patches ) ;</mark>
15 <mark>g</mark> <mark>=</mark> <mark>z e r o s (3</mark> <mark>∗</mark> <mark>numel ( nodesMinim )</mark> <mark>,1) ;</mark>
16 <mark>g ( [ 1 : 3 : end</mark> <mark>2 : 3 : end</mark> <mark>3 : 3 : end ] )</mark> <mark>=</mark> <mark>[ csDep ( indx (1) ) ;</mark> <mark>d i f f</mark> <mark>( csDep ( indx ) )</mark> <mark>] ;</mark>
17 <mark>g</mark> <mark>=</mark> <mark>g ( d o f s M i n i m</mark> <mark>l o c a l ) ;</mark>
18
Here, ’ D ~~d~~ ensities ~~p~~ atches ’ is a vector of size 3 _∥T ∥×_ 1 containing all _<u>∂W</u>_ <u>(</u> <u>F</u> <u>(</u> <u>v</u> <u>))</u>
Here, ’ D ~~d~~ ensities ~~p~~ atches ’ is a vector of size 3 _∥T ∥×_ 1 containing all _<u>∂W</u>_ <u>(</u> <u>F</u> <u>(</u> <u>v</u> <u>))</u> for every
_∂vn_
_n ∈{_ 1 _, . . ., d|M|}_ given by (30). Note that the function density ~~D~~ ~~G~~ radientVector ~~3~~ D uses
the input 3 _×_ 3 cell structure ’ D ~~F~~ ~~p~~ atches ’, where D ~~F~~ ~~p~~ atches _{j, m}_ ( _n_ ) = <sup>_<u>∂</u>_</sup> _∂v_ <sup><u>F</u></sup> <sup>_<u>j,m</u>_</sup> _n_ <sup>.</sup>
Benchmark 3 _The_ _script_ _`benchmark3.m`_ _evaluates_ _approximations_ _of_ _∇Jgrad_ ( _v_ ) _on_ _the_ _sequence_
_of_ _the_ _uniform_ _mesh_ _refinements_ _defined_ _in_ _Benchmark_ _2._ _In_ _order_ _to_ _provide_ _higher_ _accuracy_ _of_
_evaluation_ _times,_ _the_ _energies_ _are_ _recomputed_ _10_ _times._ _Table_ _3_ _provide_ _evaluation_ _times_ _of_ _the_
_gradient_ _approximations_ _both_ _in_ _the_ _exact_ _and_ _numerical_ _case_ _(the_ _times_ _for_ _setting_ _up_ _’mesh’_
_and_ _’patches’_ _structures_ _are_ _not_ _included)._
_∂v_ <sup><u>F</u></sup> <sup>_<u>j,m</u>_</sup> _n_ <sup>.</sup>
mesh
level
number of free
dofs
evaluation (10x)
of exact _∇J_ ( v ):
evaluation (10x)
of num. _∇J_ ( v ):
<u>time</u> <u>[s]</u> <u>time</u> <u>[s]</u>
1 2133 0.12 0.08
2 11925 0.14 0.15
3 77517 1.18 1.51
4 554013 12.47 15.64
5 4178493 487.34 533.24
Table 3: Benchmark 3 - energy gradient evaluation times in 3D.
### 7 Application to practical energy minimizations
For a practical energy minimization, the trust-region method [4] available in the MATLAB
Optimization Toolbox is utilized. Standard stopping criteria (the first-order optimality, tolerance
on the argument and tolerance on the function) equal to 10 <sup>_−_</sup> <sup>6</sup> are considered in all benchmarks.
The method also allows to specify the sparsity pattern of the Hessian matrix _∇_ <sup>2</sup> _J_ ( _v_ ) in free
degrees of freedom, i.e., only positions (indices) of nonzero entries. The sparsity pattern is
directly given by a finite element discretization.
Figure 6: The sparsity pattern of the 3D bar domain based on nodes connectivity (left) and its
extension to the vector problem (right).
19
Example 2 _The_ _sparsity_ _pattern_ _related_ _to_ _the_ _3D_ _bar_ _domain_ _of_ _Fig._ _2_ _is_ _displayed_ _in_ _Fig._ _6_
_(left)._ _It corresponds to the FEM mesh not taking the Dirichlet boundary conditions into account._
_Therefore,_ _it_ _is_ _of_ _size_ 729 _×_ 729 _._ _In_ _practical_ _computations,_ _it_ _is_ _first_ _extended_ _from_ _a_ _scalar_ _to_
_a_ _vector_ _problem_ _and_ _then_ _restricted_ _to_ _the_ _’_ _mesh.dofsMinim_ _’_ _indices_ _(right)._ _Since_ _there_ _are_
_18_ _Dirichlet_ _nodes_ _fixed_ _in_ _all_ _three_ _directions,_ _the_ _corresponding_ _number_ _of_ _rows_ _and_ _columns_ _of_
_the_ _right_ _hessian_ _sparsity_ _pattern_ _is_ (729 _−_ 18) _∗_ 3 = 2133 _._
7.1 Benchmark 4: time-dependent hyperelasticity in 3D
We consider the elastic bar specified in Benchmark 2 with a time-dependent nonhomogeneous
Dirichlet boundary conditions on the right wall ( _x_ = _lx_ ). The torsion of the right wall is described
by the formula (19) for _x_ = _lx_ = 0 _._ 4, where the rotation angle is assumed to be a time dependent
function _α_ = _α_ ( _t_ ) = _αmaxt/T_ for a sequence of integer discrete times _t_ _∈{_ 1 _,_ 2 _, . . ., T_ _}_ . Here
we assume the final time _T_ = 24 and the maximal angle of rotation _αmax_ = 8 _π_ ensuring four
full rotations of the right Dirichlet wall around the x-axis. Altogether we solve a sequence of _T_
minimization problems (1) with the Neo-Hook energy density (4) and no loading ( f = 0).
The trust-region method accepts an initial deformation approximation. For the first discrete
time we run iterations from the identity _v_ ( _x_ ) = _x, x_ _∈_ Ωand for the next discrete time the
minimizer of the previous discrete time problem serves as its initial approximation. We output
the found energy minimizer for each minimization problem with some minimizers shown in form
of the deformed meshes in Fig. 7. Additionally, we also provide the minimization time, the
number of the trust-region iterations and the value of the corresponding minimal energy.
The overall performance is explained in Table 4 for separate computations on tetrahedral
meshes of levels 1, 2, 3 applying the numerical gradient evaluation of Subsection 6.1 only with
the choice _ε_ = 10 <sup>_−_</sup> <sup>6</sup> . We notice that the minimizations of finer meshes require only slightly
higher number of iterations, which is acceptable. Comparison of the values _Jgrad_ ( u ) in each line
of Table 4 indicates convergence in space of the energy minimizers.
<u>level</u> <u>1,</u> <u>2133</u> <u>free</u> <u>dofs</u> <u>level</u> <u>2,</u> <u>11925</u> <u>free</u> <u>dofs</u> <u>level</u> <u>3,</u> <u>77517</u> <u>free</u> <u>dofs</u>
<u>step</u> <u>time</u> <u>[s]</u> <u>iters</u> _<u>Jgrad</u>_ <u>(</u> <u>u</u> <u>)</u> <u>time</u> <u>[s]</u> <u>iters</u> _<u>Jgrad</u>_ <u>(</u> <u>u</u> <u>)</u> <u>time</u> <u>[s]</u> <u>iters</u> _<u>Jgrad</u>_ <u>(</u> <u>u</u> <u>)</u>
t=3 6.65 40 3.1177 66.23 47 1.8244 2148.62 93 1.4631
t=6 10.42 60 12.4423 117.74 76 7.2962 1404.68 68 5.8533
t=9 10.33 60 27.8993 125.76 85 16.4079 1441.84 73 13.1735
t=12 18.43 104 49.5506 102.11 68 29.1664 1277.04 65 23.4286
t=15 15.51 81 77.3859 127.17 87 45.5677 1130.02 58 36.6236
t=18 18.31 97 111.3369 110.65 75 65.5470 1540.90 76 52.7641
t=21 15.74 82 151.4946 74.47 51 89.1672 5523.64 290 71.7883
t=24 16.37 91 197.7577 91.79 63 116.3261 2660.44 131 93.7238
Table 4: Benchmark 4 - performance of hyperelasticity minimizations in 3D.
7.2 Benchmarks 5 and 6: hyperelasticity and p-Laplacian in 2D
Although our exposition is mainly focused on implementation details in 3D, a reduction to 2D
( _dim_ = 2) is straightforward.
As the first example we consider a square domain with lengths _lx_ = _ly_ = 2 perforated by a
hole with radius _r_ = 1 _/_ 3 (Fig. 8 left) and whose center is located at the center of the square,
subjected to zero Dirichlet boundary condition on the bottom and left edges, a constant loading
f ( x ) = ( _−_ 3 _._ 5 _·_ 10 <sup>7</sup> _, −_ 3 _._ 5 _·_ 10 <sup>7</sup> ) and the elastic parameters specified in Benchmark 2. We assume
20
(a) _t_ = 3 _._
(b) _t_ = 6.
(c) _t_ = 9 _._
(d) _t_ = 12 _._
(e) _t_ = 15 _._
(f) _t_ = 18 _s._
(g) _t_ = 21 _._
(h) _t_ = 24 _._
Figure 7: Benchmark 4 - deformation of the tetrahedal mesh subjected to the right time-rotating
Dirichlet plane with the underlying Neo-Hookean density.
21
the choice _ε_ = 10 <sup>_−_</sup> <sup>6</sup> in the evaluation of the numerical gradient. The resulting deformation and
the deformation gradient densities are depicted in Fig. 8 (right).
Figure 8: Benchmark 5 - a triangulation of the square domain perforated by a hole (left) and its
deformation with the underlying Neo-Hookean density (right).
Figure 9: Benchmark 6 - a triangulation of the L-shape domain (left) and the solution p-Laplacian
for the power _p_ = 3 and a constant loading _f_ ( x ) = _−_ 10 (right).
As the second example we minimize the p-Laplacian energy functional (5) over the L-shape
domain (Fig. 9 left). The constant loading _f_ = _−_ 10 is assumed together with zero Dirichlet
boundary conditions on the full domain boundary. For the numerical gradient we assume _ε_ =
10 <sup>_−_</sup> <sup>5</sup> . The solution is displayed in Fig. 9 (right). Table 6 depicts performance of all options for
the power _p_ = 3 and confirms faster evaluation times in comparison to our former contribution
[13]. This is mainly due to the improved vectorization concepts here, due to the faster CPU and
finally due to updates of the trust-region in-built implementation in the latest version of Matlab.
22
<u>exact</u> <u>gradient</u> <u>numerical</u> <u>gradient</u>
<u>level</u> <u>free</u> <u>dofs</u> <u>time</u> <u>[s]</u> <u>iters</u> _<u>J</u>_ <u>(</u> <u>u</u> <u>)</u> <u>time</u> <u>[s]</u> <u>iters</u> _<u>J</u>_ <u>(</u> <u>u</u> <u>)</u>
1 278 0.36 4 24.5745 0.13 4 24.5745
2 1102 0.15 4 24.3558 0.16 4 24.3558
3 4382 0.54 4 24.2957 0.54 4 24.2957
4 17470 2.35 5 24.2799 2.65 5 24.2799
5 69758 11.27 5 24.2758 12.39 5 24.2758
6 278782 83.27 6 24.2748 88.74 6 24.2748
Table 5: Benchmark 5 - performance of hyperelasticity minimizations in 2D. True values of the
energies _J_ ( u ) are multiplied by the scale factor 10 <sup>7</sup> .
<u>exact</u> <u>gradient</u> <u>numerical</u> <u>gradient</u>
<u>level</u> <u>free</u> <u>dofs</u> <u>time</u> <u>[s]</u> <u>iters</u> _<u>J</u>_ <u>(</u> <u>u</u> <u>)</u> <u>time</u> <u>[s]</u> <u>iters</u> _<u>J</u>_ <u>(</u> <u>u</u> <u>)</u>
1 33 0.02 8 -7.5353 0.03 8 -7.5353
2 161 0.05 11 -7.9729 0.12 15 -7.9729
3 705 0.11 11 -8.1039 0.19 11 -8.1039
4 2945 0.30 11 -8.1445 0.56 12 -8.1445
5 12033 1.50 11 -8.1578 2.08 12 -8.1578
6 48641 6.30 12 -8.1625 9.48 12 -8.1625
7 195585 48.61 13 -8.1642 60.62 12 -8.1642
8 784385 617.92 22 -8.1649 672.04 16 -8.1649
Table 6: Benchmark 6 - performance of p-Laplacian minimizations for _p_ = 3 in 2D.
7.3 Implementation remarks and outlooks
Assembly times in all benchmarks were obtained on a MacBook Air (M1 processor, 2020) with
16 GB memory running MATLAB R2021a. Our implementation is available at
```
https://www.mathworks.com/matlabcentral/fileexchange/97889
```
for download and testing. It is based on own codes of [3, 6, 15] used primarily for assemblies of
finite element matrices. It also utilizes the function mcolon from the reservoir simulator [11].
The names of mesh attributes were initially motivated by codes of [1] and further modified.
The 3D cuboid mesh is generated by the code of [6] and 2D meshes (the square with the hole
and the L-shape) by our own code. Vectorized evaluations of gradients of basis functions are
taken from [3, 15]. The general structure of the code was initially taken from [13] and extended
to the implementation of hyperelasticity in 2D and 3D. Many parts of this code (mainly related
to the gradient evaluation) have been significantly improved since then.
The code is designed in a modular way allowing to add different scalar (e.g. Ginzburg-Landau
[1]) and vector (e.g. topology optimization with elastoplasticity [2], shape memory alloys [8])
problems involving the first gradient energy terms.
### Acknowledgement
A. Moskovka was supported by the Strategy 21 of the CAS, program 23: City as a Laboratory
of Change; Historical Heritage and Place for Safe and Quality Life and by the R&D project
8J21AT001 Model Reduction and Optimal Control in Thermomechanics. J. Valdman announces
the support of the Czech Science Foundation (GACR) through the grant GF19-29646L Large
Strain Challenges in Materials Science.
23
### References
[1] J. Alberty, C. Carstensen, S. Funken: _Remarks_ _around_ _50_ _lines_ _of_ _Matlab:_ _short_ _finite_
_element_ _implementation_, Numerical Algorithms 20, 1999, 117-137.
[2] S. Almi, U. Stefanelli: _Topology_ _Optimization_ _for_ _Incremental_ _Elastoplasticity:_ _A_ _Phase-_
_Field_ _Approach_, SIAM Journal on Control and Optimization, 2021, Vol. 59, No. 1 : pp.
339-364.
[3] I. Anjam, J. Valdman: _Fast_ _MATLAB_ _assembly_ _of_ _FEM_ _matrices_ _in_ _2D_ _and_ _3D:_ _edge_
_elements_, Applied Mathematics and Computation, 2015, 267, 252–263.
[4] A.R. Conn, N.I.M. Gould, P.L. Toint: _Trust-Region_ _Methods._ SIAM, Philadelphia, 2000.
[5] P.G. Ciarlet: _The_ _Finite_ _Element_ _Method_ _for_ _Elliptic_ _Problems_, SIAM, Philadelphia, 2002.
[6] M. Cerm´ak, <sup>ˇ</sup> S. Sysala, J. Valdman: _Efficient_ _and_ _flexible_ _MATLAB_ _implementation_ _of_ _2D_
_and_ _3D_ _elastoplastic_ _problems_, Applied Mathematics and Computation, 2019, 355, 595-614.
[7] P. Dr´abek, J. Milota: _Methods of Nonlinear Analysis:_ _Applications to Differential Equations_
(second edition), Birkhauser, 2013.
[8] M. Frost, B. Beneˇsov´a, P. Sedl´ak: _A_ _microscopically_ _motivated_ _constitutive_ _model_ _for_
_shape_ _memory_ _alloys:_ _formulation,_ _analysis_ _and_ _computations_, Math. Mech. Solids, 21(3):
358–382, 2016.
[9] J. Koko: _Fast_ _MATLAB_ _assembly_ _of_ _FEM_ _matrices_ _in_ _2D_ _and_ _3D_ _using_ _cell-array_ _ap-_
_proach_, International Journal of Modeling, Simulation, and Scientific Computing Vol. 7, No.
3 (2016).
[10] M. Kruˇz´ık, T. Roub´ıˇcek: _Mathematical_ _Methods_ _in_ _Continuum_ _Mechanics_ _of_ _Solids_,
Springer, 2019.
[11] K. A. Lie: _An_ _introduction_ _to_ _reservoir_ _simulation_ _using_ _MATLAB:_ _User_ _guide_ _for_ _the_
_Matlab_ _Reservoir_ _Simulation_ _Toolbox_ _(MRST)_, Technical report, SINTEF ICT, December
2016. [(http://www.sintef.no/projectweb/mrst/).](http://www.sintef.no/projectweb/mrst/)
[12] J. E. Marsden, T. J.R. Hughes: _Mathematical_ _foundations_ _of_ _elasticity_, Dover Publications,
1994.
[13] C. Matonoha, A. Moskovka, J. Valdman: _Minimization_ _of_ _p-Laplacian_ _via_ _the_ _Finite_ _Ele-_
_ment_ _Method_ _in_ _MATLAB_, I. Lirkov and S. Margenov (eds): LSSC 2021, LNCS 13127, pp.
496–503 (2022).
[14] MATLAB documentation to Minimization with Gradient and Hessian Sparsity Pattern,
```
https://www.mathworks.com/help/optim/ug/minimization-with-gradient-and-hes
```
`[sian-sparsity-pattern.html](https://www.mathworks.com/help/optim/ug/minimization-with-gradient-and-hessian-sparsity-pattern.html)` .
[15] T. Rahman, J. Valdman: _Fast_ _MATLAB_ _assembly_ _of_ _FEM_ _matrices_ _in_ _2D_ _and_ _3D:_ _nodal_
_elements_, Applied Mathematics and Computation, 2013, 219, 7151-7158.
[16] G. K. Rose: _Computational_ _Methods_ _for_ _Nonlinear_ _Systems_ _Analysis_ _With_ _Applications_ _in_
_Mathematics and Engineering_ (2017), Doctor of Philosophy (PhD), Dissertation, Mechanical
& Aerospace Engineering, Old Dominion University.
[17] T. Weinberg, B. Soused´ık: _Fast_ _implementation_ _of_ _mixed_ _RT0_ _finite_ _elements_ _in_ _MATLAB_,
SIAM Undergraduate Research Online, volume 12, 2018.
24
섹션 본문
섹션 본문이 없습니다.
참고문헌
참고문헌 정보가 없습니다.