58using std::reverse_copy;
73 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
75 int nDistFromPrevProfile = 0;
76 int nDistToNextProfile = 0;
78 double dPrevProfileDeepWaterWaveHeight = 0;
79 double dPrevProfileDeepWaterWaveAngle = 0;
80 double dPrevProfileDeepWaterWavePeriod = 0;
81 double dNextProfileDeepWaterWaveHeight = 0;
82 double dNextProfileDeepWaterWaveAngle = 0;
83 double dNextProfileDeepWaterWavePeriod = 0;
86 for (
int nPoint = 0; nPoint <
m_VCoast[nCoast].nGetCoastlineSize(); nPoint++)
89 if (
m_VCoast[nCoast].bIsProfileAtCoastPoint(nPoint))
99 m_VCoast[nCoast].SetCoastDeepWaterWaveHeight(nPoint, dThisDeepWaterWaveHeight);
100 m_VCoast[nCoast].SetCoastDeepWaterWaveAngle(nPoint, dThisDeepWaterWaveAngle);
101 m_VCoast[nCoast].SetCoastDeepWaterWavePeriod(nPoint, dThisDeepWaterWavePeriod);
104 nDistFromPrevProfile = 0;
105 dPrevProfileDeepWaterWaveHeight = dThisDeepWaterWaveHeight;
106 dPrevProfileDeepWaterWaveAngle = dThisDeepWaterWaveAngle;
107 dPrevProfileDeepWaterWavePeriod = dThisDeepWaterWavePeriod;
112 if (pNextProfile == NULL)
120 dDist = nDistToNextProfile;
133 nDistFromPrevProfile++;
134 nDistToNextProfile--;
136 double const dPrevWeight = (dDist - nDistFromPrevProfile) / dDist;
137 double const dNextWeight = (dDist - nDistToNextProfile) / dDist;
138 double const dThisDeepWaterWaveHeight = (dPrevWeight * dPrevProfileDeepWaterWaveHeight) + (dNextWeight * dNextProfileDeepWaterWaveHeight);
139 double const dThisDeepWaterWaveAngle =
dKeepWithin360((dPrevWeight * dPrevProfileDeepWaterWaveAngle) + (dNextWeight * dNextProfileDeepWaterWaveAngle));
140 double const dThisDeepWaterWavePeriod = (dPrevWeight * dPrevProfileDeepWaterWavePeriod) + (dNextWeight * dNextProfileDeepWaterWavePeriod);
142 m_VCoast[nCoast].SetCoastDeepWaterWaveHeight(nPoint, dThisDeepWaterWaveHeight);
143 m_VCoast[nCoast].SetCoastDeepWaterWaveAngle(nPoint, dThisDeepWaterWaveAngle);
144 m_VCoast[nCoast].SetCoastDeepWaterWavePeriod(nPoint, dThisDeepWaterWavePeriod);
160 vector<bool> VbBreakingAll;
162 vector<double> VdXAll;
163 vector<double> VdYAll;
164 vector<double> VdHeightXAll;
165 vector<double> VdHeightYAll;
168 bool bSomeNonStartOrEndOfCoastProfiles =
false;
170 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
172 int const nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
173 int const nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
175 static bool bDownCoast =
true;
178 for (
int nn = 0; nn < nNumProfiles; nn++)
180 vector<bool> VbBreaking;
183 vector<double> VdHeightX;
184 vector<double> VdHeightY;
189 pProfile =
m_VCoast[nCoast].pGetProfileWithDownCoastSeq(nn);
192 pProfile =
m_VCoast[nCoast].pGetProfileWithUpCoastSeq(nn);
215 if (VbBreaking.empty())
222 bSomeNonStartOrEndOfCoastProfiles =
true;
234 VdXAll.insert(VdXAll.end(), VdX.begin(), VdX.end());
235 VdYAll.insert(VdYAll.end(), VdY.begin(), VdY.end());
236 VdHeightXAll.insert(VdHeightXAll.end(), VdHeightX.begin(), VdHeightX.end());
237 VdHeightYAll.insert(VdHeightYAll.end(), VdHeightY.begin(), VdHeightY.end());
238 VbBreakingAll.insert(VbBreakingAll.end(), VbBreaking.begin(), VbBreaking.end());
241 bDownCoast = !bDownCoast;
245 if (!bSomeNonStartOrEndOfCoastProfiles)
247 LogStream <<
m_ulIter <<
": waves are on-shore only, for start and/or end of coast profiles" << endl;
253 double dDeepWaterWaveX;
254 double dDeepWaterWaveY;
267 int const nPolyID =
m_pRasterGrid->m_Cell[nX][0].nGetPolygonID();
272 VdXAll.push_back(nX);
278 dDeepWaterWaveX =
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveHeight() * sin(
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveAngle() *
PI / 180);
279 dDeepWaterWaveY =
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveHeight() * cos(
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveAngle() *
PI / 180);
282 VdHeightXAll.push_back(dDeepWaterWaveX);
283 VdHeightYAll.push_back(dDeepWaterWaveY);
294 VdXAll.push_back(nX);
304 VdHeightXAll.push_back(dDeepWaterWaveX);
305 VdHeightYAll.push_back(dDeepWaterWaveY);
314 int const nPolyID =
m_pRasterGrid->m_Cell[0][nY].nGetPolygonID();
320 VdYAll.push_back(nY);
325 dDeepWaterWaveX =
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveHeight() * sin(
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveAngle() *
PI / 180);
326 dDeepWaterWaveY =
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveHeight() * cos(
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveAngle() *
PI / 180);
329 VdHeightXAll.push_back(dDeepWaterWaveX);
330 VdHeightYAll.push_back(dDeepWaterWaveY);
342 VdYAll.push_back(nY);
351 VdHeightXAll.push_back(dDeepWaterWaveX);
352 VdHeightYAll.push_back(dDeepWaterWaveY);
367 if (VbBreakingAll.empty())
518 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
520 int const nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
522 for (
int nProfile = 0; nProfile < nNumProfiles; nProfile++)
591 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
593 int const nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
594 int const nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
597 for (
int n = 0; n < nNumProfiles - 1; n++)
604 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize; nCoastPoint++)
607 double const dBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nCoastPoint);
608 double const dCoastPointWavePeriod =
m_VCoast[nCoast].dGetCoastDeepWaterWavePeriod(nCoastPoint);
613 m_VCoast[nCoast].SetBreakingWaveHeight(nCoastPoint, 0);
621 double const dWaveEnergy = dErosiveWaveForce *
m_dTimeStep * 3600;
622 m_VCoast[nCoast].SetWaveEnergyAtBreaking(nCoastPoint, dWaveEnergy);
635 double dWaveToNormalAngle = 0;
639 dWaveToNormalAngle = fmod((dWaveAngle - dCoastAngle + 360), 360) - 90;
643 dWaveToNormalAngle = fmod((dWaveAngle - dCoastAngle + 360), 360) - 270;
645 if ((dWaveToNormalAngle >= 90) || (dWaveToNormalAngle <= -90))
648 return dWaveToNormalAngle;
671 int const nSeaHand =
m_VCoast[nCoast].nGetSeaHandedness();
675 double const dFluxOrientationThis =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint);
676 double dFluxOrientationPrev = 0;
677 double dFluxOrientationNext = 0;
679 if (nCoastPoint == 0)
681 dFluxOrientationPrev = dFluxOrientationThis;
682 dFluxOrientationNext =
m_VCoast[nCoast].dGetFluxOrientation(1);
685 else if (nCoastPoint == nCoastSize - 1)
687 dFluxOrientationPrev =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint - 2);
688 dFluxOrientationNext = dFluxOrientationThis;
693 dFluxOrientationPrev =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint - 1);
694 dFluxOrientationNext =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint + 1);
715 double dWaveToNormalAnglePrev;
720 double const dPrevDeepWaterWaveAngle =
m_VCoast[nCoast].dGetCoastDeepWaterWaveAngle(nCoastPoint - 1);
727 dWaveToNormalAnglePrev = dWaveToNormalAngle;
736 double dWaveToNormalAngleNext;
738 if (nCoastPoint < nCoastSize - 1)
741 double const dNextDeepWaterWaveAngle =
m_VCoast[nCoast].dGetCoastDeepWaterWaveAngle(nCoastPoint + 1);
748 dWaveToNormalAngleNext = dWaveToNormalAngle;
759 if (dWaveToNormalAngle > 45)
761 if (dWaveToNormalAnglePrev < 45)
763 dWaveToNormalAngle = 45;
769 dWaveToNormalAngle = dWaveToNormalAnglePrev;
777 if (dWaveToNormalAngle < -45)
779 if (dWaveToNormalAngleNext > -45)
781 dWaveToNormalAngle = -45;
787 dWaveToNormalAngle = dWaveToNormalAngleNext;
798 dWaveToNormalAngle = dFluxOrientationPrev;
806 dWaveToNormalAngle = dFluxOrientationNext;
810 bool bBreaking =
false;
813 int nProfileBreakingDist = 0;
815 double dProfileBreakingWaveHeight =
DBL_NODATA;
816 double dProfileBreakingWaveAngle = 0;
817 double dProfileBreakingDepth = 0;
823 vector<bool> VbWaveIsBreaking(nProfileSize, 0);
825 vector<double> VdWaveHeight(nProfileSize, 0);
826 vector<double> VdWaveSetupSurge(nProfileSize, 0);
828 vector<double>
const VdWaveSetupRunUp(nProfileSize, 0);
829 vector<double> VdWaveDirection(nProfileSize, 0);
834 double const dCShoreTimeStep = 3600;
838 vector<double> VdProfileZ;
839 vector<double> VdProfileDistXY;
840 vector<double> VdProfileFrictionFactor;
857 if (VdProfileDistXY.empty())
866 dWaveToNormalAngle =
tMax(dWaveToNormalAngle, -80.0);
867 dWaveToNormalAngle =
tMin(dWaveToNormalAngle, 80.0);
869 int const nProfileDistXYSize =
static_cast<int>(VdProfileDistXY.size());
870 vector<double> VdFreeSurfaceStd(nProfileDistXYSize, 0);
871 vector<double> VdSinWaveAngleRadians(nProfileDistXYSize, 0);
872 vector<double> VdFractionBreakingWaves(nProfileDistXYSize, 0);
875 int const nILine = 1;
876 int const nIProfl = 0;
877 int const nIPerm = 0;
878 int const nIOver = 0;
879 int const nIWCInt = 0;
880 int const nIRoll = 0;
881 int const nIWind = 0;
882 int const nITide = 0;
884 int const nNWave = 1;
885 int const nNSurge = 1;
886 double const dDX = VdProfileDistXY.back() / (
static_cast<double>(VdProfileDistXY.size() - 1));
887 double const dWaveInitTime = 0;
888 double const dSurgeInitTime = 0;
890#if defined CSHORE_FILE_INOUT || CSHORE_BOTH
899#if defined CSHORE_FILE_INOUT
901 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);
921 strErr = to_string(
m_ulIter) +
": CShore WARNING 1: negative depth at the first node ";
925 strErr = to_string(
m_ulIter) +
": CShore WARNING 2: negative value at end of landward marching computation ";
929 strErr = to_string(
m_ulIter) +
": CShore WARNING 3: large energy gradients at the first node: small waves with short period at sea boundary ";
933 strErr = to_string(
m_ulIter) +
": CShore WARNING 4: zero energy at the first node ";
937 strErr = to_string(
m_ulIter) +
": CShore WARNING 5: at end of landward marching computation, insufficient water depth ";
941 strErr = to_string(
m_ulIter) +
": CShore WARNING 7: did not reach convergence ";
945 strErr +=
"(coast " + to_string(nCoast) +
" profile " + to_string(pProfile->
nGetCoastID()) +
" profile length " + to_string(nOutSize) +
")\n";
954 string strOSETUP =
"OSETUP";
955 string strOYVELO =
"OYVELO";
956 string strOPARAM =
"OPARAM";
958 nRet =
nReadCShoreOutput(nProfile, &strOSETUP, 4, 4, &VdProfileDistXY, &VdFreeSurfaceStd);
963 nRet =
nReadCShoreOutput(nProfile, &strOYVELO, 4, 2, &VdProfileDistXY, &VdSinWaveAngleRadians);
968 nRet =
nReadCShoreOutput(nProfile, &strOPARAM, 4, 3, &VdProfileDistXY, &VdFractionBreakingWaves);
979 nRet = system(
"./clean.bat");
984 string strCommand =
"./save_CShore_output.sh ";
987 strCommand += to_string(nCoast);
989 strCommand += to_string(nProfile);
991 nRet = system(strCommand.c_str());
997 nRet = system(
"./clean.sh");
1011#if defined CSHORE_ARG_INOUT || CSHORE_BOTH
1018 vector<double> VdInitTime = {dWaveInitTime, dCShoreTimeStep};
1019 vector<double> VdTPIn = {dDeepWaterWavePeriod, dDeepWaterWavePeriod};
1020 vector<double> VdHrmsIn = {dProfileDeepWaterWaveHeight, dProfileDeepWaterWaveHeight};
1021 vector<double> VdWangIn = {dWaveToNormalAngle, dWaveToNormalAngle};
1022 vector<double> VdTSurg = {dSurgeInitTime, dCShoreTimeStep};
1023 vector<double> VdSWLin = {dSurgeLevel, dSurgeLevel};
1024 vector<double> VdFPInp = VdProfileFrictionFactor;
1055 &nProfileDistXYSize,
1056 &VdProfileDistXY[0],
1061 &VdXYDistFromCShoreOut[0],
1062 &VdFreeSurfaceStdOut[0],
1063 &VdWaveSetupSurgeOut[0],
1064 &VdSinWaveAngleRadiansOut[0],
1065 &VdFractionBreakingWavesOut[0]);
1072 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for coast " << nCoast <<
" profile " << pProfile->
nGetCoastID() <<
", only " << nOutSize <<
" CShore output rows, abandoning this profile" << endl;
1096 strErr = to_string(
m_ulIter) +
": CShore WARNING 1: negative depth at the first node ";
1100 strErr = to_string(
m_ulIter) +
": CShore WARNING 2: negative value at end of landward marching computation ";
1104 strErr = to_string(
m_ulIter) +
": CShore WARNING 3: large energy gradients at the first node: small waves with short period at sea boundary ";
1108 strErr = to_string(
m_ulIter) +
": CShore WARNING 4: zero energy at the first node ";
1112 strErr = to_string(
m_ulIter) +
": CShore WARNING 5: at end of landward marching computation, insufficient water depth ";
1116 strErr = to_string(
m_ulIter) +
": CShore WARNING 7: did not reach convergence ";
1120 strErr +=
"(coast " + to_string(nCoast) +
" profile " + to_string(pProfile->
nGetCoastID()) +
" profile length " + to_string(nOutSize) +
")\n";
1130 InterpolateCShoreOutput(&VdProfileDistXY, nOutSize, nProfileSize, &VdXYDistFromCShoreOut, &VdFreeSurfaceStdOut, &VdWaveSetupSurgeOut, &VdSinWaveAngleRadiansOut, &VdFractionBreakingWavesOut, &VdFreeSurfaceStd, &VdWaveSetupSurge, &VdSinWaveAngleRadians, &VdFractionBreakingWaves);
1133#if defined CSHORE_BOTH
1138 string strCommand =
"./save_CShore_output.sh ";
1141 strCommand += to_string(nCoast);
1143 strCommand += to_string(nProfile);
1145 nRet = system(strCommand.c_str());
1162 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1168 if (nProfilePoint >
static_cast<int>(VdFreeSurfaceStd.size()) - 1)
1172 if (isnan(VdFreeSurfaceStd[nProfilePoint]))
1173 VdFreeSurfaceStd[nProfilePoint] = 0;
1175 VdWaveHeight[nProfilePoint] = sqrt(8) * VdFreeSurfaceStd[nProfilePoint];
1178 if (isnan(VdSinWaveAngleRadians[nProfilePoint]))
1180 VdSinWaveAngleRadians[nProfilePoint] = 0;
1181 VdWaveHeight[nProfilePoint] = 0;
1185 if (VdSinWaveAngleRadians[nProfilePoint] < -1)
1186 VdSinWaveAngleRadians[nProfilePoint] = -1;
1188 if (VdSinWaveAngleRadians[nProfilePoint] > 1)
1189 VdSinWaveAngleRadians[nProfilePoint] = 1;
1191 double const dAlpha = asin(VdSinWaveAngleRadians[nProfilePoint]) * (180 /
PI);
1194 VdWaveDirection[nProfilePoint] =
dKeepWithin360(dAlpha + 90 + dFluxOrientationThis);
1197 VdWaveDirection[nProfilePoint] =
dKeepWithin360(dAlpha + 270 + dFluxOrientationThis);
1200 if (isnan(VdFractionBreakingWaves[nProfilePoint]))
1202 VdFractionBreakingWaves[nProfilePoint] = 0;
1203 VdWaveHeight[nProfilePoint] = 0;
1211 dProfileBreakingWaveHeight = VdWaveHeight[nProfilePoint];
1212 dProfileBreakingWaveAngle = VdWaveDirection[nProfilePoint];
1213 dProfileBreakingDepth =
m_pRasterGrid->m_Cell[nX][nY].dGetSeaDepth();
1214 nProfileBreakingDist = nProfilePoint + 1;
1219 VbWaveIsBreaking[nProfilePoint] = bBreaking;
1222 if (dProfileBreakingWaveHeight >= dProfileDeepWaterWaveHeight)
1234 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1243 double const dSeaDepth =
m_pRasterGrid->m_Cell[nX][nY].dGetSeaDepth();
1245 if (dSeaDepth > dDepthLookupMax)
1248 dProfileWaveHeight = dProfileDeepWaterWaveHeight;
1249 dProfileWaveAngle = dProfileDeepWaterWaveAngle;
1257 double const dL =
m_dL_0 * sqrt(tanh((2 *
PI * dSeaDepth) /
m_dL_0));
1258 double const dC =
m_dC_0 * tanh((2 *
PI * dSeaDepth) / dL);
1259 double const dk = 2 *
PI / dL;
1260 double const dn = ((2 * dSeaDepth * dk) / (sinh(2 * dSeaDepth * dk)) + 1) / 2;
1261 double const dKs = sqrt(
m_dC_0 / (dn * dC * 2));
1262 double const dAlpha = (180 /
PI) * asin((dC /
m_dC_0) * sin((
PI / 180) * dWaveToNormalAngle));
1263 double const dKr = sqrt(cos((
PI / 180) * dWaveToNormalAngle) / cos((
PI / 180) * dAlpha));
1264 dProfileWaveHeight = dProfileDeepWaterWaveHeight * dKs * dKr;
1267 dProfileWaveAngle =
dKeepWithin360(dAlpha + 90 + dFluxOrientationThis);
1270 dProfileWaveAngle =
dKeepWithin360(dAlpha + 270 + dFluxOrientationThis);
1275 dProfileBreakingWaveHeight = dProfileWaveHeight;
1276 dProfileBreakingWaveAngle = dProfileWaveAngle;
1286 dProfileWaveAngle = dProfileBreakingWaveAngle;
1288 dProfileWaveHeight = dProfileBreakingWaveHeight * (nProfilePoint / nProfileBreakingDist);
1290 dProfileBreakingDepth = dSeaDepth;
1291 nProfileBreakingDist = nProfilePoint;
1296 VdWaveDirection[nProfilePoint] = dProfileWaveAngle;
1297 VdWaveHeight[nProfilePoint] = dProfileWaveHeight;
1298 VbWaveIsBreaking[nProfilePoint] = bBreaking;
1303 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1313 double const dWaveHeight = VdWaveHeight[nProfilePoint];
1314 double const dWaveAngle = VdWaveDirection[nProfilePoint];
1316 bBreaking = VbWaveIsBreaking[nProfilePoint];
1319 pVdX->push_back(nX);
1320 pVdY->push_back(nY);
1321 pVdHeightX->push_back(dWaveHeight * sin(dWaveAngle *
PI / 180));
1322 pVdHeightY->push_back(dWaveHeight * cos(dWaveAngle *
PI / 180));
1323 pVbBreaking->push_back(bBreaking);
1344 double const dDiffProfileDistXY = hypot(dXDist, dYDist);
1347 double const dtanBeta = tan(
tAbs(
m_pRasterGrid->m_Cell[nX1][nY1].dGetSeaDepth() -
m_pRasterGrid->m_Cell[nX][nY].dGetSeaDepth()) / dDiffProfileDistXY);
1350 int nValidPointsWaveHeight = 0;
1351 int nValidPointsWaveSetup = 0;
1353 for (
int nPoint = 0; nPoint < static_cast<int>(VdWaveHeight.size()); nPoint++)
1355 if (VdWaveHeight[nPoint] > 1e-4)
1357 nValidPointsWaveHeight += 1;
1366 nValidPointsWaveHeight -= 1;
1368 for (
int nPoint = 0; nPoint < static_cast<int>(VdWaveSetupSurge.size()); nPoint++)
1370 if (
tAbs(VdWaveSetupSurge[nPoint]) < 1)
1372 nValidPointsWaveSetup += 1;
1381 nValidPointsWaveSetup -= 1;
1383 double dWaveHeight = 0;
1388 dWaveHeight = VdWaveHeight[nValidPointsWaveHeight];
1397 dRunUp = 0.36 * pow(9.81, 0.5) * dtanBeta * pow(dWaveHeight, 0.5) * dDeepWaterWavePeriod;
1403 double const dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1404 dRunUp = 1.86 * dWaveHeight * pow(pow(dtanBeta / dS0, 0.5), 0.71);
1410 double const dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1413 double const dH0OverL0 = (1 / dS0) * dWaveHeight;
1414 double const dTmp1 = 0.35 * dWaveHeight * pow(dH0OverL0, 0.5);
1415 double const dTmp2 = pow(dH0OverL0 * ((0.563 * dWaveHeight * dWaveHeight) + 0.0004), 0.5);
1416 dRunUp = 1.1 * (dTmp1 + (dTmp2 / 2));
1419 if ((
tAbs(dRunUp) < 1e-4) || (isnan(dRunUp)))
1424 double dWaveSetupSurge = 0;
1429 dWaveSetupSurge = VdWaveSetupSurge[nValidPointsWaveSetup];
1432 if ((
tAbs(dWaveSetupSurge) < 1e-4) || (isnan(dWaveSetupSurge)))
1434 dWaveSetupSurge = 0;
1439 m_VCoast[nCoast].SetCoastWaveHeight(nCoastPoint, dWaveHeight);
1440 m_VCoast[nCoast].SetWaveSetupSurge(nCoastPoint, dWaveSetupSurge);
1441 m_VCoast[nCoast].SetRunUp(nCoastPoint, dRunUp);
1443 if (nProfileBreakingDist > 0)
1446 m_VCoast[nCoast].SetBreakingWaveHeight(nCoastPoint, dProfileBreakingWaveHeight);
1447 m_VCoast[nCoast].SetBreakingWaveAngle(nCoastPoint, dProfileBreakingWaveAngle);
1448 m_VCoast[nCoast].SetDepthOfBreaking(nCoastPoint, dProfileBreakingDepth);
1449 m_VCoast[nCoast].SetBreakingDistance(nCoastPoint, nProfileBreakingDist);
1468#if defined CSHORE_FILE_INOUT
1472int 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)
1475 ofstream CShoreOutStream;
1476 CShoreOutStream.open(
CSHORE_INFILE.c_str(), ios::out | ios::app);
1478 if (CShoreOutStream.fail())
1486 CShoreOutStream << 3 << endl;
1487 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1488 CShoreOutStream <<
"CShore input file created by CoastalME for iteration " <<
m_ulIter <<
", coast " << nCoast <<
", profile " << nProfile << endl;
1489 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1490 CShoreOutStream << nILine <<
" -> ILINE" << endl;
1491 CShoreOutStream << nIProfl <<
" -> IPROFL" << endl;
1492 CShoreOutStream << nIPerm <<
" -> IPERM" << endl;
1493 CShoreOutStream << nIOver <<
" -> IOVER" << endl;
1494 CShoreOutStream << nIWcint <<
" -> IWCINT" << endl;
1495 CShoreOutStream << nIRoll <<
" -> IROLL" << endl;
1496 CShoreOutStream << nIWind <<
" -> IWIND" << endl;
1497 CShoreOutStream << nITide <<
" -> ITIDE" << endl;
1498 CShoreOutStream << fixed;
1499 CShoreOutStream << setw(11) << setprecision(4) << dX <<
" -> DX" << endl;
1501 CShoreOutStream << setw(11) << nILab <<
" -> ILAB" << endl;
1502 CShoreOutStream << setw(11) << nWave <<
" -> NWAVE" << endl;
1503 CShoreOutStream << setw(11) << nSurge <<
" -> NSURGE" << endl;
1506 CShoreOutStream << setw(11) << setprecision(2) << dWaveInitTime;
1507 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1508 CShoreOutStream << setw(11) << dHrms;
1509 CShoreOutStream << setw(11) << dWaveAngle << endl;
1512 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1513 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1514 CShoreOutStream << setw(11) << dHrms;
1515 CShoreOutStream << setw(11) << dWaveAngle << endl;
1518 CShoreOutStream << setw(11) << setprecision(2) << dSurgeInitTime;
1519 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1522 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1523 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1526 CShoreOutStream << setw(8) << pVdXdist->size() <<
" -> NBINP" << endl;
1528 CShoreOutStream << fixed << setprecision(4);
1530 for (
unsigned int i = 0; i < pVdXdist->size(); i++)
1532 CShoreOutStream << setw(11) << pVdXdist->at(i) << setw(11) << pVdBottomElevation->at(i) << setw(11) << pVdWaveFriction->at(i) << endl;
1534 CShoreOutStream << endl;
1537 CShoreOutStream.close();
1548 bool bIsBehindIntervention =
false;
1555 double dProfileDistXY = 0;
1556 double dProfileFricFact;
1557 double dPrevDist = -1;
1559 for (
int i = nProfSize - 1; i >= 0; i--)
1565 if (i == nProfSize - 1)
1572 dProfileDistXY = dProfileDistXY + hypot(dXDist, dYDist);
1577 dProfileDistXY += 0.1;
1584 int const nTopLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
1595 double const dTopElev =
m_pRasterGrid->m_Cell[nX][nY].dGetSedimentTopElev() +
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1603 VdVZ->push_back(0.1);
1606 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;
1611 VdVZ->push_back(VdProfileZ);
1617 VdVZ->push_back(VdProfileZ);
1621 VdDistXY->push_back(dProfileDistXY);
1624 double const dInterventionHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1627 if (dInterventionHeight > 0 || bIsBehindIntervention)
1631 bIsBehindIntervention =
true;
1638 VdFricF->push_back(dProfileFricFact);
1641 dPrevDist = dProfileDistXY;
1647#if defined CSHORE_FILE_INOUT
1651int CSimulation::nReadCShoreOutput(
int const nProfile,
string const *strCShoreFilename,
int const nExpectedColumns,
int const nCShorecolumn, vector<double>
const *pVdProfileDistXYCME, vector<double> *pVdInterpolatedValues)
1655 InStream.open(strCShoreFilename->c_str(), ios::in);
1658 if (!InStream.is_open())
1661 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", cannot open " << *strCShoreFilename <<
" for input" << endl;
1667 vector<double> VdXYDistCShore;
1668 vector<double> VdValuesCShore;
1672 int nExpectedRows = 0;
1675 while (getline(InStream, strLineIn))
1686 string strErr =
ERR +
"invalid integer for number of expected rows '" + VstrItems[1] +
"' in " + *strCShoreFilename +
"\n";
1694 nExpectedRows = stoi(VstrItems[1]);
1702 int nCols =
static_cast<int>(VstrItems.size());
1704 if (nCols != nExpectedColumns)
1707 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedColumns <<
" CShore output columns but read " << nCols <<
" columns from header section of file " << *strCShoreFilename << endl;
1713 VdXYDistCShore.push_back(strtod(VstrItems[0].c_str(), NULL));
1714 VdValuesCShore.push_back(strtod(VstrItems[nCShorecolumn - 1].c_str(), NULL));
1719 int nReadRows =
static_cast<int>(VdXYDistCShore.size());
1721 if (nReadRows != nExpectedRows)
1724 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedRows <<
" CShore output rows, but read " << nReadRows <<
" rows from file " << *strCShoreFilename << endl;
1733 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for profile " << nProfile <<
", only " << nReadRows <<
" CShore output rows in file " << *strCShoreFilename << endl;
1736 VdXYDistCShore.push_back(VdXYDistCShore[0]);
1737 VdValuesCShore.push_back(VdValuesCShore[0]);
1744 vector<double> VdXYDistCShoreTmp(nReadRows, 0);
1746 for (
int i = 0; i < nReadRows; i++)
1747 VdXYDistCShoreTmp[i] = VdXYDistCShore[nReadRows - 1] - VdXYDistCShore[i];
1750 reverse(VdXYDistCShoreTmp.begin(), VdXYDistCShoreTmp.end());
1753 reverse(VdValuesCShore.begin(), VdValuesCShore.end());
1756 vector<double> VdDistXYCopy(pVdProfileDistXYCME->begin(), pVdProfileDistXYCME->end());
1765#if defined CSHORE_ARG_INOUT || CSHORE_BOTH
1769void 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)
1776 bool bTooShort =
false;
1779 if (nOutSize < nProfileSize)
1782 nTooShort = nProfileSize - nOutSize;
1803 double dLastDiff = pVdXYDistFromCShore->at(nOutSize - 1) - pVdXYDistFromCShore->at(nOutSize - 2);
1805 for (
int n = 0; n < nTooShort; n++)
1806 pVdXYDistFromCShore->at(nOutSize + n) = pVdXYDistFromCShore->at(nOutSize - 1 + n) + dLastDiff;
1808 for (
int n = 0; n < nTooShort; n++)
1809 pVdFreeSurfaceStdCShore->at(nOutSize + n) = pVdFreeSurfaceStdCShore->at(nOutSize - 1);
1811 for (
int n = 0; n < nTooShort; n++)
1812 pVdWaveSetupSurgeCShore->at(nOutSize + n) = pVdWaveSetupSurgeCShore->at(nOutSize - 1);
1816 for (
int n = 0; n < nTooShort; n++)
1817 pVdSinWaveAngleRadiansCShore->at(nOutSize + n) = pVdSinWaveAngleRadiansCShore->at(nOutSize - 1);
1819 dLastDiff = pVdFractionBreakingWavesCShore->at(nOutSize - 1) - pVdFractionBreakingWavesCShore->at(nOutSize - 2);
1821 for (
int n = 0; n < nTooShort; n++)
1822 pVdFractionBreakingWavesCShore->at(nOutSize + n) =
tMin(pVdFractionBreakingWavesCShore->at(nOutSize - 1 + n) + dLastDiff, 1.0);
1833 vector<double> VdXYDistCShoreTmp(nProfileSize);
1834 copy(pVdXYDistFromCShore->begin(), pVdXYDistFromCShore->begin() + nProfileSize, begin(VdXYDistCShoreTmp));
1837 vector<double> VdFreeSurfaceStdCShoreTmp(nProfileSize);
1838 reverse_copy(pVdFreeSurfaceStdCShore->begin(), pVdFreeSurfaceStdCShore->begin() + nProfileSize, begin(VdFreeSurfaceStdCShoreTmp));
1840 vector<double> VdWaveSetupSurgeCShoreTmp(nProfileSize);
1841 reverse_copy(pVdWaveSetupSurgeCShore->begin(), pVdWaveSetupSurgeCShore->begin() + nProfileSize, begin(VdWaveSetupSurgeCShoreTmp));
1843 vector<double> VdSinWaveAngleRadiansCShoreTmp(nProfileSize);
1844 reverse_copy(pVdSinWaveAngleRadiansCShore->begin(), pVdSinWaveAngleRadiansCShore->begin() + nProfileSize, begin(VdSinWaveAngleRadiansCShoreTmp));
1846 vector<double> VdFractionBreakingWavesCShoreTmp(nProfileSize);
1847 reverse_copy(pVdFractionBreakingWavesCShore->begin(), pVdFractionBreakingWavesCShore->begin() + nProfileSize, begin(VdFractionBreakingWavesCShoreTmp));
1884 bool bModfiedWaveHeightisBreaking =
false;
1885 bool bProfileIsinShadowZone =
false;
1888 int nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1889 double dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1890 double dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1891 double dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1894 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1902 bProfileIsinShadowZone =
true;
1905 double const dWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight();
1911 bModfiedWaveHeightisBreaking =
true;
1914 dThisBreakingWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveAngle();
1916 nThisBreakingDist = nProfilePoint;
1922 if (bProfileIsinShadowZone && bModfiedWaveHeightisBreaking)
1925 if (dThisBreakingWaveHeight > dThisBreakingDepth * 0.78)
1927 dThisBreakingWaveHeight = dThisBreakingDepth * 0.78;
1931 m_VCoast[nCoast].SetBreakingWaveHeight(nThisCoastPoint, dThisBreakingWaveHeight);
1932 m_VCoast[nCoast].SetBreakingWaveAngle(nThisCoastPoint, dThisBreakingWaveAngle);
1933 m_VCoast[nCoast].SetDepthOfBreaking(nThisCoastPoint, dThisBreakingDepth);
1934 m_VCoast[nCoast].SetBreakingDistance(nThisCoastPoint, nThisBreakingDist);
1939 else if (bProfileIsinShadowZone && (!bModfiedWaveHeightisBreaking))
1967 int const nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1968 double const dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1969 double const dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1970 double const dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1971 double const dThisWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nThisCoastPoint);
1973 double const dThisRunUp =
m_VCoast[nCoast].dGetRunUp(nThisCoastPoint);
1990 pTmpProfile = pNextProfile;
2001 int const nDistBetween = nNextCoastPoint - nThisCoastPoint;
2004 if (nDistBetween <= 0)
2008 int const nNextBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nNextCoastPoint);
2009 double const dNextBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nNextCoastPoint);
2010 double const dNextBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nNextCoastPoint);
2011 double const dNextBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nNextCoastPoint);
2012 double const dNextWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nNextCoastPoint);
2013 double const dNextRunUp =
m_VCoast[nCoast].dGetRunUp(nNextCoastPoint);
2016 for (
int n = nThisCoastPoint; n <= nNextCoastPoint; n++)
2019 int const nDist = n - nThisCoastPoint;
2020 double const dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween);
2021 double const dNextWeight = 1 - dThisWeight;
2022 double dWaveSetupSurge = 0;
2025 dWaveSetupSurge = (dThisWeight * dThisWaveSetupSurge) + (dNextWeight * dNextWaveSetupSurge);
2026 m_VCoast[nCoast].SetWaveSetupSurge(n, dWaveSetupSurge);
2028 dRunUp = (dThisWeight * dThisRunUp) + (dNextWeight * dNextRunUp);
2029 m_VCoast[nCoast].SetRunUp(n, dRunUp);
2041 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
2056 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
2060 m_VCoast[nCoast].SetBreakingWaveHeight(n, dNextBreakingWaveHeight);
2061 m_VCoast[nCoast].SetBreakingWaveAngle(n, dNextBreakingWaveAngle);
2062 m_VCoast[nCoast].SetDepthOfBreaking(n, dNextBreakingDepth);
2063 m_VCoast[nCoast].SetBreakingDistance(n, nNextBreakingDist);
2072 for (
int n = nThisCoastPoint + 1; n <= nNextCoastPoint; n++)
2076 m_VCoast[nCoast].SetBreakingWaveHeight(n, dThisBreakingWaveHeight);
2077 m_VCoast[nCoast].SetBreakingWaveAngle(n, dThisBreakingWaveAngle);
2078 m_VCoast[nCoast].SetDepthOfBreaking(n, dThisBreakingDepth);
2079 m_VCoast[nCoast].SetBreakingDistance(n, nThisBreakingDist);
2086 for (
int n = nThisCoastPoint + 1; n < nNextCoastPoint; n++)
2088 int const nDist = n - nThisCoastPoint;
2095 if ((dNextBreakingDepth > 0) && (dThisBreakingDepth > 0))
2097 double const dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween);
2098 double const dNextWeight = 1 - dThisWeight;
2100 dBreakingWaveHeight = (dThisWeight * dThisBreakingWaveHeight) + (dNextWeight * dNextBreakingWaveHeight),
2101 dBreakingWaveAngle = (dThisWeight * dThisBreakingWaveAngle) + (dNextWeight * dNextBreakingWaveAngle),
2102 dBreakingDepth = (dThisWeight * dThisBreakingDepth) + (dNextWeight * dNextBreakingDepth),
2103 dBreakingDist = (dThisWeight * nThisBreakingDist) + (dNextWeight * nNextBreakingDist);
2106 else if (dNextBreakingDepth > 0)
2108 dBreakingWaveHeight = dNextBreakingWaveHeight,
2109 dBreakingWaveAngle = dNextBreakingWaveAngle,
2110 dBreakingDepth = dNextBreakingDepth,
2111 dBreakingDist = nNextBreakingDist;
2114 else if (dThisBreakingDepth > 0)
2116 dBreakingWaveHeight = dThisBreakingWaveHeight,
2117 dBreakingWaveAngle = dThisBreakingWaveAngle,
2118 dBreakingDepth = dThisBreakingDepth,
2119 dBreakingDist = nThisBreakingDist;
2124 m_VCoast[nCoast].SetBreakingWaveHeight(n, dBreakingWaveHeight);
2125 m_VCoast[nCoast].SetBreakingWaveAngle(n, dBreakingWaveAngle);
2126 m_VCoast[nCoast].SetDepthOfBreaking(n, dBreakingDepth);
2136 int const nCoastPoints =
m_VCoast[nCoast].nGetCoastlineSize();
2139 vector<int> nVCoastWaveHeightX;
2140 vector<double> dVCoastWaveHeightY;
2143 for (
int n = 0; n < nCoastPoints; n++)
2145 double const dCoastWaveHeight =
m_VCoast[nCoast].dGetCoastWaveHeight(n);
2149 nVCoastWaveHeightX.push_back(n);
2150 dVCoastWaveHeightY.push_back(dCoastWaveHeight);
2155 if ((nVCoastWaveHeightX.size() >= 3) && (nVCoastWaveHeightX.size() == dVCoastWaveHeightY.size()))
2157 for (
int n = 0; n < nCoastPoints; n++)
2159 double const dInterpCoastWaveHeight =
dGetInterpolatedValue(&nVCoastWaveHeightX, &dVCoastWaveHeightY, n,
false);
2160 m_VCoast[nCoast].SetCoastWaveHeight(n, dInterpCoastWaveHeight);
2166 for (
int n = 0; n < nCoastPoints; n++)
2168 m_VCoast[nCoast].SetCoastWaveHeight(n, 0);
2178 int const nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
2180 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize; nCoastPoint++)
2185 if (nCoastPoint == 0)
2195 else if (nCoastPoint == nCoastSize - 1)
2221 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 90);
2225 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 270);
2233 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 0);
2237 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 180);
2243 double dAzimuthAngle;
2246 dAzimuthAngle = (180 /
PI) * (
PI * 0.5 - atan(dYDiff / dXDiff));
2249 dAzimuthAngle = (180 /
PI) * (
PI * 1.5 - atan(dYDiff / dXDiff));
2251 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, dAzimuthAngle);
2273 int const nPolyID =
m_pRasterGrid->m_Cell[nX][nY].nGetPolygonID();
2276 bool const bActive =
m_pRasterGrid->m_Cell[nX][nY].bIsInActiveZone();
2281 double const dTmpd50 =
m_pRasterGrid->m_Cell[nX][nY].dGetUnconsD50();
2288 VnPolygonD50Count[nPolyID]++;
2289 VdPolygonD50[nPolyID] += dTmpd50;
2314 int nDownDriftNum = 0;
2317 double dWaveHeight = 0;
2318 double dWaveAngle = 0;
2326 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2329 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2330 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2335 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2343 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2348 nDownDriftNum = nTmp;
2362 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2365 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2366 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2371 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2379 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2384 nDownDriftNum = nTmp;
2398 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2401 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2402 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2407 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2415 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2420 nDownDriftNum = nTmp;
2434 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2437 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2438 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2443 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2451 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2456 nDownDriftNum = nTmp;
2467 dWaveHeight /= nRead;
2468 dWaveAngle /= nRead;
2480 double const dDeepWaterWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveHeight();
2488 double const dDeepWaterWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveAngle();
2496 int const nShadowZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetShadowZoneNumber();
2498 if (nShadowZoneCode <= 0)
2501 if ((nShadow == 4) || (nShadow + nDownDrift == 4) || (nShadow + nCoast == 4))
2503 m_pRasterGrid->m_Cell[nX][nY].SetShadowZoneNumber(nShadowNum);
2510 int const nDownDriftZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetDownDriftZoneNumber();
2512 if ((nDownDriftZoneCode == 0) && (nDownDrift == 4))
2514 m_pRasterGrid->m_Cell[nX][nY].SetDownDriftZoneNumber(nDownDriftNum);
2524 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
2526 for (
int nPoly = 0; nPoly <
m_VCoast[nCoast].nGetNumPolygons(); nPoly++)
2531 if (VnPolygonD50Count[nPolyID] > 0)
2532 VdPolygonD50[nPolyID] /= VnPolygonD50Count[nPolyID];
Contains CGeom2DPoint definitions.
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 of polygons.
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
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.
vector< double > VdInterpolateCShoreProfileOutput(vector< double > const *, vector< double > const *, vector< double > const *)
Returns a linearly interpolated vector of doubles, to make CShore profile output compatible with CME....
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
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
int m_nNumPolygonGlobal
Number of global (all coasts) polygons.
double dGetInterpolatedValue(vector< double > const *, vector< double > const *, double, bool)
int nDoAllPropagateWaves(void)
Simulates wave propagation along all coastline-normal profiles, on all coasts.
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[])
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.