Entries for November 2017
-
Vectorial Finite Elements
$ \newcommand{\BAhat}{\hat{\boldsymbol{A}}} \newcommand{\Buhat}{\hat{\boldsymbol{u}}} \newcommand{\Bbhat}{\hat{\boldsymbol{b}}} $Many initial boundary value problems require solving for unknown vector fields, such as solving for displacements in a mechanical problem. Discretization of weak forms of such problems leads to higher-order linear systems which need to be reshaped to be solved by regular linear solvers. There are also more indices involved than a scalar problem, which can be confusing. In this post, I’ll try to elucidate the procedure by deriving for a basic higher-order system and giving an example.
The weak formulation of a linear vectorial problem reads
Find u∈V such that
a(u,v)=b(v)(1)for all v∈V.
Discretizations of vectorial problems requires the expansion of vectorial quantities as linear combinations of the basis vectors ei:
u=i=1∑nduiei(2)where {ui}i=1nd are the components corresponding to the basis vectors and nd=dimV. Here, we chose Cartesian basis vectors for simplicity.
We can therefore express its discretization as
uh=I=1∑nnuINI=I=1∑nni=1∑nduiIeiNI.(3)Substituting discretized functions in the weak formulation, we obtain
a(uh,vh)=i=1∑ndj=1∑nda(uh,jej,vh,iei)=I=1∑nnJ=1∑nni=1∑ndj=1∑ndujJviIa(ejNJ,eiNI)(4)and
b(vh)=i=1∑ndb(vh,iei)=I=1∑nni=1∑ndviIb(eiNI).(5)We define the following arrays
AijIJbiI=a(ejNJ,eiNI)=b(eiNI).(6)Hence we can express the linear system
a(uh,vh)=b(vh)(7)as
I=1∑nnJ=1∑nni=1∑ndj=1∑ndujJviIAijIJ=I=1∑nni=1∑ndviIbiI.(8)For arbitrary vh, this yields the following system of equations
J=1∑nnj=1∑ndAijIJujJ=biI(9)for i=1,…,nd and I=1,…,nn.
We reshape this higher-order system as shown in the previous post Reshaping Higher Order Linear Systems:
A^u^=b^(10)by defining a map id that maps original indices to the reshaped indices
id:={[1,nn]×[1,nd](I,i)→[1,nnnd]↦nd(I−1)+i(11)where we used 1-based indexing of the arrays. We set
αβ:=id(I,i):=id(J,j)=nd(I−1)+i=nd(J−1)+j(12)and write
A^αβ=AijIJ,u^β=ujJandb^α=biI(13)The inverse index mapping can be obtained as shown in the previous post.
Example: Linear Elasticity
Our initial-boundary value problem is
−divσut=ργ=uˉ=tˉinononΩ∂Ωu∂Ωt(14)The weak formulation reads
Find u∈V such that
−∫Ωdivσ⋅vdv=∫Ωργ⋅vdv(15)for all v∈V where V=H1(Ω).
We apply integration by parts on the left-hand side
∫Ωdivσ⋅vdv=∫Ωdiv(σv)dv−∫Ωσ:∇vdv(16)and apply the divergence theorem to the first resulting term:
∫Ωdiv(σv)dv=∫∂Ωttˉ⋅vda(17)Substituting the linear stress σ=C:ε=C:∇u, we obtain the following variational forms:
a(u,v)b(v)=∫Ω∇v:C:∇udv=∫Ωργ⋅vdv+∫∂Ωttˉ⋅vda(18)(19)We have the following discretizations of the unknown function and test function
uh=J=1∑nnuJNJandvh=I=1∑nnvINI.(20)With the given discretizations, the matrix corresponding to (18) can be calculated as
AijIJ=a(ejNJ,eiNI)=∫Ω∇(eiNI):C:∇(ejNJ)dv=∫Ω(ei⊗∇NI):C:(ej⊗∇NJ)dv=∫Ω∂xk∂NICikjl∂xl∂NJdv,(21)and finally obtain
AijIJ=∫ΩBkICikjlBlJdv.(22)The vector corresponding to (19) is calculated as
biI=b(eiNI)=∫∂Ωttˉ⋅(eiNI)da+∫Ωργ⋅(eiNI)dv(23)which yields
biI=∫∂ΩttˉiNIda+∫ΩργiNIdv(24) -
Reshaping Higher Order Linear Systems
$ \newcommand{\BAhat}{\hat{\boldsymbol{A}}} \newcommand{\Buhat}{\hat{\boldsymbol{u}}} \newcommand{\Bbhat}{\hat{\boldsymbol{b}}} $In vectorial problems, we end up with linear systems of higher order, such as
k=1∑Nl=1∑MAijklukl=bij(1)for i=1,…,N and j=1,…,M.
These systems cannot be solved readily with existing software. In order to be able to solve them with existing software, we need to reshape them by defining a matrix of matrices A^ and vector of vectors u^ and b^:
A^A1111⋮A1M11AN111⋮ANM11⋯⋱⋯⋮⋯⋱⋯A111M⋮A1M1MAN11M⋮ANM1M⋯⋱⋯A11N1⋮A1MN1AN1N1⋮ANMN1⋯⋱⋯⋮⋯⋱⋯A11NM⋮A1MNMAN1NM⋮ANMNMu^u11⋮u1M⋮uN1⋮uNM=b^b11⋮b1M⋮bN1⋮bNM(2)This allows us to express the linear system as
A^u^=b^(3)Here, we reshape the system by defining a map id that maps original indices to the reshaped indices
id:={[1,N]×[1,M](i,j)→[1,NM]↦M(i−1)+j(4)where we used 1-based indexing of the arrays. We set
αβ:=id(i,j):=id(k,l)=M(i−1)+j=M(k−1)+l(5)and write
A^αβ=Aijkl,u^β=uklandb^α=bij(6)For reference, the inverse of the index mapping reads
id−1:={[1,NM]α→[1,N]×[1,M]↦(1+(α−mod(α,M))/M,mod(α,M))(7)Thus, we have for our reshaped indices,
ji=mod(α,M)=1+(α−j)/Mandlk=mod(β,M)=1+(β−l)/M(8)Expressed as a regular linear system (3), the higher-order system (1) can be solved with a linear solver such as LAPACK.
-
Linear Finite Elements
Beginning with this post, I’ll be publishing about the basics of finite element formulations, from personal notes that accumulated over the years. This one is about linear and scalar problems which came to be the “Hello World” for FE. Details regarding spaces and discretization are omitted for the sake of brevity. For those who want to delve into theory, I recommend “The Finite Element Method: Theory, Implementation, and Applications” by Larson and Bengzon.
The weak formulation of a canonical linear problem reads
Find u∈V such that
a(u,v)=b(v)(1)for all v∈V where a(⋅,⋅) is a bilinear form and b(⋅) is a linear form.
We define the discretization of u as
uh:=J=1∑nnuJNJ,uh∈VhwhereVh⊂V(2)The discretization uh is a linear combination of basis functions NJ and corresponding scalars uJ, J=1,…,nn so that Vh is a subset of V. The discretization of (1) then reads
a(uh,vh)=b(vh)∀vh∈Vh.(3)We then have
a(J=1∑nnuJNJ,I=1∑nnvINI)=b(I=1∑nnvINI)(4)Using the linearity properties,
a(αu,βv)=αβa(u,v)andb(αv)=αb(v)(5)we obtain
I=1∑nnJ=1∑nnuJvIa(NJ,NI)=I=1∑nnvIb(NI).(6)For arbitrary test function values vI, we can express (6) as a system of nn equations
J=1∑nnuJa(NJ,NI)=b(NI)(7)for I=1,2,…,nn. If we expand the summations as
a(N1,N1)u1a(N1,N2)u1⋮a(N1,Nnn)u1+a(N2,N1)u2+a(N2,N2)u2⋮+a(N2,Nnn)u2+⋯+⋯⋮+⋯+a(Nnn,N1)unn+a(Nnn,N2)unn⋮+a(Nnn,Nnn)unn=b(N1)=b(N2)⋮=b(Nnn)we can see that the terms with a constitute a matrix A and the terms with b constitute a vector b, allowing us to write
Au=b(8)where we chose to express the unknown coefficients uI as a vector u=[u1,u2,…,unn]T.
\It can be seen that the components of the A and b are defined as
AIJ=a(NJ,NI)andbI=b(NI),(9)we can express the linear system as
A11u1A21u1⋮Ann1u1+A12u2+A22u2⋮+Ann2u2+⋯+⋯⋮+⋯+A1nnunn+A2nnunn⋮+Annnnunn=b1=b2⋮=bnnNote that with the given definitions, (7) becomes
J=1∑nnAIJuJ=bIforI=1,2,…nn.(10)Example: Poisson’s Equation
In the weak form of Poisson’s equation
−Δuu=f=0inonΩ∂Ω(11)The weak formulation reads
Find u∈V such that
−∫ΩΔ(u)vdv=∫Ωfvdv(12)for all v∈V where V=H01(Ω).
Applying integration by parts and divergence theorem on the left-hand side
∫ΩΔ(u)vdv=∫Ω∇⋅(∇(u)v)dv−∫Ω∇u⋅∇vdv=v=0 on ∂Ω∫∂Ωv(∇u⋅n)da−∫Ω∇u⋅∇vdv(13)We have the following variational forms:
a(u,v)b(v)=∫Ω∇u⋅∇vdv=∫Ωfvdv(14)Following (7), we can calculate the stiffness matrix A as
AIJ=a(NJ,NI)=∫Ω∇NJ⋅∇NIdv=∫ΩBJ⋅BIdv(15)where we have defined the gradient of the basis functions as
BI:=∇NI.(16)Similarly, we integrate the force term into a vector b as
bI=∫ΩfNIdv(17)