We define with the top and bottom channel walls, the cylinder walls, the inlet and the outlet.
Formally, the PDE we want to solve is: find the velocity vector and the pressure such that
where , and is the Reynolds number.
The inflow condition is given by
with the maximum velocity and the height of the channel.
In order to approximate this problem we choose a formulation based on inf-sup stable triangular elements with continuous velocities and pressures. The interpolation spaces are defined as follows. The velocity interpolation space is
where denotes an arbitrary cell of the FE mesh , and is the usual Lagrangian FE space of order defined on a mesh of triangles or tetrahedra. On the other hand, the space for the pressure is given by
The weak form associated to these interpolation spaces reads: find such that for all where and are the set of functions in fulfilling the Dirichlet boundary conditions and the homogeneous Dirichlet boundary conditions respectively. The weak residual evaluated at a given pair is the linear form defined as
with
Note that the bilinear form is associated with the linear part of the PDE, whereas is the contribution to the residual resulting from the convective term.
In order to solve this nonlinear weak equation with a Newton-Raphson method, one needs to compute the Jacobian associated with the residual . In this case, the Jacobian evaluated at a pair is the bilinear form defined as
where results from the linearization of the convective term, namely
We start by importing the packages and loading the provided mesh in the file perforated_plate_tiny.msh
:
using Gridap, GridapGmsh
using DrWatson
msh_file = projectdir("meshes/perforated_plate_tiny.msh")
model = GmshDiscreteModel(msh_file)
Open the resulting files with ParaView. Visualize the faces of the model and color them by each of the available fields. Identify the tag names representing the boundaries (top and bottom channel walls), (cylinder walls), (inlet) and (outlet).
writevtk(model,datadir("perforated_plate"))
Define the test FESpaces
for velocity and pressure, as described above. The velocity space should be a vector-valued lagrangian space of order k
with appropriate boundary conditions. The pressure space should be an unconstrained lagrangian space of order k-1
.
D = 2
k = 2
Define the boundary conditions for velocity. You should define three functions u_in
, u_w
and u_c
representing the prescribed dirichlet values at , and respectively.
Define the trial and test spaces for the velocity and pressure fields, as well as the corresponding multi-field spaces.
#U =
#P =
#Y =
#X =
As usual, we start by defining the triangulations and measures we will need to define the weak form. In this case, we need to define the measure associate with the bulk , as well as the measure associated with the outlet boundary .
degree = k
Ω = Triangulation(model)
dΩ = Measure(Ω,degree)
Γ_out = BoundaryTriangulation(model,tags="outlet")
n_Γout = get_normal_vector(Γ_out)
dΓ_out = Measure(Γ_out,degree)
We also define the Reynolds number and functions to represent the convective term and its linearization.
const Re = 20
conv(u,∇u) = Re*(∇u')⋅u
dconv(du,∇du,u,∇u) = conv(u,∇du)+conv(du,∇u)
Define the weak form for our problem. You should start by defining the bilinear forms and and the trilinear form . Then use these components to build the residual and the jacobian .
#a((u,p),(v,q)) =
#c(u,v) =
#dc(u,du,v) =
#res((u,p),(v,q)) =
#jac((u,p),(du,dp),(v,q)) =
We can finally define the FEOperator
as usual
op = FEOperator(res,jac,X,Y)
Create a nonlinear Newton-Raphson solver and solve the problem. Print the solutions to a .vtk
file and examine the obtained solution.
using LineSearches: BackTracking
This tutorial follows test case 2D-1 from (Schafer,1996)[https://link.springer.com/chapter/10.1007/978-3-322-89849-4_39]