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