CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
simulation.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 <assert.h>
25
26#include <ios>
27using std::fixed;
28
29#include <iostream>
30using std::cerr;
31using std::cout;
32using std::cin;
33using std::endl;
34using std::ios;
35
36#include <iomanip>
37using std::setprecision;
38
39#include <cfloat>
40
41#include <string>
42using std::to_string;
43
44#include <filesystem> // C++17 and later, needed for missing output directory creation
45using std::filesystem::is_directory;
46using std::filesystem::exists;
47using std::filesystem::create_directories;
48
49#include <random>
50using std::random_device;
51
52#include "cme.h"
53#include "simulation.h"
54#include "raster_grid.h"
55#include "coast.h"
56
57//===============================================================================================================================
59//===============================================================================================================================
61{
62 // Initialization
180
181 m_bGDALCanCreate = true;
182
185
186 m_nLayers =
194 m_nGISSave =
195 m_nUSave =
201 // m_nNThisIterCliffCollapse =
202 // m_nNTotCliffCollapse =
216 m_nLevel =
218
219 // TODO 011 May wish to make this a user-supplied value
221
222 m_nXMinBoundingBox = INT_MAX;
223 m_nXMaxBoundingBox = INT_MIN;
224 m_nYMinBoundingBox = INT_MAX;
225 m_nYMaxBoundingBox = INT_MIN;
226
227 // cppcheck-suppress useInitializationList
228 m_GDALWriteIntDataType = GDT_Unknown;
229 // cppcheck-suppress useInitializationList
230 m_GDALWriteFloatDataType = GDT_Unknown;
231
234
235 m_ulIter =
248
249 for (int i = 0; i < NRNG; i++)
250 m_ulRandSeed[i] = 0;
251
252 for (int i = 0; i < SAVEMAX; i++)
253 m_dUSaveTime[i] = 0;
254
271 m_dClkLast =
276 m_dOrigSWL =
280 m_dC_0 =
281 m_dL_0 =
288 m_dR =
289 m_dD50Fine =
290 m_dD50Sand =
300 m_dKLS =
302 m_dG =
378
379 m_dMinSWL = DBL_MAX;
380 m_dMaxSWL = DBL_MIN;
381
382 for (int i = 0; i < 6; i++)
383 m_dGeoTransform[i] = 0;
384
385 // TODO 011 May wish to make this a user-supplied value
387
419
421 m_tSysEndTime = 0;
422
423 m_pRasterGrid = NULL;
424}
425
426//===============================================================================================================================
428//===============================================================================================================================
430{
431 // Close output files if open
432 if (LogStream && LogStream.is_open())
433 {
434 LogStream.flush();
435 LogStream.close();
436 }
437
438 if (OutStream && OutStream.is_open())
439 {
440 OutStream.flush();
441 OutStream.close();
442 }
443
444 if (SeaAreaTSStream && SeaAreaTSStream.is_open())
445 {
446 SeaAreaTSStream.flush();
447 SeaAreaTSStream.close();
448 }
449
451 {
454 }
455
457 {
460 }
461
463 {
466 }
467
469 {
472 }
473
475 {
478 }
479
481 {
484 }
485
487 {
490 }
491
493 {
496 }
497
498 if (m_pRasterGrid)
499 delete m_pRasterGrid;
500}
501
502//===============================================================================================================================
504//===============================================================================================================================
506{
507 return m_dMissingValue;
508}
509
510//===============================================================================================================================
512//===============================================================================================================================
514{
515 return m_dThisIterSWL;
516}
517
518//===============================================================================================================================
520//===============================================================================================================================
525
526// //===============================================================================================================================
527// //! Returns the max elevation of the beach above SWL
528// //===============================================================================================================================
529// double CSimulation::dGetMaxBeachElevAboveSWL (void) const
530// {
531// return m_dMaxBeachElevAboveSWL;
532// }
533
534//===============================================================================================================================
535// Returns the cell side length
536//===============================================================================================================================
537// double CSimulation::dGetCellSide(void) const
538// {
539// return m_dCellSide;
540// }
541
542//===============================================================================================================================
544//===============================================================================================================================
546{
547 return m_nXGridSize;
548}
549
550//===============================================================================================================================
552//===============================================================================================================================
554{
555 return m_nYGridSize;
556}
557
558//===============================================================================================================================
560//===============================================================================================================================
561double CSimulation::dGetD50Fine (void) const
562{
563 return m_dD50Fine;
564}
565
566//===============================================================================================================================
568//===============================================================================================================================
569double CSimulation::dGetD50Sand (void) const
570{
571 return m_dD50Sand;
572}
573
574//===============================================================================================================================
576//===============================================================================================================================
577double CSimulation::dGetD50Coarse (void) const
578{
579 return m_dD50Coarse;
580}
581
582//===============================================================================================================================
584//===============================================================================================================================
585int CSimulation::nDoSimulation(int nArg, char const* pcArgv[])
586{
587 // ================================================== initialization section ================================================
588 // Hello, World!
590
591 // Start the clock ticking
592 StartClock();
593
594 // Deal with command-line parameters
595 int nRet = nHandleCommandLineParams(nArg, pcArgv);
596 if (nRet != RTN_OK)
597 return (nRet);
598
599 // Find out the folder in which the CoastalME executable sits, in order to open the .ini file (they are assumed to be in the same folder)
600 if (! bFindExeDir(pcArgv[0]))
601 return (RTN_ERR_CMEDIR);
602
603 // OK, we are off, tell the user about the licence and the start time
605
606 // Read the .ini file and get the name of the run-data file, and path for output etc.
607 if (! bReadIniFile())
608 return (RTN_ERR_INI);
609
610 // Check if output dir exists
611 if ((! is_directory(m_strOutPath.c_str())) || (! exists(m_strOutPath.c_str())))
612 {
613 // Output dir does not exist
614 bool bCreateDir = false;
615 if ((isatty(fileno(stdout))) && (isatty(fileno(stderr))))
616 {
617 // Running with stdout and stderr as a tty, so ask the user if they wish to create it
618 char ch;
619 cerr << endl << "Output folder '" << m_strOutPath << "' does not exist. Create it? (Y/N) ";
620 cerr.flush();
621 cin.get(ch);
622
623 if ((ch == 'y') || (ch == 'Y'))
624 bCreateDir = true;
625 }
626 else
627 {
628 // Running with stdout or stderr not a tty, so create output dir rather than abort
629 bCreateDir = true;
630 }
631
632 if (bCreateDir)
633 {
634 // Yes, so create the directory
635 create_directories(m_strOutPath.c_str());
636 cerr << m_strOutPath << " created" << endl << endl;
637 }
638 else
639 // Nope, just end the run
640 return RTN_USER_ABORT;
641 }
642
643 // We have the name of the run-data input file, so read it
644 if (! bReadRunDataFile())
645 return RTN_ERR_RUNDATA;
646
647 // Check raster GIS output format
650
651 // Check vector GIS output format
654
655 // Open log file
656 if (! bOpenLogFile())
657 return (RTN_ERR_LOGFILE);
658
659 // Set up the time series output files
660 if (! bSetUpTSFiles())
661 return (RTN_ERR_TSFILE);
662
663 // Initialize the random number generators
664 for (int n = 0; n < NRNG; n++)
665 m_Rand[n].seed(m_ulRandSeed[n]);
666
667 // If we are doing Savitzky-Golay smoothing of the vector coastline(s), calculate the filter coefficients
670
671 // Create the raster grid object
672 m_pRasterGrid = new CGeomRasterGrid(this);
673
674 // Read in the basement layer (must have this file), create the raster grid, then read in the basement DEM data to the array
676 nRet = nReadRasterBasementDEM();
677 if (nRet != RTN_OK)
678 return nRet;
679
680 // If we are simulating cliff collapse: then now that we have a value for m_dCellSide, we can check some more input parameters. Talus must be more than one cell wide, and since the number of cells must be odd, three cells is the minimum width
682 {
684 if (nTmp < 3)
685 {
686 string strErr = ERR + "cliff deposition must have a planview width of at least three cells. The current setting of " + to_string(m_dCliffDepositionPlanviewWidth) + " m gives a planview width of " + to_string(nTmp) + " cells. Please edit " + m_strDataPathName;
687 cerr << strErr << endl;
688 LogStream << strErr << endl;
689 OutStream << strErr << endl;
690 return RTN_ERR_RUNDATA;
691 }
692 }
693
694 // Do some more initialisation
695 // cppcheck-suppress truncLongCastAssignment
697
698 // Mark edge cells, as defined by the basement layer
700 if (nRet != RTN_OK)
701 return nRet;
702
703 // // DEBUG CODE =================================================================================================================
704 // for (int n = 0; n < m_VEdgeCell.size(); n++)
705 // {
706 // LogStream << "[" << m_VEdgeCell[n].nGetX() << "][" << m_VEdgeCell[n].nGetY() << "] = {" << dGridCentroidXToExtCRSX(m_VEdgeCell[n].nGetX()) << ", " << dGridCentroidYToExtCRSY(m_VEdgeCell[n].nGetY()) << "} " << m_VEdgeCellEdge[n] << endl;
707 // }
708 // // DEBUG CODE =================================================================================================================
709
710 // If we are using the default cell spacing, then now that we know the size of the raster cells, we can set the size of profile spacing in m
713 else
714 {
715 // The user specified a profile spacing, is this too small?
717
719 {
720 cerr << ERR << "profile spacing was specified as " << m_dCoastNormalAvgSpacing << " m, which is " << m_nCoastNormalAvgSpacing << " cells. Polygon creation works poorly if profile spacing is less than " << MIN_PROFILE_SPACING << " cells, i.e. " << MIN_PROFILE_SPACING *m_dCellSide << " m" << endl;
721
722 LogStream << ERR << "profile spacing was specified as " << m_dCoastNormalAvgSpacing << " m, which is " << m_nCoastNormalAvgSpacing << " cells. Polygon creation works poorly if profile spacing is less than " << MIN_PROFILE_SPACING << " cells, i.e. " << MIN_PROFILE_SPACING *m_dCellSide << " m" << endl;
723
725 }
726 }
727
728 // We have at least one filename for the first layer, so add the correct number of layers. Note the the number of layers does not change during the simulation: however layers can decrease in thickness until they have zero thickness
730
731 for (int nX = 0; nX < m_nXGridSize; nX++)
732 for (int nY = 0; nY < m_nYGridSize; nY++)
733 m_pRasterGrid->m_Cell[nX][nY].AppendLayers (m_nLayers);
734
735 // Tell the user what is happening then read in the layer files
737
738 for (int nLayer = 0; nLayer < m_nLayers; nLayer++)
739 {
740 // Read in the initial fine unconsolidated sediment depth file(s)
743 if (nRet != RTN_OK)
744 return (nRet);
745
746 // Read in the initial sand unconsolidated sediment depth file
749 if (nRet != RTN_OK)
750 return (nRet);
751
752 // Read in the initial coarse unconsolidated sediment depth file
755 if (nRet != RTN_OK)
756 return (nRet);
757
758 // Read in the initial fine consolidated sediment depth file
760 nRet = nReadRasterGISFile(FINE_CONS_RASTER, nLayer);
761 if (nRet != RTN_OK)
762 return (nRet);
763
764 // Read in the initial sand consolidated sediment depth file
766 nRet = nReadRasterGISFile(SAND_CONS_RASTER, nLayer);
767 if (nRet != RTN_OK)
768 return (nRet);
769
770 // Read in the initial coarse consolidated sediment depth file
773 if (nRet != RTN_OK)
774 return (nRet);
775 }
776
777 // Read in the initial suspended sediment depth file
780 if (nRet != RTN_OK)
781 return (nRet);
782
783 // Maybe read in the landform class data, otherwise calculate this during the first timestep using identification rules
784 if (! m_strInitialLandformFile.empty())
785 {
788 if (nRet != RTN_OK)
789 return (nRet);
790 }
791
792 // Maybe read in intervention data
793 if (! m_strInterventionClassFile.empty())
794 {
797 if (nRet != RTN_OK)
798 return (nRet);
799
802 if (nRet != RTN_OK)
803 return (nRet);
804 }
805
806 // Maybe read in the tide data
807 if (! m_strTideDataFile.empty())
808 {
810 nRet = nReadTideDataFile();
811 if (nRet != RTN_OK)
812 return (nRet);
813 }
814
815 // Read in the erosion potential shape function data
817 nRet = nReadShapeFunctionFile();
818 if (nRet != RTN_OK)
819 return (nRet);
820
821 // Do we want to output the erosion potential look-up values, for checking purposes?
824
825 // OK, now read in the vector files (if any)
828
829 // Maybe read in deep water wave station data
831 {
832 // We are reading deep water wave height, orientation and period from a file of vector points and file time series
834
835 // Read in vector points
837 if (nRet != RTN_OK)
838 return (nRet);
839
840 int nWaveStations = static_cast<int> (m_VnDeepWaterWaveStationID.size());
841
842 if (nWaveStations == 1)
844
845 // Read in time series values, and initialize the vector which stores each timestep's deep water wave height, orientation and period
846 nRet = nReadWaveStationInputFile (nWaveStations);
847 if (nRet != RTN_OK)
848 return (nRet);
849 }
850
851 // Maybe read in sediment input event data
853 {
854 // We are reading sediment input event data
856
857 // Read in vector points for sediment input events
859 if (nRet != RTN_OK)
860 return (nRet);
861
862 // Read in the time series values for sediment input events
864 if (nRet != RTN_OK)
865 return (nRet);
866 }
867
868 // Maybe read in flood input location
870 {
871 // We are reading sediment input event data
873
874 // Read in vector points for sediment input events
876 if (nRet != RTN_OK)
877 return (nRet);
878 }
879
880 // Open the main output
881 OutStream.open (m_strOutFile.c_str(), ios::out | ios::trunc);
882
883 if (! OutStream)
884 {
885 // Error, cannot open Out file
886 cerr << ERR << "cannot open " << m_strOutFile << " for output" << endl;
887 return (RTN_ERR_OUTFILE);
888 }
889
890 // Write beginning-of-run information to Out and Log files
892
893 // Start initializing
895
896 // Misc initialization calcs
897 m_nCoastMax = COAST_LENGTH_MAX * tMax(m_nXGridSize, m_nYGridSize); // Arbitrary but probably OK
898 m_nCoastMin = tMin(m_nXGridSize, m_nYGridSize); // In some cases the following rule doesn't work TODO 007 Info needed
899 // nRound(COAST_LENGTH_MIN_X_PROF_SPACE * m_dCoastNormalAvgSpacing / m_dCellSide); // TODO 007 Info needed
900 m_nCoastCurvatureInterval = tMax(nRound(m_dCoastNormalAvgSpacing / (m_dCellSide * 2)), 2); // TODO 007 Info needed
901
902 // For beach erosion/deposition, conversion from immersed weight to bulk volumetric (sand and voids) transport rate (Leo Van Rijn) TODO 007 need full reference
904
905 m_bConsChangedThisIter.resize(m_nLayers, false);
906 m_bUnconsChangedThisIter.resize(m_nLayers, false);
907
908 // Normalize sediment erodibility values, so that none are > 1
913
914 // Intialise SWL
916
917 // If SWL changes during the simulation, calculate the per-timestep increment (could be -ve)
919 {
922 }
923
924 // ===================================================== The main loop ======================================================
925 // Tell the user what is happening
927
928 while (true)
929 {
930 // Check that we haven't gone on too long: if not then update timestep number etc.
931 if (bTimeToQuit())
932 break;
933
934 // Tell the user how the simulation is progressing
936
938 LogStream << "TIMESTEP " << m_ulIter << " " << string(154, '=') << endl;
939
940 LogStream << fixed << setprecision(3);
941
942 // Check to see if there is a new intervention in place: if so, update it on the RasterGrid array
943 nRet = nUpdateIntervention();
944 if (nRet != RTN_OK)
945 return nRet;
946
947 // Calculate changes due to external forcing (change in still water level, tide level and deep water waves height, orientation and period)
948 nRet = nCalcExternalForcing();
949 if (nRet != RTN_OK)
950 return nRet;
951
952 // Do per-timestep intialization: set up the grid cells ready for this timestep, also initialize per-timestep totals. Note that in the first timestep, all cells (including hinterland cells) are given the deep water wave values
954 if (nRet != RTN_OK)
955 return nRet;
956
957 // Next find out which cells are inundated and locate the coastline(s). This also gives to all sea cells, wave values which are the same as the deep water values. For shallow water sea cells, these wave values will be changed later, in nDoAllPropagateWaves()
958 int nValidCoast = 0;
959 nRet = nLocateSeaAndCoasts(nValidCoast);
960 if (nRet != RTN_OK)
961 return nRet;
962
963 // Tell the user how the simulation is progressing
965
966 // Locate estuaries TODO 044 someday...
967
968 // For all cells, use classification rules to assign sea and hinterland landform categories
970 if (nRet != RTN_OK)
971 return nRet;
972
973 // For every coastline, use classification rules to assign landform categories
975 if (nRet != RTN_OK)
976 return nRet;
977
978 // Create all coastline-normal profiles, in coastline-concave-curvature sequence
979 nRet = nCreateAllProfiles();
980 if (nRet != RTN_OK)
981 return nRet;
982
983 // Check the coastline-normal profiles for intersection
984 nRet = nCheckAllProfiles();
985 if (nRet != RTN_OK)
986 return nRet;
987
988 // // DEBUG CODE =================
989 // for (int nCoast = 0; nCoast < static_cast<int>(m_VCoast.size()); nCoast++)
990 // {
991 // for (int nCoastPoint = 0; nCoastPoint < m_VCoast[nCoast].nGetCoastlineSize(); nCoastPoint++)
992 // {
993 // if (m_VCoast[nCoast].bIsProfileAtCoastPoint(nCoastPoint))
994 // {
995 // CGeomProfile const* pProfile = m_VCoast[nCoast].pGetProfileAtCoastPoint(nCoastPoint);
996 // int nProfile = pProfile->nGetCoastID();
997 //
998 // LogStream << m_ulIter << ": profile " << nProfile << " bStartOfCoast = " << pProfile->bStartOfCoast() << " bEndOfCoast = " << pProfile->bEndOfCoast() << " bCShoreProblem = " << pProfile->bCShoreProblem() << " bHitLand = " << pProfile->bHitLand() << " bHitCoast = " << pProfile->bHitCoast() << " bTooShort = " << pProfile->bTooShort() << " bTruncated = " << pProfile->bTruncated() << " bHitAnotherProfileBadly = " << pProfile->bHitAnotherProfileBadly() << endl;
999 // }
1000 // }
1001 // }
1002 // // DEBUG CODE =================
1003
1004 // Tell the user how the simulation is progressing
1006
1007 // Create the coast polygons
1008 nRet = nCreateAllPolygons();
1009 if (nRet != RTN_OK)
1010 return nRet;
1011
1012 // // DEBUG CODE =========================================================================================================
1013 // int nNODATA = 0;
1014 // int nPoly0 = 0;
1015 // int nPoly24 = 0;
1016 // for (int nX = 0; nX < m_nXGridSize; nX++)
1017 // {
1018 // for (int nY = 0; nY < m_nYGridSize; nY++)
1019 // {
1020 // int nTmp = m_pRasterGrid->m_Cell[nX][nY].nGetPolygonID();
1021 // if (nTmp == INT_NODATA)
1022 // nNODATA++;
1023 //
1024 // if (nTmp == 0)
1025 // nPoly0++;
1026 //
1027 // if (nTmp == 24)
1028 // nPoly24++;
1029 // }
1030 // }
1031 // LogStream << "Before marking polygon cells, N cells with NODATA polygon ID = " << nNODATA << endl;
1032 // // LogStream << "Before marking polygon cells, N cells with zero polygon ID = " << nPoly0 << endl;
1033 // LogStream << "Before marking polygon cells, N cells with 24 polygon ID = " << nPoly24 << endl;
1034 // // DEBUG CODE =========================================================================================================
1035
1036 // Mark cells of the raster grid that are within each polygon, and do some polygon initialization
1038
1039 // Calculate the length of the shared normal between each polygon and the adjacent polygon(s)
1041 if (nRet != RTN_OK)
1042 return nRet;
1043
1044 // Tell the user how the simulation is progressing
1046
1047 // // DEBUG CODE =========================================================================================================
1048 // nNODATA = 0;
1049 // nPoly0 = 0;
1050 // nPoly24 = 0;
1051 // for (int nX = 0; nX < m_nXGridSize; nX++)
1052 // {
1053 // for (int nY = 0; nY < m_nYGridSize; nY++)
1054 // {
1055 // int nTmp = m_pRasterGrid->m_Cell[nX][nY].nGetPolygonID();
1056 // if (nTmp == INT_NODATA)
1057 // nNODATA++;
1058 //
1059 // if (nTmp == 0)
1060 // nPoly0++;
1061 //
1062 // if (nTmp == 24)
1063 // nPoly24++;
1064 // }
1065 // }
1066 // LogStream << "After marking polygon cells, N cells with NODATA polygon ID = " << nNODATA << endl;
1067 // // LogStream << "After marking polygon cells, N cells with zero polygon ID = " << nPoly0 << endl;
1068 // LogStream << "After marking polygon cells, N cells with 24 polygon ID = " << nPoly24 << endl;
1069 // // DEBUG CODE =========================================================================================================
1070 // PropagateWind();
1071
1072 // Give every coast point a value for deep water wave height and direction
1074 if (nRet != RTN_OK)
1075 return nRet;
1076
1077 // // DEBUG CODE ===============
1078 // for (int nCoast = 0; nCoast < static_cast<int>(m_VCoast.size()); nCoast++)
1079 // {
1080 // LogStream << "====================" << endl;
1081 //
1082 // for (int nProfile = 0; nProfile < m_VCoast[nCoast].nGetNumProfiles(); nProfile++)
1083 // {
1084 // CGeomProfile* pProfile = m_VCoast[nCoast].pGetProfile(nProfile);
1085 // int nCell = pProfile->nGetNumCellsInProfile();
1086 // LogStream << "Profile " << pProfile->nGetCoastID() << " nGetNumCellsInProfile() = " << nCell << endl;
1087 // }
1088 //
1089 // LogStream << endl;
1090 //
1091 // for (int nProfile = 0; nProfile < m_VCoast[nCoast].nGetNumProfiles(); nProfile++)
1092 // {
1093 // CGeomProfile* pProfile = m_VCoast[nCoast].pGetProfileWithDownCoastSeq(nProfile);
1094 // int nCell = pProfile->nGetNumCellsInProfile();
1095 // LogStream << "Profile " << pProfile->nGetCoastID() << " nGetNumCellsInProfile() = " << nCell << endl;
1096 // }
1097 //
1098 // LogStream << "====================" << endl;
1099 // }
1100 // // DEBUG CODE =====================
1101
1102 // Change the wave properties in all shallow water sea cells: propagate waves and define the active zone, also locate wave shadow zones
1103 nRet = nDoAllPropagateWaves();
1104 if (nRet != RTN_OK)
1105 return nRet;
1106
1107 // Output polygon share table and pre-existing sediment table to log file
1109 {
1110 for (int nCoast = 0; nCoast < nValidCoast; nCoast++)
1111 {
1112 WritePolygonShareTable(nCoast);
1114 }
1115 }
1116
1117 // Tell the user how the simulation is progressing
1119
1120 // // DEBUG CODE ===========================================================================================================
1121 // string strOutFile = m_strOutPath;
1122 // strOutFile += "sea_wave_height_CHECKPOINT_";
1123 // strOutFile += to_string(m_ulIter);
1124 // strOutFile += ".tif";
1125 //
1126 // GDALDriver* pDriver = GetGDALDriverManager()->GetDriverByName("gtiff");
1127 // GDALDataset* pDataSet = pDriver->Create(strOutFile.c_str(), m_nXGridSize, m_nYGridSize, 1, GDT_Float64, m_papszGDALRasterOptions);
1128 // pDataSet->SetProjection(m_strGDALBasementDEMProjection.c_str());
1129 // pDataSet->SetGeoTransform(m_dGeoTransform);
1130 //
1131 // int nn = 0;
1132 // double* pdRaster = new double[m_nXGridSize * m_nYGridSize];
1133 // for (int nY = 0; nY < m_nYGridSize; nY++)
1134 // {
1135 // for (int nX = 0; nX < m_nXGridSize; nX++)
1136 // {
1137 // pdRaster[nn++] = m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight();
1138 // }
1139 // }
1140 //
1141 // GDALRasterBand* pBand = pDataSet->GetRasterBand(1);
1142 // pBand->SetNoDataValue(m_dMissingValue);
1143 // int nRet = pBand->RasterIO(GF_Write, 0, 0, m_nXGridSize, m_nYGridSize, pdRaster, m_nXGridSize, m_nYGridSize, GDT_Float64, 0, 0, NULL);
1144 //
1145 // if (nRet == CE_Failure)
1146 // return RTN_ERR_GRIDCREATE;
1147 //
1148 // GDALClose(pDataSet);
1149 // delete[] pdRaster;
1150 // // DEBUG CODE ===========================================================================================================
1151 //
1152 // // DEBUG CODE ===========================================================================================================
1153 // strOutFile = m_strOutPath;
1154 // strOutFile += "sea_wave_angle_CHECKPOINT_";
1155 // strOutFile += to_string(m_ulIter);
1156 // strOutFile += ".tif";
1157 //
1158 // pDriver = GetGDALDriverManager()->GetDriverByName("gtiff");
1159 // pDataSet = pDriver->Create(strOutFile.c_str(), m_nXGridSize, m_nYGridSize, 1, GDT_Float64, m_papszGDALRasterOptions);
1160 // pDataSet->SetProjection(m_strGDALBasementDEMProjection.c_str());
1161 // pDataSet->SetGeoTransform(m_dGeoTransform);
1162 //
1163 // nn = 0;
1164 // pdRaster = new double[m_nXGridSize * m_nYGridSize];
1165 // for (int nY = 0; nY < m_nYGridSize; nY++)
1166 // {
1167 // for (int nX = 0; nX < m_nXGridSize; nX++)
1168 // {
1169 // pdRaster[nn++] = m_pRasterGrid->m_Cell[nX][nY].dGetWaveAngle();
1170 // }
1171 // }
1172 //
1173 // pBand = pDataSet->GetRasterBand(1);
1174 // pBand->SetNoDataValue(m_dMissingValue);
1175 // nRet = pBand->RasterIO(GF_Write, 0, 0, m_nXGridSize, m_nYGridSize, pdRaster, m_nXGridSize, m_nYGridSize, GDT_Float64, 0, 0, NULL);
1176 //
1177 // if (nRet == CE_Failure)
1178 // return RTN_ERR_GRIDCREATE;
1179 //
1180 // GDALClose(pDataSet);
1181 // delete[] pdRaster;
1182 // // DEBUG CODE ===========================================================================================================
1183
1184 // Save the not-deposited values, to be shown in the logfile after we've finished beach sediment movement
1187
1190 {
1191 LogStream << m_ulIter << ": AT ITERATION START m_dDepositionSandDiff = " << m_dDepositionSandDiff * m_dCellArea << " m_dUnconsSandNotDepositedLastIter = " << m_dUnconsSandNotDepositedLastIter << endl;
1192 LogStream << m_ulIter << ": AT ITERATION START m_dDepositionCoarseDiff = " << m_dDepositionCoarseDiff * m_dCellArea << " m_dUnconsCoarseNotDepositedLastIter = " << m_dUnconsCoarseNotDepositedLastIter << endl;
1193 }
1194
1196 {
1197 // Calculate elevation change on the consolidated sediment which comprises the coastal platform
1199 if (nRet != RTN_OK)
1200 return nRet;
1201 }
1202
1203 // Output shore platform erosion table to log file
1205 {
1206 for (int nCoast = 0; nCoast < nValidCoast; nCoast++)
1208 }
1209
1211 {
1212 // Do all cliff collapses for this timestep (if any)
1214 if (nRet != RTN_OK)
1215 return nRet;
1216 }
1217
1218 // Output cliff collapse table to log file
1220 {
1221 for (int nCoast = 0; nCoast < nValidCoast; nCoast++)
1223 }
1224
1225 // Tell the user how the simulation is progressing
1227
1229 {
1230 // Next simulate beach erosion and deposition i.e. simulate alongshore transport of unconsolidated sediment (longshore drift) between polygons. First calculate potential sediment movement between polygons
1232
1233 // Do within-sediment redistribution of unconsolidated sediment, constraining potential sediment movement to give actual (i.e. supply-limited) sediment movement to/from each polygon in three size clases
1235 if (nRet != RTN_OK)
1236 return nRet;
1237 }
1238
1239 // If we have sediment input events, then check to see whether this is time for an event to occur. If it is, then do it
1240 if (m_bSedimentInput)
1241 {
1243 if (nRet != RTN_OK)
1244 return nRet;
1245
1246 // If we have had at least one sediment input event this iteration, then output the sediment event per polygon table to the log file
1248 {
1249 for (int nCoast = 0; nCoast < nValidCoast; nCoast++)
1251 }
1252 }
1253
1254// // Add the fine sediment that was eroded this timestep (from the shore platform, from cliff collapse, from erosion of existing fine sediment during cliff collapse talus deposition, and from beach erosion; minus the fine sediment from beach erosion that went off-grid) to the suspended sediment load
1255// double dFineThisIter = m_dThisIterActualPlatformErosionFineCons + m_dThisIterCliffCollapseErosionFineUncons + m_dThisIterCliffCollapseErosionFineCons + m_dThisIterCliffCollapseFineErodedDuringDeposition + m_dThisIterBeachErosionFine - m_dThisIterLeftGridUnconsFine;
1256//
1257// m_dThisIterFineSedimentToSuspension += dFineThisIter;
1258
1259 // Tell the user how the simulation is progressing
1261
1262 // // DEBUG CODE ===========================================================================================================
1263 // string strOutFile = m_strOutPath;
1264 // strOutFile += "sea_wave_height_CHECKPOINT_";
1265 // strOutFile += to_string(m_ulIter);
1266 // strOutFile += ".tif";
1267 //
1268 // GDALDriver* pDriver = GetGDALDriverManager()->GetDriverByName("gtiff");
1269 // GDALDataset* pDataSet = pDriver->Create(strOutFile.c_str(), m_nXGridSize, m_nYGridSize, 1, GDT_Float64, m_papszGDALRasterOptions);
1270 // pDataSet->SetProjection(m_strGDALBasementDEMProjection.c_str());
1271 // pDataSet->SetGeoTransform(m_dGeoTransform);
1272 //
1273 // int nn = 0;
1274 // double* pdRaster = new double[m_nXGridSize * m_nYGridSize];
1275 // for (int nY = 0; nY < m_nYGridSize; nY++)
1276 // {
1277 // for (int nX = 0; nX < m_nXGridSize; nX++)
1278 // {
1279 // pdRaster[nn++] = m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight();
1280 // }
1281 // }
1282 //
1283 // GDALRasterBand* pBand = pDataSet->GetRasterBand(1);
1284 // pBand->SetNoDataValue(m_dMissingValue);
1285 // int nRet = pBand->RasterIO(GF_Write, 0, 0, m_nXGridSize, m_nYGridSize, pdRaster, m_nXGridSize, m_nYGridSize, GDT_Float64, 0, 0, NULL);
1286 //
1287 // if (nRet == CE_Failure)
1288 // return RTN_ERR_GRIDCREATE;
1289 //
1290 // GDALClose(pDataSet);
1291 // delete[] pdRaster;
1292 // // DEBUG CODE ===========================================================================================================
1293 //
1294 // // DEBUG CODE ===========================================================================================================
1295 // strOutFile = m_strOutPath;
1296 // strOutFile += "sea_wave_angle_CHECKPOINT_";
1297 // strOutFile += to_string(m_ulIter);
1298 // strOutFile += ".tif";
1299 //
1300 // pDriver = GetGDALDriverManager()->GetDriverByName("gtiff");
1301 // pDataSet = pDriver->Create(strOutFile.c_str(), m_nXGridSize, m_nYGridSize, 1, GDT_Float64, m_papszGDALRasterOptions);
1302 // pDataSet->SetProjection(m_strGDALBasementDEMProjection.c_str());
1303 // pDataSet->SetGeoTransform(m_dGeoTransform);
1304 //
1305 // nn = 0;
1306 // pdRaster = new double[m_nXGridSize * m_nYGridSize];
1307 // for (int nY = 0; nY < m_nYGridSize; nY++)
1308 // {
1309 // for (int nX = 0; nX < m_nXGridSize; nX++)
1310 // {
1311 // pdRaster[nn++] = m_pRasterGrid->m_Cell[nX][nY].dGetWaveAngle();
1312 // }
1313 // }
1314 //
1315 // pBand = pDataSet->GetRasterBand(1);
1316 // pBand->SetNoDataValue(m_dMissingValue);
1317 // nRet = pBand->RasterIO(GF_Write, 0, 0, m_nXGridSize, m_nYGridSize, pdRaster, m_nXGridSize, m_nYGridSize, GDT_Float64, 0, 0, NULL);
1318 //
1319 // if (nRet == CE_Failure)
1320 // return RTN_ERR_GRIDCREATE;
1321 //
1322 // GDALClose(pDataSet);
1323 // delete[] pdRaster;
1324 // // DEBUG CODE ===========================================================================================================
1325
1326 // Do some end-of-timestep updates to the raster grid, also update per-timestep and running totals
1327 nRet = nUpdateGrid();
1328 if (nRet != RTN_OK)
1329 return nRet;
1330
1331 // Make water level inundation on grid
1333 {
1334 m_nLevel = 0;
1335
1336 nRet = nLocateFloodAndCoasts();
1337 if (nRet != RTN_OK)
1338 return nRet;
1339 }
1340
1342 {
1343 // TODO 007 Info needed
1344 m_nLevel = 1;
1345
1346 nRet = nLocateFloodAndCoasts();
1347 if (nRet != RTN_OK)
1348 return nRet;
1349 }
1350
1351 // Now save results, first the raster and vector GIS files if required
1352 m_bSaveGISThisIter = false;
1353
1355 {
1356 m_bSaveGISThisIter = true;
1357
1358 // Save the values from the RasterGrid array into raster GIS files
1359 if (! bSaveAllRasterGISFiles())
1361
1362 // Tell the user how the simulation is progressing
1364
1365 // Save the vector GIS files
1366 if (! bSaveAllVectorGISFiles())
1368
1369 // Tell the user how the simulation is progressing
1371 }
1372
1373 // Output per-timestep results to the .out file
1375 return (RTN_ERR_TEXT_FILE_WRITE);
1376
1377 // Now output time series CSV stuff
1378 if (! bWriteTSFiles())
1380
1381 // Tell the user how the simulation is progressing
1383
1384 // Update grand totals
1386
1387 } // ================================================ End of main loop ======================================================
1388
1389 // =================================================== post-loop tidying =====================================================
1390 // Tell the user what is happening
1392
1393 // Write end-of-run information to Out, Log and time-series files
1394 nRet = nWriteEndRunDetails();
1395 if (nRet != RTN_OK)
1396 return (nRet);
1397
1398 // Do end-of-run memory clerance
1400
1401 return RTN_OK;
1402}
Geometry cass used to represent the raster grid of cell objects.
Definition raster_grid.h:35
double m_dThisIterPotentialBeachErosion
Total potential beach erosion (all size classes of unconsolidated sediment) for this iteration (depth...
Definition simulation.h:796
double m_dCliffDepositionPlanviewWidth
Planview width of cliff collapse talus (m)
Definition simulation.h:871
bool m_bCliffCollapseSave
Save cliff collapse raster GIS files?
Definition simulation.h:206
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_bAvgSeaDepthSave
Save average sea depth raster GIS files?
Definition simulation.h:95
void WritePolygonSedimentInputEventTable(int const)
Writes to the log file a table showing per-polygon sediment input event totals.
double m_dAllCellsDeepWaterWaveHeight
Deep water wave height (m) for all sea cells.
Definition simulation.h:709
bool m_bDeepWaterWaveAngleSave
Save deep water wave angle raster GIS files?
Definition simulation.h:233
static void AnnounceInitializing(void)
Tells the user that we are now initializing.
Definition utils.cpp:618
int m_nGISMaxSaveDigits
The maximum number of digits in GIS filenames. These can be sequential, or the iteration number.
Definition simulation.h:458
bool m_bTopSurfSave
Save fop surface (sediment and sea) raster DEMs?
Definition simulation.h:86
int m_nYMinBoundingBox
The minimum y value of the bounding box.
Definition simulation.h:500
static void AnnounceReadSCAPEShapeFunctionFile(void)
Now reading the SCAPE shape function file.
Definition utils.cpp:610
void CalcSavitzkyGolayCoeffs(void)
Calculates the Savitzky-Golay smoothing coefficients for a given size of smoothing window....
bool bCheckRasterGISOutputFormat(void)
Checks whether the selected raster GDAL driver supports file creation, 32-bit doubles,...
static void AnnounceIsRunning(void)
Tell the user that the simulation is now running.
Definition utils.cpp:627
bool m_bSedimentTopSurfSave
Save sediment top surface raster DEMs?
Definition simulation.h:83
bool m_bFineUnconsSedSave
Save fine unconsolidated sediment raster GIS files?
Definition simulation.h:179
int nLocateSeaAndCoasts(int &)
First find all connected sea areas, then locate the vector coastline(s), then put these onto the rast...
double m_dNotchDepthAtCollapse
Notch overhang (i.e. length of horizontal incision) to initiate collapse (m)
Definition simulation.h:862
bool m_bFloodSWLSetupSurgeLine
Are we saving the flood still water level setup surge line? TODO 007.
Definition simulation.h:416
time_t m_tSysEndTime
System finish-simulation time.
double m_dTotalCoarseUnconsInPolygons
Total coarse unconsolidated sediment in all polygons, before polygon-to-polygon movement (only cells ...
Definition simulation.h:961
bool m_bSedimentInputAtPoint
Do we have sediment inputat a point?
Definition simulation.h:371
double m_dMinSWL
Minimum still water level.
Definition simulation.h:676
double m_dG
Gravitational acceleration (m**2/sec)
Definition simulation.h:766
void AnnounceReadDeepWaterWaveValuesGIS(void) const
Tells the user that we are now reading the deep water wave values GIS file.
Definition utils.cpp:465
double m_dThisIterSWL
The still water level for this timestep (this includes tidal changes and any long-term SWL change)
Definition simulation.h:667
int m_nBeachErosionDepositionEquation
Which beach erosion-deposition equation is used. Possible values are UNCONS_SEDIMENT_EQUATION_CERC an...
Definition simulation.h:488
ofstream CliffCollapseNetChangeTSStream
Cliff collapse net change (erosion - deposition) time series file output stream.
bool m_bCoastSave
Save.
Definition simulation.h:251
bool m_bBeachDepositionTSSave
Save the beach (unconsolidated sediment) deposition time series file?
Definition simulation.h:299
bool bWritePerTimestepResults(void)
Write the results for this timestep to the .out file.
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
double dGetThisIterTotWaterLevel(void) const
Returns this timestep's total water level.
void AnnounceReadInitialSandConsSedGIS(int const) const
Tells the user that we are now reading the initial sand consolidated sediment depth GIS file.
Definition utils.cpp:572
int m_nXGridSize
The size of the grid in the x direction.
Definition simulation.h:431
int nAssignLandformsForAllCoasts(void)
Each timestep, classify coastal landforms and assign a coastal landform object to every point on ever...
void AnnounceReadInitialSandUnconsSedGIS(int const) const
Tells the user that we are now reading the initial sand unconsolidated sediment depth GIS file.
Definition utils.cpp:533
double m_dL_0
Deep water wave length (m)
Definition simulation.h:700
double m_dWaveDataWrapHours
Number of hours after which deep water wave data wraps.
Definition simulation.h:913
double m_dMaxUserInputWavePeriod
Used to constrain depth of closure.
Definition simulation.h:721
bool m_bFloodSetupSurgeRunupTSSave
Save the flood setup surge runup time series file? TODO 007 Does this work correctly?
Definition simulation.h:311
bool bSetUpTSFiles(void)
The bSetUpTSFiles member function sets up the time series files.
Definition utils.cpp:1078
ofstream LogStream
int nWriteEndRunDetails(void)
Writes end-of-run information to Out, Log and time-series files.
void AnnounceReadInitialFineUnconsSedGIS(int const) const
Tells the user that we are now reading the initial fine unconsolidated sediment depth GIS file.
Definition utils.cpp:520
double m_dThisIterBeachErosionCoarse
Total actual beach erosion (coarse unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:805
char ** m_papszGDALVectorOptions
Options for GDAL when handling vector files.
Definition simulation.h:428
double m_dStartIterUnconsCoarseAllCells
Depth (m) of coarse unconsolidated sediment at the start of the simulation, all cells (both inside an...
Definition simulation.h:943
int nReadRasterGISFile(int const, int const)
Reads all other raster GIS datafiles into the RasterGrid array.
double m_dCoastNormalLength
Length of the cost-normal profiles, in m.
Definition simulation.h:778
void WritePolygonCliffCollapseErosion(int const)
Writes to the log file a table showing per-polygon per-polygon cliff collapse.
int nLocateFloodAndCoasts(void)
First find all connected sea areas, then locate the vector coastline(s), then put these onto the rast...
bool m_bSaveGISThisIter
Save GIS files this iteration?
Definition simulation.h:314
long double m_ldGTotCliffCollapseCoarseErodedDuringDeposition
All-simulation total of coarse sediment eroded during talus deposition following cliff collapse (m)
default_random_engine m_Rand[NRNG]
The c++11 random number generators.
double m_dUnconsCoarseNotDepositedLastIter
Depth of unconsolidated coarse sediment that could not be deposited during the last iteration,...
Definition simulation.h:976
double m_dCPUClock
Total elapsed CPU time.
Definition simulation.h:649
bool bSaveAllVectorGISFiles(void)
The bSaveAllvectorGISFiles member function saves the vector GIS files TODO 081 Choose more files to o...
bool m_bSingleDeepWaterWaveValues
Do we have just a point source for (i.e. only a single measurement of) deep water wave values.
Definition simulation.h:362
int m_nThisSave
Used in calculations of GIS save intervals.
Definition simulation.h:467
long m_lGDALMaxCanWrite
The maximum integer value which GDAL can write, can be UINT8_MAX, INT16_MAX, UINT16_MAX,...
Definition simulation.h:547
bool m_bAvgWaveAngleAndHeightSave
Save average wave angle and average wave height raster GIS files?
Definition simulation.h:113
double m_dSouthEastXExtCRS
The south-east x coordinate, in the external coordinate reference system (CRS)
Definition simulation.h:604
int m_nMissingValue
The value used for integer missing values.
Definition simulation.h:491
bool m_bAvgWaveAngleSave
Save average wave angle raster GIS files?
Definition simulation.h:107
long double m_ldGTotActualCoarseBeachErosion
All-simulation total of coarse sediment eroded during beach (unconsolidated sediment) movement (m)
int nCalcExternalForcing(void)
Calculate external forcings: change in still water level, tide level and deep water waves height,...
int nReadWaveStationInputFile(int const)
Reads the deep water wave station input data. Each point in m_strDeepWaterWavesInputFile is a triad o...
double m_dFineErodibilityNormalized
Relative erodibility of fine unconsolidated beach sediment, normalized.
Definition simulation.h:751
void WriteLookUpData(void) const
Output the erosion potential look-up values, for checking purposes.
double m_dThisIterCliffCollapseFineErodedDuringDeposition
Total fine sediment eroded during Dean profile deposition of talus following cliff collapse (depth in...
Definition simulation.h:829
bool m_bInvalidNormalsSave
Save invalid coastline-normal vector GIS files?
Definition simulation.h:257
bool m_bShadowBoundarySave
Save wave shadow boundary vector GIS files?
Definition simulation.h:272
double m_dThisIterDiffWaveSetupSurgeWaterLevel
TODO 007 Info needed.
Definition simulation.h:688
int nReadSedimentInputEventFile(void)
Reads the sediment input event file.
double m_dThisIterActualPlatformErosionCoarseCons
Total actual platform erosion (coarse consolidated sediment) for this iteration (depth in m)
Definition simulation.h:793
bool m_bActualBeachErosionSave
Save actual (supply-limited) beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:146
int nDoAllShorePlatFormErosion(void)
Does platform erosion on all coastlines by first calculating platform erosion on coastline-normal pro...
int m_nYGridSize
The size of the grid in the y direction.
Definition simulation.h:434
double m_dThisIterTopElevMin
This-iteration lowest elevation of DEM.
Definition simulation.h:919
bool m_bStillWaterLevelTSSave
Save the still water level time series file?
Definition simulation.h:281
bool m_bRunUpSave
Are we saving runup? TODO 007.
Definition simulation.h:395
GDALDataType m_GDALWriteIntDataType
The data type used by GDAL for integer operations, can be GDT_Byte, GDT_Int16, GDT_UInt16,...
Definition simulation.h:541
long double m_ldGTotCliffTalusFineToSuspension
All-simulation total of fine sediment moved to suspension, due to cliff collapse (m)
bool m_bCliffCollapseDepositionSave
Save cliff collapse deposition raster GIS files?
Definition simulation.h:212
bool m_bTotalActualPlatformErosionSave
Save total actual (supply-limited) shore platform erosion raster GIS files?
Definition simulation.h:140
bool m_bPolygonUnconsSedUpOrDownDriftSave
Save polygon unconsolidated sediment up- or down-drift raster GIS files?
Definition simulation.h:242
double m_dCoarseErodibility
The relative erodibility (0- 1) of coarse unconsolidated beach sediment.
Definition simulation.h:748
double m_dGeoTransform[6]
GDAL geotransformation info (see http://www.gdal.org/classGDALDataset.html)
Definition simulation.h:652
double m_dCliffTalusMinDepositionLength
Planview length of cliff deposition talus (m)
Definition simulation.h:874
double m_dMissingValue
Missing value.
Definition simulation.h:910
int m_nUnconsSedimentHandlingAtGridEdges
How sediment which moves off an edge of the grid is handled. Possible values are GRID_EDGE_CLOSED,...
Definition simulation.h:485
double m_dSandErodibility
The relative erodibility (0- 1) of sand unconsolidated beach sediment.
Definition simulation.h:745
bool m_bBasementElevSave
Save basement raster DEMs?
Definition simulation.h:80
double m_dInvCellDiagonal
Inverse of m_dCellDiagonal.
Definition simulation.h:625
int m_nSimStartHour
Start time of the simulation (hours)
Definition simulation.h:515
double m_dCoarseErodibilityNormalized
Relative erodibility of coarse unconsolidated beach sediment, normalized.
Definition simulation.h:757
bool m_bCoarseUnconsSedSave
Save coarse unconsolidated sediment raster GIS files?
Definition simulation.h:185
bool m_bSuspSedTSSave
Save the suspended sediment time series file?
Definition simulation.h:305
bool m_bCliffCollapseNetTSSave
Save the cliff collapse net change time series file?
Definition simulation.h:293
double m_dStartIterSuspFineInPolygons
Depth (m) of fine suspended sediment at the start of the simulation (only cells in polygons)
Definition simulation.h:934
bool m_bPotentialPlatformErosionMaskSave
Save potential platform erosion mask raster GIS files?
Definition simulation.h:221
unsigned long m_ulThisIterNumCoastCells
The number of grid cells which are marked as coast, for this iteration.
Definition simulation.h:568
static void AnnounceSimEnd(void)
Announce the end of the simulation.
Definition utils.cpp:1392
unsigned long m_ulNumCells
The number of cells in the grid.
Definition simulation.h:562
double m_dTotPotentialPlatformErosionBetweenProfiles
Total potential platform erosion between profiles.
Definition simulation.h:850
int nGetGridYMax(void) const
Returns the size of the grid in the Y direction.
void AnnounceReadICGIS(void) const
Tells the user that we are now reading the Intervention class GIS file.
Definition utils.cpp:437
int nCheckForSedimentInputEvent(void)
Check to see if we have any sediment input events this timestep, if so then do the event(s)
double m_dWaveDepthRatioForWaveCalcs
Start depth for wave calculations.
Definition simulation.h:703
bool m_bWaveHeightSave
Save wave height raster GIS files?
Definition simulation.h:98
bool m_bFloodLocation
Are we saving the flood location? TODO 007.
Definition simulation.h:410
void WriteStartRunDetails(void)
Writes beginning-of-run information to Out and Log files.
double m_dThisIterCliffCollapseErosionCoarseUncons
This-iteration total of coarse unconsolidated sediment produced by cliff collapse (m^3)
Definition simulation.h:886
bool m_bGDALCanCreate
Is the selected GDAL output file format capable of writing files?
Definition simulation.h:347
bool m_bLandformSave
Save coast landform raster GIS files?
Definition simulation.h:161
ofstream CliffCollapseDepositionTSStream
Cliff collapse deposition time series file output stream.
long double m_ldGTotCoarseBeachDeposition
All-simulation total of coarse sediment deposited during beach (unconsolidated sediment) movement (m)
double m_dDepositionCoarseDiff
Error term: if we are unable to deposit enough unconslidated coarse on polygon(s),...
Definition simulation.h:841
bool m_bTotalBeachDepositionSave
Save total beach (unconsolidated sediment) deposition raster GIS files?
Definition simulation.h:158
int m_nCoastMax
Maximum valid coast length when searching for coasts, actually is COAST_LENGTH_MAX * tMax(m_nXGridSiz...
Definition simulation.h:470
double m_dBeachSedimentPorosity
The porosity of unconsolidated beach sediment (0 - 1)
Definition simulation.h:739
double dGetMissingValue(void) const
Returns the NODATA value.
int m_nSimStartSec
Start time of the simulation (seconds)
Definition simulation.h:509
int m_nSimStartDay
Start date of the simulation (day)
Definition simulation.h:518
unsigned long m_ulThisIterNumActualPlatformErosionCells
The number of grid cells on which actual platform erosion occurs, for this iteration.
Definition simulation.h:574
bool m_bSandUnconsSedSave
Save sand unconsolidated sediment raster GIS files?
Definition simulation.h:182
bool m_bActualPlatformErosionTSSave
Save the actual (supply-limited) shore platform erosion time series file?
Definition simulation.h:284
int m_nXMaxBoundingBox
The maximum x value of the bounding box.
Definition simulation.h:497
long double m_ldGTotPotentialSedLostBeachErosion
All-simulation total of potential sediment lost via beach (unconsolidated) sediment movement (m),...
Definition simulation.h:993
double m_dThisIterCliffCollapseErosionFineUncons
This-iteration total of fine unconsolidated sediment produced by cliff collapse (m^3)
Definition simulation.h:880
double dGetD50Coarse(void) const
Returns the global d50 value for coarse sediment.
bool m_bTotCliffCollapseSave
Save total cliff collapse raster GIS files?
Definition simulation.h:209
int nReadShapeFunctionFile(void)
Reads the shape of the erosion potential distribution (see shape function in Walkden & Hall,...
static void AnnounceAddLayers(void)
Tells the user that we are now adding layers.
Definition utils.cpp:398
int nDoAllActualBeachErosionAndDeposition(void)
Does between-polygon and within-polygon actual (supply-limited) redistribution of transported beach s...
bool m_bDoShorePlatformErosion
Simulate shore platform erosion?
Definition simulation.h:338
bool m_bSliceSave
Save slices?
Definition simulation.h:89
void WritePolygonShorePlatformErosion(int const)
Writes to the log file a table showing per-polygon unconsolidated sand/coarse sediment derived from e...
bool m_bRasterPolygonSave
Save raster polygon raster GIS files?
Definition simulation.h:218
bool m_bBeachDepositionSave
Save beach (unconsolidated sediment) deposition raster GIS files?
Definition simulation.h:155
double m_dNorthWestYExtCRS
The north-west y coordinate, in the external coordinate reference system (CRS)
Definition simulation.h:601
bool m_bSaveRegular
Save GIS files at regular intervals?
Definition simulation.h:248
int m_nLayers
The number of sediment layers.
Definition simulation.h:437
bool bFindExeDir(char const *)
Finds the folder (directory) in which the CoastalME executable is located.
Definition utils.cpp:208
double m_dStartIterConsCoarseAllCells
Depth (m) of coarse consolidated sediment at the start of the simulation, all cells (both inside and ...
Definition simulation.h:952
double m_dStartIterConsSandAllCells
Depth (m) of sand consolidated sediment at the start of the simulation, all cells (both inside and ou...
Definition simulation.h:949
bool m_bSedimentInputAlongLine
Do we have sediment input along a line?
Definition simulation.h:377
bool m_bSedimentInput
Do we have sediment input events?
Definition simulation.h:368
unsigned long m_ulThisIterNumBeachDepositionCells
The number of grid cells on which beach (unconsolidated sediment) deposition occurs,...
Definition simulation.h:583
double m_dInmersedToBulkVolumetric
For beach erosion/deposition, conversion from immersed weight to bulk volumetric (sand and voids) tra...
Definition simulation.h:769
bool m_bNormalsSave
Save coastline-normal vector GIS files?
Definition simulation.h:254
bool m_bAvgWaveHeightSave
Save wave height raster GIS files?
Definition simulation.h:101
CSimulation(void)
The CSimulation constructor.
double m_dDepositionSandDiff
Error term: if we are unable to deposit enough unconslidated sand on polygon(s), this is held over to...
Definition simulation.h:838
bool m_bHaveSandSediment
Does this simulation consider sand-sized sediment?
Definition simulation.h:74
unsigned long m_ulMissingValueBasementCells
The number of basement cells marked with as missing value.
Definition simulation.h:592
double m_dThisiterUnconsCoarseInput
Depth (m) of coarse unconsolidated sediment added, at this iteration.
Definition simulation.h:928
int nReadVectorGISFile(int const)
Reads vector GIS datafiles using OGR.
bool bReadRunDataFile(void)
Reads the run details input file and does some initialization.
int m_nUSave
If user-defined GIS save intervals, the number of these.
Definition simulation.h:464
double m_dThisIterPotentialPlatformErosion
Total potential platform erosion (all size classes of consolidated sediment) for this iteration (dept...
Definition simulation.h:784
bool bWriteTSFiles(void)
Write the results for this timestep to the time series CSV files.
double m_dDeanProfileStartAboveSWL
Berm height i.e. height above SWL of start of depositional Dean profile.
Definition simulation.h:907
int m_nSavGolCoastPoly
The order of the coastline profile smoothing polynomial if Savitsky-Golay smoothing is used (usually ...
Definition simulation.h:446
bool m_bSeaDepthSave
Save sea depth raster GIS files?
Definition simulation.h:92
bool m_bWaveAngleAndHeightSave
Save wave angle and wave height raster GIS files?
Definition simulation.h:110
double m_dNotchBaseBelowSWL
Notch base below SWL (m)
Definition simulation.h:865
int m_nRunUpEquation
The run-up equation used TODO 007.
Definition simulation.h:533
long double m_ldGTotCliffCollapseFine
All-simulation total of fine sediment from cliff collapse (m)
bool m_bWorldFile
Write a GIS World file?
Definition simulation.h:359
long double m_ldGTotCliffTalusCoarseDeposition
All-simulation total of coarse sediment deposited as talus following cliff collapse (m)
void AnnounceReadSedimentEventInputValuesGIS(void) const
Tells the user that we are now reading the sediment input events GIS file.
Definition utils.cpp:479
double dGetD50Fine(void) const
Returns the global d50 value for fine sediment.
double m_dDepthOverDBMax
Maximum value of deoth over DB, is used in erosion potential look-up function.
Definition simulation.h:844
long double m_ldGTotCliffCollapseCoarse
All-simulation total of coarse sediment from cliff collapse (m)
double m_dFineErodibility
The relative erodibility (0- 1) of fine unconsolidated beach sediment.
Definition simulation.h:742
double m_dThisiterUnconsFineInput
Depth (m) of fine unconsolidated sediment added, at this iteration.
Definition simulation.h:922
time_t m_tSysStartTime
System start-simulation time.
double m_dBreakingWaveHeightDepthRatio
Breaking wave height-to-depth ratio.
Definition simulation.h:706
void AnnounceReadFloodLocationGIS(void) const
Tells the user that we are now reading the flood location GIS file.
Definition utils.cpp:493
bool bCheckVectorGISOutputFormat(void)
Checks whether the selected vector OGR driver supports file creation etc.
bool m_bHaveWaveStationData
Do we have wave station data?
Definition simulation.h:365
double m_dSeaWaterDensity
Density of sea water in kg/m**3.
Definition simulation.h:655
int nDoSimulation(int, char const *[])
Runs the simulation.
void StartClock(void)
Starts the clock ticking.
Definition utils.cpp:185
long double m_ldGTotSuspendedSediment
All-simulation total of suspended sediment (m)
int nCreateAllPolygons(void)
Create polygons, and mark the polygon boundaries on the raster grid.
double m_dSandErodibilityNormalized
Relative erodibility of sand unconsolidated beach sediment, normalized.
Definition simulation.h:754
double m_dR
Coast platform resistance to erosion R, see Walkden & Hall, 2011.
Definition simulation.h:724
bool m_bActiveZoneSave
Save active zone raster GIS files?
Definition simulation.h:203
void AnnounceReadInitialSuspSedGIS(void) const
Tells the user that we are now reading the initial suspended sediment depth GIS file.
Definition utils.cpp:507
ofstream StillWaterLevelTSStream
SWL time series file output stream.
void DoEndOfRunDeletes(void)
Do end-of-run memory clearance.
Definition utils.cpp:2772
double m_dThisIterActualPlatformErosionSandCons
Total actual platform erosion (sand consolidated sediment) for this iteration (depth in m)
Definition simulation.h:790
bool m_bOmitSearchWestEdge
Omit the west edge of the grid from coast-end searches?
Definition simulation.h:332
bool m_bSedimentInputAtCoast
Do we have sediment input at the coast?
Definition simulation.h:374
static void AnnounceReadRasterFiles(void)
Now reading raster GIS files.
Definition utils.cpp:407
double m_dCliffErosionResistance
Resistance of cliff to notch erosion.
Definition simulation.h:859
double m_dThisIterBeachDepositionCoarse
Total beach deposition (coarse unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:811
double m_dD50Sand
The D50 for sand sediment.
Definition simulation.h:730
long double m_ldGTotCliffTalusSandDeposition
All-simulation total of sand sediment deposited as talus following cliff collapse (m)
double m_dCellDiagonal
Length of a cell's diagonal (in external CRS units)
Definition simulation.h:619
bool m_bDeepWaterWaveHeightSave
Save deep water wave height raster GIS files?
Definition simulation.h:236
bool m_bMeanWaveEnergySave
Save mean wave energy raster GIS files?
Definition simulation.h:122
double m_dKLS
Transport parameter KLS in the CERC equation.
Definition simulation.h:760
double m_dInvCellSide
Inverse of m_dCellSide.
Definition simulation.h:622
int m_nWavePropagationModel
The wave propagation model used. Possible values are WAVE_MODEL_CSHORE and WAVE_MODEL_COVE.
Definition simulation.h:506
long double m_ldGTotCliffCollapseSandErodedDuringDeposition
All-simulation total of sand sediment eroded during talus deposition following cliff collapse (m)
double m_dAllCellsDeepWaterWaveAngle
Deep water wave angle for all sea cells.
Definition simulation.h:712
double m_dSimElapsed
Time simulated so far, in hours.
Definition simulation.h:634
bool m_bCoastCurvatureSave
Save coastline-curvature vector GIS files?
Definition simulation.h:260
int nGetGridXMax(void) const
Returns the cell size.
int m_nDeepWaterWaveDataNumTimeSteps
The duration of data for deep water waves, expressed as a number of time steps.
Definition simulation.h:527
void AnnounceReadBasementDEM(void) const
Tells the user that we are now reading the DEM file.
Definition utils.cpp:377
int nConvertMetresToNumCells(double const) const
Given a length in m, this returns the rounded equivalent number of cells.
long double m_ldGTotCoarseSedimentInput
All-simulation total of coarse sediment input (m)
double m_dThisIterUnconsCoarseCliffDeposition
This-iteration total of coarse unconsolidated sediment deposited due to cliff collapse (m^3)
Definition simulation.h:901
bool m_bGDALCanWriteInt32
Is the selected GDAL output file format capable of writing 32-bit integers to files?
Definition simulation.h:353
bool m_bRasterWaveFloodLineSave
Are we saving the raster wave flood line? TODO 007.
Definition simulation.h:404
bool m_bBreakingWaveHeightSave
Save breaking wave height raster GIS files?
Definition simulation.h:125
double m_dThisIterTotSeaDepth
Total sea depth (m) for this iteration.
Definition simulation.h:781
double m_dTotPotentialPlatformErosionOnProfiles
Total potential platform erosion on profiles.
Definition simulation.h:847
int m_nCoastMin
Minimum valid coast legth when searching for coass, actualli is tMin(m_nXGridSize,...
Definition simulation.h:473
double m_dRegularSaveTime
The time of the next save, in hours from the start of the simulation, if we are saving regularly.
Definition simulation.h:637
bool m_bPolygonNodeSave
Save polygon node vector GIS files?
Definition simulation.h:263
bool m_bOmitSearchNorthEdge
Omit the north edge of the grid from coast-end searches?
Definition simulation.h:326
long double m_ldGTotCoarseActualPlatformErosion
All-simulation total of coarse sediment actual platform erosion (m)
Definition simulation.h:990
long double m_ldGTotFineActualPlatformErosion
All-simulation total of fine sediment actual platform erosion (m)
Definition simulation.h:984
double m_dThisIterUnconsSandCliffDeposition
This-iteration total of sand unconsolidated sediment deposited due to cliff collapse (m^3)
Definition simulation.h:898
vector< int > m_VnDeepWaterWaveStationID
ID for deep water wave station, this corresponds with the ID in the wave time series file.
long double m_ldGTotSandSedimentInput
All-simulation total of sand sediment input (m)
bool m_bFloodSetupSurgeTSSave
Save the flood setup surge time series file? TODO 007 Does this work correctly?
Definition simulation.h:308
bool m_bTotalPotentialPlatformErosionSave
Save total potential shore platform erosion raster GIS files?
Definition simulation.h:137
bool m_bSetupSurgeFloodMaskSave
Are we saving the setup surge flood mask? TODO 007.
Definition simulation.h:398
bool m_bWaveEnergySinceCollapseSave
Save wave energy since cliff collapse raster GIS files?
Definition simulation.h:119
double m_dNorthWestXExtCRS
The north-west x coordinate, in the external coordinate reference system (CRS)
Definition simulation.h:598
double m_dD50Coarse
The D50 for coarse sediment.
Definition simulation.h:733
static void AnnounceStart(void)
Tells the user that we have started the simulation.
Definition utils.cpp:177
static int nUpdateIntervention(void)
Check to see if we have a new intervention in place (not yet implemented)
int m_nCoastCurvatureInterval
Coast curvature interval is a length, measured in coastline points.
Definition simulation.h:455
ofstream CliffCollapseErosionTSStream
Cliff collapse erosion time series file output stream.
double m_dThisIterPotentialSedLostBeachErosion
Total unconsolidated sediment from beach erosion (all size classes) lost from the grid this iteration...
Definition simulation.h:817
double m_dSouthEastYExtCRS
The south-east y coordinate, in the external coordinate reference system (CRS)
Definition simulation.h:607
bool m_bPotentialBeachErosionSave
Save potential beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:143
long double m_ldGTotCliffCollapseFineErodedDuringDeposition
All-simulation total of fine sediment eroded during talus deposition following cliff collapse (m)
~CSimulation(void)
The CSimulation destructor.
long double m_ldGTotCoarseDepositionDiff
All-simulation total of shortfall in unconsolidated coarse sediment deposition (m,...
int nSetAllCoastpointDeepWaterWaveValues(void)
Give every coast point a value for deep water wave height and direction TODO 005 This may not be real...
double m_dCoastNormalAvgSpacing
Average spacing of the cost-normal profiles, in m.
Definition simulation.h:775
double m_dStartIterConsFineAllCells
Depth (m) of fine consolidated sediment at the start of the simulation, all cells (both inside and ou...
Definition simulation.h:946
long double m_ldGTotActualCoarseLostBeachErosion
All-simulation total of coarse sediment lost via beach (unconsolidated) sediment movement (m)
bool m_bGISSaveDigitsSequential
Are the GIS save digits (which are part of each GIS file name) sequential, or are they the iteration ...
Definition simulation.h:422
int nUpdateGrid(void)
Update all cells in the raster raster grid and do some per-timestep accounting.
int m_nSimStartMonth
Start date of the simulation (month)
Definition simulation.h:521
int nAssignLandformsForAllCells(void)
Each timestep, classify landforms for cells that are not on the coastline.
bool m_bSuspSedSave
Save suspended sediment raster GIS files?
Definition simulation.h:173
double m_dMinCliffTalusHeightFrac
Minimum height of the landward end of cliff collapse talus, as a fraction of cliff elevation.
Definition simulation.h:877
double m_dThisIterBeachErosionSand
Total actual beach erosion (sand unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:802
double m_dAccumulatedSeaLevelChange
If long-term SWL changes, the total change so far since the start of simulation.
Definition simulation.h:673
bool m_bPolygonBoundarySave
Save polygon boundary vector GIS files?
Definition simulation.h:266
void WritePolygonPreExistingSedimentTable(int const)
Writes to the log file a table showing per-polygon pre-existing unconsolidated sediment.
bool m_bStormSurgeSave
Are we saving the storm surge? TODO 007.
Definition simulation.h:392
bool m_bActualPlatformErosionSave
Save actual (supply-limited) shore platform erosion raster GIS files?
Definition simulation.h:134
double m_dThisIterFineSedimentToSuspension
Total fine unconsolidated sediment in suspension for this iteration (depth in m)
Definition simulation.h:814
int nDoAllWaveEnergyToCoastLandforms(void)
Update accumulated wave energy in coastal landform objects.
double m_dThisIterBeachErosionFine
Total actual beach erosion (fine unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:799
void DoAllPotentialBeachErosion(void)
Uses either the CERC equation or the Kamphuis (1990) equation to calculate potential (unconstrained) ...
double m_dThisIterCliffCollapseSandErodedDuringDeposition
Total sand sediment eroded during Dean profile deposition of talus following cliff collapse (depth in...
Definition simulation.h:832
int m_nSimStartMin
Start time of the simulation (minutes)
Definition simulation.h:512
bool bSaveAllRasterGISFiles(void)
The bSaveAllRasterGISFiles member function saves the raster GIS files using values from the RasterGri...
unsigned long m_ulThisIterNumActualBeachErosionCells
The number of grid cells on which actual beach (unconsolidated sediment) erosion occurs,...
Definition simulation.h:580
bool bReadIniFile(void)
The bReadIniFile member function reads the initialization file.
bool m_bHaveFineSediment
Does this simulation consider fine-sized sediment?
Definition simulation.h:71
double m_dCliffDepositionA
Scale parameter A for cliff deposition (m^(1/3)), may be zero for auto-calculation.
Definition simulation.h:868
string m_strDataPathName
Folder in which the CME data file is found.
string m_strOutPath
Path for all output files.
bool m_bBeachErosionTSSave
Save the beach (unconsolidated sediment) erosion time series file?
Definition simulation.h:296
int m_nYMaxBoundingBox
The maximum y value of the bounding box.
Definition simulation.h:503
string m_strTideDataFile
Name of tide data file.
vector< bool > m_bUnconsChangedThisIter
One element per layer: has the consolidated sediment of this layer been changed during this iteration...
bool m_bTotalPotentialBeachErosionSave
Save total potential beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:149
unsigned long m_ulThisIterNumPotentialPlatformErosionCells
The number of grid cells on which potential platform erosion occurs, for this iteration.
Definition simulation.h:571
double m_dStartIterUnconsSandAllCells
Depth (m) of sand unconsolidated sediment at the start of the simulation, all cells (both inside and ...
Definition simulation.h:940
double m_dMaxSWL
Maximum still water level.
Definition simulation.h:679
long double m_ldGTotActualSandLostBeachErosion
All-simulation total of sand sediment lost via beach (unconsolidated) sediment movement (m)
Definition simulation.h:999
double m_dDeltaSWLPerTimestep
If long-term SWL changes, the increment per timestep.
Definition simulation.h:664
int m_nGISSave
The save number for GIS files (can be sequential, or the iteration number)
Definition simulation.h:461
string m_strInterventionClassFile
Name of intervention class file.
long double m_ldGTotActualFineLostBeachErosion
All-simulation total of fine sediment lost via beach (unconsolidated) sediment movement (m)
Definition simulation.h:996
bool m_bFloodSWLSetupLine
Are we saving the flood still water level setup line? TODO 007.
Definition simulation.h:413
bool m_bSeaMaskSave
Save sea mask raster GIS files?
Definition simulation.h:224
double m_dThisIterCliffCollapseErosionFineCons
This-iteration total of fine consolidated sediment produced by cliff collapse (m^3)
Definition simulation.h:889
bool m_bInterventionClassSave
Save intervention class raster GIS files?
Definition simulation.h:167
long double m_ldGTotCoarseSedLostCliffCollapse
All-simulation total of coarse sediment lost via cliff collapse (m)
long double m_ldGTotSandActualPlatformErosion
All-simulation total of sand sediment actual platform erosion (m)
Definition simulation.h:987
int m_nSimStartYear
Start date of the simulation (year)
Definition simulation.h:524
bool m_bTotalActualBeachErosionSave
Save total actual (supply-limited) beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:152
void WritePolygonShareTable(int const)
Writes to the log file a table showing polygon to polygon shares of unconsolidated sediment transport...
bool m_bRasterCoastlineSave
Save raster coastline GIS files?
Definition simulation.h:197
long double m_ldGTotSandSedLostCliffCollapse
All-simulation total of sand sediment lost via cliff collapse (m)
double m_dUnconsSandNotDepositedLastIter
Depth of unconsolidated sand sediment that could not be deposited during the last iteration,...
Definition simulation.h:973
double m_dThisIterDiffWaveSetupWaterLevel
TODO 007 Info needed.
Definition simulation.h:685
bool m_bInterventionHeightSave
Save intervention height raster GIS files?
Definition simulation.h:170
double m_dTotalCoarseConsInPolygons
Total coarse consolidated sediment in all polygons, before polygon-to-polygon movement (only cells in...
Definition simulation.h:970
int m_nCoastCurvatureMovingWindowSize
Definition simulation.h:538
ofstream SeaAreaTSStream
Sea area time series file output stream.
unsigned long m_ulThisIterNumSeaCells
The number of grid cells which are marked as sea, for this iteration.
Definition simulation.h:565
void AnnounceReadIHGIS(void) const
Tells the user that we are now reading the Intervention height GIS file.
Definition utils.cpp:451
double m_dTotalSandUnconsInPolygons
Total sand unconsolidated sediment in all polygons, before polygon-to-polygon movement (only cells in...
Definition simulation.h:958
void AnnounceReadInitialCoarseConsSedGIS(int const) const
Tells the user that we are now reading the initial coarse consolidated sediment depth GIS file.
Definition utils.cpp:585
bool m_bRiverineFlooding
Are we doing flooding? TODO 007.
Definition simulation.h:386
long m_lGDALMinCanWrite
The minimum integer value which GDAL can write, can be zero, INT16_MIN, INT32_MIN.
Definition simulation.h:550
int nCreateAllProfiles(void)
Create coastline-normal profiles for all coastlines. The first profiles are created 'around' the most...
double m_dStartIterUnconsFineAllCells
Depth (m) of fine unconsolidated sediment at the start of the simulation, all cells (both inside and ...
Definition simulation.h:937
bool m_bSandConsSedSave
Save sand consolidated sediment raster GIS files?
Definition simulation.h:191
bool m_bSedimentInputEventSave
Save sediment inut data?
Definition simulation.h:380
bool m_bHaveCoarseSediment
Does this simulation consider coarse-sized sediment?
Definition simulation.h:77
double m_dRegularSaveInterval
The interval between regular saves, in hours.
Definition simulation.h:640
long double m_ldGTotActualFineBeachErosion
All-simulation total of fine sediment eroded during beach (unconsolidated sediment) movement (m)
bool m_bPolygonUnconsSedGainOrLossSave
Save polygon unconsolidated sediment gain or loss raster GIS files?
Definition simulation.h:245
void MarkPolygonCells(void)
Marks cells of the raster grid that are within each coastal polygon. The flood fill code used here is...
double m_dTimeStep
The length of an iteration (a time step) in hours.
Definition simulation.h:631
unsigned long m_ulTotPotentialPlatformErosionOnProfiles
The number of cells on which on-profile average potential shore platform erosion occurs.
Definition simulation.h:586
bool m_bCliffCollapseDepositionTSSave
Save the cliff collapse deposition time series file?
Definition simulation.h:290
int m_nXMinBoundingBox
The minimum x value of the bounding box.
Definition simulation.h:494
double dGetD50Sand(void) const
Returns the global d50 value for sand sediment.
ofstream PlatformErosionTSStream
Shore platform erosion time series file output stream.
void DoEndOfTimestepTotals(void)
Update and print totals at the end of each timestep.
double m_dCellArea
Area of a cell (in external CRS units)
Definition simulation.h:616
bool m_bDeepWaterWaveAngleAndHeightSave
Save deep water wave angle and wave height raster GIS files?
Definition simulation.h:116
unsigned long m_ulTotPotentialPlatformErosionBetweenProfiles
The number of cells on which between-profile average potential shore platform erosion occurs.
Definition simulation.h:589
double m_dCoastNormalRandSpacingFactor
Random factor for spacing of along-coast normals.
Definition simulation.h:904
double m_dMaxUserInputWaveHeight
Maximum deep water wave height.
Definition simulation.h:718
void AnnounceReadInitialFineConsSedGIS(int const) const
Tells the user that we are now reading the initial fine consolidated sediment depth GIS file.
Definition utils.cpp:559
bool m_bBeachProtectionSave
Save beach protection raster GIS files>
Definition simulation.h:128
double m_dFinalSWL
The end-of-simulation still water (m), is same as m_dOrigSWL unless SWL changes.
Definition simulation.h:661
bool m_bDoBeachSedimentTransport
Simulate unconsolidated sediment (beach) transport?
Definition simulation.h:344
unsigned long m_ulThisIterNumPotentialBeachErosionCells
The number of grid cells on which potential beach (unconsolidated sediment) erosion occurs,...
Definition simulation.h:577
bool m_bFineConsSedSave
Save fine consolidated sediment raster GIS files?
Definition simulation.h:188
bool m_bShadowDowndriftBoundarySave
Save wave shadow downdrift boundary vector GIS files?
Definition simulation.h:275
int m_nCoastSmooth
Which method to use for coast smoothing.
Definition simulation.h:440
bool m_bDeepWaterWavePeriodSave
Save deep water wave period raster GIS files?
Definition simulation.h:239
string m_strInitialLandformFile
Name of initial landform file.
double m_dC_0
Deep water wave speed (m/s)
Definition simulation.h:697
double m_dThisIterCliffCollapseErosionSandCons
This-iteration total of sand consolidated sediment produced by cliff collapse (m^3)
Definition simulation.h:892
bool m_bBeachSedimentChangeNetTSSave
Save the beach (unconsolidated sediment) net change time series file?
Definition simulation.h:302
double m_dThisIterBeachDepositionSand
Total beach deposition (sand unconsolidated sediment) for this iteration (depth in m)
Definition simulation.h:808
int nReadTideDataFile(void)
Reads the tide time series data.
bool m_bCoarseConsSedSave
Save coarse consolidated sediment raster GIS files?
Definition simulation.h:194
bool m_bSeaAreaTSSave
Save the sea area time series file?
Definition simulation.h:278
bool m_bScaleRasterOutput
Scale raster output?
Definition simulation.h:356
double dGetThisIterSWL(void) const
Returns this timestep's still water level.
double m_dThisIterLeftGridUnconsCoarse
Total coarse unconsolidated sediment lost from the grid this iteration (depth in m)
Definition simulation.h:826
double m_dThisIterCliffCollapseErosionSandUncons
This-iteration total of sand unconsolidated sediment produced by cliff collapse (m^3)
Definition simulation.h:883
double m_dD50Fine
The D50 for fine sediment.
Definition simulation.h:727
bool m_bOmitSearchSouthEdge
Omit the south edge of the grid from coast-end searches?
Definition simulation.h:329
bool m_bBeachMaskSave
Save beach mask raster GIS files?
Definition simulation.h:227
bool bOpenLogFile(void)
Opens the log file.
Definition utils.cpp:354
double m_dTotalSandConsInPolygons
Total sand consolidated sediment in all polygons, before polygon-to-polygon movement (only cells in p...
Definition simulation.h:967
unsigned long m_ulIter
The number of the current iteration (time step)
Definition simulation.h:553
void AnnounceLicence(void)
Tells the user about the licence.
Definition utils.cpp:242
bool m_bAvgSuspSedSave
Save average suspended sediment raster GIS files?
Definition simulation.h:176
double m_dBeachSedimentDensity
The density of unconsolidated beach sediment (kg/m**3)
Definition simulation.h:736
int m_nNumPolygonGlobal
Number of global (all coasts) polygons.
Definition simulation.h:482
int nReadRasterBasementDEM(void)
Reads a raster DEM of basement elevation data to the Cell array.
double m_dSimDuration
Duration of simulation, in hours.
Definition simulation.h:628
double m_dTotalFineUnconsInPolygons
Total fine unconsolidated sediment in all polygons, before polygon-to-polygon movement (only cells in...
Definition simulation.h:955
long double m_ldGTotSandDepositionDiff
All-simulation total of shortfall in unconsolidated sand sediment deposition (m, not currently used)
ofstream FloodSetupSurgeTSStream
Flood setup surge time series file output stream.
bool bTimeToQuit(void)
Checks to see if the simulation has gone on too long, amongst other things.
Definition utils.cpp:1292
double m_dTotalFineConsInPolygons
Total fine consolidated sediment in all polygons, before polygon-to-polygon movement (only cells in p...
Definition simulation.h:964
double m_dThisiterUnconsSandInput
Depth (m) of sand unconsolidated sediment added, at this iteration.
Definition simulation.h:925
double m_dExtCRSGridArea
The area of the grid (in external CRS units)
Definition simulation.h:610
int nDoAllPropagateWaves(void)
Simulates wave propagation along all coastline-normal profiles.
bool m_bOutputProfileData
Output profile data?
Definition simulation.h:317
double m_dThisIterDiffWaveSetupSurgeRunupWaterLevel
TODO 007 Info needed.
Definition simulation.h:691
double m_dCellSide
Length of a cell side (in external CRS units)
Definition simulation.h:613
double m_dMaxBeachElevAboveSWL
Maximum elevation of beach above SWL (m)
Definition simulation.h:856
long double m_ldGTotActualSandBeachErosion
All-simulation total of sand sediment eroded during beach (unconsolidated sediment) movement (m)
bool m_bRasterNormalSave
Save raster coastline-normal GIS files?
Definition simulation.h:200
double m_dBreakingWaveHeight
The height of breaking waves (m)
Definition simulation.h:694
void AnnounceProgress(void)
Displays information regarding the progress of the simulation.
Definition utils.cpp:1601
bool m_bTotCliffCollapseDepositionSave
Save total cliff collapse deposition raster GIS files?
Definition simulation.h:215
double m_dAllCellsDeepWaterWavePeriod
Deep water wave period for all sea cells.
Definition simulation.h:715
double m_dThisIterCliffCollapseCoarseErodedDuringDeposition
Total coarse sediment eroded during Dean profile deposition of talus following cliff collapse (depth ...
Definition simulation.h:835
int nMarkBoundingBoxEdgeCells(void)
Mark cells which are at the edge of a bounding box which represents the valid part of the grid,...
long double m_ldGTotSandBeachDeposition
All-simulation total of sand sediment deposited during beach (unconsolidated sediment) movement (m)
double m_dUSaveTime[SAVEMAX]
Save time, in hours from the start of the simukation, if we are not saving regularly.
Definition simulation.h:643
void AnnounceReadLGIS(void) const
Tells the user that we are now reading the Landscape category GIS file.
Definition utils.cpp:423
int m_nCoastNormalAvgSpacing
Average spacing between cost normals, measured in cells.
Definition simulation.h:452
double m_dThisIterTopElevMax
This-iteration highest elevation of DEM.
Definition simulation.h:916
double m_dThisIterActualPlatformErosionFineCons
Total actual platform erosion (fine consolidated sediment) for this iteration (depth in m)
Definition simulation.h:787
long double m_ldGTotPotentialBeachErosion
All-simulation total of potential beach erosion (m), all size classes.
double m_dProfileMaxSlope
Maximum slope on costline-normal profiles.
Definition simulation.h:853
int m_nProfileSmoothWindow
The size of the window used for running-mean coast-normal profile smoothing (must be odd)
Definition simulation.h:449
bool m_bDoCliffCollapse
Simulate cliff collapse?
Definition simulation.h:341
static void AnnounceReadVectorFiles(void)
Now reading vector GIS files.
Definition utils.cpp:415
double m_dThisIterCliffCollapseErosionCoarseCons
This-iteration total of coarse consolidated sediment produced by cliff collapse (m^3)
Definition simulation.h:895
double m_dThisIterLeftGridUnconsSand
Total sand unconsolidated sediment lost from the grid this iteration (depth in m)
Definition simulation.h:823
unsigned long m_ulRandSeed[NRNG]
A seed for each of the NRNG random number generators.
Definition simulation.h:559
double m_dDepthOfClosure
Depth of closure (in m) TODO 007 can be calculated using Hallermeier, R.J. (1978) or Birkemeier (1985...
Definition simulation.h:772
int nCheckAllProfiles(void)
Check all coastline-normal profiles and modify the profiles if they intersect, then mark valid profil...
int nInitGridAndCalcStillWaterLevel(void)
At the beginning of each timestep: clear vector coasts, profiles, and polygons, initialize the raster...
Definition init_grid.cpp:46
double m_dOrigSWL
The start-of-simulation still water level (m)
Definition simulation.h:658
double m_dStartIterSuspFineAllCells
Depth (m) of fine suspended sediment at the start of the simulation, all cells (both inside and outsi...
Definition simulation.h:931
string m_strOutFile
Name of main output file.
bool m_bSetupSurgeRunupFloodMaskSave
Are we saving the setup surge runup flood mask? TODO 007.
Definition simulation.h:401
double m_dThisIterDiffTotWaterLevel
TODO 007 Info needed.
Definition simulation.h:682
vector< bool > m_bConsChangedThisIter
One element per layer: has the consolidated sediment of this layer been changed during this iteration...
ofstream FineSedSuspensionTSStream
Fine sediment in suspension time series file output stream.
ofstream FloodSetupSurgeRunupTSStream
Flood setup surge runup time series file output stream.
bool m_bWaveSetupSave
Are we saving the wave setup? TODO 007.
Definition simulation.h:389
int nDoPolygonSharedBoundaries(void)
For between-polygon potential sediment routing: find which are the adjacent polygons,...
void AnnounceReadTideData(void) const
Now reading tide data file.
Definition utils.cpp:598
double m_dClkLast
Last value returned by clock()
Definition simulation.h:646
bool m_bShadowZoneCodesSave
Save wave shadow zones raster GIS files?
Definition simulation.h:230
long double m_ldGTotFineSedimentInput
All-simulation total of fine sediment input (m)
double m_dThisIterMeanSWL
The mean still water level for this timestep (does not include tidal changes, but includes any long-t...
Definition simulation.h:670
bool m_bCliffCollapseErosionTSSave
Save the cliff collapse erosion time series file?
Definition simulation.h:287
bool m_bPotentialPlatformErosionSave
Save potential shore platform erosion raster GIS files?
Definition simulation.h:131
long double m_ldGTotPotentialPlatformErosion
All-simulation total of potential platform erosion (m), all size classes.
Definition simulation.h:981
GDALDataType m_GDALWriteFloatDataType
Thw data type used by GDAL for floating point operations, can be GDT_Byte, GDT_Int16,...
Definition simulation.h:544
bool m_bGDALCanWriteFloat
Is the selected GDAL output file format capable of writing floating-point values to files?
Definition simulation.h:350
void AnnounceReadInitialCoarseUnconsSedGIS(int const) const
Tells the user that we are now reading the initial coarse unconsolidated sediment depth GIS file.
Definition utils.cpp:546
int nHandleCommandLineParams(int, char const *[])
Handles command-line parameters.
Definition utils.cpp:86
long double m_ldGTotCliffCollapseSand
All-simulation total of sand sediment from cliff collapse (m)
char ** m_papszGDALRasterOptions
Options for GDAL when handling raster files.
Definition simulation.h:425
ofstream OutStream
The main output file stream.
double m_dDurationUnitsMult
Multiplier for duration units, to convert to hours.
Definition simulation.h:595
bool m_bFloodSWLSetupSurgeRunupLine
Are we saving the flood still water level setup surge runup line? TODO 007.
Definition simulation.h:419
unsigned long m_ulTotTimestep
The target number of iterations.
Definition simulation.h:556
bool m_bOutputParallelProfileData
Output parallel profile data?
Definition simulation.h:320
double m_dKamphuis
Transport parameter for the Kamphuis equation.
Definition simulation.h:763
bool m_bOutputErosionPotentialData
Output erosion potential data?
Definition simulation.h:323
int m_nLevel
TODO 007 Used in WAVESETUP + SURGE + RUNUP.
Definition simulation.h:536
bool m_bSedimentInputThisIter
Do we have a sediment input event this iteration?
Definition simulation.h:383
bool m_bCliffNotchSave
Save cliff notch incision depth vector GIS files?
Definition simulation.h:269
bool m_bVectorWaveFloodLineSave
Are we saving the vector wave flood line? TODO 007.
Definition simulation.h:407
bool m_bWaveAngleSave
Save wave angle raster GIS files?
Definition simulation.h:104
bool m_bOmitSearchEastEdge
Omit the east edge of the grid from coast-end searches?
Definition simulation.h:335
int m_nCoastSmoothWindow
The size of the window used for coast smoothing. Must be an odd number.
Definition simulation.h:443
double m_dThisIterLeftGridUnconsFine
Total fine unconsolidated sediment lost from the grid this iteration (depth in m)
Definition simulation.h:820
bool m_bLocalSlopeSave
Save local slope raster GIS files?
Definition simulation.h:164
This file contains global definitions for CoastalME.
int const INT_NODATA
Definition cme.h:362
T tMin(T a, T b)
Definition cme.h:1136
double const TOLERANCE
Definition cme.h:698
int const SAND_CONS_RASTER
Definition cme.h:454
int const SEDIMENT_INPUT_EVENT_LOCATION_VEC
Definition cme.h:481
string const ERR
Definition cme.h:775
int const RTN_ERR_LOGFILE
Definition cme.h:587
int const RTN_ERR_RASTER_GIS_OUT_FORMAT
Definition cme.h:594
int const RTN_ERR_RASTER_FILE_WRITE
Definition cme.h:597
int const LOG_FILE_MIDDLE_DETAIL
Definition cme.h:377
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
Definition cme.h:1176
int const RTN_ERR_PROFILESPACING
Definition cme.h:601
int const FLOOD_LOCATION_VEC
Definition cme.h:486
int const DEEP_WATER_WAVE_STATIONS_VEC
Definition cme.h:478
int const RTN_ERR_RUNDATA
Definition cme.h:584
double const MASS_BALANCE_TOLERANCE
Definition cme.h:700
T tMax(T a, T b)
Definition cme.h:1123
int const RTN_ERR_TSFILE
Definition cme.h:589
int const INTERVENTION_CLASS_RASTER
Definition cme.h:461
int const RTN_ERR_VECTOR_GIS_OUT_FORMAT
Definition cme.h:595
int const RTN_USER_ABORT
Definition cme.h:580
int const SMOOTH_SAVITZKY_GOLAY
Definition cme.h:657
int const RTN_ERR_CMEDIR
Definition cme.h:583
int const RTN_ERR_INI
Definition cme.h:582
int const RTN_OK
Definition cme.h:577
int const RTN_ERR_TEXT_FILE_WRITE
Definition cme.h:596
int const RTN_ERR_VECTOR_FILE_WRITE
Definition cme.h:598
int const SAND_UNCONS_RASTER
Definition cme.h:457
int const FINE_UNCONS_RASTER
Definition cme.h:456
int const COARSE_UNCONS_RASTER
Definition cme.h:458
double const DBL_NODATA
Definition cme.h:707
int const RTN_ERR_OUTFILE
Definition cme.h:588
int const SUSP_SED_RASTER
Definition cme.h:459
int const FINE_CONS_RASTER
Definition cme.h:453
int const COARSE_CONS_RASTER
Definition cme.h:455
int const COAST_LENGTH_MAX
Definition cme.h:354
int const MIN_PROFILE_SPACING
Definition cme.h:371
int const LANDFORM_RASTER
Definition cme.h:460
int const INTERVENTION_HEIGHT_RASTER
Definition cme.h:462
int const RTN_ERR_TIMESERIES_FILE_WRITE
Definition cme.h:599
Contains CRWCoast definitions.
Contains CGeomRasterGrid definitions.
Contains CSimulation definitions.
int const SAVEMAX
Definition simulation.h:57
int const NRNG
Definition simulation.h:56
int nRound(double const d)
Version of the above that returns an int.