1 | function md=BasinConstrain(md,domain);
|
---|
2 | %BASINCONSTRAIN constrain basin, using a constraint domain outline, to dirichlet boundary conditions.
|
---|
3 | %
|
---|
4 | % usage: md=BasinConstrain(md,constraindomain)
|
---|
5 | %
|
---|
6 | % where constraindomain is an Argus domain outline file enclosing the geographical area of interest.
|
---|
7 | %
|
---|
8 | % See also: N/A
|
---|
9 |
|
---|
10 | %prepare barycentre positions.
|
---|
11 | xelem=md.x(md.elements)*[1;1;1]/3;
|
---|
12 | yelem=md.y(md.elements)*[1;1;1]/3;
|
---|
13 |
|
---|
14 | %now, flag grids and elements outside the domain outline.
|
---|
15 | [gridondomain elementondomain]=ContourToMesh(md.elements,md.x,md.y,expread(domain,1),'element and node',2);
|
---|
16 | gridnotondomain=find(~gridondomain);
|
---|
17 | elementnotondomain=find(~elementondomain);
|
---|
18 |
|
---|
19 | %all elements outside the constraint domain are equivalent to water. all grids outside are spc'd.
|
---|
20 | md.gridondirichlet_diag(gridnotondomain)=1;
|
---|
21 | md.dirichletvalues_diag(gridnotondomain,1)=md.vx_obs(gridnotondomain);
|
---|
22 | md.dirichletvalues_diag(gridnotondomain,2)=md.vy_obs(gridnotondomain);
|
---|
23 | md.elementonwater(elementnotondomain)=1;
|
---|
24 |
|
---|
25 |
|
---|
26 | %now, make sure all elements on water have grids that are spc'd, otherwise, we'll get a singular problem.
|
---|
27 | pos=find(md.elementonwater);
|
---|
28 | grids=unique(md.elements(pos,:));
|
---|
29 |
|
---|
30 | md.gridondirichlet_diag(grids)=1;
|
---|
31 | md.dirichletvalues_diag(grids,1)=md.vx_obs(grids);
|
---|
32 | md.dirichletvalues_diag(grids,2)=md.vy_obs(grids);
|
---|
33 |
|
---|