43using std::resetiosflags;
44using std::setiosflags;
45using std::setprecision;
50using std::reverse_copy;
65 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
67 int nDistFromPrevProfile = 0;
68 int nDistToNextProfile = 0;
70 double dPrevProfileDeepWaterWaveHeight = 0;
71 double dPrevProfileDeepWaterWaveAngle = 0;
72 double dPrevProfileDeepWaterWavePeriod = 0;
73 double dNextProfileDeepWaterWaveHeight = 0;
74 double dNextProfileDeepWaterWaveAngle = 0;
75 double dNextProfileDeepWaterWavePeriod = 0;
78 for (
int nPoint = 0; nPoint <
m_VCoast[nCoast].nGetCoastlineSize(); nPoint++)
81 if (
m_VCoast[nCoast].bIsProfileAtCoastPoint(nPoint))
91 m_VCoast[nCoast].SetCoastDeepWaterWaveHeight(nPoint, dThisDeepWaterWaveHeight);
92 m_VCoast[nCoast].SetCoastDeepWaterWaveAngle(nPoint, dThisDeepWaterWaveAngle);
93 m_VCoast[nCoast].SetCoastDeepWaterWavePeriod(nPoint, dThisDeepWaterWavePeriod);
96 nDistFromPrevProfile = 0;
97 dPrevProfileDeepWaterWaveHeight = dThisDeepWaterWaveHeight;
98 dPrevProfileDeepWaterWaveAngle = dThisDeepWaterWaveAngle;
99 dPrevProfileDeepWaterWavePeriod = dThisDeepWaterWavePeriod;
103 if (pNextProfile == NULL)
111 dDist = nDistToNextProfile;
124 nDistFromPrevProfile++;
125 nDistToNextProfile--;
127 double dPrevWeight = (dDist - nDistFromPrevProfile) / dDist;
128 double dNextWeight = (dDist - nDistToNextProfile) / dDist;
129 double dThisDeepWaterWaveHeight = (dPrevWeight * dPrevProfileDeepWaterWaveHeight) + (dNextWeight * dNextProfileDeepWaterWaveHeight);
130 double dThisDeepWaterWaveAngle =
dKeepWithin360((dPrevWeight * dPrevProfileDeepWaterWaveAngle) + (dNextWeight * dNextProfileDeepWaterWaveAngle));
131 double dThisDeepWaterWavePeriod = (dPrevWeight * dPrevProfileDeepWaterWavePeriod) + (dNextWeight * dNextProfileDeepWaterWavePeriod);
133 m_VCoast[nCoast].SetCoastDeepWaterWaveHeight(nPoint, dThisDeepWaterWaveHeight);
134 m_VCoast[nCoast].SetCoastDeepWaterWaveAngle(nPoint, dThisDeepWaterWaveAngle);
135 m_VCoast[nCoast].SetCoastDeepWaterWavePeriod(nPoint, dThisDeepWaterWavePeriod);
151 vector<bool> VbBreakingAll;
153 vector<double> VdXAll;
154 vector<double> VdYAll;
155 vector<double> VdHeightXAll;
156 vector<double> VdHeightYAll;
159 bool bSomeNonStartOrEndOfCoastProfiles =
false;
160 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
162 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
163 int nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
165 static bool bDownCoast =
true;
168 for (
int nn = 0; nn < nNumProfiles; nn++)
170 vector<bool> VbBreaking;
173 vector<double> VdHeightX;
174 vector<double> VdHeightY;
179 pProfile =
m_VCoast[nCoast].pGetProfileWithDownCoastSeq(nn);
181 pProfile =
m_VCoast[nCoast].pGetProfileWithUpCoastSeq(nn);
202 if (VbBreaking.empty())
209 bSomeNonStartOrEndOfCoastProfiles =
true;
221 VdXAll.insert(VdXAll.end(), VdX.begin(), VdX.end());
222 VdYAll.insert(VdYAll.end(), VdY.begin(), VdY.end());
223 VdHeightXAll.insert(VdHeightXAll.end(), VdHeightX.begin(), VdHeightX.end());
224 VdHeightYAll.insert(VdHeightYAll.end(), VdHeightY.begin(), VdHeightY.end());
225 VbBreakingAll.insert(VbBreakingAll.end(), VbBreaking.begin(), VbBreaking.end());
228 bDownCoast = ! bDownCoast;
232 if (! bSomeNonStartOrEndOfCoastProfiles)
234 LogStream <<
m_ulIter <<
": waves are on-shore only, for start and/or end of coast profiles" << endl;
240 double dDeepWaterWaveX;
241 double dDeepWaterWaveY;
258 VdXAll.push_back(nX);
264 dDeepWaterWaveX =
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveHeight() * sin(
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveAngle() *
PI / 180);
265 dDeepWaterWaveY =
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveHeight() * cos(
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveAngle() *
PI / 180);
268 VdHeightXAll.push_back(dDeepWaterWaveX);
269 VdHeightYAll.push_back(dDeepWaterWaveY);
279 VdXAll.push_back(nX);
289 VdHeightXAll.push_back(dDeepWaterWaveX);
290 VdHeightYAll.push_back(dDeepWaterWaveY);
304 VdYAll.push_back(nY);
309 dDeepWaterWaveX =
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveHeight() * sin(
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveAngle() *
PI / 180);
310 dDeepWaterWaveY =
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveHeight() * cos(
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveAngle() *
PI / 180);
313 VdHeightXAll.push_back(dDeepWaterWaveX);
314 VdHeightYAll.push_back(dDeepWaterWaveY);
325 VdYAll.push_back(nY);
334 VdHeightXAll.push_back(dDeepWaterWaveX);
335 VdHeightYAll.push_back(dDeepWaterWaveY);
350 if (VbBreakingAll.empty())
499 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
501 int nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
503 for (
int nProfile = 0; nProfile < nNumProfiles; nProfile++)
572 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
574 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
575 int nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
578 for (
int n = 0; n < nNumProfiles - 1; n++)
585 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize; nCoastPoint++)
588 double dBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nCoastPoint);
589 double dCoastPointWavePeriod =
m_VCoast[nCoast].dGetCoastDeepWaterWavePeriod(nCoastPoint);
594 m_VCoast[nCoast].SetBreakingWaveHeight(nCoastPoint, 0);
601 double dWaveEnergy = dErosiveWaveForce *
m_dTimeStep * 3600;
602 m_VCoast[nCoast].SetWaveEnergyAtBreaking(nCoastPoint, dWaveEnergy);
614 double dWaveToNormalAngle = 0;
618 dWaveToNormalAngle = fmod((dWaveAngle - dCoastAngle + 360), 360) - 90;
621 dWaveToNormalAngle = fmod((dWaveAngle - dCoastAngle + 360), 360) - 270;
623 if ((dWaveToNormalAngle >= 90) || (dWaveToNormalAngle <= -90))
626 return dWaveToNormalAngle;
649 int nSeaHand =
m_VCoast[nCoast].nGetSeaHandedness();
653 double dFluxOrientationThis =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint);
654 double dFluxOrientationPrev = 0;
655 double dFluxOrientationNext = 0;
657 if (nCoastPoint == 0)
659 dFluxOrientationPrev = dFluxOrientationThis;
660 dFluxOrientationNext =
m_VCoast[nCoast].dGetFluxOrientation(1);
662 else if (nCoastPoint == nCoastSize - 1)
664 dFluxOrientationPrev =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint - 2);
665 dFluxOrientationNext = dFluxOrientationThis;
669 dFluxOrientationPrev =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint - 1);
670 dFluxOrientationNext =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint + 1);
691 double dWaveToNormalAnglePrev;
695 double dPrevDeepWaterWaveAngle =
m_VCoast[nCoast].dGetCoastDeepWaterWaveAngle(nCoastPoint - 1);
701 dWaveToNormalAnglePrev = dWaveToNormalAngle;
710 double dWaveToNormalAngleNext;
711 if (nCoastPoint < nCoastSize - 1)
714 double dNextDeepWaterWaveAngle =
m_VCoast[nCoast].dGetCoastDeepWaterWaveAngle(nCoastPoint + 1);
720 dWaveToNormalAngleNext = dWaveToNormalAngle;
731 if (dWaveToNormalAngle > 45)
733 if (dWaveToNormalAnglePrev < 45)
735 dWaveToNormalAngle = 45;
740 dWaveToNormalAngle = dWaveToNormalAnglePrev;
747 if (dWaveToNormalAngle < -45)
749 if (dWaveToNormalAngleNext > -45)
751 dWaveToNormalAngle = -45;
756 dWaveToNormalAngle = dWaveToNormalAngleNext;
766 dWaveToNormalAngle = dFluxOrientationPrev;
773 dWaveToNormalAngle = dFluxOrientationNext;
777 bool bBreaking =
false;
780 int nProfileBreakingDist = 0;
782 double dProfileBreakingWaveHeight =
DBL_NODATA;
783 double dProfileBreakingWaveAngle = 0;
784 double dProfileBreakingDepth = 0;
790 vector<bool> VbWaveIsBreaking(nProfileSize, 0);
792 vector<double> VdWaveHeight(nProfileSize, 0);
793 vector<double> VdWaveSetupSurge(nProfileSize, 0);
795 vector<double> VdWaveSetupRunUp(nProfileSize, 0);
796 vector<double> VdWaveDirection(nProfileSize, 0);
801 double dCShoreTimeStep = 3600;
805 vector<double> VdProfileZ;
806 vector<double> VdProfileDistXY;
807 vector<double> VdProfileFrictionFactor;
823 if (VdProfileDistXY.empty())
832 dWaveToNormalAngle =
tMax(dWaveToNormalAngle, -80.0);
833 dWaveToNormalAngle =
tMin(dWaveToNormalAngle, 80.0);
835 int nProfileDistXYSize =
static_cast<int>(VdProfileDistXY.size());
836 vector<double> VdFreeSurfaceStd(nProfileDistXYSize, 0);
837 vector<double> VdSinWaveAngleRadians(nProfileDistXYSize, 0);
838 vector<double> VdFractionBreakingWaves(nProfileDistXYSize, 0);
852 double dDX = VdProfileDistXY.back() / (
static_cast<double>(VdProfileDistXY.size() - 1));
853 double dWaveInitTime = 0;
854 double dSurgeInitTime = 0;
856#if defined CSHORE_FILE_INOUT || CSHORE_BOTH
863#if defined CSHORE_FILE_INOUT
865 nRet =
nCreateCShoreInfile(nCoast, nProfile, nILine, nIProfl, nIPerm, nIOver, nIWCInt, nIRoll, nIWind, nITide, nILab, nNWave, nNSurge, dDX, dCShoreTimeStep, dWaveInitTime, dDeepWaterWavePeriod, dProfileDeepWaterWaveHeight, dWaveToNormalAngle, dSurgeInitTime, dSurgeLevel, &VdProfileDistXY, &VdProfileZ, &VdProfileFrictionFactor);
884 strErr = to_string(
m_ulIter) +
": CShore WARNING 1: negative depth at the first node ";
888 strErr = to_string(
m_ulIter) +
": CShore WARNING 2: negative value at end of landward marching computation ";
892 strErr = to_string(
m_ulIter) +
": CShore WARNING 3: large energy gradients at the first node: small waves with short period at sea boundary ";
896 strErr = to_string(
m_ulIter) +
": CShore WARNING 4: zero energy at the first node ";
900 strErr = to_string(
m_ulIter) +
": CShore WARNING 5: at end of landward marching computation, insufficient water depth ";
904 strErr = to_string(
m_ulIter) +
": CShore WARNING 7: did not reach convergence ";
908 strErr +=
"(coast " + to_string(nCoast) +
" profile " + to_string(pProfile->
nGetCoastID()) +
" profile length " + to_string(nOutSize) +
")\n";
917 string strOSETUP =
"OSETUP";
918 string strOYVELO =
"OYVELO";
919 string strOPARAM =
"OPARAM";
921 nRet =
nReadCShoreOutput(nProfile, &strOSETUP, 4, 4, &VdProfileDistXY, &VdFreeSurfaceStd);
925 nRet =
nReadCShoreOutput(nProfile, &strOYVELO, 4, 2, &VdProfileDistXY, &VdSinWaveAngleRadians);
929 nRet =
nReadCShoreOutput(nProfile, &strOPARAM, 4, 3, &VdProfileDistXY, &VdFractionBreakingWaves);
939 nRet = system(
"./clean.bat");
943 string strCommand =
"./save_CShore_output.sh ";
946 strCommand += to_string(nCoast);
948 strCommand += to_string(nProfile);
950 nRet = system(strCommand.c_str());
955 nRet = system(
"./clean.sh");
966#if defined CSHORE_ARG_INOUT || CSHORE_BOTH
973 vector<double> VdInitTime = {dWaveInitTime, dCShoreTimeStep};
974 vector<double> VdTPIn = {dDeepWaterWavePeriod, dDeepWaterWavePeriod};
975 vector<double> VdHrmsIn = {dProfileDeepWaterWaveHeight, dProfileDeepWaterWaveHeight};
976 vector<double> VdWangIn = {dWaveToNormalAngle, dWaveToNormalAngle};
977 vector<double> VdTSurg = {dSurgeInitTime, dCShoreTimeStep};
978 vector<double> VdSWLin = {dSurgeLevel, dSurgeLevel};
979 vector<double> VdFPInp = VdProfileFrictionFactor;
1010 &nProfileDistXYSize,
1011 &VdProfileDistXY[0],
1016 &VdXYDistFromCShoreOut[0],
1017 &VdFreeSurfaceStdOut[0],
1018 &VdWaveSetupSurgeOut[0],
1019 &VdSinWaveAngleRadiansOut[0],
1020 &VdFractionBreakingWavesOut[0]);
1027 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for coast " << nCoast <<
" profile " << pProfile->
nGetCoastID() <<
", only " << nOutSize <<
" CShore output rows, abandoning this profile" << endl;
1051 strErr = to_string(
m_ulIter) +
": CShore WARNING 1: negative depth at the first node ";
1055 strErr = to_string(
m_ulIter) +
": CShore WARNING 2: negative value at end of landward marching computation ";
1059 strErr = to_string(
m_ulIter) +
": CShore WARNING 3: large energy gradients at the first node: small waves with short period at sea boundary ";
1063 strErr = to_string(
m_ulIter) +
": CShore WARNING 4: zero energy at the first node ";
1067 strErr = to_string(
m_ulIter) +
": CShore WARNING 5: at end of landward marching computation, insufficient water depth ";
1071 strErr = to_string(
m_ulIter) +
": CShore WARNING 7: did not reach convergence ";
1075 strErr +=
"(coast " + to_string(nCoast) +
" profile " + to_string(pProfile->
nGetCoastID()) +
" profile length " + to_string(nOutSize) +
")\n";
1085 InterpolateCShoreOutput(&VdProfileDistXY, nOutSize, nProfileSize, &VdXYDistFromCShoreOut, &VdFreeSurfaceStdOut, &VdWaveSetupSurgeOut, &VdSinWaveAngleRadiansOut, &VdFractionBreakingWavesOut, &VdFreeSurfaceStd, &VdWaveSetupSurge, &VdSinWaveAngleRadians, &VdFractionBreakingWaves);
1088#if defined CSHORE_BOTH
1089 #if ! defined _WIN32
1092 string strCommand =
"./save_CShore_output.sh ";
1095 strCommand += to_string(nCoast);
1097 strCommand += to_string(nProfile);
1099 nRet = system(strCommand.c_str());
1112 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1118 if (nProfilePoint >
static_cast<int>(VdFreeSurfaceStd.size()) - 1)
1122 if (isnan(VdFreeSurfaceStd[nProfilePoint]))
1123 VdFreeSurfaceStd[nProfilePoint] = 0;
1125 VdWaveHeight[nProfilePoint] = sqrt(8) * VdFreeSurfaceStd[nProfilePoint];
1128 if (isnan(VdSinWaveAngleRadians[nProfilePoint]))
1130 VdSinWaveAngleRadians[nProfilePoint] = 0;
1131 VdWaveHeight[nProfilePoint] = 0;
1135 if (VdSinWaveAngleRadians[nProfilePoint] < -1)
1136 VdSinWaveAngleRadians[nProfilePoint] = -1;
1137 if (VdSinWaveAngleRadians[nProfilePoint] > 1)
1138 VdSinWaveAngleRadians[nProfilePoint] = 1;
1140 double dAlpha = asin(VdSinWaveAngleRadians[nProfilePoint]) * (180 /
PI);
1142 VdWaveDirection[nProfilePoint] =
dKeepWithin360(dAlpha + 90 + dFluxOrientationThis);
1144 VdWaveDirection[nProfilePoint] =
dKeepWithin360(dAlpha + 270 + dFluxOrientationThis);
1147 if (isnan(VdFractionBreakingWaves[nProfilePoint]))
1149 VdFractionBreakingWaves[nProfilePoint] = 0;
1150 VdWaveHeight[nProfilePoint] = 0;
1158 dProfileBreakingWaveHeight = VdWaveHeight[nProfilePoint];
1159 dProfileBreakingWaveAngle = VdWaveDirection[nProfilePoint];
1160 dProfileBreakingDepth =
m_pRasterGrid->m_Cell[nX][nY].dGetSeaDepth();
1161 nProfileBreakingDist = nProfilePoint + 1;
1166 VbWaveIsBreaking[nProfilePoint] = bBreaking;
1169 if (dProfileBreakingWaveHeight >= dProfileDeepWaterWaveHeight)
1181 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1190 double dSeaDepth =
m_pRasterGrid->m_Cell[nX][nY].dGetSeaDepth();
1191 if (dSeaDepth > dDepthLookupMax)
1194 dProfileWaveHeight = dProfileDeepWaterWaveHeight;
1195 dProfileWaveAngle = dProfileDeepWaterWaveAngle;
1203 double dC =
m_dC_0 * tanh((2 *
PI * dSeaDepth) / dL);
1204 double dk = 2 *
PI / dL;
1205 double dn = ((2 * dSeaDepth * dk) / (sinh(2 * dSeaDepth * dk)) + 1) / 2;
1206 double dKs = sqrt(
m_dC_0 / (dn * dC * 2));
1207 double dAlpha = (180 /
PI) * asin((dC /
m_dC_0) * sin((
PI / 180) * dWaveToNormalAngle));
1208 double dKr = sqrt(cos((
PI / 180) * dWaveToNormalAngle) / cos((
PI / 180) * dAlpha));
1209 dProfileWaveHeight = dProfileDeepWaterWaveHeight * dKs * dKr;
1211 dProfileWaveAngle =
dKeepWithin360(dAlpha + 90 + dFluxOrientationThis);
1213 dProfileWaveAngle =
dKeepWithin360(dAlpha + 270 + dFluxOrientationThis);
1218 dProfileBreakingWaveHeight = dProfileWaveHeight;
1219 dProfileBreakingWaveAngle = dProfileWaveAngle;
1228 dProfileWaveAngle = dProfileBreakingWaveAngle;
1230 dProfileWaveHeight = dProfileBreakingWaveHeight * (nProfilePoint / nProfileBreakingDist);
1232 dProfileBreakingDepth = dSeaDepth;
1233 nProfileBreakingDist = nProfilePoint;
1238 VdWaveDirection[nProfilePoint] = dProfileWaveAngle;
1239 VdWaveHeight[nProfilePoint] = dProfileWaveHeight;
1240 VbWaveIsBreaking[nProfilePoint] = bBreaking;
1245 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1255 double dWaveHeight = VdWaveHeight[nProfilePoint];
1256 double dWaveAngle = VdWaveDirection[nProfilePoint];
1258 bBreaking = VbWaveIsBreaking[nProfilePoint];
1261 pVdX->push_back(nX);
1262 pVdY->push_back(nY);
1263 pVdHeightX->push_back(dWaveHeight * sin(dWaveAngle *
PI / 180));
1264 pVdHeightY->push_back(dWaveHeight * cos(dWaveAngle *
PI / 180));
1265 pVbBreaking->push_back(bBreaking);
1286 double dDiffProfileDistXY = hypot(dXDist, dYDist);
1292 int nValidPointsWaveHeight = 0;
1293 int nValidPointsWaveSetup = 0;
1295 for (
int nPoint = 0; nPoint < static_cast<int>(VdWaveHeight.size()); nPoint++)
1297 if (VdWaveHeight[nPoint] > 1e-4)
1299 nValidPointsWaveHeight += 1;
1306 nValidPointsWaveHeight -= 1;
1309 for (
int nPoint = 0; nPoint < static_cast<int>(VdWaveSetupSurge.size()); nPoint++)
1311 if (
tAbs(VdWaveSetupSurge[nPoint]) < 1)
1313 nValidPointsWaveSetup += 1;
1320 nValidPointsWaveSetup -= 1;
1322 double dWaveHeight = 0;
1327 dWaveHeight = VdWaveHeight[nValidPointsWaveHeight];
1335 dRunUp = 0.36 * pow(9.81, 0.5) * dtanBeta * pow(dWaveHeight, 0.5) * dDeepWaterWavePeriod;
1340 double dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1341 dRunUp = 1.86 * dWaveHeight * pow(pow(dtanBeta / dS0, 0.5), 0.71);
1346 double dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1349 double dH0OverL0 = (1 / dS0) * dWaveHeight;
1350 double dTmp1 = 0.35 * dWaveHeight * pow(dH0OverL0, 0.5);
1351 double dTmp2 = pow(dH0OverL0 * ((0.563 * dWaveHeight * dWaveHeight) + 0.0004), 0.5);
1352 dRunUp = 1.1 * (dTmp1 + (dTmp2 / 2));
1355 if ((
tAbs(dRunUp) < 1e-4) || (isnan(dRunUp)))
1360 double dWaveSetupSurge = 0;
1365 dWaveSetupSurge = VdWaveSetupSurge[nValidPointsWaveSetup];
1368 if ((
tAbs(dWaveSetupSurge) < 1e-4) || (isnan(dWaveSetupSurge)))
1370 dWaveSetupSurge = 0;
1375 m_VCoast[nCoast].SetCoastWaveHeight(nCoastPoint, dWaveHeight);
1376 m_VCoast[nCoast].SetWaveSetupSurge(nCoastPoint, dWaveSetupSurge);
1377 m_VCoast[nCoast].SetRunUp(nCoastPoint, dRunUp);
1379 if (nProfileBreakingDist > 0)
1382 m_VCoast[nCoast].SetBreakingWaveHeight(nCoastPoint, dProfileBreakingWaveHeight);
1383 m_VCoast[nCoast].SetBreakingWaveAngle(nCoastPoint, dProfileBreakingWaveAngle);
1384 m_VCoast[nCoast].SetDepthOfBreaking(nCoastPoint, dProfileBreakingDepth);
1385 m_VCoast[nCoast].SetBreakingDistance(nCoastPoint, nProfileBreakingDist);
1403#if defined CSHORE_FILE_INOUT
1407int CSimulation::nCreateCShoreInfile(
int const nCoast,
int const nProfile,
int const nILine,
int const nIProfl,
int const nIPerm,
int const nIOver,
int const nIWcint,
int const nIRoll,
int const nIWind,
int const nITide,
int const nILab,
int const nWave,
int const nSurge,
double const dX,
double const dTimestep,
double const dWaveInitTime,
double const dWavePeriod,
double const dHrms,
double const dWaveAngle,
double const dSurgeInitTime,
double const dSurgeLevel, vector<double>
const* pVdXdist, vector<double>
const* pVdBottomElevation, vector<double>
const* pVdWaveFriction)
1410 ofstream CShoreOutStream;
1411 CShoreOutStream.open(
CSHORE_INFILE.c_str(), ios::out | ios::app);
1412 if (CShoreOutStream.fail())
1420 CShoreOutStream << 3 << endl;
1421 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1422 CShoreOutStream <<
"CShore input file created by CoastalME for iteration " <<
m_ulIter <<
", coast " << nCoast <<
", profile " << nProfile << endl;
1423 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1424 CShoreOutStream << nILine <<
" -> ILINE" << endl;
1425 CShoreOutStream << nIProfl <<
" -> IPROFL" << endl;
1426 CShoreOutStream << nIPerm <<
" -> IPERM" << endl;
1427 CShoreOutStream << nIOver <<
" -> IOVER" << endl;
1428 CShoreOutStream << nIWcint <<
" -> IWCINT" << endl;
1429 CShoreOutStream << nIRoll <<
" -> IROLL" << endl;
1430 CShoreOutStream << nIWind <<
" -> IWIND" << endl;
1431 CShoreOutStream << nITide <<
" -> ITIDE" << endl;
1432 CShoreOutStream << fixed;
1433 CShoreOutStream << setw(11) << setprecision(4) << dX <<
" -> DX" << endl;
1435 CShoreOutStream << setw(11) << nILab <<
" -> ILAB" << endl;
1436 CShoreOutStream << setw(11) << nWave <<
" -> NWAVE" << endl;
1437 CShoreOutStream << setw(11) << nSurge <<
" -> NSURGE" << endl;
1440 CShoreOutStream << setw(11) << setprecision(2) << dWaveInitTime;
1441 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1442 CShoreOutStream << setw(11) << dHrms;
1443 CShoreOutStream << setw(11) << dWaveAngle << endl;
1446 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1447 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1448 CShoreOutStream << setw(11) << dHrms;
1449 CShoreOutStream << setw(11) << dWaveAngle << endl;
1452 CShoreOutStream << setw(11) << setprecision(2) << dSurgeInitTime;
1453 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1456 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1457 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1460 CShoreOutStream << setw(8) << pVdXdist->size() <<
" -> NBINP" << endl;
1462 CShoreOutStream << fixed << setprecision(4);
1463 for (
unsigned int i = 0; i < pVdXdist->size(); i++)
1465 CShoreOutStream << setw(11) << pVdXdist->at(i) << setw(11) << pVdBottomElevation->at(i) << setw(11) << pVdWaveFriction->at(i) << endl;
1467 CShoreOutStream << endl;
1470 CShoreOutStream.close();
1481 bool bIsBehindIntervention =
false;
1488 double dProfileDistXY = 0;
1489 double dProfileFricFact;
1490 double dPrevDist = -1;
1492 for (
int i = nProfSize - 1; i >= 0; i--)
1498 if (i == nProfSize - 1)
1504 dProfileDistXY = dProfileDistXY + hypot(dXDist, dYDist);
1509 dProfileDistXY += 0.1;
1516 int const nTopLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
1527 double dTopElev =
m_pRasterGrid->m_Cell[nX][nY].dGetSedimentTopElev() +
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1535 VdVZ->push_back(0.1);
1538 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for coast " << nCoast <<
", profile " << pProfile->
nGetCoastID() <<
", elevation at the landward end is " << dTopElev <<
" m. This is lower than this-iteration SWL (" <<
m_dThisIterSWL <<
" m). For CShore, changing the landward elevation for profile " << pProfile->
nGetCoastID() <<
" to " <<
m_dThisIterSWL + 0.1 <<
"m" << endl;
1542 VdVZ->push_back(VdProfileZ);
1547 VdVZ->push_back(VdProfileZ);
1551 VdDistXY->push_back(dProfileDistXY);
1554 double dInterventionHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1557 if (dInterventionHeight > 0 || bIsBehindIntervention)
1561 bIsBehindIntervention =
true;
1567 VdFricF->push_back(dProfileFricFact);
1570 dPrevDist = dProfileDistXY;
1576#if defined CSHORE_FILE_INOUT
1580int CSimulation::nReadCShoreOutput(
int const nProfile,
string const *strCShoreFilename,
int const nExpectedColumns,
int const nCShorecolumn, vector<double>
const* pVdProfileDistXYCME, vector<double>* pVdInterpolatedValues)
1584 InStream.open(strCShoreFilename->c_str(), ios::in);
1587 if (! InStream.is_open())
1590 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", cannot open " << *strCShoreFilename <<
" for input" << endl;
1596 vector<double> VdXYDistCShore;
1597 vector<double> VdValuesCShore;
1601 int nExpectedRows = 0;
1603 while (getline(InStream, strLineIn))
1614 string strErr =
ERR +
"invalid integer for number of expected rows '" + VstrItems[1] +
"' in " + *strCShoreFilename +
"\n";
1622 nExpectedRows = stoi(VstrItems[1]);
1629 int nCols =
static_cast<int>(VstrItems.size());
1630 if (nCols != nExpectedColumns)
1633 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedColumns <<
" CShore output columns but read " << nCols <<
" columns from header section of file " << *strCShoreFilename << endl;
1639 VdXYDistCShore.push_back(strtod(VstrItems[0].c_str(), NULL));
1640 VdValuesCShore.push_back(strtod(VstrItems[nCShorecolumn - 1].c_str(), NULL));
1645 int nReadRows =
static_cast<int>(VdXYDistCShore.size());
1646 if (nReadRows != nExpectedRows)
1649 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedRows <<
" CShore output rows, but read " << nReadRows <<
" rows from file " << *strCShoreFilename << endl;
1658 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for profile " << nProfile <<
", only " << nReadRows <<
" CShore output rows in file " << *strCShoreFilename << endl;
1661 VdXYDistCShore.push_back(VdXYDistCShore[0]);
1662 VdValuesCShore.push_back(VdValuesCShore[0]);
1669 vector<double> VdXYDistCShoreTmp(nReadRows, 0);
1670 for (
int i = 0; i < nReadRows; i++)
1671 VdXYDistCShoreTmp[i] = VdXYDistCShore[nReadRows - 1] - VdXYDistCShore[i];
1674 reverse(VdXYDistCShoreTmp.begin(), VdXYDistCShoreTmp.end());
1677 reverse(VdValuesCShore.begin(), VdValuesCShore.end());
1680 vector<double> VdDistXYCopy(pVdProfileDistXYCME->begin(), pVdProfileDistXYCME->end());
1689#if defined CSHORE_ARG_INOUT || CSHORE_BOTH
1693void CSimulation::InterpolateCShoreOutput(vector<double>
const* pVdProfileDistXYCME,
int const nOutSize,
int const nProfileSize, vector<double>* pVdXYDistFromCShore, vector<double>* pVdFreeSurfaceStdCShore, vector<double>* pVdWaveSetupSurgeCShore, vector<double>* pVdSinWaveAngleRadiansCShore, vector<double>* pVdFractionBreakingWavesCShore, vector<double>* pVdFreeSurfaceStdCME, vector<double>* pVdWaveSetupSurgeCME, vector<double>* pVdSinWaveAngleRadiansCME, vector<double>* pVdFractionBreakingWavesCME)
1700 bool bTooShort =
false;
1702 if (nOutSize < nProfileSize)
1705 nTooShort = nProfileSize - nOutSize;
1726 double dLastDiff = pVdXYDistFromCShore->at(nOutSize-1) - pVdXYDistFromCShore->at(nOutSize-2);
1727 for (
int n = 0; n < nTooShort; n++)
1728 pVdXYDistFromCShore->at(nOutSize + n) = pVdXYDistFromCShore->at(nOutSize-1 + n) + dLastDiff;
1730 for (
int n = 0; n < nTooShort; n++)
1731 pVdFreeSurfaceStdCShore->at(nOutSize + n) = pVdFreeSurfaceStdCShore->at(nOutSize-1);
1733 for (
int n = 0; n < nTooShort; n++)
1734 pVdWaveSetupSurgeCShore->at(nOutSize + n) = pVdWaveSetupSurgeCShore->at(nOutSize-1);
1738 for (
int n = 0; n < nTooShort; n++)
1739 pVdSinWaveAngleRadiansCShore->at(nOutSize + n) = pVdSinWaveAngleRadiansCShore->at(nOutSize-1);
1741 dLastDiff = pVdFractionBreakingWavesCShore->at(nOutSize-1) - pVdFractionBreakingWavesCShore->at(nOutSize-2);
1742 for (
int n = 0; n < nTooShort; n++)
1743 pVdFractionBreakingWavesCShore->at(nOutSize + n) =
tMin(pVdFractionBreakingWavesCShore->at(nOutSize-1 + n) + dLastDiff, 1.0);
1754 vector<double> VdXYDistCShoreTmp(nProfileSize);
1755 copy(pVdXYDistFromCShore->begin(), pVdXYDistFromCShore->begin() + nProfileSize, begin(VdXYDistCShoreTmp));
1758 vector<double> VdFreeSurfaceStdCShoreTmp(nProfileSize);
1759 reverse_copy(pVdFreeSurfaceStdCShore->begin(), pVdFreeSurfaceStdCShore->begin() + nProfileSize, begin(VdFreeSurfaceStdCShoreTmp));
1761 vector<double> VdWaveSetupSurgeCShoreTmp(nProfileSize);
1762 reverse_copy(pVdWaveSetupSurgeCShore->begin(), pVdWaveSetupSurgeCShore->begin() + nProfileSize, begin(VdWaveSetupSurgeCShoreTmp));
1764 vector<double> VdSinWaveAngleRadiansCShoreTmp(nProfileSize);
1765 reverse_copy(pVdSinWaveAngleRadiansCShore->begin(), pVdSinWaveAngleRadiansCShore->begin() + nProfileSize, begin(VdSinWaveAngleRadiansCShoreTmp));
1767 vector<double> VdFractionBreakingWavesCShoreTmp(nProfileSize);
1768 reverse_copy(pVdFractionBreakingWavesCShore->begin(), pVdFractionBreakingWavesCShore->begin() + nProfileSize, begin(VdFractionBreakingWavesCShoreTmp));
1805 bool bModfiedWaveHeightisBreaking =
false;
1806 bool bProfileIsinShadowZone =
false;
1809 int nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1810 double dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1811 double dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1812 double dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1815 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1823 bProfileIsinShadowZone =
true;
1826 double dWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight();
1832 bModfiedWaveHeightisBreaking =
true;
1835 dThisBreakingWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveAngle();
1837 nThisBreakingDist = nProfilePoint;
1843 if (bProfileIsinShadowZone && bModfiedWaveHeightisBreaking)
1846 if (dThisBreakingWaveHeight > dThisBreakingDepth * 0.78)
1848 dThisBreakingWaveHeight = dThisBreakingDepth * 0.78;
1852 m_VCoast[nCoast].SetBreakingWaveHeight(nThisCoastPoint, dThisBreakingWaveHeight);
1853 m_VCoast[nCoast].SetBreakingWaveAngle(nThisCoastPoint, dThisBreakingWaveAngle);
1854 m_VCoast[nCoast].SetDepthOfBreaking(nThisCoastPoint, dThisBreakingDepth);
1855 m_VCoast[nCoast].SetBreakingDistance(nThisCoastPoint, nThisBreakingDist);
1859 else if (bProfileIsinShadowZone && (! bModfiedWaveHeightisBreaking))
1887 int const nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1888 double dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1889 double dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1890 double dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1891 double dThisWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nThisCoastPoint);
1893 double dThisRunUp =
m_VCoast[nCoast].dGetRunUp(nThisCoastPoint);
1909 pTmpProfile = pNextProfile;
1920 int const nDistBetween = nNextCoastPoint - nThisCoastPoint;
1923 if (nDistBetween <= 0)
1927 int nNextBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nNextCoastPoint);
1928 double dNextBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nNextCoastPoint);
1929 double dNextBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nNextCoastPoint);
1930 double dNextBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nNextCoastPoint);
1931 double dNextWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nNextCoastPoint);
1932 double dNextRunUp =
m_VCoast[nCoast].dGetRunUp(nNextCoastPoint);
1935 for (
int n = nThisCoastPoint; n <= nNextCoastPoint; n++)
1938 int nDist = n - nThisCoastPoint;
1939 double dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween);
1940 double dNextWeight = 1 - dThisWeight;
1941 double dWaveSetupSurge = 0;
1944 dWaveSetupSurge = (dThisWeight * dThisWaveSetupSurge) + (dNextWeight * dNextWaveSetupSurge);
1945 m_VCoast[nCoast].SetWaveSetupSurge(n, dWaveSetupSurge);
1947 dRunUp = (dThisWeight * dThisRunUp) + (dNextWeight * dNextRunUp);
1948 m_VCoast[nCoast].SetRunUp(n, dRunUp);
1960 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
1974 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
1978 m_VCoast[nCoast].SetBreakingWaveHeight(n, dNextBreakingWaveHeight);
1979 m_VCoast[nCoast].SetBreakingWaveAngle(n, dNextBreakingWaveAngle);
1980 m_VCoast[nCoast].SetDepthOfBreaking(n, dNextBreakingDepth);
1981 m_VCoast[nCoast].SetBreakingDistance(n, nNextBreakingDist);
1989 for (
int n = nThisCoastPoint + 1; n <= nNextCoastPoint; n++)
1993 m_VCoast[nCoast].SetBreakingWaveHeight(n, dThisBreakingWaveHeight);
1994 m_VCoast[nCoast].SetBreakingWaveAngle(n, dThisBreakingWaveAngle);
1995 m_VCoast[nCoast].SetDepthOfBreaking(n, dThisBreakingDepth);
1996 m_VCoast[nCoast].SetBreakingDistance(n, nThisBreakingDist);
2003 for (
int n = nThisCoastPoint + 1; n < nNextCoastPoint; n++)
2005 int nDist = n - nThisCoastPoint;
2012 if ((dNextBreakingDepth > 0) && (dThisBreakingDepth > 0))
2015 dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween),
2016 dNextWeight = 1 - dThisWeight;
2018 dBreakingWaveHeight = (dThisWeight * dThisBreakingWaveHeight) + (dNextWeight * dNextBreakingWaveHeight),
2019 dBreakingWaveAngle = (dThisWeight * dThisBreakingWaveAngle) + (dNextWeight * dNextBreakingWaveAngle),
2020 dBreakingDepth = (dThisWeight * dThisBreakingDepth) + (dNextWeight * dNextBreakingDepth),
2021 dBreakingDist = (dThisWeight * nThisBreakingDist) + (dNextWeight * nNextBreakingDist);
2023 else if (dNextBreakingDepth > 0)
2025 dBreakingWaveHeight = dNextBreakingWaveHeight,
2026 dBreakingWaveAngle = dNextBreakingWaveAngle,
2027 dBreakingDepth = dNextBreakingDepth,
2028 dBreakingDist = nNextBreakingDist;
2030 else if (dThisBreakingDepth > 0)
2032 dBreakingWaveHeight = dThisBreakingWaveHeight,
2033 dBreakingWaveAngle = dThisBreakingWaveAngle,
2034 dBreakingDepth = dThisBreakingDepth,
2035 dBreakingDist = nThisBreakingDist;
2040 m_VCoast[nCoast].SetBreakingWaveHeight(n, dBreakingWaveHeight);
2041 m_VCoast[nCoast].SetBreakingWaveAngle(n, dBreakingWaveAngle);
2042 m_VCoast[nCoast].SetDepthOfBreaking(n, dBreakingDepth);
2052 int nCoastPoints =
m_VCoast[nCoast].nGetCoastlineSize();
2055 vector<int> nVCoastWaveHeightX;
2056 vector<double> dVCoastWaveHeightY;
2059 for (
int n = 0; n < nCoastPoints; n++)
2061 double dCoastWaveHeight =
m_VCoast[nCoast].dGetCoastWaveHeight(n);
2065 nVCoastWaveHeightX.push_back(n);
2066 dVCoastWaveHeightY.push_back(dCoastWaveHeight);
2071 if ((nVCoastWaveHeightX.size() >= 3) && (nVCoastWaveHeightX.size() == dVCoastWaveHeightY.size()))
2073 for (
int n = 0; n < nCoastPoints; n++)
2075 double dInterpCoastWaveHeight =
dGetInterpolatedValue(&nVCoastWaveHeightX, &dVCoastWaveHeightY, n,
false);
2076 m_VCoast[nCoast].SetCoastWaveHeight(n, dInterpCoastWaveHeight);
2081 for (
int n = 0; n < nCoastPoints; n++)
2083 m_VCoast[nCoast].SetCoastWaveHeight(n, 0);
2093 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
2095 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize; nCoastPoint++)
2100 if (nCoastPoint == 0)
2109 else if (nCoastPoint == nCoastSize - 1)
2134 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 90);
2137 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 270);
2144 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 0);
2147 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 180);
2152 double dAzimuthAngle;
2154 dAzimuthAngle = (180 /
PI) * (
PI * 0.5 - atan(dYDiff / dXDiff));
2156 dAzimuthAngle = (180 /
PI) * (
PI * 1.5 - atan(dYDiff / dXDiff));
2158 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, dAzimuthAngle);
2183 bool bActive =
m_pRasterGrid->m_Cell[nX][nY].bIsInActiveZone();
2188 double dTmpd50 =
m_pRasterGrid->m_Cell[nX][nY].dGetUnconsD50();
2194 VnPolygonD50Count[nID]++;
2195 VdPolygonD50[nID] += dTmpd50;
2220 int nDownDriftNum = 0;
2223 double dWaveHeight = 0;
2224 double dWaveAngle = 0;
2231 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2234 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2235 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2240 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2247 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2251 nDownDriftNum = nTmp;
2263 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2266 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2267 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2272 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2279 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2283 nDownDriftNum = nTmp;
2295 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2298 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2299 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2304 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2311 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2315 nDownDriftNum = nTmp;
2327 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2330 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2331 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2336 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2343 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2347 nDownDriftNum = nTmp;
2357 dWaveHeight /= nRead;
2358 dWaveAngle /= nRead;
2370 double dDeepWaterWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveHeight();
2377 double dDeepWaterWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveAngle();
2384 int nShadowZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetShadowZoneNumber();
2385 if (nShadowZoneCode <= 0)
2388 if ((nShadow == 4) || (nShadow + nDownDrift == 4) || (nShadow + nCoast == 4))
2390 m_pRasterGrid->m_Cell[nX][nY].SetShadowZoneNumber(nShadowNum);
2397 int nDownDriftZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetDownDriftZoneNumber();
2398 if ((nDownDriftZoneCode == 0) && (nDownDrift == 4))
2400 m_pRasterGrid->m_Cell[nX][nY].SetDownDriftZoneNumber(nDownDriftNum);
2410 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
2412 for (
int nPoly = 0; nPoly <
m_VCoast[nCoast].nGetNumPolygons(); nPoly++)
2417 if (VnPolygonD50Count[nID] > 0)
2418 VdPolygonD50[nID] /= VnPolygonD50Count[nID];
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Geometry class used to represent 2D point objects with floating-point coordinates.
double dGetY(void) const
Returns the CGeom2DPoint object's double Y coordinate.
double dGetX(void) const
Returns the CGeom2DPoint object's double X coordinate.
Geometry class used for coast polygon objects.
void SetAvgUnconsD50(double const)
Set the average d50 for unconsolidated sediment on this polygon.
int nGetCoastID(void) const
Get the coast ID, this is the same as the down-coast sequence.
Geometry class used to represent coast profile objects.
double dGetProfileDeepWaterWaveAngle(void) const
Returns the deep-water wave orientation for this profile.
double dGetProfileDeepWaterWaveHeight(void) const
Returns the deep-water wave height for this profile.
int nGetCoastPoint(void) const
Returns the coast point at which the profile starts.
CGeomProfile * pGetDownCoastAdjacentProfile(void) const
CGeom2DIPoint * pPtiGetCellInProfile(int const)
Returns a single cell in the profile.
int nGetNumCellsInProfile(void) const
Returns the number of cells in the profile.
void SetCShoreProblem(bool const)
Sets a switch to indicate whether this profile has a CShore problem.
bool bOKIncStartAndEndOfCoast(void) const
Returns true if this is a problem-free profile (however it could be a start-of-coast or an end-of-coa...
int nGetCoastID(void) const
Returns the profile's coast ID.
bool bStartOfCoast(void) const
Returns the switch to indicate whether this is a start-of-coast profile.
vector< CGeom2DIPoint > * pPtiVGetCellsInProfile(void)
Returns all cells in the profile.
bool bEndOfCoast(void) const
Returns the switch to indicate whether this is an end-of-coast profile.
double dGetProfileDeepWaterWavePeriod(void) const
Returns the deep-water wave Period for this profile.
int m_nLogFileDetail
The level of detail in the log file output. Can be LOG_FILE_LOW_DETAIL, LOG_FILE_MIDDLE_DETAIL,...
double m_dAllCellsDeepWaterWaveHeight
Deep water wave height (m) for all sea cells.
void InterpolateCShoreOutput(vector< double > const *, int const, int const, vector< double > *, vector< double > *, vector< double > *, vector< double > *, vector< double > *, vector< double > *, vector< double > *, vector< double > *, vector< double > *)
double m_dG
Gravitational acceleration (m**2/sec)
double m_dThisIterSWL
The still water level for this timestep (this includes tidal changes and any long-term SWL change)
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
int nCalcWavePropertiesOnProfile(int const, int const, CGeomProfile *, vector< double > *, vector< double > *, vector< double > *, vector< double > *, vector< bool > *)
Calculates wave properties along a coastline-normal profile using either the COVE linear wave theory ...
int m_nXGridSize
The size of the grid in the x direction.
double m_dL_0
Deep water wave length (m)
vector< CRWCoast > m_VCoast
The coastline objects.
bool m_bSingleDeepWaterWaveValues
Do we have just a point source for (i.e. only a single measurement of) deep water wave values.
int m_nYGridSize
The size of the grid in the y direction.
int nDoAllShadowZones(void)
Finds wave shadow zones and modifies waves in and near them. Note that where up-coast and down-coast ...
static double dKeepWithin360(double const)
Constrains the supplied angle to be within 0 and 360 degrees.
void CalcCoastTangents(int const)
Calculates tangents to a coastline: the tangent is assumed to be the orientation of energy/sediment f...
double m_dWaveDepthRatioForWaveCalcs
Start depth for wave calculations.
int nCreateCShoreInfile(int const, int const, int const, int const, int const, int const, int const, int const, int const, int const, int const, int const, int const, double const, double const, double const, double const, double const, double const, double const, double const, vector< double > const *, vector< double > const *, vector< double > const *)
void InterpolateWavePropertiesBetweenProfiles(int const, int const)
Interpolates wave properties from profiles to the coastline points between two profiles....
int nInterpolateWavesToPolygonCells(vector< double > const *, vector< double > const *, vector< double > const *, vector< double > const *)
Interpolates wave properties from all profiles to all within-polygon sea cells, using GDALGridCreate(...
int m_nRunUpEquation
The run-up equation used TODO 007.
double m_dBreakingWaveHeightDepthRatio
Breaking wave height-to-depth ratio.
int nReadCShoreOutput(int const, string const *, int const, int const, vector< double > const *, vector< double > *)
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...
void CalcD50AndFillWaveCalcHoles(void)
Calculates an average d50 for each polygon. Also fills in 'holes' in active zone and wave calcs i....
string m_strCMEDir
The CME folder.
int m_nWavePropagationModel
The wave propagation model used. Possible values are WAVE_MODEL_CSHORE and WAVE_MODEL_COVE.
double m_dAllCellsDeepWaterWaveAngle
Deep water wave angle for all sea cells.
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_dTimeStep
The length of an iteration (a time step) in hours.
int nGetThisProfileElevationsForCShore(int const, CGeomProfile *, int const, vector< double > *, vector< double > *, vector< double > *)
Get profile horizontal distance and bottom elevation vectors in CShore units.
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,...
void ModifyBreakingWavePropertiesWithinShadowZoneToCoastline(int const, int const)
Modifies the wave breaking properties at coastline points of profiles within the shadow zone.
double m_dC_0
Deep water wave speed (m/s)
unsigned long m_ulIter
The number of the current iteration (time step)
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...
int m_nNumPolygonGlobal
Number of global (all coasts) polygons.
int nDoAllPropagateWaves(void)
Simulates wave propagation along all coastline-normal profiles.
double m_dDepthOfClosure
Depth of closure (in m) TODO 007 can be calculated using Hallermeier, R.J. (1978) or Birkemeier (1985...
void InterpolateWaveHeightToCoastPoints(int const)
Linearly interpolates wave properties from profiles to the coastline cells between two profiles.
static vector< string > * VstrSplit(string const *, char const, vector< string > *)
From http://stackoverflow.com/questions/236129/split-a-string-in-c They implement (approximately) Pyt...
static double dCalcWaveAngleToCoastNormal(double const, double const, int const)
Calculates the angle between the wave direction and a normal to the coastline tangent....
This file contains global definitions for CoastalME.
int const NO_NONZERO_THICKNESS_LAYERS
int const WAVE_MODEL_COVE
int const RTN_ERR_NO_TOP_LAYER
int const RTN_ERR_CSHORE_FILE_INPUT
double const CSHORE_FRICTION_FACTOR
int const WAVE_MODEL_CSHORE
int const LOG_FILE_MIDDLE_DETAIL
int const RTN_ERR_CSHORE_ERROR
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
double const WALKDEN_HALL_PARAM_2
int const RTN_ERR_READING_CSHORE_FILE_OUTPUT
double const CSHORE_SURGE_LEVEL
bool const SAVE_CSHORE_OUTPUT
int const CSHOREARRAYOUTSIZE
The size of the arrays output by CShore. If you change this, then you must also set the same value on...
double const WALKDEN_HALL_PARAM_1
int const RTN_ERR_CSHORE_EMPTY_PROFILE
string const CSHORE_INFILE
Contains CRWCoast definitions.
void CShoreWrapper(int const *, int const *, int const *, int const *, int const *, int const *, int const *, int const *, int const *, int const *, int const *, double const *, double const *, double[], double[], double[], double[], double[], double[], int const *, double[], double[], double[], int *, int *, double[], double[], double[], double[], double[])
vector< double > VdInterpolateCShoreProfileOutput(vector< double > const *pVdX, vector< double > const *pVdY, vector< double > const *pVdXNew)
Returns a linearly interpolated vector of doubles, to make CShore profile output compatible with CME....
double dGetInterpolatedValue(vector< double > const *pVdXdata, vector< double > const *pVdYdata, double dX, bool bExtrapolate)
Definitions of routines which return interpolated value at x from parallel arrays.
Contains CSimulation definitions.
bool bIsStringValidInt(string &str)
Checks to see if a string can be read as a valid integer, from https://stackoverflow....
int nRound(double const d)
Version of the above that returns an int.