-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathoutflow.ca
48 lines (37 loc) · 1.57 KB
/
outflow.ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
Copyright (c) 2013 Centre for Water Systems,
University of Exeter
This file is part of cafloodpro.
cafloodpro is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
// Update the water depth by removing the water
// that infiltrate into the ground.
// ATTENTION, This version add the volume extracted into a buffer
CA_FUNCTION outflow(CA_GRID grid, CA_CELLBUFF_REAL_IO WD, CA_CELLBUFF_STATE_I MASK, CA_CELLBUFF_REAL_IO VOL, CA_REAL tol)
{
// Initialise the grid
CA_GRID_INIT(grid);
// Read Mask.
CA_STATE mask = caReadCellBuffState(grid,MASK,0);
// Read bit 31 (true if the main cell is nodata and at least one
// neighbour has data)
CA_STATE bit31 = caReadBitsState(mask,31,32);
// If bit 31 is false do nothing.
if(bit31 == 0)
return;
// Retrieve the current value of the water depth.
CA_REAL wd = caReadCellBuffReal(grid,WD,0);
//if (wd < tol)
// return;
// Update the water depth value with the removed amount.
caWriteCellBuffReal(grid,VOL,wd);
}