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