CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
do_sediment_input_event.cpp
Go to the documentation of this file.
1
12
13/*==============================================================================================================================
14
15This file is part of CoastalME, the Coastal Modelling Environment.
16
17CoastalME 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
19This 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
21You 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 <iostream>
25using std::cout;
26using std::endl;
27
28#include <algorithm>
29using std::begin;
30using std::end;
31using std::find;
32
33#include "cme.h"
34#include "simulation.h"
35#include "cell.h"
36#include "coast.h"
38
39//===============================================================================================================================
41//===============================================================================================================================
43{
45
46 // Go through all sediment input events, check for any this timestep
47 int nEvents = static_cast<int>(m_pVSedInputEvent.size());
48
49 for (int n = 0; n < nEvents; n++)
50 {
51 if (m_pVSedInputEvent[n]->ulGetEventTimeStep() == m_ulIter)
52 {
54
55 int nRet = nDoSedimentInputEvent(n);
56 if (nRet != RTN_OK)
57 return nRet;
58 }
59 }
60
61 return RTN_OK;
62}
63
64//===============================================================================================================================
66//===============================================================================================================================
68{
69 // Get values for the sediment input event
70 int nLocID = m_pVSedInputEvent[nEvent]->nGetLocationID();
71 double dFineSedVol = m_pVSedInputEvent[nEvent]->dGetFineSedVol();
72 double dSandSedVol = m_pVSedInputEvent[nEvent]->dGetSandSedVol();
73 double dCoarseSedVol = m_pVSedInputEvent[nEvent]->dGetCoarseSedVol();
74 double dLen = m_pVSedInputEvent[nEvent]->dGetLen();
75 double dWidth = m_pVSedInputEvent[nEvent]->dGetWidth();
76 // double dThick = m_pVSedInputEvent[nEvent]->dGetThick();
77
78 // TODO 083 Get all three kinds of sediment input events working correctly
79
81 {
82 // The sediment input event is at a user-specified point, or in a block at the nearest point on a coast to a user-specified point. So get the point from values read from the shapefile
83 int nEvents = static_cast<int>(m_VnSedimentInputLocationID.size());
84 int nPointGridX = -1;
85 int nPointGridY = -1;
86
87 for (int n = 0; n < nEvents; n++)
88 {
89 if (m_VnSedimentInputLocationID[n] == nLocID)
90 {
91 nPointGridX = nRound(m_VdSedimentInputLocationX[n]); // In grid coords
92 nPointGridY = nRound(m_VdSedimentInputLocationY[n]); // In grid coords
93 }
94 }
95
96 if (nPointGridX == -1)
97 // Should never get here
99
100 // All OK, so get landform
101 CRWCellLandform* pLandform = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLandform();
102
103 // Is this sediment input event at a pre-specified fixed point, or in a block on a coast, or where a line intersects with a coast?
105 {
106 // Sediment input is at a user-specified point
108 LogStream << m_ulIter << ": Sediment input event " << nEvent+1 << " at point [" << nPointGridX << "][" << nPointGridY << "] = {" << dGridXToExtCRSX(nPointGridX) << ", " << dGridYToExtCRSY(nPointGridY) << "] with location ID " << nLocID;
109
110 int nTopLayer = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetTopLayerAboveBasement();
111
112 // Is some fine unconsolidated sediment being input?
113 double dFineDepth = dFineSedVol / m_dCellArea;
114 if (dFineDepth > 0)
115 {
116 // Yes, so add to this cell's fine unconsolidated sediment
117 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddFineSedimentInputDepth(dFineDepth);
118
119 // And update the sediment top elevation value
120 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].CalcAllLayerElevsAndD50();
121
122 int nThisPoly = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetPolygonID();
123 if (nThisPoly != INT_NODATA)
124 {
125 // Add to this polygon's fine sediment input total
126 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsFine(dFineDepth);
127 }
128
129 // Add to the this-iteration total of fine sediment input
130 m_dThisiterUnconsFineInput += dFineDepth;
131
132 // And assign the cell's landform
135 }
136
137 // Is some sand-sized unconsolidated sediment being input?
138 double dSandDepth = dSandSedVol / m_dCellArea;
139 if (dSandDepth > 0)
140 {
141 // Yes, so add to this cell's sand unconsolidated sediment
142 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddSandSedimentInputDepth(dSandDepth);
143
144 // And update the sediment top elevation value
145 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].CalcAllLayerElevsAndD50();
146
147 int nThisPoly = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetPolygonID();
148 if (nThisPoly != INT_NODATA)
149 {
150 // Add to this polygon's sand sediment input total
151 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsSand(dSandDepth);
152 }
153
154 // Add to the this-iteration total of sand sediment input
155 m_dThisiterUnconsSandInput += dSandDepth;
156
157 // And assign the cell's landform
160 }
161
162 // Is some coarse unconsolidated sediment being input?
163 double dCoarseDepth = dCoarseSedVol / m_dCellArea;
164 if (dCoarseDepth > 0)
165 {
166 // Yes, so add to this cell's coarse unconsolidated sediment
167 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddCoarseSedimentInputDepth(dCoarseDepth);
168
169 // And update the sediment top elevation value
170 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].CalcAllLayerElevsAndD50();
171
172 int nThisPoly = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetPolygonID();
173 if (nThisPoly != INT_NODATA)
174 {
175 // Add to this polygon's coarse sediment input total
176 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsCoarse(dCoarseDepth);
177 }
178
179 // Add to the this-iteration total of coarse sediment input
180 m_dThisiterUnconsCoarseInput += dCoarseDepth;
181
182 // And assign the cell's landform
185 }
186
188 LogStream << ", depth of fine sediment added = " << dFineDepth << " m, depth of sand sediment added = " << dSandDepth << " m, depth of coarse sediment added = " << dCoarseDepth << " m" << endl;
189 }
191 {
192 // Is in a sediment block, seaward from a coast
194 LogStream << m_ulIter << ": Sediment input event " << nEvent+1 << " with location ID " << nLocID << " at closest point on coast to [" << nPointGridX << "][" << nPointGridY << "] = {" << dGridXToExtCRSX(nPointGridX) << ", " << dGridYToExtCRSY(nPointGridY) << "]" << endl;
195
196 // Find the closest point on the coastline
197 CGeom2DIPoint PtiCoastPoint = PtiFindClosestCoastPoint(nPointGridX, nPointGridY);
198
199 int nCoastX = PtiCoastPoint.nGetX();
200 int nCoastY = PtiCoastPoint.nGetY();
201
203 LogStream << m_ulIter << ": Closest coast point is at [" << nCoastX << "][" << nCoastY << "] = {" << dGridXToExtCRSX(nCoastX) << ", " << dGridYToExtCRSY(nCoastY) << "}, along-coast width of sediment block = " << dWidth << " m, coast-normal length of sediment block = " << dLen << " m" << endl;
204
205 int nCoast = m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLandform()->nGetCoast();
206 int nCoastPoint = m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLandform()->nGetPointOnCoast();
207 int nHalfWidth = nRound(dWidth / m_dCellSide);
208 int nLength = nRound(dLen / m_dCellSide);
209 int nCoastLen = m_VCoast[nCoast].nGetCoastlineSize();
210 int nCoastXBefore = nCoastX;
211 int nCoastYBefore = nCoastY;
212 int nCoastXAfter = nCoastX;
213 int nCoastYAfter = nCoastY;
214
215 if (nCoastPoint > 0)
216 {
217 nCoastXBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint - 1)->nGetX();
218 nCoastYBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint - 1)->nGetY();
219 }
220
221 if (nCoastPoint < nCoastLen - 1)
222 {
223 nCoastXAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint + 1)->nGetX();
224 nCoastYAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint + 1)->nGetY();
225 }
226
227 int nCoastHand = m_VCoast[nCoast].nGetSeaHandedness();
228 int nPerpHand = LEFT_HANDED;
229
230 if (nCoastHand == LEFT_HANDED)
231 nPerpHand = RIGHT_HANDED;
232
233 vector<CGeom2DIPoint> VPoints;
234
235 // If size of plume is smaller than a cell, choose the current coast point
236 if (nHalfWidth == 0)
237 {
238 VPoints.push_back(PtiCoastPoint);
239 }
240 else
241 {
242 // It is larger than a cell
243 vector<int> VnCentrePointsXOffset, VnCentrePointsYOffset;
244
245 for (int m = 0; m < nHalfWidth; m++)
246 {
247 if (m == 0)
248 {
249 VPoints.push_back(CGeom2DIPoint(nCoastX, nCoastY));
250 for (int n = 1; n < nLength; n++)
251 {
252 CGeom2DIPoint PtiTmp = PtiGetPerpendicular(nCoastXBefore, nCoastYBefore, nCoastXAfter, nCoastYAfter, n, nPerpHand);
253
254 if (bIsWithinValidGrid(&PtiTmp))
255 {
256 VPoints.push_back(PtiTmp);
257
258 VnCentrePointsXOffset.push_back(PtiTmp.nGetX() - nCoastX);
259 VnCentrePointsYOffset.push_back(PtiTmp.nGetY() - nCoastY);
260 }
261 }
262 }
263 else
264 {
265 int nCoastPointInBlockBefore = nCoastPoint - m;
266 int nCoastPointInBlockAfter = nCoastPoint + m;
267
268 if (nCoastPointInBlockBefore >= 0)
269 {
270 int nCoastXInBlockBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockBefore)->nGetX();
271 int nCoastYInBlockBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockBefore)->nGetY();
272
273 if (bIsWithinValidGrid(nCoastXInBlockBefore, nCoastYInBlockBefore))
274 {
275 VPoints.push_back(CGeom2DIPoint(nCoastXInBlockBefore, nCoastYInBlockBefore));
276
277 for (unsigned int n = 0; n < VnCentrePointsXOffset.size(); n++)
278 {
279 int nXTmp = nCoastXInBlockBefore + VnCentrePointsXOffset[n];
280 int nYTmp = nCoastYInBlockBefore + VnCentrePointsYOffset[n];
281
282 if (bIsWithinValidGrid(nXTmp, nYTmp))
283 VPoints.push_back(CGeom2DIPoint(nXTmp, nYTmp));
284 }
285 }
286 }
287
288 if (nCoastPointInBlockAfter < nCoastLen)
289 {
290 int nCoastXInBlockAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockAfter)->nGetX();
291 int nCoastYInBlockAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockAfter)->nGetY();
292
293 if (bIsWithinValidGrid(nCoastXInBlockAfter, nCoastYInBlockAfter))
294 {
295 VPoints.push_back(CGeom2DIPoint(nCoastXInBlockAfter, nCoastYInBlockAfter));
296
297 for (unsigned int n = 0; n < VnCentrePointsXOffset.size(); n++)
298 {
299 int nXTmp = nCoastXInBlockAfter + VnCentrePointsXOffset[n];
300 int nYTmp = nCoastYInBlockAfter + VnCentrePointsYOffset[n];
301
302 if (bIsWithinValidGrid(nXTmp, nYTmp))
303 {
304 CGeom2DIPoint PtiTmp(nXTmp, nYTmp);
305
306 // Is this cell already in the array?
307 if (find(begin(VPoints), end(VPoints), PtiTmp) == end(VPoints))
308 // No it isn't
309 VPoints.push_back(PtiTmp);
310 }
311 }
312 }
313 }
314 }
315 }
316
317 // // DEBUG CODE ===============================================================================================================
318 // LogStream << endl;
319 // unsigned int m = 0;
320 // for (unsigned int n = 0; n < VPoints.size(); n++)
321 // {
322 // LogStream << "[" << VPoints[n].nGetX() << ", " << VPoints[n].nGetY() << "] ";
323 // m++;
324 // if (m == VnCentrePointsXOffset.size() + 1)
325 // {
326 // LogStream << endl;
327 // m = 0;
328 // }
329 // }
330 // LogStream << endl;
331 // // DEBUG CODE ===============================================================================================================
332 }
333
334 // OK we now know which cells are part of the sediment block, and so will receive sediment input. Next calculate the volume per cell
335 double dFineDepth = dFineSedVol / m_dCellArea;
336 double dSandDepth = dSandSedVol / m_dCellArea;
337 double dCoarseDepth = dCoarseSedVol / m_dCellArea;
338
340 LogStream << m_ulIter << ": Total depth of fine sediment added = " << dFineDepth << " m, total depth of sand sediment added = " << dSandDepth << " m, total depth of coarse sediment added = " << dCoarseDepth << " m" << endl;
341
342 size_t nArea = VPoints.size();
343 double dArea = static_cast<double>(nArea);
344 double dFineDepthPerCell = dFineDepth / dArea;
345 double dSandDepthPerCell = dSandDepth / dArea;
346 double dCoarseDepthPerCell = dCoarseDepth / dArea;
347
348 // OK, so finally: put some sediment onto each cell in the sediment block
349 int nTopLayer = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetTopLayerAboveBasement();
350 for (unsigned int n = 0; n < nArea; n++)
351 {
352 int nX = VPoints[n].nGetX();
353 int nY = VPoints[n].nGetY();
354
355 // Add to this cell's fine unconsolidated sediment
356 m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddFineSedimentInputDepth(dFineDepthPerCell);
357
358 // Add to this cell's sand unconsolidated sediment
359 m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddSandSedimentInputDepth(dSandDepthPerCell);
360
361 // Add to this cell's coarse unconsolidated sediment
362 m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddCoarseSedimentInputDepth(dCoarseDepthPerCell);
363 }
364
365 // Add to the this-iteration totals
366 m_dThisiterUnconsFineInput += dFineDepth;
367 m_dThisiterUnconsSandInput += dSandDepth;
368 m_dThisiterUnconsCoarseInput += dCoarseDepth;
369 }
370 }
372 {
373 // The location of the sediment input event is where a line intersects a coast. First get the line, using values read from the shapefile
374 int nPoints = static_cast<int>(m_VnSedimentInputLocationID.size());
375 vector<int> VnLineGridX;
376 vector<int> VnLineGridY;
377
378 for (int n = 0; n < nPoints; n++)
379 {
380 if (m_VnSedimentInputLocationID[n] == nLocID)
381 {
382 VnLineGridX.push_back(nRound(m_VdSedimentInputLocationX[n]));
383 VnLineGridY.push_back(nRound(m_VdSedimentInputLocationY[n]));
384 }
385 }
386
387 // // DEBUG CODE ===========================================================================================================
388 // string strOutFile = m_strOutPath;
389 // strOutFile += "00_sediment_input_line_CHECK_";
390 // strOutFile += to_string(m_ulIter);
391 // strOutFile += ".tif";
392 //
393 // GDALDriver* pDriver = GetGDALDriverManager()->GetDriverByName("gtiff");
394 // GDALDataset* pDataSet = pDriver->Create(strOutFile.c_str(), m_nXGridSize, m_nYGridSize, 1, GDT_Float64, m_papszGDALRasterOptions);
395 // pDataSet->SetProjection(m_strGDALBasementDEMProjection.c_str());
396 // pDataSet->SetGeoTransform(m_dGeoTransform);
397 //
398 // int nn = 0;
399 // double* pdRaster = new double[m_nXGridSize * m_nYGridSize];
400 // for (int nY = 0; nY < m_nYGridSize; nY++)
401 // {
402 // for (int nX = 0; nX < m_nXGridSize; nX++)
403 // {
404 // pdRaster[nn++] = 0;
405 // }
406 // }
407 //
408 // for (unsigned int n = 0; n < VnLineGridX.size() - 1; n++)
409 // {
410 // int nX = VnLineGridX[n];
411 // int nY = VnLineGridY[n];
412 // int m = (nY * m_nXGridSize) + nX;
413 //
414 // pdRaster[m] = 1;
415 // }
416 //
417 // GDALRasterBand* pBand = pDataSet->GetRasterBand(1);
418 // pBand->SetNoDataValue(m_dMissingValue);
419 // int nRet = pBand->RasterIO(GF_Write, 0, 0, m_nXGridSize, m_nYGridSize, pdRaster, m_nXGridSize, m_nYGridSize, GDT_Float64, 0, 0, NULL);
420 //
421 // if (nRet == CE_Failure)
422 // return RTN_ERR_GRIDCREATE;
423 //
424 // GDALClose(pDataSet);
425 // delete[] pdRaster;
426 // // DEBUG CODE ===========================================================================================================
427
428 // Should never get here
429 if (VnLineGridX.size() == 0)
431
433 LogStream << m_ulIter << ": Sediment input event " << nEvent << " at line/coast intersection for line with ID " << nLocID << endl;
434
435 // Now go along the line, joining each pair of points by a straight line
436 int nCoastX = -1;
437 int nCoastY = -1;
438
439 for (unsigned int n = 0; n < VnLineGridX.size() - 1; n++)
440 {
441 int nXStart = VnLineGridX[n];
442 int nXEnd = VnLineGridX[n + 1];
443 int nYStart = VnLineGridY[n];
444 int nYEnd = VnLineGridY[n + 1];
445
446 // Interpolate between pairs of points using a simple DDA line algorithm, see http://en.wikipedia.org/wiki/Digital_differential_analyzer_(graphics_algorithm). Bresenham's algorithm gave occasional gaps
447 double dXInc = nXEnd - nXStart;
448 double dYInc = nYEnd - nYStart;
449 double dLength = tMax(tAbs(dXInc), tAbs(dYInc));
450
451 dXInc /= dLength;
452 dYInc /= dLength;
453
454 double dX = nXStart;
455 double dY = nYStart;
456
457 // Process each interpolated point
458 for (int m = 0; m <= nRound(dLength); m++)
459 {
460 int nX = nRound(dX);
461 int nY = nRound(dY);
462
463 // Have we hit a coastline cell?
464 if (bIsWithinValidGrid(nX, nY) && m_pRasterGrid->m_Cell[nX][nY].bIsCoastline())
465 {
466 nCoastX = nX;
467 nCoastY = nY;
468 break;
469 }
470
471 // Two diagonal(ish) raster lines can cross each other without any intersection, so must also test an adjacent cell for intersection (does not matter which adjacent cell)
472 if (bIsWithinValidGrid(nX, nY + 1) && m_pRasterGrid->m_Cell[nX][nY + 1].bIsCoastline())
473 {
474 nCoastX = nX;
475 nCoastY = nY + 1;
476 break;
477 }
478
479 // Increment for next time
480 dX += dXInc;
481 dY += dYInc;
482 }
483
484 // Did we find an intersection?
485 if (nCoastX != -1)
486 break;
487 }
488
489 // Did we find an intersection?
490 if (nCoastX == -1)
491 {
492 // Nope
494 LogStream << m_ulIter << ": No line/coast intersection found" << endl;
495
497 }
498
499 // OK we have an intersection of the line and coast. We will input the sediment here
501 LogStream << m_ulIter << ": line/coast intersection is at [" << nCoastX << "][" << nCoastY << "] = {" << dGridXToExtCRSX(nCoastX) << ", " << dGridYToExtCRSY(nCoastY) << "}" << endl;
502
503 // Get landform and top layer
504 CRWCellLandform* pLandform = m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLandform();
505 int nTopLayer = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetTopLayerAboveBasement();
506
507 // Is some fine unconsolidated sediment being input?
508 double dFineDepth = dFineSedVol / m_dCellArea;
509 if (dFineDepth > 0)
510 {
511 // Yes, so add to this cell's fine unconsolidated sediment
512 m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddFineSedimentInputDepth(dFineDepth);
513
514 // And update the sediment top elevation value
515 m_pRasterGrid->m_Cell[nCoastX][nCoastY].CalcAllLayerElevsAndD50();
516
517 int nThisPoly = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetPolygonID();
518 if (nThisPoly != INT_NODATA)
519 {
520 // Add to this polygon's fine sediment input total
521 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsFine(dFineDepth);
522 }
523
524 // Add to the this-iteration total of fine sediment input
525 m_dThisiterUnconsFineInput += dFineDepth;
526
527 // And assign the cell's landform
530 }
531
532 // Is some sand-sized unconsolidated sediment being input?
533 double dSandDepth = dSandSedVol / m_dCellArea;
534 if (dSandDepth > 0)
535 {
536 // Yes, so add to this cell's sand unconsolidated sediment
537 m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddSandSedimentInputDepth(dSandDepth);
538
539 // And update the sediment top elevation value
540 m_pRasterGrid->m_Cell[nCoastX][nCoastY].CalcAllLayerElevsAndD50();
541
542 int nThisPoly = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetPolygonID();
543 if (nThisPoly != INT_NODATA)
544 {
545 // Add to this polygon's sand sediment input total
546 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsSand(dSandDepth);
547 }
548
549 // Add to the this-iteration total of sand sediment input
550 m_dThisiterUnconsSandInput += dSandDepth;
551
552 // And assign the cell's landform
555 }
556
557 // Is some coarse unconsolidated sediment being input?
558 double dCoarseDepth = dCoarseSedVol / m_dCellArea;
559 if (dCoarseDepth > 0)
560 {
561 // Yes, so add to this cell's coarse unconsolidated sediment
562 m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddCoarseSedimentInputDepth(dCoarseDepth);
563
564 // And update the sediment top elevation value
565 m_pRasterGrid->m_Cell[nCoastX][nCoastY].CalcAllLayerElevsAndD50();
566
567 int nThisPoly = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetPolygonID();
568 if (nThisPoly != INT_NODATA)
569 {
570 // Add to this polygon's coarse sediment input total
571 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsCoarse(dCoarseDepth);
572 }
573
574 // Add to the this-iteration total of coarse sediment input
575 m_dThisiterUnconsCoarseInput += dCoarseDepth;
576
577 // And assign the cell's landform
580 }
581
583 LogStream << m_ulIter << "; depth of fine sediment added = " << dFineDepth << " m, depth of sand sediment added = " << dSandDepth << " m, depth of coarse sediment added = " << dCoarseDepth << " m" << endl;
584 }
585
586 return RTN_OK;
587}
Contains CGeomCell definitions.
Geometry class used to represent 2D point objects with integer coordinates.
Definition 2di_point.h:29
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
Definition 2di_point.cpp:48
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:42
Real-world class used to represent the landform of a cell.
void SetLFCategory(int const)
Set the landform category.
void SetLFSubCategory(int const)
Set the both the landform sub-category, and the landform category.
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:531
bool m_bSedimentInputAtPoint
Do we have sediment inputat a point?
Definition simulation.h:369
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
ofstream LogStream
vector< CRWCoast > m_VCoast
The coastline objects.
vector< int > m_VnSedimentInputLocationID
ID for sediment input location, this corresponds with the ID in the sediment input time series file.
static CGeom2DIPoint PtiGetPerpendicular(CGeom2DIPoint const *, CGeom2DIPoint const *, double const, int const)
Returns a CGeom2DIPoint (grid CRS) which is the 'other' point of a two-point vector passing through P...
int nCheckForSedimentInputEvent(void)
Check to see if we have any sediment input events this timestep, if so then do the event(s)
bool m_bSedimentInputAlongLine
Do we have sediment input along a line?
Definition simulation.h:375
double m_dThisiterUnconsCoarseInput
Depth (m) of coarse unconsolidated sediment added, at this iteration.
Definition simulation.h:932
int nDoSedimentInputEvent(int const)
Do a sediment input event.
double m_dThisiterUnconsFineInput
Depth (m) of fine unconsolidated sediment added, at this iteration.
Definition simulation.h:926
vector< double > m_VdSedimentInputLocationX
X coordinate (grid CRS) for sediment input event.
bool m_bSedimentInputAtCoast
Do we have sediment input at the coast?
Definition simulation.h:372
double dGridYToExtCRSY(double const) const
Given a real-valued Y-axis ordinate in the raster grid CRS (i.e. not the centroid of a cell),...
vector< CSedInputEvent * > m_pVSedInputEvent
Sediment input events.
vector< double > m_VdSedimentInputLocationY
X coordinate (grid CRS) for sediment input event.
CGeom2DIPoint PtiFindClosestCoastPoint(int const, int const)
Finds the closest point on any coastline to a given point.
double m_dCellArea
Area of a cell (in external CRS units)
Definition simulation.h:617
bool bIsWithinValidGrid(int const, int const) const
Checks whether the supplied point (an x-y pair, in the grid CRS) is within the raster grid,...
double dGridXToExtCRSX(double const) const
Given a real-valued X-axis ordinate in the raster grid CRS (i.e. not the centroid of a cell),...
Definition gis_utils.cpp:92
unsigned long m_ulIter
The number of the current iteration (time step)
Definition simulation.h:554
double m_dThisiterUnconsSandInput
Depth (m) of sand unconsolidated sediment added, at this iteration.
Definition simulation.h:929
double m_dCellSide
Length of a cell side (in external CRS units)
Definition simulation.h:614
bool m_bSedimentInputThisIter
Do we have a sediment input event this iteration?
Definition simulation.h:381
vector< CGeomCoastPolygon * > m_pVCoastPolygon
Pointers to coast polygon objects, in down-coast sequence TODO 044 Will need to use global polygon ID...
This file contains global definitions for CoastalME.
int const INT_NODATA
Definition cme.h:365
int const LF_CAT_SEDIMENT_INPUT
Definition cme.h:427
int const LOG_FILE_MIDDLE_DETAIL
Definition cme.h:380
int const LF_SUBCAT_SEDIMENT_INPUT_UNCONSOLIDATED
Definition cme.h:452
T tMax(T a, T b)
Definition cme.h:1125
int const RTN_OK
Definition cme.h:580
int const RIGHT_HANDED
Definition cme.h:400
T tAbs(T a)
Definition cme.h:1150
int const RTN_ERR_SEDIMENT_INPUT_EVENT
Definition cme.h:645
int const LEFT_HANDED
Definition cme.h:401
Contains CRWCoast definitions.
Contains CSedInputEvent definitions.
Contains CSimulation definitions.
int nRound(double const d)
Version of the above that returns an int.