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 "cell.h"
35#include "coast.h"
37
38//===============================================================================================================================
40//===============================================================================================================================
42{
44
45 // Go through all sediment input events, check for any this timestep
46 int nEvents = static_cast<int>(m_pVSedInputEvent.size());
47
48 for (int n = 0; n < nEvents; n++)
49 {
50 if (m_pVSedInputEvent[n]->ulGetEventTimeStep() == m_ulIter)
51 {
53
54 int nRet = nDoSedimentInputEvent(n);
55 if (nRet != RTN_OK)
56 return nRet;
57 }
58 }
59
60 return RTN_OK;
61}
62
63//===============================================================================================================================
65//===============================================================================================================================
67{
68 // Get values for the sediment input event
69 int nLocID = m_pVSedInputEvent[nEvent]->nGetLocationID();
70 double dFineSedVol = m_pVSedInputEvent[nEvent]->dGetFineSedVol();
71 double dSandSedVol = m_pVSedInputEvent[nEvent]->dGetSandSedVol();
72 double dCoarseSedVol = m_pVSedInputEvent[nEvent]->dGetCoarseSedVol();
73 double dLen = m_pVSedInputEvent[nEvent]->dGetLen();
74 double dWidth = m_pVSedInputEvent[nEvent]->dGetWidth();
75 // double dThick = m_pVSedInputEvent[nEvent]->dGetThick();
76
77 // TODO 083 Get all three kinds of sediment input events working correctly
78
80 {
81 // 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
82 int nEvents = static_cast<int>(m_VnSedimentInputLocationID.size());
83 int nPointGridX = -1;
84 int nPointGridY = -1;
85
86 for (int n = 0; n < nEvents; n++)
87 {
88 if (m_VnSedimentInputLocationID[n] == nLocID)
89 {
90 nPointGridX = nRound(m_VdSedimentInputLocationX[n]); // In grid coords
91 nPointGridY = nRound(m_VdSedimentInputLocationY[n]); // In grid coords
92 }
93 }
94
95 if (nPointGridX == -1)
96 // Should never get here
98
99 // All OK, so get landform
100 CRWCellLandform* pLandform = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLandform();
101
102 // 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?
104 {
105 // Sediment input is at a user-specified point
107 LogStream << m_ulIter << ": Sediment input event " << nEvent+1 << " at point [" << nPointGridX << "][" << nPointGridY << "] = {" << dGridXToExtCRSX(nPointGridX) << ", " << dGridYToExtCRSY(nPointGridY) << "] with location ID " << nLocID;
108
109 int nTopLayer = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetTopLayerAboveBasement();
110
111 // Is some fine unconsolidated sediment being input?
112 double dFineDepth = dFineSedVol / m_dCellArea;
113 if (dFineDepth > 0)
114 {
115 // Yes, so add to this cell's fine unconsolidated sediment
116 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddFineSedimentInputDepth(dFineDepth);
117
118 // And update the sediment top elevation value
119 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].CalcAllLayerElevsAndD50();
120
121 int nThisPoly = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetPolygonID();
122 if (nThisPoly != INT_NODATA)
123 {
124 // Add to this polygon's fine sediment input total
125 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsFine(dFineDepth);
126 }
127
128 // Add to the this-iteration total of fine sediment input
129 m_dThisiterUnconsFineInput += dFineDepth;
130
131 // And assign the cell's landform
134 }
135
136 // Is some sand-sized unconsolidated sediment being input?
137 double dSandDepth = dSandSedVol / m_dCellArea;
138 if (dSandDepth > 0)
139 {
140 // Yes, so add to this cell's sand unconsolidated sediment
141 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddSandSedimentInputDepth(dSandDepth);
142
143 // And update the sediment top elevation value
144 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].CalcAllLayerElevsAndD50();
145
146 int nThisPoly = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetPolygonID();
147 if (nThisPoly != INT_NODATA)
148 {
149 // Add to this polygon's sand sediment input total
150 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsSand(dSandDepth);
151 }
152
153 // Add to the this-iteration total of sand sediment input
154 m_dThisiterUnconsSandInput += dSandDepth;
155
156 // And assign the cell's landform
159 }
160
161 // Is some coarse unconsolidated sediment being input?
162 double dCoarseDepth = dCoarseSedVol / m_dCellArea;
163 if (dCoarseDepth > 0)
164 {
165 // Yes, so add to this cell's coarse unconsolidated sediment
166 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddCoarseSedimentInputDepth(dCoarseDepth);
167
168 // And update the sediment top elevation value
169 m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].CalcAllLayerElevsAndD50();
170
171 int nThisPoly = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetPolygonID();
172 if (nThisPoly != INT_NODATA)
173 {
174 // Add to this polygon's coarse sediment input total
175 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsCoarse(dCoarseDepth);
176 }
177
178 // Add to the this-iteration total of coarse sediment input
179 m_dThisiterUnconsCoarseInput += dCoarseDepth;
180
181 // And assign the cell's landform
184 }
185
187 LogStream << ", depth of fine sediment added = " << dFineDepth << " m, depth of sand sediment added = " << dSandDepth << " m, depth of coarse sediment added = " << dCoarseDepth << " m" << endl;
188 }
190 {
191 // Is in a sediment block, seaward from a coast
193 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;
194
195 // Find the closest point on the coastline
196 CGeom2DIPoint PtiCoastPoint = PtiFindClosestCoastPoint(nPointGridX, nPointGridY);
197
198 int nCoastX = PtiCoastPoint.nGetX();
199 int nCoastY = PtiCoastPoint.nGetY();
200
202 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;
203
204 int nCoast = m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLandform()->nGetCoast();
205 int nCoastPoint = m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLandform()->nGetPointOnCoast();
206 int nHalfWidth = nRound(dWidth / m_dCellSide);
207 int nLength = nRound(dLen / m_dCellSide);
208 int nCoastLen = m_VCoast[nCoast].nGetCoastlineSize();
209 int nCoastXBefore = nCoastX;
210 int nCoastYBefore = nCoastY;
211 int nCoastXAfter = nCoastX;
212 int nCoastYAfter = nCoastY;
213
214 if (nCoastPoint > 0)
215 {
216 nCoastXBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint - 1)->nGetX();
217 nCoastYBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint - 1)->nGetY();
218 }
219
220 if (nCoastPoint < nCoastLen - 1)
221 {
222 nCoastXAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint + 1)->nGetX();
223 nCoastYAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint + 1)->nGetY();
224 }
225
226 int nCoastHand = m_VCoast[nCoast].nGetSeaHandedness();
227 int nPerpHand = LEFT_HANDED;
228
229 if (nCoastHand == LEFT_HANDED)
230 nPerpHand = RIGHT_HANDED;
231
232 vector<CGeom2DIPoint> VPoints;
233
234 // If size of plume is smaller than a cell, choose the current coast point
235 if (nHalfWidth == 0)
236 {
237 VPoints.push_back(PtiCoastPoint);
238 }
239 else
240 {
241 // It is larger than a cell
242 vector<int> VnCentrePointsXOffset, VnCentrePointsYOffset;
243
244 for (int m = 0; m < nHalfWidth; m++)
245 {
246 if (m == 0)
247 {
248 VPoints.push_back(CGeom2DIPoint(nCoastX, nCoastY));
249 for (int n = 1; n < nLength; n++)
250 {
251 CGeom2DIPoint PtiTmp = PtiGetPerpendicular(nCoastXBefore, nCoastYBefore, nCoastXAfter, nCoastYAfter, n, nPerpHand);
252
253 if (bIsWithinValidGrid(&PtiTmp))
254 {
255 VPoints.push_back(PtiTmp);
256
257 VnCentrePointsXOffset.push_back(PtiTmp.nGetX() - nCoastX);
258 VnCentrePointsYOffset.push_back(PtiTmp.nGetY() - nCoastY);
259 }
260 }
261 }
262 else
263 {
264 int nCoastPointInBlockBefore = nCoastPoint - m;
265 int nCoastPointInBlockAfter = nCoastPoint + m;
266
267 if (nCoastPointInBlockBefore >= 0)
268 {
269 int nCoastXInBlockBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockBefore)->nGetX();
270 int nCoastYInBlockBefore = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockBefore)->nGetY();
271
272 if (bIsWithinValidGrid(nCoastXInBlockBefore, nCoastYInBlockBefore))
273 {
274 VPoints.push_back(CGeom2DIPoint(nCoastXInBlockBefore, nCoastYInBlockBefore));
275
276 for (unsigned int n = 0; n < VnCentrePointsXOffset.size(); n++)
277 {
278 int nXTmp = nCoastXInBlockBefore + VnCentrePointsXOffset[n];
279 int nYTmp = nCoastYInBlockBefore + VnCentrePointsYOffset[n];
280
281 if (bIsWithinValidGrid(nXTmp, nYTmp))
282 VPoints.push_back(CGeom2DIPoint(nXTmp, nYTmp));
283 }
284 }
285 }
286
287 if (nCoastPointInBlockAfter < nCoastLen)
288 {
289 int nCoastXInBlockAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockAfter)->nGetX();
290 int nCoastYInBlockAfter = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPointInBlockAfter)->nGetY();
291
292 if (bIsWithinValidGrid(nCoastXInBlockAfter, nCoastYInBlockAfter))
293 {
294 VPoints.push_back(CGeom2DIPoint(nCoastXInBlockAfter, nCoastYInBlockAfter));
295
296 for (unsigned int n = 0; n < VnCentrePointsXOffset.size(); n++)
297 {
298 int nXTmp = nCoastXInBlockAfter + VnCentrePointsXOffset[n];
299 int nYTmp = nCoastYInBlockAfter + VnCentrePointsYOffset[n];
300
301 if (bIsWithinValidGrid(nXTmp, nYTmp))
302 {
303 CGeom2DIPoint PtiTmp(nXTmp, nYTmp);
304
305 // Is this cell already in the array?
306 if (find(begin(VPoints), end(VPoints), PtiTmp) == end(VPoints))
307 // No it isn't
308 VPoints.push_back(PtiTmp);
309 }
310 }
311 }
312 }
313 }
314 }
315
316 // // DEBUG CODE ===============================================================================================================
317 // LogStream << endl;
318 // unsigned int m = 0;
319 // for (unsigned int n = 0; n < VPoints.size(); n++)
320 // {
321 // LogStream << "[" << VPoints[n].nGetX() << ", " << VPoints[n].nGetY() << "] ";
322 // m++;
323 // if (m == VnCentrePointsXOffset.size() + 1)
324 // {
325 // LogStream << endl;
326 // m = 0;
327 // }
328 // }
329 // LogStream << endl;
330 // // DEBUG CODE ===============================================================================================================
331 }
332
333 // OK we now know which cells are part of the sediment block, and so will receive sediment input. Next calculate the volume per cell
334 double dFineDepth = dFineSedVol / m_dCellArea;
335 double dSandDepth = dSandSedVol / m_dCellArea;
336 double dCoarseDepth = dCoarseSedVol / m_dCellArea;
337
339 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;
340
341 size_t nArea = VPoints.size();
342 double dArea = static_cast<double>(nArea);
343 double dFineDepthPerCell = dFineDepth / dArea;
344 double dSandDepthPerCell = dSandDepth / dArea;
345 double dCoarseDepthPerCell = dCoarseDepth / dArea;
346
347 // OK, so finally: put some sediment onto each cell in the sediment block
348 int nTopLayer = m_pRasterGrid->m_Cell[nPointGridX][nPointGridY].nGetTopLayerAboveBasement();
349 for (unsigned int n = 0; n < nArea; n++)
350 {
351 int nX = VPoints[n].nGetX();
352 int nY = VPoints[n].nGetY();
353
354 // Add to this cell's fine unconsolidated sediment
355 m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddFineSedimentInputDepth(dFineDepthPerCell);
356
357 // Add to this cell's sand unconsolidated sediment
358 m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddSandSedimentInputDepth(dSandDepthPerCell);
359
360 // Add to this cell's coarse unconsolidated sediment
361 m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddCoarseSedimentInputDepth(dCoarseDepthPerCell);
362 }
363
364 // Add to the this-iteration totals
365 m_dThisiterUnconsFineInput += dFineDepth;
366 m_dThisiterUnconsSandInput += dSandDepth;
367 m_dThisiterUnconsCoarseInput += dCoarseDepth;
368 }
369 }
371 {
372 // The location of the sediment input event is where a line intersects a coast. First get the line, using values read from the shapefile
373 int nPoints = static_cast<int>(m_VnSedimentInputLocationID.size());
374 vector<int> VnLineGridX;
375 vector<int> VnLineGridY;
376
377 for (int n = 0; n < nPoints; n++)
378 {
379 if (m_VnSedimentInputLocationID[n] == nLocID)
380 {
381 VnLineGridX.push_back(nRound(m_VdSedimentInputLocationX[n]));
382 VnLineGridY.push_back(nRound(m_VdSedimentInputLocationY[n]));
383 }
384 }
385
386 // // DEBUG CODE ===========================================================================================================
387 // string strOutFile = m_strOutPath;
388 // strOutFile += "00_sediment_input_line_CHECK_";
389 // strOutFile += to_string(m_ulIter);
390 // strOutFile += ".tif";
391 //
392 // GDALDriver* pDriver = GetGDALDriverManager()->GetDriverByName("gtiff");
393 // GDALDataset* pDataSet = pDriver->Create(strOutFile.c_str(), m_nXGridSize, m_nYGridSize, 1, GDT_Float64, m_papszGDALRasterOptions);
394 // pDataSet->SetProjection(m_strGDALBasementDEMProjection.c_str());
395 // pDataSet->SetGeoTransform(m_dGeoTransform);
396 //
397 // int nn = 0;
398 // double* pdRaster = new double[m_nXGridSize * m_nYGridSize];
399 // for (int nY = 0; nY < m_nYGridSize; nY++)
400 // {
401 // for (int nX = 0; nX < m_nXGridSize; nX++)
402 // {
403 // pdRaster[nn++] = 0;
404 // }
405 // }
406 //
407 // for (unsigned int n = 0; n < VnLineGridX.size() - 1; n++)
408 // {
409 // int nX = VnLineGridX[n];
410 // int nY = VnLineGridY[n];
411 // int m = (nY * m_nXGridSize) + nX;
412 //
413 // pdRaster[m] = 1;
414 // }
415 //
416 // GDALRasterBand* pBand = pDataSet->GetRasterBand(1);
417 // pBand->SetNoDataValue(m_dMissingValue);
418 // int nRet = pBand->RasterIO(GF_Write, 0, 0, m_nXGridSize, m_nYGridSize, pdRaster, m_nXGridSize, m_nYGridSize, GDT_Float64, 0, 0, NULL);
419 //
420 // if (nRet == CE_Failure)
421 // return RTN_ERR_GRIDCREATE;
422 //
423 // GDALClose(pDataSet);
424 // delete[] pdRaster;
425 // // DEBUG CODE ===========================================================================================================
426
427 // Should never get here
428 if (VnLineGridX.size() == 0)
430
432 LogStream << m_ulIter << ": Sediment input event " << nEvent << " at line/coast intersection for line with ID " << nLocID << endl;
433
434 // Now go along the line, joining each pair of points by a straight line
435 int nCoastX = -1;
436 int nCoastY = -1;
437
438 for (unsigned int n = 0; n < VnLineGridX.size() - 1; n++)
439 {
440 int nXStart = VnLineGridX[n];
441 int nXEnd = VnLineGridX[n + 1];
442 int nYStart = VnLineGridY[n];
443 int nYEnd = VnLineGridY[n + 1];
444
445 // 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
446 double dXInc = nXEnd - nXStart;
447 double dYInc = nYEnd - nYStart;
448 double dLength = tMax(tAbs(dXInc), tAbs(dYInc));
449
450 dXInc /= dLength;
451 dYInc /= dLength;
452
453 double dX = nXStart;
454 double dY = nYStart;
455
456 // Process each interpolated point
457 for (int m = 0; m <= nRound(dLength); m++)
458 {
459 int nX = nRound(dX);
460 int nY = nRound(dY);
461
462 // Have we hit a coastline cell?
463 if (bIsWithinValidGrid(nX, nY) && m_pRasterGrid->m_Cell[nX][nY].bIsCoastline())
464 {
465 nCoastX = nX;
466 nCoastY = nY;
467 break;
468 }
469
470 // 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)
471 if (bIsWithinValidGrid(nX, nY + 1) && m_pRasterGrid->m_Cell[nX][nY + 1].bIsCoastline())
472 {
473 nCoastX = nX;
474 nCoastY = nY + 1;
475 break;
476 }
477
478 // Increment for next time
479 dX += dXInc;
480 dY += dYInc;
481 }
482
483 // Did we find an intersection?
484 if (nCoastX != -1)
485 break;
486 }
487
488 // Did we find an intersection?
489 if (nCoastX == -1)
490 {
491 // Nope
493 LogStream << m_ulIter << ": No line/coast intersection found" << endl;
494
496 }
497
498 // OK we have an intersection of the line and coast. We will input the sediment here
500 LogStream << m_ulIter << ": line/coast intersection is at [" << nCoastX << "][" << nCoastY << "] = {" << dGridXToExtCRSX(nCoastX) << ", " << dGridYToExtCRSY(nCoastY) << "}" << endl;
501
502 // Get landform and top layer
503 CRWCellLandform* pLandform = m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLandform();
504 int nTopLayer = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetTopLayerAboveBasement();
505
506 // Is some fine unconsolidated sediment being input?
507 double dFineDepth = dFineSedVol / m_dCellArea;
508 if (dFineDepth > 0)
509 {
510 // Yes, so add to this cell's fine unconsolidated sediment
511 m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddFineSedimentInputDepth(dFineDepth);
512
513 // And update the sediment top elevation value
514 m_pRasterGrid->m_Cell[nCoastX][nCoastY].CalcAllLayerElevsAndD50();
515
516 int nThisPoly = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetPolygonID();
517 if (nThisPoly != INT_NODATA)
518 {
519 // Add to this polygon's fine sediment input total
520 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsFine(dFineDepth);
521 }
522
523 // Add to the this-iteration total of fine sediment input
524 m_dThisiterUnconsFineInput += dFineDepth;
525
526 // And assign the cell's landform
529 }
530
531 // Is some sand-sized unconsolidated sediment being input?
532 double dSandDepth = dSandSedVol / m_dCellArea;
533 if (dSandDepth > 0)
534 {
535 // Yes, so add to this cell's sand unconsolidated sediment
536 m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddSandSedimentInputDepth(dSandDepth);
537
538 // And update the sediment top elevation value
539 m_pRasterGrid->m_Cell[nCoastX][nCoastY].CalcAllLayerElevsAndD50();
540
541 int nThisPoly = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetPolygonID();
542 if (nThisPoly != INT_NODATA)
543 {
544 // Add to this polygon's sand sediment input total
545 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsSand(dSandDepth);
546 }
547
548 // Add to the this-iteration total of sand sediment input
549 m_dThisiterUnconsSandInput += dSandDepth;
550
551 // And assign the cell's landform
554 }
555
556 // Is some coarse unconsolidated sediment being input?
557 double dCoarseDepth = dCoarseSedVol / m_dCellArea;
558 if (dCoarseDepth > 0)
559 {
560 // Yes, so add to this cell's coarse unconsolidated sediment
561 m_pRasterGrid->m_Cell[nCoastX][nCoastY].pGetLayerAboveBasement(nTopLayer)->pGetUnconsolidatedSediment()->AddCoarseSedimentInputDepth(dCoarseDepth);
562
563 // And update the sediment top elevation value
564 m_pRasterGrid->m_Cell[nCoastX][nCoastY].CalcAllLayerElevsAndD50();
565
566 int nThisPoly = m_pRasterGrid->m_Cell[nCoastX][nCoastY].nGetPolygonID();
567 if (nThisPoly != INT_NODATA)
568 {
569 // Add to this polygon's coarse sediment input total
570 m_pVCoastPolygon[nThisPoly]->SetSedimentInputUnconsCoarse(dCoarseDepth);
571 }
572
573 // Add to the this-iteration total of coarse sediment input
574 m_dThisiterUnconsCoarseInput += dCoarseDepth;
575
576 // And assign the cell's landform
579 }
580
582 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;
583 }
584
585 return RTN_OK;
586}
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:530
bool m_bSedimentInputAtPoint
Do we have sediment inputat a point?
Definition simulation.h:371
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:377
double m_dThisiterUnconsCoarseInput
Depth (m) of coarse unconsolidated sediment added, at this iteration.
Definition simulation.h:928
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:922
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:374
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:616
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:553
double m_dThisiterUnconsSandInput
Depth (m) of sand unconsolidated sediment added, at this iteration.
Definition simulation.h:925
double m_dCellSide
Length of a cell side (in external CRS units)
Definition simulation.h:613
bool m_bSedimentInputThisIter
Do we have a sediment input event this iteration?
Definition simulation.h:383
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:362
int const LF_CAT_SEDIMENT_INPUT
Definition cme.h:424
int const LOG_FILE_MIDDLE_DETAIL
Definition cme.h:377
int const LF_SUBCAT_SEDIMENT_INPUT_UNCONSOLIDATED
Definition cme.h:449
T tMax(T a, T b)
Definition cme.h:1123
int const RTN_OK
Definition cme.h:577
int const RIGHT_HANDED
Definition cme.h:397
T tAbs(T a)
Definition cme.h:1148
int const RTN_ERR_SEDIMENT_INPUT_EVENT
Definition cme.h:642
int const LEFT_HANDED
Definition cme.h:398
Contains CRWCoast definitions.
Contains CSedInputEvent definitions.
int nRound(double const d)
Version of the above that returns an int.