38using std::stable_sort;
56 if ((nVLeft.size() >= 4) && (nVRight.size() >= 4))
67 for (
unsigned int n = 3; n < nVLeft.size(); n++)
69 if (nVRight[1] == nVLeft[n])
75 for (
unsigned int n = 3; n < nVRight.size(); n++)
77 if (nVLeft[1] == nVRight[n])
83 bool bDownCoast = nVLeft[2];
86 return nVLeft < nVRight;
89 return nVLeft > nVRight;
100 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
105 LogStream <<
m_ulIter <<
": Calculating unconsolidated sediment transport" << endl;
122 vector<vector<int> > nVVPolyAndAdjacent;
123 for (
int nn = 0; nn <
m_VCoast[nCoast].nGetNumPolygons(); nn++)
126 vector<int> nVPolyAndAdj;
137 nVPolyAndAdj.push_back(
true);
144 nVPolyAndAdj.push_back(nAdjPolyID);
150 nVPolyAndAdj.push_back(
false);
157 nVPolyAndAdj.push_back(nAdjPolyID);
162 nVVPolyAndAdjacent.push_back(nVPolyAndAdj);
172 vector<int> VnSourcePolyDownCoastSeq;
173 for (
int n = 0; n < static_cast<int>(nVVPolyAndAdjacent.size()); n++)
175 for (
int m = 0; m < static_cast<int>(nVVPolyAndAdjacent[n].size()); m++)
178 VnSourcePolyDownCoastSeq.push_back(nVVPolyAndAdjacent[n][m]);
183 vector<int>::iterator it = find(VnSourcePolyDownCoastSeq.begin(), VnSourcePolyDownCoastSeq.end(), nVVPolyAndAdjacent[n][m]);
184 if (it != VnSourcePolyDownCoastSeq.end())
190 pPoly =
m_VCoast[nCoast].pGetPolygon(*it);
200 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
203 for (
int n = 0; n < nNumPolygons; n++)
205 int nPolygon = nVVPolyAndAdjacent[n][1];
241 if (dCoarseDepositionTarget > 0)
254 LogStream <<
" dCoarseDepositionTarget now = " << dCoarseDepositionTarget << endl;
258 double dCoarseDeposited = 0;
263 double dCoarseNotDeposited = dCoarseDepositionTarget - dCoarseDeposited;
264 if (dCoarseNotDeposited > 0)
273 if (dSandDepositionTarget > 0)
286 LogStream <<
" dSandDepositionTarget now = " << dSandDepositionTarget << endl;
290 double dSandDeposited = 0;
295 double dSandNotDeposited = dSandDepositionTarget - dSandDeposited;
296 if (dSandNotDeposited > 0)
322 if (dPotentialErosion > 0)
327 if (dExistingUnconsFine > 0)
333 double dFineErosionTarget =
tMin(dFinePotentialErosion, dExistingUnconsFine);
336 double dFineEroded = 0;
356 double dSandEroded = 0;
357 if (dExistingUnconsSand > 0)
363 double dSandErosionTarget =
tMin(dSandPotentialErosion, dExistingUnconsSand);
400 double dCoarseEroded = 0;
401 if (dExistingUnconsCoarse > 0)
407 double dCoarseErosionTarget =
tMin(dCoarsePotentialErosion, dExistingUnconsCoarse);
414 if (dCoarseEroded > 0)
425 if ((dSandEroded + dCoarseEroded) > 0)
431 for (
int nn = 0; nn < nNumAdjPoly; nn++)
445 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;
454 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;
474 int nOtherEndPoly = 0;
483 if (dCoarseEroded > 0)
509 if (dCoarseEroded > 0)
530 for (
int nn = 0; nn < nNumAdjPoly; nn++)
543 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;
553 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;
566 int nOtherEndPoly = 0;
575 if (dCoarseEroded > 0)
601 if (dCoarseEroded > 0)
659 int nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
661 for (
int nn = nPolygons-1; nn >= 0; nn--)
663 int nThisPoly = nVVPolyAndAdjacent[nn][1];
667 if (dSandToDepositOnPoly > 0)
670 double dSandDeposited = 0;
675 double dSandNotDeposited = dSandToDepositOnPoly - dSandDeposited;
676 if (dSandNotDeposited > 0)
684 if (dCoarseToDepositOnPoly > 0)
687 double dCoarseDeposited = 0;
692 double dCoarseNotDeposited = dCoarseToDepositOnPoly - dCoarseDeposited;
693 if (dCoarseNotDeposited > 0)
713 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
715 for (
int nPoly = 0; nPoly < nNumPolygons; nPoly++)
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 downcoast this iteration?
int nGetCoastID(void) const
Get the coast ID, this is the same as the down-coast sequence.
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,...
double m_dThisIterBeachErosionCoarse
Total actual beach erosion (coarse unconsolidated sediment) for this iteration (depth in m)
vector< CRWCoast > m_VCoast
The coastline objects.
double m_dFineErodibilityNormalized
Relative erodibility of fine unconsolidated beach sediment, normalized.
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,...
double m_dCoarseErodibilityNormalized
Relative erodibility of coarse unconsolidated beach sediment, normalized.
double m_dDepositionCoarseDiff
Error term: if we are unable to deposit enough unconslidated coarse on polygon(s),...
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...
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.
double m_dThisIterBeachErosionSand
Total actual beach erosion (sand unconsolidated sediment) for this iteration (depth in m)
double m_dThisIterFineSedimentToSuspension
Total fine unconsolidated sediment in suspension for this iteration (depth in m)
double m_dThisIterBeachErosionFine
Total actual beach erosion (fine unconsolidated sediment) for this iteration (depth in m)
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)
double m_dThisIterLeftGridUnconsCoarse
Total coarse unconsolidated sediment lost from the grid this iteration (depth in m)
unsigned long m_ulIter
The number of the current iteration (time step)
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)
This file contains global definitions for CoastalME.
int const LOG_FILE_MIDDLE_DETAIL
int const GRID_EDGE_CLOSED
int const GRID_EDGE_RECIRCULATE
double const MASS_BALANCE_TOLERANCE
int const LOG_FILE_HIGH_DETAIL
Contains CRWCoast definitions.
bool bPolygonAndAdjCompare(const vector< int > &nVLeft, const vector< int > &nVRight)
Function used to sort polygons before doing the polygon-to-polygon source-target pattern....
Contains CSimulation definitions.