Weak Form FEA II
Weak Form FEA II
It is common in FEM to use the weak form formulation instead of the direct formulation (strong form) as
the weak form formulation allows less restrictions on the solution’s behavior (differentiability).
• Statement 1
The problem of solving the following boundary value problem,
−∆u = f in Ω, (1)
u = 0 on ∂Ω. (2)
is equivalent to
• Statement 2
Find u such that
∫ ∫ ∫ ∫
∇u · ∇vdS = f vdS, (3)
Ω Ω
for all v such that v = 0 on ∂Ω.
(Proof)
• Statement 1 ⇒ Statement 2
Multiply a function that vanishes on the boundary, v, on both sides of Eq. (1) to get
∫ ∫ ∫ ∫
− ∆u v dS = f v dS. (4)
Ω Ω
= ∇u · ∇v dS, (5)
Ω
Just go backwards.
1
or
N (∫ ∫
∑ ) ∫ ∫
∇ei · ∇ej dS uj = f ei dS, (7)
j=1 Ω Ω
or
Lu = c, (8)
where ∫ ∫ ∫ ∫
Lij = ∇ei · ∇ej dS, ci = f ei dS.
Ω Ω
This result is, of course, identical to what we already derived using the Galerkin method in Lecture Note
22. The term “weak” comes from the fact that the weak form requires u to be differentiable only once while
the strong form requires u to be differentiable twice.
FreeFem++
Introduction
FreeFem++ is free software developed by a team at Laboratoire Jacques-Louis Lions, Université Pierre et
Marie Curie, Paris, to solve a system of 2-D and 3-D partial differential equations numerically using the finite
element method. FreeFem++ uses a high-level language similar to C++ to define equations, mesh, the
solution method to be used and plot the result. Unlike commercial software such as ANSYS, it is necessary
that you have to enter the differential equation in weak form directly along with the boundary condition.
Example 1
We wish to solve a Poisson type equation
∂2u ∂2u
+ 2 = 2, (9)
∂x2 ∂y
2
Figure 2: Poisson Equation.
defined over a unit circle shown in Figure 2 with the Dirichlet boundary condition of
u=0
The following steps need to be prepared before implementing this example problem in FreeFem++.
2. Build a mesh where the number of nodes on the boundary needs to be specified. Based on this
information, mesh will be automatically generated.
3. (Important) Rewrite the differential equation in weak form to be entered into FreeFem++.
∆u − 2 = 0. (10)
= − ∇u · ∇vds, (12)
Ω
where we used the fact that v vanishes on the boundary. Therefore, Equation (10) can be written as
∫ ∫ ( ) ∫ ∫
∂u ∂v ∂u ∂v
+ ds + 2vds = 0. (13)
Ω ∂x ∂x ∂y ∂y Ω
3
// Define the border first.
border myBorder(t=0,2*pi){x=cos(t);y=sin(t);};
// Make mesh based on the number of nodes on the border.
mesh myMesh=buildmesh(myBorder(20));
// Let’s plot the mesh.
plot(myMesh);
// Define FEM linear space based on the mesh using P1 (piecewise linear elements).
fespace myVh(myMesh, P1);
// Two functions, myU and myV, are defined in the linear space, myVh.
myVh myU, myV;
// Solve the Poisson equation with prescribed boundary condition.
solve myEq(myU, myV)=int2d(myMesh)(dx(myU)*dx(myV)+dy(myU)*dy(myV))
+int2d(myMesh)(2*myV)+on(myBorder, myU=0);
// Finally, plot the solution in 2-D.
plot(myU,dim=2,fill=true);
In the program above, those words beginning with “my” represent user defined variables. All other words
are system built-in variables.
Figure 4: Solution.
Example 2 (p.1059)
4
Taken from an example in Lecture 21.
∂2u ∂2u
+ 2 = 0 inD, (14)
∂x2 ∂y
u(0, y) = 0 (0 < y < 1) (15)
u(1, y) = f (y) (0 < y < 1) (16)
u(x, 0) = u(x, 1) = 0 (0 < x < 1) (17)
// Define two functions, myU and myV, in the FEM space, myVh.
myVh myU, myV;
5
// Solving the Poisson equation with the given boundary conditions.
solve myPoisson(myU,myV)=int2d(myMesh)(dx(myU)*dx(myV)+dy(myU)*dy(myV))
+int2d(myMesh)(2*myV)+on(myBorder1,myU=0)+on(myBorder2,myU=0)
+on(myBorder3,myU=1)+on(myBorder4,myU=0);
plot(myU,dim=3,fill=true);
Example 3
fespace myVh(myMesh,P1);
plot(u,dim=3,fill=true,value=true);
Example 4
Beam (elasticity)
6
Figure 6: Two materials
• Strong form
µ∆ui + (µ + λ)uj,ji + bi = 0
• Weak form ∫ ∫ ∫ ∫ ∫ ∫
−µ ui,j vi,j dS − (µ + λ) uj,j vj,j dS + bi vi dS = 0.
// file lame.edp
mesh Th=square(10,10,[20*x,2*y-1]);
fespace Vh(Th,P2);
Vh u,v,uu,vv;
real sqrt2=sqrt(2.);
macro epsilon(u1,u2) [dx(u1),dy(u2),(dy(u1)+dx(u2))/sqrt2] // EOM
//the sqrt2 is because we want: epsilon(u1,u2)’* epsilon(v1,v2) $== \epsilon(\bm{u}): \epsilon(\bm{v})
macro div(u,v) ( dx(u)+dy(v) ) // EOM
7
Figure 7: Two materials
cout << " - dep. max x = "<< dxmin<< " y=" << dymin << endl;
cout << " dep. (20,0) = " << u(20,0) << " " << v(20,0) << endl;
8
Figure 8: Beam (elasticity, before deformation)
9
Figure 9: Beam (elasticity, after deformation)
10