1 % demo of a finite element simulation
3 % Script solving a laplace problem (-laplace u = 0) with suitable
4 % general dirichlet and neuman boundary conditions
5 % Currently only cartesian grids are supported in the underlying
8 % Bernard Haasdonk 5.7.2006
10 %| \todo make work again for release
12 disp('Demonstration that solves a laplace-problem -laplace u = 0:')
16 disp('setting parameters');
19 params.xrange = [0,1]; % grid x-coordinate range
20 params.yrange = [0,1]; % grid y-coordinate range
21 params.xnumintervals = 100; % number of grid cells in x-direction
22 params.ynumintervals = 50; % number of grid cells in y-direction
24 % the following exceeds the size of sparse-matrices, which can be
25 % linearly indexed (180000 elements, ... sec comp time)
26 %params.nx = 600; % number of grid cells in x-direction
27 %params.ny = 300; % number of grid cells in y-direction
29 % the following is trivially solvable by linear indices <= 1.6e9
30 %params.nx = 200; % number of grid cells in x-direction
31 %params.ny = 100; % number of grid cells in y-direction
33 % set upper boundary to dirichlet, middle of upper and the lower boundary
34 % to neuman, set left and right to neuman
35 params.bnd_rect_corner1 = [params.xrange(1) , params.yrange(2) ; ...
36 params.xrange(1)+ 250e-6 , params.yrange(2); ...
37 params.xrange(1) , params.yrange(1); ...
38 params.xrange(1) , params.yrange(1); ...
39 params.xrange(2) , params.yrange(1);
41 params.bnd_rect_corner1 = params.bnd_rect_corner1' - eps;
42 params.bnd_rect_corner2 = [params.xrange(2), params.yrange(2); ...
43 params.xrange(2)-250e-6, params.yrange(2); ...
44 params.xrange(2), params.yrange(1); ...
45 params.xrange(1), params.yrange(2); ...
46 params.xrange(2), params.yrange(2)
48 params.bnd_rect_corner2 = params.bnd_rect_corner2' + eps;
50 params.bnd_rect_index = [-1, -2, -2, -2, -2];
53 grid = construct_grid(params);
57 params.name_dirichlet_values = 'leftright';
58 params.c_dir_left = 1.0; % pressure left
59 params.c_dir_right = 0.5; % pressure right
60 params.dir_middle = params.xrange(2)/2;
62 %params.name_dirichlet_values = 'homogeneous';
64 params.name_neuman_values = 'pressure_gdl';
65 params.c_neu_max = 1000; % maximum velocity in middle of left and right side
67 %params.name_neuman_values = 'homogeneous';
70 params.show_colorbar = 1;
74 disp('solving system');
75 p = fem_laplace(grid,params);
77 disp('plotting result');
80 plot_vertex_data(grid,p,params);
81 %plot_p1_data(p,params);
88 % TO BE ADJUSTED TO NEW SYNTAX