38using std::stable_sort;
55 bool bDownCoastLeft = nVLeft[2];
56 bool bDownCoastRight = nVRight[2];
69 if ((nVLeft.size() >= 4) && (nVRight.size() >= 4))
72 bool bLHSOffEdge =
false;
74 for (
unsigned int n = 3; n < nVLeft.size(); n++)
88 bool bRHSOffEdge =
false;
90 for (
unsigned int n = 3; n < nVRight.size(); n++)
104 if (! bDownCoastRight)
109 bool bLeftFound =
false;
111 for (
unsigned int n = 3; n < nVLeft.size(); n++)
113 if (nVLeft[n] == nVRight[1])
122 bool bRightFound =
false;
124 for (
unsigned int n = 3; n < nVRight.size(); n++)
126 if (nVRight[n] == nVLeft[1])
136 if (nVLeft[1] < nVRight[1])
154 if ((nVLeft.size() >= 4) && (nVRight.size() >= 4))
157 bool bLHSOffEdge =
false;
159 for (
unsigned int n = 3; n < nVLeft.size(); n++)
173 bool bRHSOffEdge =
false;
175 for (
unsigned int n = 3; n < nVRight.size(); n++)
189 if (! bDownCoastRight)
194 bool bLeftFound =
false;
196 for (
unsigned int n = 3; n < nVLeft.size(); n++)
198 if (nVLeft[n] == nVRight[1])
207 bool bRightFound =
false;
209 for (
unsigned int n = 3; n < nVRight.size(); n++)
211 if (nVRight[n] == nVLeft[1])
221 if (nVLeft[1] < nVRight[1])
237 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
242 LogStream <<
m_ulIter <<
": Calculating unconsolidated sediment transport" << endl;
259 vector<vector<int> > nVVPolyAndAdjacent;
260 vector<int> nVPolyAndAdj;
262 for (
int nn = 0; nn <
m_VCoast[nCoast].nGetNumPolygons(); nn++)
265 nVPolyAndAdj.clear();
276 nVPolyAndAdj.push_back(
true);
283 nVPolyAndAdj.push_back(nAdjPolyID);
290 nVPolyAndAdj.push_back(
false);
297 nVPolyAndAdj.push_back(nAdjPolyID);
302 nVVPolyAndAdjacent.push_back(nVPolyAndAdj);
313 vector<int> VnSourcePolygons;
315 for (
int n = 0; n < static_cast<int>(nVVPolyAndAdjacent.size()); n++)
317 int nThisPoly = nVVPolyAndAdjacent[n][1];
318 VnSourcePolygons.push_back(nThisPoly);
320 for (
int m = 3; m < static_cast<int>(nVVPolyAndAdjacent[n].size()); m++)
323 int nToFind = nVVPolyAndAdjacent[n][m];
326 if (it != VnSourcePolygons.end())
332 pPoly =
m_VCoast[nCoast].pGetPolygon(nToFind);
341 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
344 for (
int nPoly = 0; nPoly < nNumPolygons; nPoly++)
346 int nPolygon = nVVPolyAndAdjacent[nPoly][1];
381 if (dCoarseDepositionTarget > 0)
394 LogStream <<
" dCoarseDepositionTarget now = " << dCoarseDepositionTarget << endl;
398 double dCoarseDeposited = 0;
404 double dCoarseNotDeposited = dCoarseDepositionTarget - dCoarseDeposited;
406 if (dCoarseNotDeposited > 0)
415 if (dSandDepositionTarget > 0)
428 LogStream <<
" dSandDepositionTarget now = " << dSandDepositionTarget << endl;
432 double dSandDeposited = 0;
438 double dSandNotDeposited = dSandDepositionTarget - dSandDeposited;
440 if (dSandNotDeposited > 0)
467 if (dPotentialErosion > 0)
472 if (dExistingUnconsFine > 0)
478 double dFineErosionTarget =
tMin(dFinePotentialErosion, dExistingUnconsFine);
481 double dFineEroded = 0;
502 double dSandEroded = 0;
504 if (dExistingUnconsSand > 0)
510 double dSandErosionTarget =
tMin(dSandPotentialErosion, dExistingUnconsSand);
548 double dCoarseEroded = 0;
550 if (dExistingUnconsCoarse > 0)
556 double dCoarseErosionTarget =
tMin(dCoarsePotentialErosion, dExistingUnconsCoarse);
564 if (dCoarseEroded > 0)
575 if ((dSandEroded + dCoarseEroded) > 0)
582 for (
int nn = 0; nn < nNumAdjPoly; nn++)
596 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;
606 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;
626 int nOtherEndPoly = 0;
635 if (dCoarseEroded > 0)
662 if (dCoarseEroded > 0)
685 for (
int nn = 0; nn < nNumAdjPoly; nn++)
698 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;
709 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;
722 int nOtherEndPoly = 0;
731 if (dCoarseEroded > 0)
758 if (dCoarseEroded > 0)
816 int nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
819 for (
int nn = nPolygons - 1; nn >= 0; nn--)
821 int nThisPoly = nVVPolyAndAdjacent[nn][1];
826 if (dSandToDepositOnPoly > 0)
829 double dSandDeposited = 0;
835 double dSandNotDeposited = dSandToDepositOnPoly - dSandDeposited;
837 if (dSandNotDeposited > 0)
846 if (dCoarseToDepositOnPoly > 0)
849 double dCoarseDeposited = 0;
855 double dCoarseNotDeposited = dCoarseToDepositOnPoly - dCoarseDeposited;
857 if (dCoarseNotDeposited > 0)
877 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
879 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 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...
double m_dThisIterBeachErosionCoarse
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
double m_dCoarseErodibilityNormalized
Relative erodibility of coarse unconsolidated beach sediment, normalized.
double m_dDepositionCoarseDiff
int nDoAllActualBeachErosionAndDeposition(void)
Does between-polygon and within-polygon actual (supply-limited) redistribution of transported beach s...
double m_dDepositionSandDiff
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
double m_dThisIterFineSedimentToSuspension
double m_dThisIterBeachErosionFine
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
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
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.