rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
compute_gdl_velocity2.m
Go to the documentation of this file.
1 % script computing a velocity field for simple gdl model by solving a
2 % laplace problem with suitable boundary conditions
3 %
4 % three components are put together:
5 %
6 % .p0...______......______......______..p1..
7 % | |
8 % | |
9 % -----------------------------------------
10 %
11 % |- = neumann 0 conditions
12 % ... dirichlet conditions: linearly decreasing pressure
13 
14 % Bernard Haasdonk 6.7.2006
15 
16 %%%%%%%%%%%%%%%%%%%%%%%% compute pressure
17 params = [];
18 
19 disp('setting parameters');
20 
21 params.xrange = [-1250e-6,2250e-6]; % grid x-coordinate range
22 params.yrange = [0,200e-6]; % grid y-coordinate range
23 params.xnumintervals = 497; % number of grid cells in x-direction:
24  % multiple of 7
25 params.ynumintervals = 41; % number of grid cells in y-direction
26 
27 % set upper boundary to dirichlet, middle of upper and the lower boundary
28 % to neuman, set left and right to neuman
29 params.bnd_rect_corner1 = [params.xrange(1) , params.yrange(2) ; ...
30  params.xrange(1)+ 500e-6 , params.yrange(2); ...
31  params.xrange(1)+ 1500e-6 , params.yrange(2); ...
32  params.xrange(1)+ 2500e-6 , params.yrange(2); ...
33  params.xrange(1) , params.yrange(1); ...
34  params.xrange(1) , params.yrange(1); ...
35  params.xrange(2) , params.yrange(1);
36  ];
37 params.bnd_rect_corner1 = params.bnd_rect_corner1' - eps;
38 params.bnd_rect_corner2 = [params.xrange(2), params.yrange(2); ...
39  params.xrange(1)+1000e-6, params.yrange(2); ...
40  params.xrange(1)+2000e-6, params.yrange(2); ...
41  params.xrange(1)+3000e-6, params.yrange(2); ...
42  params.xrange(2), params.yrange(1); ...
43  params.xrange(1), params.yrange(2); ...
44  params.xrange(2), params.yrange(2)
45  ];
46 params.bnd_rect_corner2 = params.bnd_rect_corner2' + eps;
47 
48 params.bnd_rect_index = [-1, -2, -2, -2, -2, -2, -2];
49 params.name_dirichlet_values = 'xstripes';
50 params.c_dir = [4,3,2,1];
51 % separating borders for changing value
52 params.dir_borders = [params.xrange(1)+750e-6, ...
53  params.xrange(1)+1750e-6, ...
54  params.xrange(1)+2750e-6];
55 %params.name_dirichlet_values = 'leftright';
56 %params.c_dir_left = 1.0; % pressure left
57 %params.c_dir_right = 0.5; % pressure right
58 %params.dir_middle = params.xrange(2)/2;
59 
60 %params.name_dirichlet_values = 'homogeneous';
61 %params.c_dir = 1.0;
62 params.name_neuman_values = 'zero';
63 %params.name_neuman_values = 'homogeneous';
64 %params.c_neu = 0;
65 
66 params.show_colorbar = 1;
67 params.no_lines = 1;
68 params.verbose = 10;
69 
70 grid = rectgrid(params);
71 
72 %tfn = fullfile(getenv('RBMATLABTEMP'),'gdl_pressure2.mat');
73 tfn = fullfile(rbmatlabhome,'datafunc','data','gdl_pressure2.mat');
74 
75 if ~exist(tfn,'file')
76  p = fem_laplace(grid,params);
77 
78  figure;
79  plot_vertex_data(grid,p,params);
80 
81  % [px,py] = gradient(reshape(p,params.nx+1,params.ny+1)',...
82  % params.xrange(2)/params.nx,params.yrange(2)/params.ny);
83  % figure;
84  % quiver(1:(params.nx+1),1:(params.ny+1),-4*px,-4*py);
85 
86  save(tfn,'p','params');
87 else
88  disp('skipping computation of data, as gdl_pressure2.mat exists')
89 end;
90 
91 
92 % plot velocity:
93 
94 % evaluate velocity in a second grid and plot as piecewise constant
95 load(tfn,'p','params');
96 params2 = [];
97 params2.xnumintervals = 350;
98 params2.ynumintervals = 50;
99 params2.xrange = params.xrange;
100 params2.yrange = params.yrange;
101 params2.verbose = 0;
102 params2.show_colorbar = 1;
103 params2.no_lines = 1;
104 params2.axis_tight = 1;
105 
106 grid2 = rectgrid(params2);
107 [ux, uy] = evaluate_gradient(grid2.CX, grid2.CY, p, params);
108 
109 factor = 1/1000;
110 ux = -ux/factor;
111 uy = -uy/factor;
112 %plot_element_data_sequence(grid2,[-ux,-uy],params2);
113 params2.plot = @fv_plot;
114 plot_sequence([-ux,-uy],grid2,params2);
115 title('gradient on whole domain');
116 
117 params2.xrange = [0e-6,1000e-6]; % grid x-coordinate range
118 params2.yrange = params.yrange;
119 params2.xnumintervals = 200;
120 grid2 = rectgrid(params2);
121 [ux, uy] = evaluate_gradient(grid2.CX, grid2.CY,p,params);
122 
123 ux = -ux/factor;
124 uy = -uy/factor;
125 plot_sequence([-ux,-uy],grid2,params2);
126 %plot_element_data_sequence(grid2,[-ux,-uy],params2);
127 title('gradient on part of domain');
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
Definition: verbose.m:17
function p = fv_plot(gridbase grid, dofs, params)
routine plotting a single fv function of fv_functions.
Definition: fv_plot.m:17
function p = plot_sequence(varargin)
plotting a sequence of data slices on polygonal 2d grid (constructed from params if empty) and provid...
Definition: plot_sequence.m:17
A cartesian rectangular grid in two dimensions with axis parallel elements.
Definition: rectgrid.m:17