CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
assign_landforms.cpp
Go to the documentation of this file.
1
10
11/* ===============================================================================================================================
12 This file is part of CoastalME, the Coastal Modelling Environment.
13
14 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.
15
16 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.
17
18 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.
19===============================================================================================================================*/
20#include <assert.h>
21
22#include <iostream>
23using std::endl;
24
25#ifdef _OPENMP
26#include <omp.h>
27#endif
28
29#include "cme.h"
30#include "simulation.h"
31#include "coast.h"
32#include "cliff.h"
33#include "drift.h"
34#include "intervention.h"
35#include "cell_layer.h"
36
37//===============================================================================================================================
39//===============================================================================================================================
41{
42 // For each coastline, put a coastal landform at every point along the coastline
43 for (int nCoast = 0; nCoast < static_cast<int>(m_VCoast.size()); nCoast++)
44 {
45 for (int nCoastPoint = 0; nCoastPoint < m_VCoast[nCoast].nGetCoastlineSize(); nCoastPoint++)
46 {
47 // Get the coords of the grid cell marked as coastline for the coastal landform object
48 int const nX = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint)->nGetX();
49 int const nY = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nCoastPoint)->nGetY();
50
51 // Store the coastline number and the number of the coastline point in the cell so we can get these quickly later
52 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetCoast(nCoast);
53 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetPointOnCoast(nCoastPoint);
54
55 // OK, start assigning coastal landforms. First, is there an intervention here?
56 if (bIsInterventionCell(nX, nY) || m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight() > 0)
57 {
58 // There is, so create an intervention object on the vector coastline with these attributes
59 int const nCat = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->nGetLFCategory();
60 CACoastLandform* pIntervention = new CRWIntervention(&m_VCoast[nCoast], nCoast, nCoastPoint, nCat);
61 m_VCoast[nCoast].AppendCoastLandform(pIntervention);
62
63#ifdef _DEBUG
64 LogStream << nCoastPoint << " [" << nX << "][" << nY << "] = {" << dGridCentroidXToExtCRSX(nX) << ", " << dGridCentroidYToExtCRSY(nY) << "} " << m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->nGetLFCategory() << " " << m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight() << endl;
65#endif
66 continue;
67 }
68
69 // OK the landform on this coast cell is something other than an intervention. First check for talus
70 int const nTopLayer = m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
71 CRWCellLayer* pTopLayer = m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer);
72
73 if (pTopLayer->bHasTalus())
74 {
75 // There is talus on this cell
76 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetLFCategory(LF_DRIFT_TALUS);
77
78 CACoastLandform* pDrift = new CRWDrift(&m_VCoast[nCoast], nCoast, nCoastPoint, LF_DRIFT_TALUS);
79 m_VCoast[nCoast].AppendCoastLandform(pDrift);
80
81 continue;
82 }
83
84 // Next, do some safety checks. Note that layer 0 is the first layer above basement
85 int const nLayer = m_pRasterGrid->m_Cell[nX][nY].nGetLayerAtElev(m_dThisIterSWL);
86 if (nLayer == ELEV_IN_BASEMENT)
87 {
88 // Should never happen
89 LogStream << m_ulIter << ": SWL (" << m_dThisIterSWL << ") is in basement on cell [" << nX << "][" << nY << "] = {" << dGridCentroidXToExtCRSX(nX) << ", " << dGridCentroidYToExtCRSY(nY) << "}, cannot assign coastal landform for coastline " << nCoast << endl;
90
92 }
93
94 if (nLayer == ELEV_ABOVE_SEDIMENT_TOP)
95 {
96 // Again, should never happen
97 LogStream << m_ulIter << ": SWL (" << m_dThisIterSWL << ") is above sediment-top elevation inc. any talus (" << m_pRasterGrid->m_Cell[nX][nY].dGetAllSedTopElevIncTalus() << ") on cell [" << nX << "][" << nY << "] = {" << dGridCentroidXToExtCRSX(nX) << ", " << dGridCentroidYToExtCRSY(nY) << "}, cannot assign coastal landform for coastline " << nCoast << endl;
98
100 }
101
102 // OK, now check what we have at SWL on this cell: is it unconsolidated or consolidated sediment?
103 double const dConsSedTop = m_pRasterGrid->m_Cell[nX][nY].dGetConsSedTopElevForLayerAboveBasement(nLayer);
104 if (dConsSedTop >= m_dThisIterSWL)
105 {
106 // We have consolidated sediment at or above SWL on this cell. Are we considering cliff collapse?
108 {
109 // OK we are considering cliff collapse, and we have consolidated sediment at SWL, so this is a cliff cell. Get the existing landform category for this cell
110 int const nCat = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->nGetLFCategory();
111 if ((nCat == LF_CLIFF_ON_COASTLINE) || (nCat == LF_CLIFF_INLAND))
112 {
113 // This cell was a cliff in some previous timestep. Is the pre-existing notch still below the top of the consolidated sediment?
114 double dNotchApexElev = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->dGetCliffNotchApexElev();
115 double const dSedTopElevNoTalus = m_pRasterGrid->m_Cell[nX][nY].dGetConsSedTopElevOmitTalus();
116 if (dNotchApexElev < dSedTopElevNoTalus)
117 {
118 // Yes, the notch is still below the top of the consolidated sediment, so get the pre-existing data stored in the cell
119 double const dAccumWaveEnergy = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->dGetAccumWaveEnergy();
120 double const dNotchIncision = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->dGetCliffNotchIncisionDepth();
121
122 // Set this as a cliff cell on the coastline
123 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetLFCategory(LF_CLIFF_ON_COASTLINE);
124
125 // Create a cliff object on the vector coastline with these attributes
126 CACoastLandform* pCliff = new CRWCliff(&m_VCoast[nCoast], nCoast, nCoastPoint, m_dCellSide, dNotchIncision, dNotchApexElev, dAccumWaveEnergy);
127 m_VCoast[nCoast].AppendCoastLandform(pCliff);
128
129#ifdef _DEBUG
130 double const dSedTopElevIncTalus = m_pRasterGrid->m_Cell[nX][nY].dGetAllSedTopElevIncTalus();
131
132 LogStream << m_ulIter << ": \tcontinues to be a cliff at [" << nX << "][" << nY << "] dAccumWaveEnergy = " << dAccumWaveEnergy << " dNotchApexElev = " << dNotchApexElev << " dSedTopElevNoTalus = " << dSedTopElevNoTalus << " dSedTopElevIncTalus = " << dSedTopElevIncTalus << " dNotchIncision = " << dNotchIncision << endl;
133#endif
134 }
135 else
136 {
137 // This was a cliff in the previous timestep, but the notch is no longer below the top of the consolidated sediment. Create a cliff object on the vector coastline without a notch
138 double const dAccumWaveEnergy = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->dGetAccumWaveEnergy();
139 double const dNotchIncision = DBL_NODATA;
140 dNotchApexElev = DBL_NODATA;
141
142 // This is a cliff cell on the coastline without a notch
143 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetLFCategory(LF_CLIFF_ON_COASTLINE);
144 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetCliffNotchApexElev(dNotchApexElev);
145 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetCliffNotchIncisionDepth(dNotchIncision);
146
147 // Create a cliff object on the vector coastline with these attributes
148 CACoastLandform* pCliff = new CRWCliff(&m_VCoast[nCoast], nCoast, nCoastPoint, m_dCellSide, dNotchIncision, dNotchApexElev, dAccumWaveEnergy);
149 m_VCoast[nCoast].AppendCoastLandform(pCliff);
150
151#ifdef _DEBUG
152 double const dSedTopElevIncTalus = m_pRasterGrid->m_Cell[nX][nY].dGetAllSedTopElevIncTalus();
153
154 LogStream << m_ulIter << ": \tPROBLEM cliff with notch above sediment top (inc any talus) at [" << nX << "][" << nY << "] dAccumWaveEnergy = " << dAccumWaveEnergy << " dNotchApexElev = " << dNotchApexElev << " dSedTopElevNoTalus = " << dSedTopElevNoTalus << " dSedTopElevIncTalus = " << dSedTopElevIncTalus << " dNotchIncision = " << dNotchIncision << endl;
155#endif
156 }
157 }
158 else
159 {
160 // This was not a cliff in the previous timestep, but it is now
161 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetLFCategory(LF_CLIFF_ON_COASTLINE);
162
163 // Get the pre-existing wave energy stored in the cell
164 double const dAccumWaveEnergy = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->dGetAccumWaveEnergy();
165
166 // The DBL_NODATA Values indicate that the cliff object does not have an incised notch
167 double dNotchIncision = DBL_NODATA;
168 double dNotchApexElev = DBL_NODATA;
169
170 // Would the new notch apex elevation be below the top of the cell's consolidated sediment?
171 double const dSedTopElevNoTalus = m_pRasterGrid->m_Cell[nX][nY].dGetConsSedTopElevOmitTalus();
172 if (m_dThisIterNewNotchApexElev < dSedTopElevNoTalus)
173 {
174 // Yes it would, so this cliff object has a notch
175 dNotchIncision = 0;
177 }
178
179 // Create a cliff object on the vector coastline with these attributes
180 CACoastLandform* pCliff = new CRWCliff(&m_VCoast[nCoast], nCoast, nCoastPoint, m_dCellSide, dNotchIncision, dNotchApexElev, dAccumWaveEnergy);
181 m_VCoast[nCoast].AppendCoastLandform(pCliff);
182
183#ifdef _DEBUG
184 double const dSedTopElevIncTalus = m_pRasterGrid->m_Cell[nX][nY].dGetAllSedTopElevIncTalus();
185
186 if (bFPIsEqual(dNotchIncision, 0.0, TOLERANCE))
187 LogStream << m_ulIter << ": \tcliff created at [" << nX << "][" << nY << "] dAccumWaveEnergy = " << dAccumWaveEnergy << " dNotchApexElev = " << dNotchApexElev << " dSedTopElevNoTalus = " << dSedTopElevNoTalus << " dSedTopElevIncTalus = " << dSedTopElevIncTalus << " dNotchIncision = " << dNotchIncision << endl;
188 else
189 LogStream << m_ulIter << ": \tNO NOTCH cliff created at [" << nX << "][" << nY << "] dAccumWaveEnergy = " << dAccumWaveEnergy << " dSedTopElevNoTalus = " << dSedTopElevNoTalus << " dSedTopElevIncTalus = " << dSedTopElevIncTalus << endl;
190#endif
191 }
192 }
193 else
194 {
195 // We have consolidated sediment at SWL but we are not considering cliff collapse. Get the pre-existing wave energy stored in the cell
196 double const dAccumWaveEnergy = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->dGetAccumWaveEnergy();
197
198 // Create a cliff object on the vector coastline
199 CACoastLandform* pCliff = new CRWCliff(&m_VCoast[nCoast], nCoast, nCoastPoint, m_dCellSide, DBL_NODATA, DBL_NODATA, dAccumWaveEnergy);
200 m_VCoast[nCoast].AppendCoastLandform(pCliff);
201
202#ifdef _DEBUG
203 LogStream << m_ulIter << ": \tcliff created (cliff collapse not considered) at " << nX << "][" << nY << "] dAccumWaveEnergy = " << dAccumWaveEnergy << " dAllSedTopElevNoTalus = " << m_pRasterGrid->m_Cell[nX][nY].dGetAllSedTopElevOmitTalus() << " dAllSedTopElevIncTalus = " << m_pRasterGrid->m_Cell[nX][nY].dGetAllSedTopElevIncTalus() << " dConsSedTopElevNoTalus = " << m_pRasterGrid->m_Cell[nX][nY].dGetConsSedTopElevOmitTalus() << " dConsSedTopElevIncTalus = " << m_pRasterGrid->m_Cell[nX][nY].dGetConsSedTopElevIncTalus() << endl;
204#endif
205 }
206 }
207 else
208 {
209 // We have unconsolidated sediment at SWL, so this is a drift cell: create a drift object on the vector coastline with these attributes
210 CACoastLandform* pDrift = new CRWDrift(&m_VCoast[nCoast], nCoast, nCoastPoint, LF_DRIFT_BEACH);
211 m_VCoast[nCoast].AppendCoastLandform(pDrift);
212
213 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetLFCategory(LF_DRIFT_BEACH);
214
215// #ifdef _DEBUG
216// LogStream << m_ulIter << ": \tdrift created at [" << nX << "][" << nY << "]" << endl;
217// #endif
218 }
219 }
220 }
221
222 // // DEBUG CODE ============================================================================================================================================
223 // for (int i = 0; i < static_cast<int>(m_VCoast.size()); i++)
224 // {
225 // for (int j = 0; j < m_VCoast[i].nGetCoastlineSize(); j++)
226 // {
227 // int nX = m_VCoast[i].pPtiGetCellMarkedAsCoastline(j)->nGetX();
228 // int nY = m_VCoast[i].pPtiGetCellMarkedAsCoastline(j)->nGetY();
229 //
230 // LogStream << m_ulIter << ": coast cell " << j << " at [" << nX << "][" << nY << "] = {" << dGridCentroidXToExtCRSX(nX) << ", " << dGridCentroidYToExtCRSY(nY) << "} has landform category = ";
231 //
232 // int nCat = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->nGetLFCategory();
233 // int nSubCat = m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->nGetLFSubCategory();
234 //
235 // switch (nCat)
236 // {
237 // case LF_HINTERLAND:
238 // LogStream << "hinterland";
239 // break;
240 //
241 // case LF_SEA:
242 // LogStream << "sea";
243 // break;
244 //
245 // case LF_CLIFF:
246 // LogStream << "cliff";
247 // break;
248 //
249 // case LF_DRIFT:
250 // LogStream << "drift";
251 // break;
252 //
253 // case LF_INTERVENTION:
254 // LogStream << "intervention";
255 // break;
256 //
257 // case LF_UNKNOWN:
258 // LogStream << "none";
259 // break;
260 //
261 // default:
262 // LogStream << "NONE";
263 // break;
264 // }
265 //
266 // LogStream << " and landform subcategory = ";
267 //
268 // switch (nSubCat)
269 // {
270 // case LF_CLIFF_ON_COASTLINE:
271 // LogStream << "cliff on coastline";
272 // break;
273 //
274 // case LF_CLIFF_INLAND:
275 // LogStream << "cliff inland";
276 // break;
277 //
278 // case LF_DRIFT_TALUS:
279 // LogStream << "talus";
280 // break;
281 //
282 // case LF_DRIFT_BEACH:
283 // LogStream << "beach";
284 // break;
285 //
286 // case LF_DRIFT_DUNES:
287 // LogStream << "dunes";
288 // break;
289 //
290 // case LF_INTERVENTION_STRUCT:
291 // LogStream << "structural intervention";
292 // break;
293 //
294 // case LF_INTERVENTION_NON_STRUCT:
295 // LogStream << "non-structural intervention";
296 // break;
297 //
298 // case LF_UNKNOWN:
299 // LogStream << "none";
300 // break;
301 //
302 // default:
303 // LogStream << "NONE";
304 // break;
305 // }
306 // LogStream << endl;
307 // }
308 // }
309 // // DEBUG CODE ============================================================================================================================================
310
311 return RTN_OK;
312}
313
314//===============================================================================================================================
316//===============================================================================================================================
317int CSimulation::nLandformToGrid(int const nCoast, int const nPoint)
318{
319 // What is the coastal landform here?
320 CACoastLandform* pCoastLandform = m_VCoast[nCoast].pGetCoastLandform(nPoint);
321 int const nCat = pCoastLandform->nGetLandFormCategory();
322 if ((nCat == LF_CLIFF_ON_COASTLINE) || (nCat == LF_CLIFF_INLAND))
323 {
324 // It's a cliff
325 CRWCliff const* pCliff = reinterpret_cast<CRWCliff*>(pCoastLandform);
326
327 int const nX = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nPoint)->nGetX();
328 int const nY = m_VCoast[nCoast].pPtiGetCellMarkedAsCoastline(nPoint)->nGetY();
329
330 // if (! pCliff->bHasCollapsed())
331 // {
332 // // The cliff has not collapsed. Get attribute values from the cliff object
333 // double const dNotchBaseElev = pCliff->dGetNotchApexElev();
334 // double const dNotchIncision = pCliff->dGetNotchIncision();
335 //
336 // // And store some attribute values in the cliff cell
337 // m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetLFSubCategory(LF_CLIFF_ON_COASTLINE);
338 // m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetCliffNotchApexElev(dNotchBaseElev);
339 // m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetCliffNotchIncisionDepth(dNotchIncision);
340 // }
341 // else
342 // {
343 // // // The cliff has collapsed: all sediment above the base of the erosional notch is gone from this cliff object via cliff collapse, so this cell is no longer a cliff
344 // // m_pRasterGrid->m_Cell[nX][nY].SetInContiguousSea();
345 // //
346 // // // Check the x-y extremities of the contiguous sea for the bounding box (used later in wave propagation)
347 // // if (nX < m_nXMinBoundingBox)
348 // // m_nXMinBoundingBox = nX;
349 // //
350 // // if (nX > m_nXMaxBoundingBox)
351 // // m_nXMaxBoundingBox = nX;
352 // //
353 // // if (nY < m_nYMinBoundingBox)
354 // // m_nYMinBoundingBox = nY;
355 // //
356 // // if (nY > m_nYMaxBoundingBox)
357 // // m_nYMaxBoundingBox = nY;
358 //
359 // int const nTopLayer = m_pRasterGrid->m_Cell[nX][nY].nGetNumOfTopLayerAboveBasement();
360 //
361 // // Safety check
362 // if (nTopLayer == INT_NODATA)
363 // return RTN_ERR_NO_TOP_LAYER;
364 //
365 // // Update the cell's layer elevations
366 // m_pRasterGrid->m_Cell[nX][nY].CalcAllLayerElevsAndD50();
367 //
368 // // And update the cell's sea depth
369 // m_pRasterGrid->m_Cell[nX][nY].SetSeaDepth();
370 // }
371
372 // Always accumulate wave energy
373 m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->SetAccumWaveEnergy(pCliff->dGetTotAccumWaveEnergy());
374 }
375 // else if (nCat == LF_DRIFT)
376 // {
377 // // It's drift, so calculate D50 TODO 002 Why might we need this?
378 // }
379
380 return RTN_OK;
381}
382
383//===============================================================================================================================
385//===============================================================================================================================
387{
388 // First pass: collect information about cells that need to be changed. This avoids race conditions from reading neighbour cells while writing to current cells
389 vector<vector<int>> vCellUpdates(m_nXGridSize, vector<int>(m_nYGridSize, -1));
390
391 // Read-only phase: determine what changes need to be made
392#ifdef _OPENMP
393#pragma omp parallel for collapse(2)
394#endif
395
396 for (int nX = 0; nX < m_nXGridSize; nX++)
397 {
398 for (int nY = 0; nY < m_nYGridSize; nY++)
399 {
400 // Get this cell's landform category
401 CRWCellLandform const* pLandform = m_pRasterGrid->m_Cell[nX][nY].pGetLandform();
402 int const nCat = pLandform->nGetLFCategory();
403
404 // Store what action to take (to avoid writing during read phase)
405 int nAction = -1; // -1 = no change, others defined below
406
407 if (m_pRasterGrid->m_Cell[nX][nY].bBasementElevIsMissingValue())
408 {
409 // Down to basement
410 nAction = 0; // Set to unknown landform
411
412 vCellUpdates[nX][nY] = nAction;
413 continue;
414 }
415
416 if (nCat == LF_SEA)
417 {
418 // This is a sea cell. Is it surrounded by drift cells, or drift and cliff?
419 if (bSurroundedByDriftCells(nX, nY))
420 nAction = 1; // Set to beach
421 else if (m_pRasterGrid->m_Cell[nX][nY].dGetAllSedTopElevOmitTalus() > m_dThisIterSWL)
422 nAction = 2; // Set to island
423 // else keep as sea (no action needed)
424
425 vCellUpdates[nX][nY] = nAction;
426 continue;
427 }
428
429 if (nCat == LF_CLIFF_ON_COASTLINE)
430 {
431 nAction = 3; // Set to cliff inland
432
433 vCellUpdates[nX][nY] = nAction;
434 continue;
435 }
436
437 int const nTopLayer = m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
438 CRWCellLayer* pTopLayer = m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nTopLayer);
439
440 if (pTopLayer->bHasTalus())
441 {
442 // There is talus here
443 nAction = 4; // Set to talus
444
445 vCellUpdates[nX][nY] = nAction;
446 continue;
447 }
448
449 if (pTopLayer->bHasUncons())
450 {
451 // This is unconsolidated sediment here TODO improve this
452 nAction = 5; // Set to beach
453
454 vCellUpdates[nX][nY] = nAction;
455 continue;
456
457 }
458
459 nAction = 6; // Set to hinterland
460
461 vCellUpdates[nX][nY] = nAction;
462 }
463 }
464
465 // Write phase: apply the changes
466 for (int nX = 0; nX < m_nXGridSize; nX++)
467 {
468 for (int nY = 0; nY < m_nYGridSize; nY++)
469 {
470 int const nAction = vCellUpdates[nX][nY];
471
472 if (nAction == -1)
473 continue; // No change
474
475 CRWCellLandform* pLandform = m_pRasterGrid->m_Cell[nX][nY].pGetLandform();
476
477 switch (nAction)
478 {
479 case 0: // Set to unknown landform
480 pLandform->SetLFCategory(LF_UNKNOWN);
481 break;
482
483 case 1: // Set to beach
484 pLandform->SetLFCategory(LF_DRIFT_BEACH);
485 break;
486
487 case 2: // Set to island
488 pLandform->SetLFCategory(LF_ISLAND);
489 break;
490
491 case 3: // Set to cliff inland
492 pLandform->SetLFCategory(LF_CLIFF_INLAND);
493 break;
494
495 case 4: // Set to talus
496 pLandform->SetLFCategory(LF_DRIFT_TALUS);
497 break;
498
499 case 5: // Set to beach
500 pLandform->SetLFCategory(LF_DRIFT_BEACH);
501 break;
502
503 case 6: // Set to hinterland
504 pLandform->SetLFCategory(LF_HINTERLAND);
505 break;
506 }
507 }
508 }
509
510 return RTN_OK;
511}
512//===============================================================================================================================
514//===============================================================================================================================
515bool CSimulation::bSurroundedByDriftCells(int const nX, int const nY)
516{
517 int nXTmp;
518 int nYTmp;
519 int nAdjacent = 0;
520
521 // North
522 nXTmp = nX;
523 nYTmp = nY - 1;
524
525 if (bIsWithinValidGrid(nXTmp, nYTmp))
526 {
527 CRWCellLandform const* pLandform = m_pRasterGrid->m_Cell[nXTmp][nYTmp].pGetLandform();
528 int const nCat = pLandform->nGetLFCategory();
529
530 if ((nCat == LF_DRIFT_BEACH) || (nCat == LF_DRIFT_TALUS) || (nCat == LF_DRIFT_DUNES) || (nCat == LF_CLIFF_INLAND) || (nCat == LF_CLIFF_ON_COASTLINE))
531 nAdjacent++;
532 }
533
534 // East
535 nXTmp = nX + 1;
536 nYTmp = nY;
537
538 if (bIsWithinValidGrid(nXTmp, nYTmp))
539 {
540 CRWCellLandform const* pLandform = m_pRasterGrid->m_Cell[nXTmp][nYTmp].pGetLandform();
541 int const nCat = pLandform->nGetLFCategory();
542
543 if ((nCat == LF_DRIFT_BEACH) || (nCat == LF_DRIFT_TALUS) || (nCat == LF_DRIFT_DUNES) || (nCat == LF_CLIFF_INLAND) || (nCat == LF_CLIFF_ON_COASTLINE))
544 nAdjacent++;
545 }
546
547 // South
548 nXTmp = nX;
549 nYTmp = nY + 1;
550
551 if (bIsWithinValidGrid(nXTmp, nYTmp))
552 {
553 CRWCellLandform const* pLandform = m_pRasterGrid->m_Cell[nXTmp][nYTmp].pGetLandform();
554 int const nCat = pLandform->nGetLFCategory();
555
556 if ((nCat == LF_DRIFT_BEACH) || (nCat == LF_DRIFT_TALUS) || (nCat == LF_DRIFT_DUNES) || (nCat == LF_CLIFF_INLAND) || (nCat == LF_CLIFF_ON_COASTLINE))
557 nAdjacent++;
558 }
559
560 // West
561 nXTmp = nX - 1;
562 nYTmp = nY;
563
564 if (bIsWithinValidGrid(nXTmp, nYTmp))
565 {
566 CRWCellLandform const* pLandform = m_pRasterGrid->m_Cell[nXTmp][nYTmp].pGetLandform();
567 int const nCat = pLandform->nGetLFCategory();
568
569 if ((nCat == LF_DRIFT_BEACH) || (nCat == LF_DRIFT_TALUS) || (nCat == LF_DRIFT_DUNES) || (nCat == LF_CLIFF_INLAND) || (nCat == LF_CLIFF_ON_COASTLINE))
570 nAdjacent++;
571 }
572
573 if (nAdjacent == 4)
574 {
575 // This cell has four LF_DRIFT neighbours
576 return true;
577 }
578
579 return false;
580}
Contains CRWCellLayer definitions.
Abstract class, used as a base class for landform objects on the coastline.
double dGetTotAccumWaveEnergy(void) const
Get total accumulated wave energy.
int nGetLandFormCategory(void) const
Get the landform category.
Real-world class used to represent the landform of a cell.
int nGetLFCategory(void) const
Get the landform category.
void SetLFCategory(int const)
Set the landform category.
Real-world class used to represent the sediment layers associated with a cell object.
Definition cell_layer.h:28
bool bHasTalus(void)
Returns true if the layer has talus, false otherwise.
bool bHasUncons(void)
Return true if the layer has unconsolidated sediment, false otherwise.
Real-world class used to represent the 'cliff' category of coastal landform object.
Definition cliff.h:28
Real-world class used to represent the 'drift' category of coastal landform object.
Definition drift.h:28
Real-world class used to represent the 'intervention' category of coastal landform objects.
double m_dThisIterSWL
The still water level for this timestep (this includes tidal changes and any long-term SWL change)
Definition simulation.h:726
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
int m_nXGridSize
The size of the grid in the x direction.
Definition simulation.h:477
int nAssignLandformsForAllCoasts(void)
Each timestep, classify coastal landforms and assign a coastal landform object to every point on ever...
ofstream LogStream
vector< CRWCoast > m_VCoast
The coastline objects.
int m_nYGridSize
The size of the grid in the y direction.
Definition simulation.h:480
double m_dThisIterNewNotchApexElev
Elevation (m) of the apex of any cliff notches created during this iteration.
Definition simulation.h:930
double dGridCentroidYToExtCRSY(int const) const
Given the integer Y-axis ordinate of a cell in the raster grid CRS, returns the external CRS Y-axis o...
Definition gis_utils.cpp:74
int nAssignLandformsForAllCells(void)
Each timestep, classify landforms for cells that are not on the coastline.
bool bSurroundedByDriftCells(int const, int const)
Returns true if this cell has four drift cells surrounding it.
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,...
unsigned long m_ulIter
The number of the current iteration (time step)
Definition simulation.h:609
double dGridCentroidXToExtCRSX(int const) const
Given the integer X-axis ordinate of a cell in the raster grid CRS, returns the external CRS X-axis o...
Definition gis_utils.cpp:65
double m_dCellSide
Length of a cell side (in external CRS units)
Definition simulation.h:672
bool bIsInterventionCell(int const, int const) const
Returns true if the cell is an intervention.
Definition utils.cpp:3066
bool m_bDoCliffCollapse
Simulate cliff collapse?
Definition simulation.h:366
int nLandformToGrid(int const, int const)
At the end of each timestep, this routine stores the attributes from a single coastal landform object...
Contains CRWCliff definitions.
This file contains global definitions for CoastalME.
double const TOLERANCE
Definition cme.h:725
int const LF_SEA
Definition cme.h:436
int const ELEV_ABOVE_SEDIMENT_TOP
Definition cme.h:671
int const LF_DRIFT_TALUS
Definition cme.h:439
int const LF_UNKNOWN
Definition cme.h:434
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
Definition cme.h:1213
int const LF_CLIFF_INLAND
Definition cme.h:438
int const LF_HINTERLAND
Definition cme.h:435
int const LF_DRIFT_DUNES
Definition cme.h:441
int const LF_ISLAND
Definition cme.h:444
int const RTN_OK
Definition cme.h:585
int const LF_CLIFF_ON_COASTLINE
Definition cme.h:437
double const DBL_NODATA
Definition cme.h:736
int const RTN_ERR_CANNOT_ASSIGN_COASTAL_LANDFORM
Definition cme.h:633
int const ELEV_IN_BASEMENT
Definition cme.h:670
int const LF_DRIFT_BEACH
Definition cme.h:440
double const SED_ELEV_TOLERANCE
Definition cme.h:726
Contains CRWCoast definitions.
Contains CRWDrift definitions.
Contains CRWIntervention definitions.
Contains CSimulation definitions.