1 function grid = set_boundary_types(grid,params)
2 %
function grid = set_boundary_types(grid,params)
3 %
function setting the boundary types of a polygonal grid.
5 % For .rectgrid
's this is already done in the constructor. For .triagrid this
6 % can be performed explicitly here. Existing boundary settings are 'painted
' by
7 % rectangles The edges with midpoints within such a rectangle are marked
10 % required fields or params:
11 % bnd_rect_corner1: coordinates of lower corner of to be marked
12 % boundaries. This can also be cell array of coordinates for
13 % drawing different rectangles.
14 % bnd_rect_corner2: coordinates of upper corner of to be marked
15 % boundaries. This can also be cell array of coordinates for
16 % drawing different rectangles.
17 % bnd_rect_index: integer index to be set on the edges in the above defined
18 % rectangle. Should not be positive integer in the range of the
19 % number of elements. Use negative indices for certain later
21 % - '-1
' is treated as Dirichlet in the numerics
22 % - '-2
' is treated as Neumann in the numerics
24 % This can also be a vector of the same length as the cell arrays
25 % defined for 'bnd_rect_corner1
' and 'bnd_rect_corner2
' in case of
26 % different boundary types on the domain.
29 % Bernard Haasdonk 14.5.2007
31 if isfield(params,'bnd_rect_index
')
33 bnd_ind = find(grid.NBI<=0);
34 SX = grid.ECX(bnd_ind);
35 SY = grid.ECY(bnd_ind);
36 if (max(params.bnd_rect_index)>0)
37 error('boundary indices must be negative!
');
39 if size(params.bnd_rect_corner1,1) == 1
40 params.bnd_rect_corner1 = params.bnd_rect_corner1';
42 if size(params.bnd_rect_corner2,1) == 1
43 params.bnd_rect_corner2 = params.bnd_rect_corner2
';
45 for i = 1:length(params.bnd_rect_index)
46 indx = (SX > params.bnd_rect_corner1(1,i)) & ...
47 (SX < params.bnd_rect_corner2(1,i)) & ...
48 (SY > params.bnd_rect_corner1(2,i)) & ...
49 (SY < params.bnd_rect_corner2(2,i));
50 grid = set_nbi(grid,bnd_ind(indx), ...
51 params.bnd_rect_index(i));