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>
31// using std::cout;
32using std::endl;
33
34// #include <string>
35// using std::to_string;
36
37#include <algorithm>
38using std::stable_sort;
39
40#include "cme.h"
41#include "simulation.h"
42#include "coast.h"
43
44namespace
45{
46//===============================================================================================================================
48//===============================================================================================================================
49bool bPolygonAndAdjCompare(const vector<int>& nVLeft, const vector<int>& nVRight)
50{
51 // Each row (vector) of this vector-of-vectors is:
52 // 0: This-polygon global ID (not used)
53 // 1: This-polygon coast ID (in down-coast seq when sorted)
54 // 2: This-polygon down-coast (true) or up-coast (false) sediment movement
55 // 3 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
56
57 bool const bDownCoastLeft = nVLeft[2];
58 bool const bDownCoastRight = nVRight[2];
59
60 if (bDownCoastLeft)
61 {
62 // LHS polygon is down-coast. First, deal with polygon 0
63 if (nVLeft[1] == 0)
64 // Do not swap LHS and RHS polygons
65 return true;
66
67 if (nVRight[1] == 0)
68 // Swap LHS and RHS polygons
69 return false;
70
71 if ((nVLeft.size() >= 4) && (nVRight.size() >= 4))
72 {
73 // Search the adjacent polygons of the LHS argument, is there an "off edge" amongst them?
74 bool bLHSOffEdge = false;
75
76 for (unsigned int n = 3; n < nVLeft.size(); n++)
77 {
78 if (nVLeft[n] == INT_NODATA)
79 {
80 bLHSOffEdge = true;
81 break;
82 }
83 }
84
85 if (bLHSOffEdge)
86 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: so swap LHS and RHS polygons
87 return false;
88
89 // Search the adjacent polygons of the RHS argument, is there an "off edge" amongst them?
90 bool bRHSOffEdge = false;
91
92 for (unsigned int n = 3; n < nVRight.size(); n++)
93 {
94 if (nVRight[n] == INT_NODATA)
95 {
96 bRHSOffEdge = true;
97 break;
98 }
99 }
100
101 if (bRHSOffEdge)
102 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: do not swap LHS and RHS polygons
103 return true;
104
105 // Do we have a local change of sediment direction?
106 if (!bDownCoastRight)
107 // Yes, there is a change of sediment direction between this and the adjacent polygon. Keep the existing sequence
108 return true;
109
110 // 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?
111 bool bLeftFound = false;
112
113 for (unsigned int n = 3; n < nVLeft.size(); n++)
114 {
115 if (nVLeft[n] == nVRight[1])
116 bLeftFound = true;
117 }
118
119 if (bLeftFound)
120 // 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
121 return true;
122
123 // Is the LHS polygon among the adjacent polygons of the RHS polygon?
124 bool bRightFound = false;
125
126 for (unsigned int n = 3; n < nVRight.size(); n++)
127 {
128 if (nVRight[n] == nVLeft[1])
129 bRightFound = true;
130 }
131
132 if (bRightFound)
133 // 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
134 return false;
135 }
136
137 // 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
138 if (nVLeft[1] < nVRight[1])
139 return true;
140
141 else
142 return false;
143 }
144
145 else
146 {
147 // LHS polygon is up-coast. First, deal with polygon 0
148 if (nVLeft[1] == 0)
149 // Swap LHS and RHS polygons
150 return false;
151
152 if (nVRight[1] == 0)
153 // Do not swap LHS and RHS polygons
154 return true;
155
156 if ((nVLeft.size() >= 4) && (nVRight.size() >= 4))
157 {
158 // Next, search the adjacent polygons of the LHS argument, is there an "off edge" amongst them?
159 bool bLHSOffEdge = false;
160
161 for (unsigned int n = 3; n < nVLeft.size(); n++)
162 {
163 if (nVLeft[n] == INT_NODATA)
164 {
165 bLHSOffEdge = true;
166 break;
167 }
168 }
169
170 if (bLHSOffEdge)
171 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: so do not swap LHS and RHS polygons
172 return true;
173
174 // Search the adjacent polygons of the RHS argument, is there an "off edge" amongst them?
175 bool bRHSOffEdge = false;
176
177 for (unsigned int n = 3; n < nVRight.size(); n++)
178 {
179 if (nVRight[n] == INT_NODATA)
180 {
181 bRHSOffEdge = true;
182 break;
183 }
184 }
185
186 if (bRHSOffEdge)
187 // Yes, there is an "off edge" among the adjacent polygons of the LHS polygon: swap LHS and RHS polygons
188 return false;
189
190 // Do we have a local change of sediment direction?
191 if (!bDownCoastRight)
192 // Yes, there is a change of sediment direction between this and the adjacent polygon. Keep the existing sequence
193 return true;
194
195 // 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?
196 bool bLeftFound = false;
197
198 for (unsigned int n = 3; n < nVLeft.size(); n++)
199 {
200 if (nVLeft[n] == nVRight[1])
201 bLeftFound = true;
202 }
203
204 if (bLeftFound)
205 // 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
206 return true;
207
208 // Is the LHS polygon among the adjacent polygons of the RHS polygon?
209 bool bRightFound = false;
210
211 for (unsigned int n = 3; n < nVRight.size(); n++)
212 {
213 if (nVRight[n] == nVLeft[1])
214 bRightFound = true;
215 }
216
217 if (bRightFound)
218 // 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
219 return false;
220 }
221
222 // 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
223 if (nVLeft[1] < nVRight[1])
224 return false;
225
226 else
227 return true;
228 }
229
230 // Default return value, should never get here
231 return true;
232}
233} // namespace
234
235//===============================================================================================================================
237//===============================================================================================================================
239{
240 for (int nCoast = 0; nCoast < static_cast<int>(m_VCoast.size()); nCoast++)
241 {
242 int nRet;
243
245 LogStream << m_ulIter << ": Calculating unconsolidated sediment transport" << endl;
246
247 // 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
249
251 {
254 }
255
256 // Now route actually-eroded sand/coarse sediment to adjacent polygons, or off-grid. Sort polygons first
257 // Each row (vector) of this vector-of-vectors is:
258 // 0: This-polygon global ID
259 // 1: This-polygon coast ID (in down-coast seq when sorted)
260 // 2: This-polygon down-coast (true) or up-coast (false) sediment movement
261 // 3 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
262 vector<vector<int>> nVVPolyAndAdjacent;
263 vector<int> nVPolyAndAdj;
264
265 for (int nn = 0; nn < m_VCoast[nCoast].nGetNumPolygons(); nn++)
266 {
267 CGeomCoastPolygon const* pPolygon = m_VCoast[nCoast].pGetPolygon(nn);
268 nVPolyAndAdj.clear();
269
270 // The first [0] nVPolyAndAdj array item is the polygon's global ID
271 nVPolyAndAdj.push_back(pPolygon->nGetGlobalID());
272
273 // The second [1] nVPolyAndAdj array item is the polygon's down-coast ID
274 nVPolyAndAdj.push_back(pPolygon->nGetCoastID());
275
276 if (pPolygon->bDownCoastThisIter())
277 {
278 // Sediment is leaving this polygon in a down-coast direction. Set this as the third [2] nVPolyAndAdj array item
279 nVPolyAndAdj.push_back(true);
280
281 // Fourth [3] and subsequent nVPolyAndAdj array items are the down-coast seqs of adjacent down-coast polygons
282 for (int nAdj = 0; nAdj < pPolygon->nGetNumDownCoastAdjacentPolygons(); nAdj++)
283 {
284 // Save the coast ID of each down-coast adjacent polygon
285 int const nAdjPolyID = pPolygon->nGetDownCoastAdjacentPolygon(nAdj);
286 nVPolyAndAdj.push_back(nAdjPolyID);
287 }
288 }
289
290 else
291 {
292 // Sediment is leaving this polygon in an up-coast direction. Set this as the third [2] nVPolyAndAdj array item
293 nVPolyAndAdj.push_back(false);
294
295 // Fourth [3] and susequent nVPolyAndAdj array items are the down-coast IDs of adjacent up-coast polygons
296 for (int nAdj = 0; nAdj < pPolygon->nGetNumUpCoastAdjacentPolygons(); nAdj++)
297 {
298 // Save the coast ID of each up-coast adjacent polygon
299 int const nAdjPolyID = pPolygon->nGetUpCoastAdjacentPolygon(nAdj);
300 nVPolyAndAdj.push_back(nAdjPolyID);
301 }
302 }
303
304 // Save this 'row'
305 nVVPolyAndAdjacent.push_back(nVPolyAndAdj);
306 }
307
308 // Write out the unsorted polygon sequence
310 WritePolygonUnsortedSequence(nCoast, nVVPolyAndAdjacent);
311
312 // 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
313 stable_sort(nVVPolyAndAdjacent.begin(), nVVPolyAndAdjacent.end(), bPolygonAndAdjCompare);
314
315 // 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
316 vector<int> VnSourcePolygons;
317
318 for (int n = 0; n < static_cast<int>(nVVPolyAndAdjacent.size()); n++)
319 {
320 int const nThisPoly = nVVPolyAndAdjacent[n][1];
321 VnSourcePolygons.push_back(nThisPoly);
322
323 for (int m = 3; m < static_cast<int>(nVVPolyAndAdjacent[n].size()); m++)
324 {
325 // Check the adjacent polygon(s) for circularities
326 int const nToFind = nVVPolyAndAdjacent[n][m];
327 vector<int>::iterator const it = find(VnSourcePolygons.begin(), VnSourcePolygons.end(), nToFind);
328
329 if (it != VnSourcePolygons.end())
330 {
331 // 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
332 CGeomCoastPolygon* pPoly = m_VCoast[nCoast].pGetPolygon(nThisPoly);
333 pPoly->AddCircularity(nToFind);
334
335 pPoly = m_VCoast[nCoast].pGetPolygon(nToFind);
336 pPoly->AddCircularity(nThisPoly);
337 }
338 }
339 }
340
342 WritePolygonSortedSequence(nCoast, nVVPolyAndAdjacent);
343
344 int const nNumPolygons = m_VCoast[nCoast].nGetNumPolygons();
345
346 // Now process all polygons and do the actual (supply-limited) unconsolidated sediment movement
347 for (int nPoly = 0; nPoly < nNumPolygons; nPoly++)
348 {
349 int const nPolygon = nVVPolyAndAdjacent[nPoly][1];
350 CGeomCoastPolygon* pPolygon = m_VCoast[nCoast].pGetPolygon(nPolygon);
351
352 // // DEBUG CODE =====================
353 // int nUpCoastProfile = pPolygon->nGetUpCoastProfile();
354 // CGeomProfile* pUpCoastProfile = m_VCoast[nCoast].pGetProfile(nUpCoastProfile);
355 // int nDownCoastProfile = pPolygon->nGetDownCoastProfile();
356 // CGeomProfile* pDownCoastProfile = m_VCoast[nCoast].pGetProfile(nDownCoastProfile);
357 // int nNumUpCoastCell = pUpCoastProfile->nGetNumCellsInProfile();
358 // int nNumDownCoastCell = pDownCoastProfile->nGetNumCellsInProfile();
359 // LogStream << "pUpCoastProfile->nGetNumCellsInProfile() = " << nNumUpCoastCell << " pDownCoastProfile->nGetNumCellsInProfile() = " << nNumDownCoastCell << endl;
360 // // DEBUG CODE =====================
361
362 // // DEBUG CODE ============================================================================================================================================
363 // // Get total depths of sand consolidated and unconsolidated for every cell
364 // if (m_ulIter == 5)
365 // {
366 // double dTmpSandUncons = 0;
367 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
368 // {
369 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
370 // {
371 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
372 // }
373 // }
374 //
375 // LogStream << endl;
376 // LogStream << "*****************************" << endl;
377 // LogStream << m_ulIter << ": before beach movement on nPoly = " << nPoly << " TOTAL UNCONSOLIDATED SAND ON ALL CELLS = " << dTmpSandUncons * m_dCellArea << endl;
378 // }
379 // // DEBUG CODE ============================================================================================================================================
380
381 // Do deposition first: does this polygon have coarse deposition?
382 double dCoarseDepositionTarget = pPolygon->dGetToDoBeachDepositionUnconsCoarse();
383
384 if (dCoarseDepositionTarget > 0)
385 {
386 // 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
388 {
389 // 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
391 LogStream << m_ulIter << ": nPoly = " << nPolygon << " dCoarseDepositionTarget was = " << dCoarseDepositionTarget * m_dCellArea << " adding m_dDepositionCoarseDiff = " << m_dDepositionCoarseDiff * m_dCellArea;
392
393 dCoarseDepositionTarget += m_dDepositionCoarseDiff;
395
397 LogStream << " dCoarseDepositionTarget now = " << dCoarseDepositionTarget << endl;
398 }
399
400 // 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
401 double dCoarseDeposited = 0;
402 nRet = nDoUnconsDepositionOnPolygon(nCoast, pPolygon, TEXTURE_COARSE, dCoarseDepositionTarget, dCoarseDeposited);
403
404 if (nRet != RTN_OK)
405 return nRet;
406
407 double const dCoarseNotDeposited = dCoarseDepositionTarget - dCoarseDeposited;
408
409 if (dCoarseNotDeposited > 0)
410 {
411 m_dDepositionCoarseDiff += dCoarseNotDeposited;
412 }
413 }
414
415 // Does this polygon have sand deposition?
416 double dSandDepositionTarget = pPolygon->dGetToDoBeachDepositionUnconsSand();
417
418 if (dSandDepositionTarget > 0)
419 {
420 // 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
422 {
423 // 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
425 LogStream << m_ulIter << ": nPolygon = " << nPolygon << " dSandDepositionTarget was = " << dSandDepositionTarget * m_dCellArea << " adding m_dDepositionSandDiff = " << m_dDepositionSandDiff * m_dCellArea;
426
427 dSandDepositionTarget += m_dDepositionSandDiff;
429
431 LogStream << " dSandDepositionTarget now = " << dSandDepositionTarget << endl;
432 }
433
434 // 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
435 double dSandDeposited = 0;
436 nRet = nDoUnconsDepositionOnPolygon(nCoast, pPolygon, TEXTURE_SAND, dSandDepositionTarget, dSandDeposited);
437
438 if (nRet != RTN_OK)
439 return nRet;
440
441 double const dSandNotDeposited = dSandDepositionTarget - dSandDeposited;
442
443 if (dSandNotDeposited > 0)
444 {
445 m_dDepositionSandDiff += dSandNotDeposited;
446 }
447
448 // // DEBUG CODE #####################
449 // if (m_ulIter == 5)
450 // {
451 // 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;
452 //
453 // double dTmpSandUncons = 0;
454 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
455 // {
456 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
457 // {
458 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
459 // }
460 // }
461 //
462 // LogStream << m_ulIter << ": after sand deposition on nPoly = " << nPoly << " TOTAL UNCONSOLIDATED SAND ON ALL CELLS = " << dTmpSandUncons * m_dCellArea << endl;
463 // }
464 // // DEBUG CODE #####################
465 }
466
467 // Now do erosion
468 double const dPotentialErosion = -pPolygon->dGetPotentialErosion();
469
470 if (dPotentialErosion > 0)
471 {
472 // There is some erosion on this polygon: process this in the sequence fine, sand, coarse. Is there any fine sediment on this polygon?
473 double const dExistingUnconsFine = pPolygon->dGetPreExistingUnconsFine();
474
475 if (dExistingUnconsFine > 0)
476 {
477 // 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
478 double const dFinePotentialErosion = dPotentialErosion * m_dFineErodibilityNormalized;
479
480 // Now reduce this further, by considering the total depth of fine sediment on the polygon
481 double const dFineErosionTarget = tMin(dFinePotentialErosion, dExistingUnconsFine);
482
483 // OK, do the supply-limited erosion of fine sediment
484 double dFineEroded = 0;
485 nRet = nDoUnconsErosionOnPolygon(nCoast, pPolygon, TEXTURE_FINE, dFineErosionTarget, dFineEroded);
486
487 if (nRet != RTN_OK)
488 return nRet;
489
490 if (dFineEroded > 0)
491 {
492 // 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
493 m_dThisIterBeachErosionFine += dFineEroded;
494
495 // Also add to the suspended load
497
498 // Store the amount of unconsolidated fine beach sediment eroded for this polygon
499 pPolygon->SetBeachErosionUnconsFine(-dFineEroded);
500 }
501 }
502
503 // Is there any sand-sized sediment on this polygon?
504 double const dExistingUnconsSand = pPolygon->dGetPreExistingUnconsSand();
505 double dSandEroded = 0;
506
507 if (dExistingUnconsSand > 0)
508 {
509 // 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
510 double const dSandPotentialErosion = dPotentialErosion * m_dSandErodibilityNormalized;
511
512 // Now reduce this further, by considering the total depth of sand sediment on the polygon
513 double const dSandErosionTarget = tMin(dSandPotentialErosion, dExistingUnconsSand);
514
515 // OK, do the supply-limited erosion of sand sediment
516 nRet = nDoUnconsErosionOnPolygon(nCoast, pPolygon, TEXTURE_SAND, dSandErosionTarget, dSandEroded);
517
518 if (nRet != RTN_OK)
519 return nRet;
520
521 if (dSandEroded > 0)
522 {
523 // We eroded some sand sediment, so add to the this-iteration total
524 m_dThisIterBeachErosionSand += dSandEroded;
525
526 // Store the amount eroded for this polygon
527 pPolygon->SetBeachErosionUnconsSand(-dSandEroded);
528 }
529
530 // // DEBUG CODE #####################
531 // if (m_ulIter == 5)
532 // {
533 // 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;
534 //
535 // double dTmpSandUncons = 0;
536 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
537 // {
538 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
539 // {
540 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
541 // }
542 // }
543 //
544 // LogStream << m_ulIter << ": after sand erosion on nPoly = " << nPoly << " TOTAL UNCONSOLIDATED SAND ON ALL CELLS = " << dTmpSandUncons * m_dCellArea << endl;
545 // }
546 // // DEBUG CODE #####################
547 }
548
549 // Is there any coarse sediment on this polygon?
550 double const dExistingUnconsCoarse = pPolygon->dGetPreExistingUnconsCoarse();
551 double dCoarseEroded = 0;
552
553 if (dExistingUnconsCoarse > 0)
554 {
555 // 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
556 double const dCoarsePotentialErosion = dPotentialErosion * m_dCoarseErodibilityNormalized;
557
558 // Now reduce this further, by considering the total depth of coarse sediment on the polygon
559 double const dCoarseErosionTarget = tMin(dCoarsePotentialErosion, dExistingUnconsCoarse);
560
561 // OK, do the supply-limited erosion of coarse sediment
562 nRet = nDoUnconsErosionOnPolygon(nCoast, pPolygon, TEXTURE_COARSE, dCoarseErosionTarget, dCoarseEroded);
563
564 if (nRet != RTN_OK)
565 return nRet;
566
567 if (dCoarseEroded > 0)
568 {
569 // We eroded some coarse sediment, so add to the this-iteration toal
570 m_dThisIterBeachErosionCoarse += dCoarseEroded;
571
572 // Store the amount eroded for this polygon
573 pPolygon->SetBeachErosionUnconsCoarse(-dCoarseEroded);
574 }
575 }
576
577 // 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
578 if ((dSandEroded + dCoarseEroded) > 0)
579 {
580 if (pPolygon->bDownCoastThisIter())
581 {
582 // Moving eroded sediment down-coast
583 int const nNumAdjPoly = pPolygon->nGetNumDownCoastAdjacentPolygons();
584
585 for (int nn = 0; nn < nNumAdjPoly; nn++)
586 {
587 int const nAdjPoly = pPolygon->nGetDownCoastAdjacentPolygon(nn);
588
589 // if (m_nLogFileDetail >= LOG_FILE_MIDDLE_DETAIL)
590 // LogStream << m_ulIter << ": polygon " << nPoly << " moves sediment down-coast to polygon " << nAdjPoly << endl;
591
592 if (nAdjPoly == INT_NODATA)
593 {
594 // Sediment is leaving the grid
595 if (pPolygon->bIsCoastStartPolygon())
596 {
597 // Error: uncons sediment movement is down-coast and off-edge, but this polygon is at the up-coast end of the coastline
599 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;
600 }
601
602 else if (pPolygon->bIsCoastEndPolygon())
603 {
604 // 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
606 {
607 // Closed grid edges: no uncons sediment moves off-grid, nothing is removed from this polygon, so cannot adjust sediment export
609 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;
610 }
611
613 {
614 // Open grid edges, so this sediment goes off-grid
615 m_dThisIterLeftGridUnconsSand += dSandEroded;
616 m_dThisIterLeftGridUnconsCoarse += dCoarseEroded;
617
618 // // DEBUG CODE ##################
619 // if (m_ulIter == 5)
620 // {
621 // LogStream << m_ulIter << ": nPoly = " << nPoly << " LOST FROM GRID = " << dSandEroded * m_dCellArea << endl;
622 // }
623 // // DEBUG CODE ##################
624 }
625
627 {
628 // Re-circulating grid edges, so adjust the sediment exported to the polygon at the up-coast end of this coastline
629 int const nOtherEndPoly = 0;
630 CGeomCoastPolygon* pOtherEndPoly = m_VCoast[nCoast].pGetPolygon(nOtherEndPoly);
631
632 if (dSandEroded > 0)
633 {
634 // Add to the still-to-do total of unconsolidated sand to be deposited on the polygon at the up-coast end of this coastline
635 pOtherEndPoly->AddToDoBeachDepositionUnconsSand(dSandEroded);
636 }
637
638 if (dCoarseEroded > 0)
639 {
640 // 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
641 pOtherEndPoly->AddToDoBeachDepositionUnconsCoarse(dCoarseEroded);
642 }
643 }
644 }
645 }
646
647 else
648 {
649 // This polygon is not at the grid edge
650 CGeomCoastPolygon* pAdjPolygon = m_VCoast[nCoast].pGetPolygon(nAdjPoly);
651 double const dBoundaryShare = pPolygon->dGetDownCoastAdjacentPolygonBoundaryShare(nn);
652
653 if (dSandEroded > 0)
654 {
655 // if (m_ulIter == 5)
656 // LogStream << m_ulIter << ": B polygon not at grid edge nPoly = " << nPoly << " nAdjPoly = " << nAdjPoly << ", dGetToDoBeachDepositionUnconsSand() on nAdjPoly is = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
657
658 // Add to the still-to-do total of unconsolidated sand to be deposited on the adjacent polygon
659 pAdjPolygon->AddToDoBeachDepositionUnconsSand(dSandEroded * dBoundaryShare);
660
661 // if (m_ulIter == 5)
662 // LogStream << m_ulIter << ": B after nAdjPoly = " << nAdjPoly << " AddToDoBeachDepositionUnconsSand(" << dSandEroded * dBoundaryShare * m_dCellArea << ") dGetToDoBeachDepositionUnconsSand() now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
663 }
664
665 if (dCoarseEroded > 0)
666 {
667 // if (m_nLogFileDetail >= LOG_FILE_ALL)
668 // LogStream << m_ulIter << ": polygon = " << nPoly << " adjacent polygon = " << nAdjPoly << ", beach deposition 1 of uncons coarse was = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea;
669
670 // Add to the still-to-do total of unconsolidated coarse sediment to be deposited on the adjacent polygon
671 pAdjPolygon->AddToDoBeachDepositionUnconsCoarse(dCoarseEroded * dBoundaryShare);
672
673 // if (m_nLogFileDetail >= LOG_FILE_ALL)
674 // LogStream << " after AddToDoBeachDepositionUnconsCoarse(" << dCoarseEroded * dBoundaryShare << ") beach deposition 1 of uncons coarse now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea << endl;
675 }
676 }
677 }
678
679 // if (m_nLogFileDetail >= LOG_FILE_ALL)
680 // LogStream << m_ulIter << ": 1 uncons sand eroded = " << dSandEroded * m_dCellArea << " 1 uncons coarse eroded = " << dCoarseEroded * m_dCellArea << endl;
681 }
682
683 else
684 {
685 // Moving eroded sediment up-coast
686 int const nNumAdjPoly = pPolygon->nGetNumUpCoastAdjacentPolygons();
687
688 for (int nn = 0; nn < nNumAdjPoly; nn++)
689 {
690 int const nAdjPoly = pPolygon->nGetUpCoastAdjacentPolygon(nn);
691 // if (m_nLogFileDetail >= LOG_FILE_ALL)
692 // LogStream << m_ulIter << ": polygon " << nPoly << " moves sediment up-coast to polygon " << nAdjPoly << endl;
693
694 if (nAdjPoly == INT_NODATA)
695 {
696 // Sediment is leaving the grid
697 if (pPolygon->bIsCoastEndPolygon())
698 {
699 // Error: uncons sediment movement is down-coast and off-edge, but this polygon is at the up-coast end of the coastline
701 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;
702 }
703
704 else if (pPolygon->bIsCoastStartPolygon())
705 {
706 // 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
708 {
709 // Closed grid edges: no uncons sediment moves off-grid, nothing is removed from this polygon, so cannot adjust sediment export
711 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;
712 }
713
715 {
716 // Open grid edges, so this sediment goes off-grid
717 m_dThisIterLeftGridUnconsSand += dSandEroded;
718 m_dThisIterLeftGridUnconsCoarse += dCoarseEroded;
719 }
720
722 {
723 // 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
724 int const nOtherEndPoly = 0;
725 CGeomCoastPolygon* pOtherEndPoly = m_VCoast[nCoast].pGetPolygon(nOtherEndPoly);
726
727 if (dSandEroded > 0)
728 {
729 // Add to the still-to-do total of unconsolidated sand to be deposited on the polygon at the up-coast end of this coastline
730 pOtherEndPoly->AddToDoBeachDepositionUnconsSand(dSandEroded);
731 }
732
733 if (dCoarseEroded > 0)
734 {
735 // 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
736 pOtherEndPoly->AddToDoBeachDepositionUnconsCoarse(dCoarseEroded);
737 }
738 }
739 }
740 }
741
742 else
743 {
744 // This polygon is not at the grid edge
745 CGeomCoastPolygon* pAdjPolygon = m_VCoast[nCoast].pGetPolygon(nAdjPoly);
746 double const dBoundaryShare = pPolygon->dGetUpCoastAdjacentPolygonBoundaryShare(nn);
747
748 if (dSandEroded > 0)
749 {
750 // if (m_ulIter == 5)
751 // LogStream << m_ulIter << ": A polygon not at grid edge nPoly = " << nPoly << " nAdjPoly = " << nAdjPoly << ", dGetToDoBeachDepositionUnconsSand() on nAdjPoly is = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
752
753 // Add to the still-to-do total of unconsolidated sand to be deposited on the the adjacent polygon
754 pAdjPolygon->AddToDoBeachDepositionUnconsSand(dSandEroded * dBoundaryShare);
755
756 // if (m_ulIter == 5)
757 // LogStream << m_ulIter << ": A after nAdjPoly = " << nAdjPoly << " AddToDoBeachDepositionUnconsSand(" << dSandEroded * dBoundaryShare * m_dCellArea << ") dGetToDoBeachDepositionUnconsSand() now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsSand() * m_dCellArea << endl;
758 }
759
760 if (dCoarseEroded > 0)
761 {
762 // if (m_ulIter == 5)
763 // LogStream << m_ulIter << ": polygon not at grid edge nPoly = " << nPoly << " nAdjPoly = " << nAdjPoly << ", beach deposition of uncons coarse was = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea << endl;
764
765 // Add to the still-to-do total of unconsolidated coarse sediment to be deposited on the adjacent polygon
766 pAdjPolygon->AddToDoBeachDepositionUnconsCoarse(+dCoarseEroded * dBoundaryShare);
767
768 // if (m_ulIter == 5)
769 // LogStream << " After AddToDoBeachDepositionUnconsCoarse(" << dCoarseEroded * dBoundaryShare << ") uncons coarse now = " << pAdjPolygon->dGetToDoBeachDepositionUnconsCoarse() * m_dCellArea << endl;
770 }
771 }
772 }
773 }
774 }
775
776 // if (m_nLogFileDetail >= LOG_FILE_ALL)
777 // LogStream << m_ulIter << ": sand eroded on poly = " << dSandEroded * m_dCellArea << " coarse eroded on poly = " << dCoarseEroded * m_dCellArea << endl;
778
779 } // if (dPotentialErosion > 0)
780
781 // // DEBUG CODE ============================================================================================================================================
782 // // Get total depths of unconsolidated sand for every cell
783 // if (m_ulIter == 5)
784 // {
785 // double dTmpSandUncons = 0;
786 // for (int nX1 = 0; nX1 < m_nXGridSize; nX1++)
787 // {
788 // for (int nY1 = 0; nY1 < m_nYGridSize; nY1++)
789 // {
790 // dTmpSandUncons += m_pRasterGrid->m_Cell[nX1][nY1].dGetTotUnconsSand();
791 // }
792 // }
793 //
794 // LogStream << endl;
795 // 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;
796 //
797 // // Now get the total in all still-to-do fields of all polygons
798 // double dToDoTot = 0;
799 //
800 // for (int nn = 0; nn < nPolygons; nn++)
801 // {
802 // CGeomCoastPolygon* pThisPolygon = m_VCoast[nCoast].pGetPolygon(nn);
803 // dToDoTot += pThisPolygon->dGetToDoBeachDepositionUnconsSand();
804 // }
805 //
806 // LogStream << endl << m_ulIter << ": dToDoTot = " << dToDoTot * m_dCellArea << endl;
807 // LogStream << m_ulIter << ": dTmpSandUncons + dToDoTot = " << (dTmpSandUncons + dToDoTot) * m_dCellArea << endl << endl;
808 //
809 // LogStream << m_ulIter << ": m_dThisIterLeftGridUnconsSand = " << m_dThisIterLeftGridUnconsSand * m_dCellArea << endl;
810 //
811 // LogStream << "*****************************" << endl;
812 // }
813 // // DEBUG CODE ============================================================================================================================================
814
815 } // for (int n = 0; n < nNumPolygons; n++)
816
817 // 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
818 int const nPolygons = m_VCoast[nCoast].nGetNumPolygons();
819
820 // for (int nn = 0; nn < nPolygons; nn++)
821 for (int nn = nPolygons - 1; nn >= 0; nn--)
822 {
823 int const nThisPoly = nVVPolyAndAdjacent[nn][1];
824 CGeomCoastPolygon* pThisPolygon = m_VCoast[nCoast].pGetPolygon(nThisPoly);
825
826 double const dSandToDepositOnPoly = pThisPolygon->dGetToDoBeachDepositionUnconsSand();
827
828 if (dSandToDepositOnPoly > 0)
829 {
830 // 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
831 double dSandDeposited = 0;
832 nRet = nDoUnconsDepositionOnPolygon(nCoast, pThisPolygon, TEXTURE_SAND, dSandToDepositOnPoly, dSandDeposited);
833
834 if (nRet != RTN_OK)
835 return nRet;
836
837 double const dSandNotDeposited = dSandToDepositOnPoly - dSandDeposited;
838
839 if (dSandNotDeposited > 0)
840 m_dDepositionSandDiff += dSandNotDeposited;
841
843 LogStream << m_ulIter << ": re-processing nThisPoly = " << nThisPoly << " dSandDeposited = " << dSandDeposited * m_dCellArea << " dSandNotDeposited = " << dSandNotDeposited * m_dCellArea << " m_dDepositionSandDiff = " << m_dDepositionSandDiff * m_dCellArea << endl;
844 }
845
846 double const dCoarseToDepositOnPoly = pThisPolygon->dGetToDoBeachDepositionUnconsCoarse();
847
848 if (dCoarseToDepositOnPoly > 0)
849 {
850 // 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
851 double dCoarseDeposited = 0;
852 nRet = nDoUnconsDepositionOnPolygon(nCoast, pThisPolygon, TEXTURE_COARSE, dCoarseToDepositOnPoly, dCoarseDeposited);
853
854 if (nRet != RTN_OK)
855 return nRet;
856
857 double const dCoarseNotDeposited = dCoarseToDepositOnPoly - dCoarseDeposited;
858
859 if (dCoarseNotDeposited > 0)
860 m_dDepositionCoarseDiff += dCoarseNotDeposited;
861
863 LogStream << m_ulIter << ": re-processing nThisPoly = " << nThisPoly << " dCoarseDeposited = " << dCoarseDeposited * m_dCellArea << " dCoarseNotDeposited = " << dCoarseNotDeposited * m_dCellArea << " m_dDepositionCoarseDiff = " << m_dDepositionCoarseDiff * m_dCellArea << endl;
864 }
865 }
866
868 WritePolygonActualMovement(nCoast, nVVPolyAndAdjacent);
869 }
870
871 return RTN_OK;
872}
873
874//===============================================================================================================================
876//===============================================================================================================================
878{
879 int const nNumPolygons = m_VCoast[nCoast].nGetNumPolygons();
880
881 for (int nPoly = 0; nPoly < nNumPolygons; nPoly++)
882 {
883 CGeomCoastPolygon* pPolygon = m_VCoast[nCoast].pGetPolygon(nPoly);
884
885 // 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
886 double const dFine = pPolygon->dGetSedimentInputUnconsFine();
887 pPolygon->SetPreExistingUnconsFine(dFine);
888
889 // Include unconsolidated sand sediment derived from platform erosion, cliff collapse, and sediment input events
890 double const dSand = pPolygon->dGetPreExistingUnconsSand() + pPolygon->dGetPlatformErosionUnconsSand() + pPolygon->dGetCliffCollapseUnconsSandDeposition() + pPolygon->dGetSedimentInputUnconsSand();
891 pPolygon->SetPreExistingUnconsSand(dSand);
892
893 // Include unconsolidated coarse sediment derived from platform erosion, cliff collapse, and sediment input events
894 double const dCoarse = pPolygon->dGetPreExistingUnconsCoarse() + pPolygon->dGetPlatformErosionUnconsCoarse() + pPolygon->dGetCliffCollapseUnconsCoarseDeposition() + pPolygon->dGetSedimentInputUnconsCoarse();
895 pPolygon->SetPreExistingUnconsCoarse(dCoarse);
896 }
897}
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.
int nGetGlobalID(void) const
Get the global ID.
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.
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?
int nGetCoastID(void) const
Get the coast ID, this is the same as the down-coast sequence of polygons.
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:1255
string const ERR
Definition cme.h:892
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:777
int const GRID_EDGE_RECIRCULATE
Definition cme.h:779
double const MASS_BALANCE_TOLERANCE
Definition cme.h:816
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:778
int const TEXTURE_SAND
Definition cme.h:516
Contains CRWCoast definitions.
Contains CSimulation definitions.