Environmental Engineering Reference
In-Depth Information
8
6
4
2
0
0
5
10
4
3
20
2
30
1
Fig. 21.3 Solution of the example setting for the Poisson equation
21.4 Solution for the 2D Poisson equation
In the previous sub-chapter the numerical solution of the Poisson equation was
described as a first example solving a stationary problem on higher dimensional
model region. Here we extend the program to deal with heterogeneous boundary
conditions and right hand side.
In the previous example Dirichlet-type boundary conditions are given at the
constant- x boundaries, while at the constant- y boundaries Neumann-type conditions
are required. In order to allow arbitrary combinations of Dirichlet- and Neumann-
type conditions, the program has to be extended. We choose to use logical vectors
for the indication of the boundary type and double vectors for the values. There are
four vectors representing the four sides of the square model region:
% boundary type indicators (1=Dirichlet, 0=Neumann no-flow)
ltop = logical(zeros(1,nx)); % top
lbottom = logical(zeros(1,nx)); % bottom
lleft = logical([ones(ny/2,1) zeros(ny/2,1)]); % left
lright = logical([zeros(ny/2,1) ones(ny/2,1)]); % right
A 1-entry in the vector indicates a Dirichlet-type condition, while a 0-entry
stands for a Neumann-type no flow condition. In the example, given by the four
commands above, we have no-flow conditions along the top and bottom boundary,
while the left and right boundary a split in two parts, one having Dirichlet- and one
Neumann-type conditions.
Corresponding to the logical vectors as boundary-type indicators we introduce
double vectors for the eventually needed boundary values:
Search WWH ::




Custom Search