1 | function [u,v]=get_obcvolcons(u,v,pm,pn,rmask,obc) |
---|
2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3 | % |
---|
4 | % Enforce integral flux conservation around the domain |
---|
5 | % |
---|
6 | % Further Information: |
---|
7 | % http://www.brest.ird.fr/Roms_tools/ |
---|
8 | % |
---|
9 | % This file is part of ROMSTOOLS |
---|
10 | % |
---|
11 | % ROMSTOOLS is free software; you can redistribute it and/or modify |
---|
12 | % it under the terms of the GNU General Public License as published |
---|
13 | % by the Free Software Foundation; either version 2 of the License, |
---|
14 | % or (at your option) any later version. |
---|
15 | % |
---|
16 | % ROMSTOOLS is distributed in the hope that it will be useful, but |
---|
17 | % WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | % GNU General Public License for more details. |
---|
20 | % |
---|
21 | % You should have received a copy of the GNU General Public License |
---|
22 | % along with this program; if not, write to the Free Software |
---|
23 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
24 | % MA 02111-1307 USA |
---|
25 | % |
---|
26 | % Copyright (c) 2001-2006 by Pierrick Penven |
---|
27 | % e-mail:Pierrick.Penven@ird.fr |
---|
28 | % |
---|
29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
30 | umask=rmask(1:end,2:end).*rmask(1:end,1:end-1); |
---|
31 | vmask=rmask(2:end,1:end).*rmask(1:end-1,1:end); |
---|
32 | % |
---|
33 | dy_u=2*umask./(pn(1:end,2:end)+pn(1:end,1:end-1)); |
---|
34 | dx_v=2*vmask./(pm(2:end,1:end)+pm(1:end-1,1:end)); |
---|
35 | udy=u.*dy_u; |
---|
36 | vdx=v.*dx_v; |
---|
37 | % |
---|
38 | Flux=obc(1)*sum(vdx(1,2:end-1))-obc(2)*sum(udy(2:end-1,end))-... |
---|
39 | obc(3)*sum(vdx(end,2:end-1))+obc(4)*sum(udy(2:end-1,1)); |
---|
40 | Cross=obc(1)*sum(dx_v(1,2:end-1))+obc(2)*sum(dy_u(2:end-1,end))+... |
---|
41 | obc(3)*sum(dx_v(end,2:end-1))+obc(4)*sum(dy_u(2:end-1,1)); |
---|
42 | vcorr=Flux/Cross; |
---|
43 | disp(['Flux correction : ',num2str(vcorr)]) |
---|
44 | % |
---|
45 | v(1,:)=obc(1)*(v(1,:)-vcorr); |
---|
46 | u(:,end)=obc(2)*(u(:,end)+vcorr); |
---|
47 | v(end,:)=obc(3)*(v(end,:)+vcorr); |
---|
48 | u(:,1)=obc(4)*(u(:,1)-vcorr); |
---|
49 | % |
---|
50 | u=u.*umask; |
---|
51 | v=v.*vmask; |
---|
52 | % |
---|
53 | return |
---|