38using std::stable_sort;
55 bool bDownCoast = nVLeft[2];
58 if ((nVLeft.size() >= 4) && (nVRight.size() >= 4))
63 for (
unsigned int n = 3; n < nVLeft.size(); n++)
65 if (nVLeft[n] == nVRight[1])
82 for (
unsigned int n = 3; n < nVRight.size(); n++)
84 if (nVRight[n] == nVLeft[1])
102 if (nVLeft[1] < nVRight[1])
132 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
137 LogStream <<
m_ulIter <<
": Calculating unconsolidated sediment transport" << endl;
154 vector<vector<int> > nVVPolyAndAdjacent;
155 vector<int> nVPolyAndAdj;
156 for (
int nn = 0; nn <
m_VCoast[nCoast].nGetNumPolygons(); nn++)
159 nVPolyAndAdj.clear();
170 nVPolyAndAdj.push_back(
true);
177 nVPolyAndAdj.push_back(nAdjPolyID);
183 nVPolyAndAdj.push_back(
false);
190 nVPolyAndAdj.push_back(nAdjPolyID);
195 nVVPolyAndAdjacent.push_back(nVPolyAndAdj);
205 vector<int> VnSourcePolyDownCoastSeq;
206 for (
int n = 0; n < static_cast<int>(nVVPolyAndAdjacent.size()); n++)
208 for (
int m = 0; m < static_cast<int>(nVVPolyAndAdjacent[n].size()); m++)
211 VnSourcePolyDownCoastSeq.push_back(nVVPolyAndAdjacent[n][m]);
216 vector<int>::iterator it = find(VnSourcePolyDownCoastSeq.begin(), VnSourcePolyDownCoastSeq.end(), nVVPolyAndAdjacent[n][m]);
217 if (it != VnSourcePolyDownCoastSeq.end())
223 pPoly =
m_VCoast[nCoast].pGetPolygon(*it);
233 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
236 for (
int n = 0; n < nNumPolygons; n++)
238 int nPolygon = nVVPolyAndAdjacent[n][1];
274 if (dCoarseDepositionTarget > 0)
287 LogStream <<
" dCoarseDepositionTarget now = " << dCoarseDepositionTarget << endl;
291 double dCoarseDeposited = 0;
296 double dCoarseNotDeposited = dCoarseDepositionTarget - dCoarseDeposited;
297 if (dCoarseNotDeposited > 0)
306 if (dSandDepositionTarget > 0)
319 LogStream <<
" dSandDepositionTarget now = " << dSandDepositionTarget << endl;
323 double dSandDeposited = 0;
328 double dSandNotDeposited = dSandDepositionTarget - dSandDeposited;
329 if (dSandNotDeposited > 0)
355 if (dPotentialErosion > 0)
360 if (dExistingUnconsFine > 0)
366 double dFineErosionTarget =
tMin(dFinePotentialErosion, dExistingUnconsFine);
369 double dFineEroded = 0;
389 double dSandEroded = 0;
390 if (dExistingUnconsSand > 0)
396 double dSandErosionTarget =
tMin(dSandPotentialErosion, dExistingUnconsSand);
433 double dCoarseEroded = 0;
434 if (dExistingUnconsCoarse > 0)
440 double dCoarseErosionTarget =
tMin(dCoarsePotentialErosion, dExistingUnconsCoarse);
447 if (dCoarseEroded > 0)
458 if ((dSandEroded + dCoarseEroded) > 0)
464 for (
int nn = 0; nn < nNumAdjPoly; nn++)
478 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;
487 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;
507 int nOtherEndPoly = 0;
516 if (dCoarseEroded > 0)
542 if (dCoarseEroded > 0)
563 for (
int nn = 0; nn < nNumAdjPoly; nn++)
576 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;
586 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;
599 int nOtherEndPoly = 0;
608 if (dCoarseEroded > 0)
634 if (dCoarseEroded > 0)
692 int nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
694 for (
int nn = nPolygons-1; nn >= 0; nn--)
696 int nThisPoly = nVVPolyAndAdjacent[nn][1];
700 if (dSandToDepositOnPoly > 0)
703 double dSandDeposited = 0;
708 double dSandNotDeposited = dSandToDepositOnPoly - dSandDeposited;
709 if (dSandNotDeposited > 0)
717 if (dCoarseToDepositOnPoly > 0)
720 double dCoarseDeposited = 0;
725 double dCoarseNotDeposited = dCoarseToDepositOnPoly - dCoarseDeposited;
726 if (dCoarseNotDeposited > 0)
746 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
748 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 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,...
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.