CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
do_beach_sediment_movement.cpp
Go to the documentation of this file.
1
12
13/* ==============================================================================================================================
14
15 This file is part of CoastalME, the Coastal Modelling Environment.
16
17 CoastalME 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.
18
19 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.
20
21 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23==============================================================================================================================*/
24#include <assert.h>
25
26#include <cmath>
27
28#include <cfloat>
29
30#include <iostream>
31using std::endl;
32
33#include <algorithm>
34using std::stable_sort;
35
36#include "cme.h"
37#include "simulation.h"
38#include "coast.h"
39
40namespace
41{
42//===============================================================================================================================
44//===============================================================================================================================
45bool bPolygonAndAdjCompare(const vector<int>& nVLeft, const vector<int>& nVRight)
46{
47 // Each row (vector) of this vector-of-vectors is:
48 // 0: This-polygon coast ID (in down-coast seq when sorted)
49 // 1: This-polygon down-coast (true) or up-coast (false) sediment movement
50 // 2 and subsequent: if sediment movement is down-coast, coast IDs of down-coast adjacent polygons; if sediment movement is up-coast, coast IDs of up-coast adjacent polygons
51
52 bool const bDownCoastLeft = nVLeft[1];
53 bool const bDownCoastRight = nVRight[1];
54
55 if (bDownCoastLeft)
56 {
57 // LHS polygon is down-coast. First, deal with polygon 0
58 if (nVLeft[0] == 0)
59 // Do not swap LHS and RHS polygons
60 return true;
61
62 if (nVRight[0] == 0)
63 // Swap LHS and RHS polygons
64 return false;
65
66 if ((nVLeft.size() >= 3) && (nVRight.size() >= 3))
67 {
68 // Search the adjacent polygons of the LHS argument, is there an "off edge" amongst them?
69 bool bLHSOffEdge = false;
70
71 for (unsigned int n = 2; n < nVLeft.size(); n++)
72 {
73 if (nVLeft[n] == INT_NODATA)
74 {
75 bLHSOffEdge = true;
76 break;
77 }
78 }
79
80 if (bLHSOffEdge)
81 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: so swap LHS and RHS polygons
82 return false;
83
84 // Search the adjacent polygons of the RHS argument, is there an "off edge" amongst them?
85 bool bRHSOffEdge = false;
86
87 for (unsigned int n = 2; n < nVRight.size(); n++)
88 {
89 if (nVRight[n] == INT_NODATA)
90 {
91 bRHSOffEdge = true;
92 break;
93 }
94 }
95
96 if (bRHSOffEdge)
97 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: do not swap LHS and RHS polygons
98 return true;
99
100 // Do we have a local change of sediment direction?
101 if (! bDownCoastRight)
102 // Yes, there is a change of sediment direction between this and the adjacent polygon. Keep the existing sequence
103 return true;
104
105 // Now sort out polygon-to-polygon dependencies. We need to put 'target' polygons after 'source' polygons, so that the source is processed before the target. So is the RHS polygon among the adjacent polygons of the LHS polygon?
106 bool bLeftFound = false;
107
108 for (unsigned int n = 2; n < nVLeft.size(); n++)
109 {
110 if (nVLeft[n] == nVRight[0])
111 bLeftFound = true;
112 }
113
114 if (bLeftFound)
115 // Yes, the RHS polygon is among the adjacent polygons of the LHS polygon, so uncons sediment movement is from the LHS polygon to the RHS polygon, and so down-coast (i.e. along the coast in the direction of increasing coastline point numbers). Keep the existing sequence
116 return true;
117
118 // Is the LHS polygon among the adjacent polygons of the RHS polygon?
119 bool bRightFound = false;
120
121 for (unsigned int n = 2; n < nVRight.size(); n++)
122 {
123 if (nVRight[n] == nVLeft[0])
124 bRightFound = true;
125 }
126
127 if (bRightFound)
128 // Yes, the LHS polygon is among the adjacent polygons of the RHS polygon, so uncons sediment movement is from the RHS polygon to the LHS polygon, and so up-coast (i.e. along the coast in the direction of decreasing coastline point numbers). Swap them
129 return false;
130 }
131
132 // Neither polygon has an "off edge", and each polygon does not have the other polygon's coast ID amongst its list of adjacent polygons. So just put the polygon in increasing own-coast sequence
133 if (nVLeft[0] < nVRight[0])
134 return true;
135
136 else
137 return false;
138 }
139
140 else
141 {
142 // LHS polygon is up-coast. First, deal with polygon 0
143 if (nVLeft[0] == 0)
144 // Swap LHS and RHS polygons
145 return false;
146
147 if (nVRight[0] == 0)
148 // Do not swap LHS and RHS polygons
149 return true;
150
151 if ((nVLeft.size() >= 3) && (nVRight.size() >= 3))
152 {
153 // Next, search the adjacent polygons of the LHS argument, is there an "off edge" amongst them?
154 bool bLHSOffEdge = false;
155
156 for (unsigned int n = 2; n < nVLeft.size(); n++)
157 {
158 if (nVLeft[n] == INT_NODATA)
159 {
160 bLHSOffEdge = true;
161 break;
162 }
163 }
164
165 if (bLHSOffEdge)
166 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: so do not swap LHS and RHS polygons
167 return true;
168
169 // Search the adjacent polygons of the RHS argument, is there an "off edge" amongst them?
170 bool bRHSOffEdge = false;
171
172 for (unsigned int n = 2; n < nVRight.size(); n++)
173 {
174 if (nVRight[n] == INT_NODATA)
175 {
176 bRHSOffEdge = true;
177 break;
178 }
179 }
180
181 if (bRHSOffEdge)
182 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: swap LHS and RHS polygons
183 return false;
184
185 // Do we have a local change of sediment direction?
186 if (! bDownCoastRight)
187 // Yes, there is a change of sediment direction between this and the adjacent polygon. Keep the existing sequence
188 return true;
189
190 // Now sort out polygon-to-polygon dependencies. We need to put 'target' polygons after 'source' polygons, so that the source is processed before the target. So is the RHS polygon among the adjacent polygons of the LHS polygon?
191 bool bLeftFound = false;
192
193 for (unsigned int n = 2; n < nVLeft.size(); n++)
194 {
195 if (nVLeft[n] == nVRight[0])
196 bLeftFound = true;
197 }
198
199 if (bLeftFound)
200 // Yes, the RHS polygon is among the adjacent polygons of the LHS polygon, so uncons sediment movement is from the LHS polygon to the RHS polygon, and so down-coast (i.e. along the coast in the direction of increasing coastline point numbers). Keep the existing sequence of polygons
201 return true;
202
203 // Is the LHS polygon among the adjacent polygons of the RHS polygon?
204 bool bRightFound = false;
205
206 for (unsigned int n = 2; n < nVRight.size(); n++)
207 {
208 if (nVRight[n] == nVLeft[0])
209 bRightFound = true;
210 }
211
212 if (bRightFound)
213 // Yes, the LHS polygon is among the adjacent polygons of the RHS polygon, so uncons sediment movement is from the RHS polygon to the LHS polygon, and so up-coast (i.e. along the coast in the direction of decreasing coastline point numbers). Swap the LHS and RHS polygons
214 return false;
215 }
216
217 // Neither polygon has an "off edge", and each polygon does not have the other polygon's coast ID amongst its list of adjacent polygons. So just put the polygons in decreasing own-coast sequence
218 if (nVLeft[0] < nVRight[0])
219 return false;
220
221 else
222 return true;
223 }
224
225 // Default return value, should never get here
226 return true;
227}
228} // namespace
229
230//===============================================================================================================================
232//===============================================================================================================================
234{
235 for (int nCoast = 0; nCoast < static_cast<int>(m_VCoast.size()); nCoast++)
236 {
237 int nRet;
238
240 LogStream << m_ulIter << ": Calculating unconsolidated sediment transport" << endl;
241
242 // Update the values of pre-existing unconsolidated sediment, for all three size classes, to include unconsolidated sediment derived from platform erosion, cliff collapse, and sediment input events
244
246 {
249 }
250
251 // Now route actually-eroded sand/coarse sediment to adjacent polygons, or off-grid. Sort polygons first
252 // Each row (vector) of this vector-of-vectors is:
253 // 0 This-polygon coast ID (in down-coast seq when sorted)
254 // 1 This-polygon down-coast (true) or up-coast (false) sediment movement
255 // 2 and subsequent: if sediment movement is down-coast, coast IDs of down-coast adjacent polygons; if sediment movement is up-coast, coast IDs of up-coast adjacent polygons
256 vector<vector<int>> nVVPolyAndAdjacent;
257 vector<int> nVPolyAndAdj;
258
259 for (int nn = 0; nn < m_VCoast[nCoast].nGetNumPolygons(); nn++)
260 {
261 CGeomCoastPolygon const* pPolygon = m_VCoast[nCoast].pGetPolygon(nn);
262 nVPolyAndAdj.clear();
263
264 // The first [0] nVPolyAndAdj array item is the polygon's down-coast ID
265 nVPolyAndAdj.push_back(pPolygon->nGetPolygonCoastID());
266
267 if (pPolygon->bDownCoastThisIter())
268 {
269 // Sediment is leaving this polygon in a down-coast direction. Set this as the second [1] nVPolyAndAdj array item
270 nVPolyAndAdj.push_back(true);
271
272 // Third [2] and subsequent nVPolyAndAdj array items are the down-coast seqs of adjacent down-coast polygons
273 for (int nAdj = 0; nAdj < pPolygon->nGetNumDownCoastAdjacentPolygons(); nAdj++)
274 {
275 // Save the coast ID of each down-coast adjacent polygon
276 int const nAdjPolyID = pPolygon->nGetDownCoastAdjacentPolygon(nAdj);
277 nVPolyAndAdj.push_back(nAdjPolyID);
278 }
279 }
280
281 else
282 {
283 // Sediment is leaving this polygon in an up-coast direction. Set this as the second [1] nVPolyAndAdj array item
284 nVPolyAndAdj.push_back(false);
285
286 // Third [2] and susequent nVPolyAndAdj array items are the down-coast IDs of adjacent up-coast polygons
287 for (int nAdj = 0; nAdj < pPolygon->nGetNumUpCoastAdjacentPolygons(); nAdj++)
288 {
289 // Save the coast ID of each up-coast adjacent polygon
290 int const nAdjPolyID = pPolygon->nGetUpCoastAdjacentPolygon(nAdj);
291 nVPolyAndAdj.push_back(nAdjPolyID);
292 }
293 }
294
295 // Save this 'row'
296 nVVPolyAndAdjacent.push_back(nVPolyAndAdj);
297 }
298
299 // Write out the unsorted polygon sequence
301 WritePolygonUnsortedSequence(nCoast, nVVPolyAndAdjacent);
302
303 // OK, now sort the array using bPolygonAndAdjCompare(), so that 'target' polygons are processed after 'source' polygons NOTE: crashes if just use "sort", related to this? https://stackoverflow.com/questions/18291620/why-will-stdsort-crash-if-the-comparison-function-is-not-as-operator
304 stable_sort(nVVPolyAndAdjacent.begin(), nVVPolyAndAdjacent.end(), bPolygonAndAdjCompare);
305
306 // And check for circularities i.e. where poly X -> poly Y -> poly X. Note that we only look for two-way circularities. i.e. we ignore poly A -> poly B -> Poly C -> poly A patterns. These are probably pretty rare, however
307 vector<int> VnSourcePolygons;
308
309 for (int n = 0; n < static_cast<int>(nVVPolyAndAdjacent.size()); n++)
310 {
311 int const nThisPoly = nVVPolyAndAdjacent[n][0];
312 VnSourcePolygons.push_back(nThisPoly);
313
314 for (int m = 2; m < static_cast<int>(nVVPolyAndAdjacent[n].size()); m++)
315 {
316 // Check the adjacent polygon(s) for circularities
317 int const nToFind = nVVPolyAndAdjacent[n][m];
318 vector<int>::iterator const it = find(VnSourcePolygons.begin(), VnSourcePolygons.end(), nToFind);
319
320 if (it != VnSourcePolygons.end())
321 {
322 // Uh-oh: this adjacent polygon is in the list of previously-processed source polygons. So store the coast ID numbers of the polygons with circularity in both polygons
323 CGeomCoastPolygon* pPoly = m_VCoast[nCoast].pGetPolygon(nThisPoly);
324 pPoly->AddCircularity(nToFind);
325
326 pPoly = m_VCoast[nCoast].pGetPolygon(nToFind);
327 pPoly->AddCircularity(nThisPoly);
328 }
329 }
330 }
331
333 WritePolygonSortedSequence(nCoast, nVVPolyAndAdjacent);
334
335 int const nNumPolygons = m_VCoast[nCoast].nGetNumPolygons();
336
337 // Now process all polygons and do the actual (supply-limited) unconsolidated sediment movement
338 for (int nPoly = 0; nPoly < nNumPolygons; nPoly++)
339 {
340 int const nPolygon = nVVPolyAndAdjacent[nPoly][0];
341 CGeomCoastPolygon* pPolygon = m_VCoast[nCoast].pGetPolygon(nPolygon);
342
343 // // DEBUG CODE =====================
344 // int nUpCoastProfile = pPolygon->nGetUpCoastProfile();
345 // CGeomProfile* pUpCoastProfile = m_VCoast[nCoast].pGetProfile(nUpCoastProfile);
346 // int nDownCoastProfile = pPolygon->nGetDownCoastProfile();
347 // CGeomProfile* pDownCoastProfile = m_VCoast[nCoast].pGetProfile(nDownCoastProfile);
348 // int nNumUpCoastCell = pUpCoastProfile->nGetNumCellsInProfile();
349 // int nNumDownCoastCell = pDownCoastProfile->nGetNumCellsInProfile();
350 // LogStream << "pUpCoastProfile->nGetNumCellsInProfile() = " << nNumUpCoastCell << " pDownCoastProfile->nGetNumCellsInProfile() = " << nNumDownCoastCell << endl;
351 // // DEBUG CODE =====================
352
353 // // DEBUG CODE ============================================================================================================================================
354 // // Get total depths of sand consolidated and unconsolidated for every cell
355 // if (m_ulIter == 5)
356 // {
357 // double dTmpSandUncons = 0;
358 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
359 // {
360 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
361 // {
362 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
363 // }
364 // }
365 //
366 // LogStream << endl;
367 // LogStream << "*****************************" << endl;
368 // LogStream << m_ulIter << ": before beach movement on nPoly = " << nPoly << " TOTAL UNCONSOLIDATED SAND ON ALL CELLS = " << dTmpSandUncons * m_dCellArea << endl;
369 // }
370 // // DEBUG CODE ============================================================================================================================================
371
372 // Do deposition first: does this polygon have coarse deposition?
373 double dCoarseDepositionTarget = pPolygon->dGetToDoBeachDepositionUnconsCoarse();
374
375 if (dCoarseDepositionTarget > 0)
376 {
377 // It does, first tho', if we have some coarse sediment which we were unable to deposit on the previously-processed polygon (which could be the last-processed polygon of the previous timestep), then add this in
379 {
380 // We had some coarse unconsolidated sediment which we were unable to deoosit on the last polygon (which could have been the last polygon of the previous iteration). So add it to the total to be deposited here
382 LogStream << m_ulIter << ": nPoly = " << nPolygon << " dCoarseDepositionTarget was = " << dCoarseDepositionTarget * m_dCellArea << " adding m_dDepositionCoarseDiff = " << m_dDepositionCoarseDiff * m_dCellArea;
383
384 dCoarseDepositionTarget += m_dDepositionCoarseDiff;
386
388 LogStream << " dCoarseDepositionTarget now = " << dCoarseDepositionTarget << endl;
389 }
390
391 // OK, do deposition of coarse sediment: calculate a net increase in depth of coarse-sized unconsolidated sediment on the cells within the polygon. Note that some cells may decrease in elevation (i.e. have some coarse-sized sediment erosion) however
392 double dCoarseDeposited = 0;
393 nRet = nDoUnconsDepositionOnPolygon(nCoast, pPolygon, TEXTURE_COARSE, dCoarseDepositionTarget, dCoarseDeposited);
394
395 if (nRet != RTN_OK)
396 return nRet;
397
398 double const dCoarseNotDeposited = dCoarseDepositionTarget - dCoarseDeposited;
399
400 if (dCoarseNotDeposited > 0)
401 {
402 m_dDepositionCoarseDiff += dCoarseNotDeposited;
403 }
404 }
405
406 // Does this polygon have sand deposition?
407 double dSandDepositionTarget = pPolygon->dGetToDoBeachDepositionUnconsSand();
408
409 if (dSandDepositionTarget > 0)
410 {
411 // It does, first tho', if we have some sand sediment which we were unable to deposit on the previously-processed polygon (which could be the last-processed polygon of the previous timestep), then add this in
413 {
414 // We had some sand unconsolidated sediment which we were unable to deoosit on the last polygon (which could have been the last polygon of the previous iteration). So add it to the total to be deposited here
416 LogStream << m_ulIter << ": nPolygon = " << nPolygon << " dSandDepositionTarget was = " << dSandDepositionTarget * m_dCellArea << " adding m_dDepositionSandDiff = " << m_dDepositionSandDiff * m_dCellArea;
417
418 dSandDepositionTarget += m_dDepositionSandDiff;
420
422 LogStream << " dSandDepositionTarget now = " << dSandDepositionTarget << endl;
423 }
424
425 // Now do deposition of sand sediment: calculate a net increase in depth of sand-sized unconsolidated sediment on the cells within the polygon. Note that some cells may decrease in elevation (i.e. have some sand-sized sediment erosion) however
426 double dSandDeposited = 0;
427 nRet = nDoUnconsDepositionOnPolygon(nCoast, pPolygon, TEXTURE_SAND, dSandDepositionTarget, dSandDeposited);
428
429 if (nRet != RTN_OK)
430 return nRet;
431
432 double const dSandNotDeposited = dSandDepositionTarget - dSandDeposited;
433
434 if (dSandNotDeposited > 0)
435 {
436 m_dDepositionSandDiff += dSandNotDeposited;
437 }
438
439 // // DEBUG CODE #####################
440 // if (m_ulIter == 5)
441 // {
442 // LogStream << m_ulIter << ": after sand deposition on nPoly = " << nPoly << " dSandDepositionTarget = " << dSandDepositionTarget * m_dCellArea << " dSandDeposited = " << dSandDeposited * m_dCellArea << " dSandNotDeposited = " << dSandNotDeposited * m_dCellArea << " m_dDepositionSandDiff = " << m_dDepositionSandDiff * m_dCellArea << endl;
443 //
444 // double dTmpSandUncons = 0;
445 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
446 // {
447 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
448 // {
449 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
450 // }
451 // }
452 //
453 // LogStream << m_ulIter << ": after sand deposition on nPoly = " << nPoly << " TOTAL UNCONSOLIDATED SAND ON ALL CELLS = " << dTmpSandUncons * m_dCellArea << endl;
454 // }
455 // // DEBUG CODE #####################
456 }
457
458 // Now do erosion
459 double const dPotentialErosion = -pPolygon->dGetPotentialErosion();
460
461 if (dPotentialErosion > 0)
462 {
463 // There is some erosion on this polygon: process this in the sequence fine, sand, coarse. Is there any fine sediment on this polygon?
464 double const dExistingUnconsFine = pPolygon->dGetPreExistingUnconsFine();
465
466 if (dExistingUnconsFine > 0)
467 {
468 // Yes there is, so crudely partition this potential value for this size class by erodibility, the result will almost always be much greater than actual (supply limited) erosion
469 double const dFinePotentialErosion = dPotentialErosion * m_dFineErodibilityNormalized;
470
471 // Now reduce this further, by considering the total depth of fine sediment on the polygon
472 double const dFineErosionTarget = tMin(dFinePotentialErosion, dExistingUnconsFine);
473
474 // OK, do the supply-limited erosion of fine sediment
475 double dFineEroded = 0;
476 nRet = nDoUnconsErosionOnPolygon(nCoast, pPolygon, TEXTURE_FINE, dFineErosionTarget, dFineEroded);
477
478 if (nRet != RTN_OK)
479 return nRet;
480
481 if (dFineEroded > 0)
482 {
483 // We eroded some fine sediment, so add to the this-iteration total. Note that total this gets added in to the suspended load elsewhere, so no need to do it here
484 m_dThisIterBeachErosionFine += dFineEroded;
485
486 // Also add to the suspended load
488
489 // Store the amount of unconsolidated fine beach sediment eroded for this polygon
490 pPolygon->SetBeachErosionUnconsFine(-dFineEroded);
491 }
492 }
493
494 // Is there any sand-sized sediment on this polygon?
495 double const dExistingUnconsSand = pPolygon->dGetPreExistingUnconsSand();
496 double dSandEroded = 0;
497
498 if (dExistingUnconsSand > 0)
499 {
500 // There is: so crudely partition this potential value for this size class by erodibility, the result will almost always be much greater than actual (supply limited) erosion
501 double const dSandPotentialErosion = dPotentialErosion * m_dSandErodibilityNormalized;
502
503 // Now reduce this further, by considering the total depth of sand sediment on the polygon
504 double const dSandErosionTarget = tMin(dSandPotentialErosion, dExistingUnconsSand);
505
506 // OK, do the supply-limited erosion of sand sediment
507 nRet = nDoUnconsErosionOnPolygon(nCoast, pPolygon, TEXTURE_SAND, dSandErosionTarget, dSandEroded);
508
509 if (nRet != RTN_OK)
510 return nRet;
511
512 if (dSandEroded > 0)
513 {
514 // We eroded some sand sediment, so add to the this-iteration total
515 m_dThisIterBeachErosionSand += dSandEroded;
516
517 // Store the amount eroded for this polygon
518 pPolygon->SetBeachErosionUnconsSand(-dSandEroded);
519 }
520
521 // // DEBUG CODE #####################
522 // if (m_ulIter == 5)
523 // {
524 // LogStream << m_ulIter << ": nPoly = " << nPoly << " dSandErosionTarget = " << dSandErosionTarget * m_dCellArea << " m_dDepositionSandDiff = " << m_dDepositionSandDiff * m_dCellArea << " dSandEroded = " << dSandEroded * m_dCellArea << " m_dThisIterBeachErosionSand = " << m_dThisIterBeachErosionSand * m_dCellArea << endl;
525 //
526 // double dTmpSandUncons = 0;
527 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
528 // {
529 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
530 // {
531 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
532 // }
533 // }
534 //
535 // LogStream << m_ulIter << ": after sand erosion on nPoly = " << nPoly << " TOTAL UNCONSOLIDATED SAND ON ALL CELLS = " << dTmpSandUncons * m_dCellArea << endl;
536 // }
537 // // DEBUG CODE #####################
538 }
539
540 // Is there any coarse sediment on this polygon?
541 double const dExistingUnconsCoarse = pPolygon->dGetPreExistingUnconsCoarse();
542 double dCoarseEroded = 0;
543
544 if (dExistingUnconsCoarse > 0)
545 {
546 // There is: so crudely partition this potential value for this size class by erodibility, the result will almost always be much greater than actual (supply limited) erosion
547 double const dCoarsePotentialErosion = dPotentialErosion * m_dCoarseErodibilityNormalized;
548
549 // Now reduce this further, by considering the total depth of coarse sediment on the polygon
550 double const dCoarseErosionTarget = tMin(dCoarsePotentialErosion, dExistingUnconsCoarse);
551
552 // OK, do the supply-limited erosion of coarse sediment
553 nRet = nDoUnconsErosionOnPolygon(nCoast, pPolygon, TEXTURE_COARSE, dCoarseErosionTarget, dCoarseEroded);
554
555 if (nRet != RTN_OK)
556 return nRet;
557
558 if (dCoarseEroded > 0)
559 {
560 // We eroded some coarse sediment, so add to the this-iteration toal
561 m_dThisIterBeachErosionCoarse += dCoarseEroded;
562
563 // Store the amount eroded for this polygon
564 pPolygon->SetBeachErosionUnconsCoarse(-dCoarseEroded);
565 }
566 }
567
568 // OK we now have the actual values of sediment eroded from this polygon, so next determine where this eroded sand and coarse sediment goes (have to consider fine sediment too, because this goes off-grid on grid-edge polygons). Only do this if some sand or coarse was eroded on this polygon
569 if ((dSandEroded + dCoarseEroded) > 0)
570 {
571 if (pPolygon->bDownCoastThisIter())
572 {
573 // Moving eroded sediment down-coast
574 int const nNumAdjPoly = pPolygon->nGetNumDownCoastAdjacentPolygons();
575
576 for (int nn = 0; nn < nNumAdjPoly; nn++)
577 {
578 int const nAdjPoly = pPolygon->nGetDownCoastAdjacentPolygon(nn);
579
580 // if (m_nLogFileDetail >= LOG_FILE_MIDDLE_DETAIL)
581 // LogStream << m_ulIter << ": polygon " << nPoly << " moves sediment down-coast to polygon " << nAdjPoly << endl;
582
583 if (nAdjPoly == INT_NODATA)
584 {
585 // Sediment is leaving the grid
586 if (pPolygon->bIsCoastStartPolygon())
587 {
588 // Error: uncons sediment movement is down-coast and off-edge, but this polygon is at the up-coast end of the coastline
590 LogStream << m_ulIter << ": " << ERR << "in sediment export. Unconsolidated sediment movement is DOWN-COAST, and sediment is leaving the grid, but polygon " << nPolygon << " is at the up-coast end of the coastline. This will result in mass balance problems." << endl;
591 }
592
593 else if (pPolygon->bIsCoastEndPolygon())
594 {
595 // This is the polygon at the down-coast end of the coastline, and uncons sediment movement is down-coast. Decide what to do based on the user setting m_nUnconsSedimentHandlingAtGridEdges
597 {
598 // Closed grid edges: no uncons sediment moves off-grid, nothing is removed from this polygon, so cannot adjust sediment export
600 LogStream << m_ulIter << ": when adjusting sediment export, polygon " << nPolygon << " is at the down-coast end of the coastline, and actual sediment movement is DOWN-COAST. Since grid edges are closed, no sand or coarse unconsolidated sediment goes off-grid so cannot adjust sediment export. This will result in mass balance problems." << endl;
601 }
602
604 {
605 // Open grid edges, so this sediment goes off-grid
606 m_dThisIterLeftGridUnconsSand += dSandEroded;
607 m_dThisIterLeftGridUnconsCoarse += dCoarseEroded;
608
609 // // DEBUG CODE ##################
610 // if (m_ulIter == 5)
611 // {
612 // LogStream << m_ulIter << ": nPoly = " << nPoly << " LOST FROM GRID = " << dSandEroded * m_dCellArea << endl;
613 // }
614 // // DEBUG CODE ##################
615 }
616
618 {
619 // Re-circulating grid edges, so adjust the sediment exported to the polygon at the up-coast end of this coastline
620 int const nOtherEndPoly = 0;
621 CGeomCoastPolygon* pOtherEndPoly = m_VCoast[nCoast].pGetPolygon(nOtherEndPoly);
622
623 if (dSandEroded > 0)
624 {
625 // Add to the still-to-do total of unconsolidated sand to be deposited on the polygon at the up-coast end of this coastline
626 pOtherEndPoly->AddToDoBeachDepositionUnconsSand(dSandEroded);
627 }
628
629 if (dCoarseEroded > 0)
630 {
631 // Add to the still-to-do total of unconsolidated coarse sediment to be deposited on the polygon at the up-coast end of this coastline
632 pOtherEndPoly->AddToDoBeachDepositionUnconsCoarse(dCoarseEroded);
633 }
634 }
635 }
636 }
637
638 else
639 {
640 // This polygon is not at the grid edge
641 CGeomCoastPolygon* pAdjPolygon = m_VCoast[nCoast].pGetPolygon(nAdjPoly);
642 double const dBoundaryShare = pPolygon->dGetDownCoastAdjacentPolygonBoundaryShare(nn);
643
644 if (dSandEroded > 0)
645 {
646 // if (m_ulIter == 5)
647 // LogStream << m_ulIter << ": B polygon not at grid edge nPoly = " << nPoly << " nAdjPoly = " << nAdjPoly << ", dGetToDoBeachDepositionUnconsSand() on nAdjPoly is = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
648
649 // Add to the still-to-do total of unconsolidated sand to be deposited on the adjacent polygon
650 pAdjPolygon->AddToDoBeachDepositionUnconsSand(dSandEroded * dBoundaryShare);
651
652 // if (m_ulIter == 5)
653 // LogStream << m_ulIter << ": B after nAdjPoly = " << nAdjPoly << " AddToDoBeachDepositionUnconsSand(" << dSandEroded * dBoundaryShare * m_dCellArea << ") dGetToDoBeachDepositionUnconsSand() now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
654 }
655
656 if (dCoarseEroded > 0)
657 {
658 // if (m_nLogFileDetail >= LOG_FILE_ALL)
659 // LogStream << m_ulIter << ": polygon = " << nPoly << " adjacent polygon = " << nAdjPoly << ", beach deposition 1 of uncons coarse was = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea;
660
661 // Add to the still-to-do total of unconsolidated coarse sediment to be deposited on the adjacent polygon
662 pAdjPolygon->AddToDoBeachDepositionUnconsCoarse(dCoarseEroded * dBoundaryShare);
663
664 // if (m_nLogFileDetail >= LOG_FILE_ALL)
665 // LogStream << " after AddToDoBeachDepositionUnconsCoarse(" << dCoarseEroded * dBoundaryShare << ") beach deposition 1 of uncons coarse now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea << endl;
666 }
667 }
668 }
669
670 // if (m_nLogFileDetail >= LOG_FILE_ALL)
671 // LogStream << m_ulIter << ": 1 uncons sand eroded = " << dSandEroded * m_dCellArea << " 1 uncons coarse eroded = " << dCoarseEroded * m_dCellArea << endl;
672 }
673
674 else
675 {
676 // Moving eroded sediment up-coast
677 int const nNumAdjPoly = pPolygon->nGetNumUpCoastAdjacentPolygons();
678
679 for (int nn = 0; nn < nNumAdjPoly; nn++)
680 {
681 int const nAdjPoly = pPolygon->nGetUpCoastAdjacentPolygon(nn);
682 // if (m_nLogFileDetail >= LOG_FILE_ALL)
683 // LogStream << m_ulIter << ": polygon " << nPoly << " moves sediment up-coast to polygon " << nAdjPoly << endl;
684
685 if (nAdjPoly == INT_NODATA)
686 {
687 // Sediment is leaving the grid
688 if (pPolygon->bIsCoastEndPolygon())
689 {
690 // Error: uncons sediment movement is down-coast and off-edge, but this polygon is at the up-coast end of the coastline
692 LogStream << m_ulIter << ": " << ERR << "in sediment export. Unconsolidated sediment movement is UP-COAST, and sediment is leaving the grid, but polygon " << nPolygon << " is at the down-coast end of the coastline. This will result in mass balance problems." << endl;
693 }
694
695 else if (pPolygon->bIsCoastStartPolygon())
696 {
697 // This is the polygon at the up-coast end of the coastline, and uncons sediment movement is up-coast. Decide what to do based on the user setting m_nUnconsSedimentHandlingAtGridEdges
699 {
700 // Closed grid edges: no uncons sediment moves off-grid, nothing is removed from this polygon, so cannot adjust sediment export
702 LogStream << m_ulIter << ": when adjusting sediment export, polygon " << nPolygon << " is at the up-coast end of the coastline, and actual sediment movement is UP-COAST. Since grid edges are closed, no sand or coarse unconsolidated sediment goes off-grid so cannot adjust sediment export" << endl;
703 }
704
706 {
707 // Open grid edges, so this sediment goes off-grid
708 m_dThisIterLeftGridUnconsSand += dSandEroded;
709 m_dThisIterLeftGridUnconsCoarse += dCoarseEroded;
710 }
711
713 {
714 // Re-circulating grid edges, so adjust the sediment exported to the polygon at the up-coast end of this coastline TODO 016 Check whether this causes mass balance problems, depending on the sequence of polygon processing
715 int const nOtherEndPoly = 0;
716 CGeomCoastPolygon* pOtherEndPoly = m_VCoast[nCoast].pGetPolygon(nOtherEndPoly);
717
718 if (dSandEroded > 0)
719 {
720 // Add to the still-to-do total of unconsolidated sand to be deposited on the polygon at the up-coast end of this coastline
721 pOtherEndPoly->AddToDoBeachDepositionUnconsSand(dSandEroded);
722 }
723
724 if (dCoarseEroded > 0)
725 {
726 // Add to the still-to-do total of unconsolidated coarse sediment to be deposited on the polygon at the up-coast end of this coastline
727 pOtherEndPoly->AddToDoBeachDepositionUnconsCoarse(dCoarseEroded);
728 }
729 }
730 }
731 }
732
733 else
734 {
735 // This polygon is not at the grid edge
736 CGeomCoastPolygon* pAdjPolygon = m_VCoast[nCoast].pGetPolygon(nAdjPoly);
737 double const dBoundaryShare = pPolygon->dGetUpCoastAdjacentPolygonBoundaryShare(nn);
738
739 if (dSandEroded > 0)
740 {
741 // if (m_ulIter == 5)
742 // LogStream << m_ulIter << ": A polygon not at grid edge nPoly = " << nPoly << " nAdjPoly = " << nAdjPoly << ", dGetToDoBeachDepositionUnconsSand() on nAdjPoly is = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
743
744 // Add to the still-to-do total of unconsolidated sand to be deposited on the the adjacent polygon
745 pAdjPolygon->AddToDoBeachDepositionUnconsSand(dSandEroded * dBoundaryShare);
746
747 // if (m_ulIter == 5)
748 // LogStream << m_ulIter << ": A after nAdjPoly = " << nAdjPoly << " AddToDoBeachDepositionUnconsSand(" << dSandEroded * dBoundaryShare * m_dCellArea << ") dGetToDoBeachDepositionUnconsSand() now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
749 }
750
751 if (dCoarseEroded > 0)
752 {
753 // if (m_ulIter == 5)
754 // LogStream << m_ulIter << ": polygon not at grid edge nPoly = " << nPoly << " nAdjPoly = " << nAdjPoly << ", beach deposition of uncons coarse was = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea << endl;
755
756 // Add to the still-to-do total of unconsolidated coarse sediment to be deposited on the adjacent polygon
757 pAdjPolygon->AddToDoBeachDepositionUnconsCoarse(+dCoarseEroded * dBoundaryShare);
758
759 // if (m_ulIter == 5)
760 // LogStream << " After AddToDoBeachDepositionUnconsCoarse(" << dCoarseEroded * dBoundaryShare << ") uncons coarse now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea << endl;
761 }
762 }
763 }
764 }
765 }
766
767 // if (m_nLogFileDetail >= LOG_FILE_ALL)
768 // LogStream << m_ulIter << ": sand eroded on poly = " << dSandEroded * m_dCellArea << " coarse eroded on poly = " << dCoarseEroded * m_dCellArea << endl;
769
770 } // if (dPotentialErosion > 0)
771
772 // // DEBUG CODE ============================================================================================================================================
773 // // Get total depths of unconsolidated sand for every cell
774 // if (m_ulIter == 5)
775 // {
776 // double dTmpSandUncons = 0;
777 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
778 // {
779 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
780 // {
781 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
782 // }
783 // }
784 //
785 // LogStream << endl;
786 // LogStream << m_ulIter << ": TOTAL UNCONSOLIDATED SAND ON ALL CELLS after beach movement on nPoly = " << nPoly << " dTmpSandUncons = " << dTmpSandUncons * m_dCellArea << " (dTmpSandUncons - m_dStartIterUnconsSandAllCells) = " << (dTmpSandUncons - m_dStartIterUnconsSandAllCells) * m_dCellArea << endl;
787 //
788 // // Now get the total in all still-to-do fields of all polygons
789 // double dToDoTot = 0;
790 //
791 // for (int nn = 0; nn < nPolygons; nn++)
792 // {
793 // CGeomCoastPolygon* pThisPolygon = m_VCoast[nCoast].pGetPolygon(nn);
794 // dToDoTot += pThisPolygon->dGetToDoBeachDepositionUnconsSand();
795 // }
796 //
797 // LogStream << endl << m_ulIter << ": dToDoTot = " << dToDoTot * m_dCellArea << endl;
798 // LogStream << m_ulIter << ": dTmpSandUncons + dToDoTot = " << (dTmpSandUncons + dToDoTot) * m_dCellArea << endl << endl;
799 //
800 // LogStream << m_ulIter << ": m_dThisIterLeftGridUnconsSand = " << m_dThisIterLeftGridUnconsSand * m_dCellArea << endl;
801 //
802 // LogStream << "*****************************" << endl;
803 // }
804 // // DEBUG CODE ============================================================================================================================================
805
806 } // for (int n = 0; n < nNumPolygons; n++)
807
808 // OK we have processed all polygons, But if there are adjacent-polygon circularities (i.e. Polygon A -> Polygon B -> Polygon A) then we may have some still-to-do deposition on at least one polygon. So look through all polygons and check their still-to-do lists
809 int const nPolygons = m_VCoast[nCoast].nGetNumPolygons();
810
811 // for (int nn = 0; nn < nPolygons; nn++)
812 for (int nn = nPolygons - 1; nn >= 0; nn--)
813 {
814 int const nThisPoly = nVVPolyAndAdjacent[nn][0];
815 CGeomCoastPolygon* pThisPolygon = m_VCoast[nCoast].pGetPolygon(nThisPoly);
816
817 double const dSandToDepositOnPoly = pThisPolygon->dGetToDoBeachDepositionUnconsSand();
818
819 if (dSandToDepositOnPoly > 0)
820 {
821 // There is some still-to-do deposition of sand sediment on this polygon: calculate a net increase in depth of sand-sized unconsolidated sediment on the cells within the polygon. Note that some cells may decrease in elevation (i.e. have some sand-sized sediment erosion) however
822 double dSandDeposited = 0;
823 nRet = nDoUnconsDepositionOnPolygon(nCoast, pThisPolygon, TEXTURE_SAND, dSandToDepositOnPoly, dSandDeposited);
824
825 if (nRet != RTN_OK)
826 return nRet;
827
828 double const dSandNotDeposited = dSandToDepositOnPoly - dSandDeposited;
829
830 if (dSandNotDeposited > 0)
831 m_dDepositionSandDiff += dSandNotDeposited;
832
834 LogStream << m_ulIter << ": re-processing nThisPoly = " << nThisPoly << " dSandDeposited = " << dSandDeposited * m_dCellArea << " dSandNotDeposited = " << dSandNotDeposited * m_dCellArea << " m_dDepositionSandDiff = " << m_dDepositionSandDiff * m_dCellArea << endl;
835 }
836
837 double const dCoarseToDepositOnPoly = pThisPolygon->dGetToDoBeachDepositionUnconsCoarse();
838
839 if (dCoarseToDepositOnPoly > 0)
840 {
841 // There is some still-to-do deposition of coarse sediment on this polygon: calculate a net increase in depth of coarse-sized unconsolidated sediment on the cells within the polygon. Note that some cells may decrease in elevation (i.e. have some coarse-sized sediment erosion) however
842 double dCoarseDeposited = 0;
843 nRet = nDoUnconsDepositionOnPolygon(nCoast, pThisPolygon, TEXTURE_COARSE, dCoarseToDepositOnPoly, dCoarseDeposited);
844
845 if (nRet != RTN_OK)
846 return nRet;
847
848 double const dCoarseNotDeposited = dCoarseToDepositOnPoly - dCoarseDeposited;
849
850 if (dCoarseNotDeposited > 0)
851 m_dDepositionCoarseDiff += dCoarseNotDeposited;
852
854 LogStream << m_ulIter << ": re-processing nThisPoly = " << nThisPoly << " dCoarseDeposited = " << dCoarseDeposited * m_dCellArea << " dCoarseNotDeposited = " << dCoarseNotDeposited * m_dCellArea << " m_dDepositionCoarseDiff = " << m_dDepositionCoarseDiff * m_dCellArea << endl;
855 }
856 }
857
859 WritePolygonActualMovement(nCoast, nVVPolyAndAdjacent);
860 }
861
862 return RTN_OK;
863}
864
865//===============================================================================================================================
867//===============================================================================================================================
869{
870 int const nNumPolygons = m_VCoast[nCoast].nGetNumPolygons();
871
872 for (int nPoly = 0; nPoly < nNumPolygons; nPoly++)
873 {
874 CGeomCoastPolygon* pPolygon = m_VCoast[nCoast].pGetPolygon(nPoly);
875
876 // Only include unconsolidated fine sediment from sediment input events, don't include any unconsolidated fine sediment from platform erosion and cliff collapse since these have gone to suspension
877 double const dFine = pPolygon->dGetSedimentInputUnconsFine();
878 pPolygon->SetPreExistingUnconsFine(dFine);
879
880 // Include unconsolidated sand sediment derived from platform erosion, cliff collapse, and sediment input events
881 double const dSand = pPolygon->dGetPreExistingUnconsSand() + pPolygon->dGetPlatformErosionUnconsSand() + pPolygon->dGetCliffCollapseUnconsSandDeposition() + pPolygon->dGetSedimentInputUnconsSand();
882 pPolygon->SetPreExistingUnconsSand(dSand);
883
884 // Include unconsolidated coarse sediment derived from platform erosion, cliff collapse, and sediment input events
885 double const dCoarse = pPolygon->dGetPreExistingUnconsCoarse() + pPolygon->dGetPlatformErosionUnconsCoarse() + pPolygon->dGetCliffCollapseUnconsCoarseDeposition() + pPolygon->dGetSedimentInputUnconsCoarse();
886 pPolygon->SetPreExistingUnconsCoarse(dCoarse);
887 }
888}
Geometry class used for coast polygon objects.
bool bIsCoastStartPolygon(void) const
Is this polygon the coast-start polygon?
double dGetSedimentInputUnconsSand(void) const
Get the value of sand sediment on the polygon derived from sediment input events(s)
double dGetPotentialErosion(void) const
Returns this timestep's total change in depth of unconsolidated sediment (all size classes) due to be...
double dGetCliffCollapseUnconsSandDeposition(void) const
Get the this-iteration total of unconsolidated sand sediment deposited from cliff collapse on this po...
bool bIsCoastEndPolygon(void) const
Is this polygon the coast-end polygon?
void SetPreExistingUnconsFine(double const)
Set the value of pre-existing unconsolidated fine sediment stored on this polygon.
double dGetPreExistingUnconsSand(void) const
Get the value of pre-existing unconsolidated sand sediment stored on this polygon.
void AddToDoBeachDepositionUnconsSand(double const)
Adds a depth (in m) of sand-sized unconsolidated sediment to this timestep's still-to-do deposition o...
void SetPreExistingUnconsSand(double const)
Set the value of pre-existing unconsolidated sand sediment stored on this polygon.
double dGetUpCoastAdjacentPolygonBoundaryShare(int const) const
Gets the boundary shares for all up-coast adjacent polygons.
int nGetUpCoastAdjacentPolygon(int const) const
Gets a single up-coast adjacent polygon.
double dGetPlatformErosionUnconsCoarse(void) const
Get the this-iteration total of unconsolidated coarse sediment derived from shore platform erosion on...
double dGetSedimentInputUnconsFine(void) const
Get the value of fine sediment on the polygon derived from sediment input events(s)
int nGetNumUpCoastAdjacentPolygons(void) const
Gets all up-coast adjacent polygons.
double dGetCliffCollapseUnconsCoarseDeposition(void) const
Get the this-iteration total of unconsolidated coarse sediment deposited from cliff collapse on this ...
double dGetDownCoastAdjacentPolygonBoundaryShare(int const) const
Gets the boundary shares for all down-coast adjacent polygons.
void SetBeachErosionUnconsFine(double const)
Sets a value (must be < 0) for this timestep's erosion of fine unconsolidated sediment (beach redistr...
double dGetPreExistingUnconsFine(void) const
Get the value of pre-existing unconsolidated fine sediment stored on this polygon.
int nGetPolygonCoastID(void) const
Get the coast ID, this is the same as the down-coast sequence of polygons.
void AddToDoBeachDepositionUnconsCoarse(double const)
Adds a depth (in m) of coarse unconsolidated sediment to this timestep's still-to-do deposition of un...
int nGetDownCoastAdjacentPolygon(int const) const
Gets a single down-coast adjacent polygon.
int nGetNumDownCoastAdjacentPolygons(void) const
Gets all down-coast adjacent polygons.
double dGetToDoBeachDepositionUnconsSand(void) const
Returns this timestep's still-to-do deposition of sand-sized unconsolidated sediment (from beach redi...
void SetPreExistingUnconsCoarse(double const)
Set the value of pre-existing unconsolidated coarse sediment stored on this polygon.
double dGetPlatformErosionUnconsSand(void) const
Get the this-iteration total of unconsolidated sand sediment derived from shore platform erosion on t...
double dGetPreExistingUnconsCoarse(void) const
Get the value of pre-existing unconsolidated coarse sediment stored on this polygon.
void SetBeachErosionUnconsSand(double const)
Sets a value (must be < 0) for this timestep's erosion of sand-sized unconsolidated sediment (beach r...
double dGetSedimentInputUnconsCoarse(void) const
Get the value of coarse sediment on the polygon derived from sediment input events(s)
bool bDownCoastThisIter(void) const
Is sediment movement on this polygon down-coast this iteration?
void AddCircularity(int const)
Add a circularity to this polygon.
void SetBeachErosionUnconsCoarse(double const)
Sets a value (must be < 0) for this timestep's erosion of coarse unconsolidated sediment (beach redis...
double dGetToDoBeachDepositionUnconsCoarse(void) const
Returns this timestep's still-to-do deposition of coarse unconsolidated sediment (from beach redistri...
int m_nLogFileDetail
The level of detail in the log file output. Can be LOG_FILE_LOW_DETAIL, LOG_FILE_MIDDLE_DETAIL,...
Definition simulation.h:574
ofstream LogStream
double m_dThisIterBeachErosionCoarse
Total actual beach erosion (coarse unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:853
vector< CRWCoast > m_VCoast
The coastline objects.
double m_dFineErodibilityNormalized
Relative erodibility of fine unconsolidated beach sediment, normalized.
Definition simulation.h:796
void WritePolygonSedimentBeforeMovement(int const)
Writes to the log file a table showing per-polygon totals of stored unconsolidated beach sediment pri...
void WritePolygonSortedSequence(int const, vector< vector< int > > &)
Writes to the log file a table showing the sorted sequence of polygon processing, and any circulariti...
int m_nUnconsSedimentHandlingAtGridEdges
How sediment which moves off an edge of the grid is handled. Possible values are GRID_EDGE_CLOSED,...
Definition simulation.h:526
double m_dCoarseErodibilityNormalized
Relative erodibility of coarse unconsolidated beach sediment, normalized.
Definition simulation.h:802
double m_dDepositionCoarseDiff
Error term: if we are unable to deposit enough unconslidated coarse on polygon(s),...
Definition simulation.h:889
int nDoAllActualBeachErosionAndDeposition(void)
Does between-polygon and within-polygon actual (supply-limited) redistribution of transported beach s...
double m_dDepositionSandDiff
Error term: if we are unable to deposit enough unconslidated sand on polygon(s), this is held over to...
Definition simulation.h:886
void WritePolygonPotentialErosion(int const)
Writes to the log file a table showing per-polygon potential erosion of all size classes of unconsoli...
void WritePolygonActualMovement(int const, vector< vector< int > > const &)
Writes to the log file a table showing per-polygon actual movement of unconsolidated beach sediment.
int nDoUnconsDepositionOnPolygon(int const, CGeomCoastPolygon *, int const, double, double &)
Deposits unconsolidated beach sediment (sand or coarse) on the cells within a polygon....
double m_dSandErodibilityNormalized
Relative erodibility of sand unconsolidated beach sediment, normalized.
Definition simulation.h:799
double m_dThisIterBeachErosionSand
Total actual beach erosion (sand unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:850
double m_dThisIterFineSedimentToSuspension
Total fine unconsolidated sediment in suspension for this iteration (depth in m)
Definition simulation.h:862
double m_dThisIterBeachErosionFine
Total actual beach erosion (fine unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:847
void AllPolygonsUpdateStoredUncons(int const)
Before simulating beach erosion, update the per-polygon values of pre-existing unconsolidated sedimen...
int nDoUnconsErosionOnPolygon(int const, CGeomCoastPolygon *, int const, double const, double &)
Erodes unconsolidated beach sediment of one texture class on the cells within a polygon....
double m_dCellArea
Area of a cell (in external CRS units)
Definition simulation.h:661
double m_dThisIterLeftGridUnconsCoarse
Total coarse unconsolidated sediment lost from the grid this iteration (depth in m)
Definition simulation.h:874
unsigned long m_ulIter
The number of the current iteration (time step)
Definition simulation.h:598
void WritePolygonUnsortedSequence(int const, vector< vector< int > > &)
Writes to the log file a table showing the unsorted sequence of polygon processing.
double m_dThisIterLeftGridUnconsSand
Total sand unconsolidated sediment lost from the grid this iteration (depth in m)
Definition simulation.h:871
STL iterator class.
This file contains global definitions for CoastalME.
int const INT_NODATA
Definition cme.h:476
T tMin(T a, T b)
Definition cme.h:1265
string const ERR
Definition cme.h:902
int const TEXTURE_COARSE
Definition cme.h:517
int const LOG_FILE_MIDDLE_DETAIL
Definition cme.h:491
int const GRID_EDGE_CLOSED
Definition cme.h:786
int const GRID_EDGE_RECIRCULATE
Definition cme.h:788
double const MASS_BALANCE_TOLERANCE
Definition cme.h:826
int const LOG_FILE_HIGH_DETAIL
Definition cme.h:492
int const TEXTURE_FINE
Definition cme.h:515
int const RTN_OK
Definition cme.h:694
int const GRID_EDGE_OPEN
Definition cme.h:787
int const TEXTURE_SAND
Definition cme.h:516
Contains CRWCoast definitions.
Contains CSimulation definitions.