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;
104 if (pNextProfile == NULL)
112 dDist = nDistToNextProfile;
125 nDistFromPrevProfile++;
126 nDistToNextProfile--;
128 double dPrevWeight = (dDist - nDistFromPrevProfile) / dDist;
129 double dNextWeight = (dDist - nDistToNextProfile) / dDist;
130 double dThisDeepWaterWaveHeight = (dPrevWeight * dPrevProfileDeepWaterWaveHeight) + (dNextWeight * dNextProfileDeepWaterWaveHeight);
131 double dThisDeepWaterWaveAngle =
dKeepWithin360((dPrevWeight * dPrevProfileDeepWaterWaveAngle) + (dNextWeight * dNextProfileDeepWaterWaveAngle));
132 double dThisDeepWaterWavePeriod = (dPrevWeight * dPrevProfileDeepWaterWavePeriod) + (dNextWeight * dNextProfileDeepWaterWavePeriod);
134 m_VCoast[nCoast].SetCoastDeepWaterWaveHeight(nPoint, dThisDeepWaterWaveHeight);
135 m_VCoast[nCoast].SetCoastDeepWaterWaveAngle(nPoint, dThisDeepWaterWaveAngle);
136 m_VCoast[nCoast].SetCoastDeepWaterWavePeriod(nPoint, dThisDeepWaterWavePeriod);
152 vector<bool> VbBreakingAll;
154 vector<double> VdXAll;
155 vector<double> VdYAll;
156 vector<double> VdHeightXAll;
157 vector<double> VdHeightYAll;
160 bool bSomeNonStartOrEndOfCoastProfiles =
false;
162 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
164 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
165 int nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
167 static bool bDownCoast =
true;
170 for (
int nn = 0; nn < nNumProfiles; nn++)
172 vector<bool> VbBreaking;
175 vector<double> VdHeightX;
176 vector<double> VdHeightY;
181 pProfile =
m_VCoast[nCoast].pGetProfileWithDownCoastSeq(nn);
184 pProfile =
m_VCoast[nCoast].pGetProfileWithUpCoastSeq(nn);
207 if (VbBreaking.empty())
214 bSomeNonStartOrEndOfCoastProfiles =
true;
226 VdXAll.insert(VdXAll.end(), VdX.begin(), VdX.end());
227 VdYAll.insert(VdYAll.end(), VdY.begin(), VdY.end());
228 VdHeightXAll.insert(VdHeightXAll.end(), VdHeightX.begin(), VdHeightX.end());
229 VdHeightYAll.insert(VdHeightYAll.end(), VdHeightY.begin(), VdHeightY.end());
230 VbBreakingAll.insert(VbBreakingAll.end(), VbBreaking.begin(), VbBreaking.end());
233 bDownCoast = ! bDownCoast;
237 if (! bSomeNonStartOrEndOfCoastProfiles)
239 LogStream <<
m_ulIter <<
": waves are on-shore only, for start and/or end of coast profiles" << endl;
245 double dDeepWaterWaveX;
246 double dDeepWaterWaveY;
264 VdXAll.push_back(nX);
270 dDeepWaterWaveX =
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveHeight() * sin(
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveAngle() *
PI / 180);
271 dDeepWaterWaveY =
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveHeight() * cos(
m_pRasterGrid->m_Cell[nX][0].dGetCellDeepWaterWaveAngle() *
PI / 180);
274 VdHeightXAll.push_back(dDeepWaterWaveX);
275 VdHeightYAll.push_back(dDeepWaterWaveY);
286 VdXAll.push_back(nX);
296 VdHeightXAll.push_back(dDeepWaterWaveX);
297 VdHeightYAll.push_back(dDeepWaterWaveY);
312 VdYAll.push_back(nY);
317 dDeepWaterWaveX =
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveHeight() * sin(
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveAngle() *
PI / 180);
318 dDeepWaterWaveY =
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveHeight() * cos(
m_pRasterGrid->m_Cell[0][nY].dGetCellDeepWaterWaveAngle() *
PI / 180);
321 VdHeightXAll.push_back(dDeepWaterWaveX);
322 VdHeightYAll.push_back(dDeepWaterWaveY);
334 VdYAll.push_back(nY);
343 VdHeightXAll.push_back(dDeepWaterWaveX);
344 VdHeightYAll.push_back(dDeepWaterWaveY);
359 if (VbBreakingAll.empty())
510 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
512 int nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
514 for (
int nProfile = 0; nProfile < nNumProfiles; nProfile++)
583 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
585 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
586 int nNumProfiles =
m_VCoast[nCoast].nGetNumProfiles();
589 for (
int n = 0; n < nNumProfiles - 1; n++)
596 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize; nCoastPoint++)
599 double dBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nCoastPoint);
600 double dCoastPointWavePeriod =
m_VCoast[nCoast].dGetCoastDeepWaterWavePeriod(nCoastPoint);
605 m_VCoast[nCoast].SetBreakingWaveHeight(nCoastPoint, 0);
613 double dWaveEnergy = dErosiveWaveForce *
m_dTimeStep * 3600;
614 m_VCoast[nCoast].SetWaveEnergyAtBreaking(nCoastPoint, dWaveEnergy);
627 double dWaveToNormalAngle = 0;
631 dWaveToNormalAngle = fmod((dWaveAngle - dCoastAngle + 360), 360) - 90;
635 dWaveToNormalAngle = fmod((dWaveAngle - dCoastAngle + 360), 360) - 270;
637 if ((dWaveToNormalAngle >= 90) || (dWaveToNormalAngle <= -90))
640 return dWaveToNormalAngle;
663 int nSeaHand =
m_VCoast[nCoast].nGetSeaHandedness();
667 double dFluxOrientationThis =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint);
668 double dFluxOrientationPrev = 0;
669 double dFluxOrientationNext = 0;
671 if (nCoastPoint == 0)
673 dFluxOrientationPrev = dFluxOrientationThis;
674 dFluxOrientationNext =
m_VCoast[nCoast].dGetFluxOrientation(1);
677 else if (nCoastPoint == nCoastSize - 1)
679 dFluxOrientationPrev =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint - 2);
680 dFluxOrientationNext = dFluxOrientationThis;
685 dFluxOrientationPrev =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint - 1);
686 dFluxOrientationNext =
m_VCoast[nCoast].dGetFluxOrientation(nCoastPoint + 1);
707 double dWaveToNormalAnglePrev;
712 double dPrevDeepWaterWaveAngle =
m_VCoast[nCoast].dGetCoastDeepWaterWaveAngle(nCoastPoint - 1);
719 dWaveToNormalAnglePrev = dWaveToNormalAngle;
728 double dWaveToNormalAngleNext;
730 if (nCoastPoint < nCoastSize - 1)
733 double dNextDeepWaterWaveAngle =
m_VCoast[nCoast].dGetCoastDeepWaterWaveAngle(nCoastPoint + 1);
740 dWaveToNormalAngleNext = dWaveToNormalAngle;
751 if (dWaveToNormalAngle > 45)
753 if (dWaveToNormalAnglePrev < 45)
755 dWaveToNormalAngle = 45;
761 dWaveToNormalAngle = dWaveToNormalAnglePrev;
769 if (dWaveToNormalAngle < -45)
771 if (dWaveToNormalAngleNext > -45)
773 dWaveToNormalAngle = -45;
779 dWaveToNormalAngle = dWaveToNormalAngleNext;
790 dWaveToNormalAngle = dFluxOrientationPrev;
798 dWaveToNormalAngle = dFluxOrientationNext;
802 bool bBreaking =
false;
805 int nProfileBreakingDist = 0;
807 double dProfileBreakingWaveHeight =
DBL_NODATA;
808 double dProfileBreakingWaveAngle = 0;
809 double dProfileBreakingDepth = 0;
815 vector<bool> VbWaveIsBreaking(nProfileSize, 0);
817 vector<double> VdWaveHeight(nProfileSize, 0);
818 vector<double> VdWaveSetupSurge(nProfileSize, 0);
820 vector<double> VdWaveSetupRunUp(nProfileSize, 0);
821 vector<double> VdWaveDirection(nProfileSize, 0);
826 double dCShoreTimeStep = 3600;
830 vector<double> VdProfileZ;
831 vector<double> VdProfileDistXY;
832 vector<double> VdProfileFrictionFactor;
849 if (VdProfileDistXY.empty())
858 dWaveToNormalAngle =
tMax(dWaveToNormalAngle, -80.0);
859 dWaveToNormalAngle =
tMin(dWaveToNormalAngle, 80.0);
861 int nProfileDistXYSize =
static_cast<int>(VdProfileDistXY.size());
862 vector<double> VdFreeSurfaceStd(nProfileDistXYSize, 0);
863 vector<double> VdSinWaveAngleRadians(nProfileDistXYSize, 0);
864 vector<double> VdFractionBreakingWaves(nProfileDistXYSize, 0);
878 double dDX = VdProfileDistXY.back() / (
static_cast<double>(VdProfileDistXY.size() - 1));
879 double dWaveInitTime = 0;
880 double dSurgeInitTime = 0;
882#if defined CSHORE_FILE_INOUT || CSHORE_BOTH
891#if defined CSHORE_FILE_INOUT
893 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);
913 strErr = to_string(
m_ulIter) +
": CShore WARNING 1: negative depth at the first node ";
917 strErr = to_string(
m_ulIter) +
": CShore WARNING 2: negative value at end of landward marching computation ";
921 strErr = to_string(
m_ulIter) +
": CShore WARNING 3: large energy gradients at the first node: small waves with short period at sea boundary ";
925 strErr = to_string(
m_ulIter) +
": CShore WARNING 4: zero energy at the first node ";
929 strErr = to_string(
m_ulIter) +
": CShore WARNING 5: at end of landward marching computation, insufficient water depth ";
933 strErr = to_string(
m_ulIter) +
": CShore WARNING 7: did not reach convergence ";
937 strErr +=
"(coast " + to_string(nCoast) +
" profile " + to_string(pProfile->
nGetCoastID()) +
" profile length " + to_string(nOutSize) +
")\n";
946 string strOSETUP =
"OSETUP";
947 string strOYVELO =
"OYVELO";
948 string strOPARAM =
"OPARAM";
950 nRet =
nReadCShoreOutput(nProfile, &strOSETUP, 4, 4, &VdProfileDistXY, &VdFreeSurfaceStd);
955 nRet =
nReadCShoreOutput(nProfile, &strOYVELO, 4, 2, &VdProfileDistXY, &VdSinWaveAngleRadians);
960 nRet =
nReadCShoreOutput(nProfile, &strOPARAM, 4, 3, &VdProfileDistXY, &VdFractionBreakingWaves);
971 nRet = system(
"./clean.bat");
976 string strCommand =
"./save_CShore_output.sh ";
979 strCommand += to_string(nCoast);
981 strCommand += to_string(nProfile);
983 nRet = system(strCommand.c_str());
989 nRet = system(
"./clean.sh");
1003#if defined CSHORE_ARG_INOUT || CSHORE_BOTH
1010 vector<double> VdInitTime = {dWaveInitTime, dCShoreTimeStep};
1011 vector<double> VdTPIn = {dDeepWaterWavePeriod, dDeepWaterWavePeriod};
1012 vector<double> VdHrmsIn = {dProfileDeepWaterWaveHeight, dProfileDeepWaterWaveHeight};
1013 vector<double> VdWangIn = {dWaveToNormalAngle, dWaveToNormalAngle};
1014 vector<double> VdTSurg = {dSurgeInitTime, dCShoreTimeStep};
1015 vector<double> VdSWLin = {dSurgeLevel, dSurgeLevel};
1016 vector<double> VdFPInp = VdProfileFrictionFactor;
1047 &nProfileDistXYSize,
1048 &VdProfileDistXY[0],
1053 &VdXYDistFromCShoreOut[0],
1054 &VdFreeSurfaceStdOut[0],
1055 &VdWaveSetupSurgeOut[0],
1056 &VdSinWaveAngleRadiansOut[0],
1057 &VdFractionBreakingWavesOut[0]);
1064 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for coast " << nCoast <<
" profile " << pProfile->
nGetCoastID() <<
", only " << nOutSize <<
" CShore output rows, abandoning this profile" << endl;
1088 strErr = to_string(
m_ulIter) +
": CShore WARNING 1: negative depth at the first node ";
1092 strErr = to_string(
m_ulIter) +
": CShore WARNING 2: negative value at end of landward marching computation ";
1096 strErr = to_string(
m_ulIter) +
": CShore WARNING 3: large energy gradients at the first node: small waves with short period at sea boundary ";
1100 strErr = to_string(
m_ulIter) +
": CShore WARNING 4: zero energy at the first node ";
1104 strErr = to_string(
m_ulIter) +
": CShore WARNING 5: at end of landward marching computation, insufficient water depth ";
1108 strErr = to_string(
m_ulIter) +
": CShore WARNING 7: did not reach convergence ";
1112 strErr +=
"(coast " + to_string(nCoast) +
" profile " + to_string(pProfile->
nGetCoastID()) +
" profile length " + to_string(nOutSize) +
")\n";
1122 InterpolateCShoreOutput(&VdProfileDistXY, nOutSize, nProfileSize, &VdXYDistFromCShoreOut, &VdFreeSurfaceStdOut, &VdWaveSetupSurgeOut, &VdSinWaveAngleRadiansOut, &VdFractionBreakingWavesOut, &VdFreeSurfaceStd, &VdWaveSetupSurge, &VdSinWaveAngleRadians, &VdFractionBreakingWaves);
1125#if defined CSHORE_BOTH
1130 string strCommand =
"./save_CShore_output.sh ";
1133 strCommand += to_string(nCoast);
1135 strCommand += to_string(nProfile);
1137 nRet = system(strCommand.c_str());
1154 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1160 if (nProfilePoint >
static_cast<int>(VdFreeSurfaceStd.size()) - 1)
1164 if (isnan(VdFreeSurfaceStd[nProfilePoint]))
1165 VdFreeSurfaceStd[nProfilePoint] = 0;
1167 VdWaveHeight[nProfilePoint] = sqrt(8) * VdFreeSurfaceStd[nProfilePoint];
1170 if (isnan(VdSinWaveAngleRadians[nProfilePoint]))
1172 VdSinWaveAngleRadians[nProfilePoint] = 0;
1173 VdWaveHeight[nProfilePoint] = 0;
1177 if (VdSinWaveAngleRadians[nProfilePoint] < -1)
1178 VdSinWaveAngleRadians[nProfilePoint] = -1;
1180 if (VdSinWaveAngleRadians[nProfilePoint] > 1)
1181 VdSinWaveAngleRadians[nProfilePoint] = 1;
1183 double dAlpha = asin(VdSinWaveAngleRadians[nProfilePoint]) * (180 /
PI);
1186 VdWaveDirection[nProfilePoint] =
dKeepWithin360(dAlpha + 90 + dFluxOrientationThis);
1189 VdWaveDirection[nProfilePoint] =
dKeepWithin360(dAlpha + 270 + dFluxOrientationThis);
1192 if (isnan(VdFractionBreakingWaves[nProfilePoint]))
1194 VdFractionBreakingWaves[nProfilePoint] = 0;
1195 VdWaveHeight[nProfilePoint] = 0;
1203 dProfileBreakingWaveHeight = VdWaveHeight[nProfilePoint];
1204 dProfileBreakingWaveAngle = VdWaveDirection[nProfilePoint];
1205 dProfileBreakingDepth =
m_pRasterGrid->m_Cell[nX][nY].dGetSeaDepth();
1206 nProfileBreakingDist = nProfilePoint + 1;
1211 VbWaveIsBreaking[nProfilePoint] = bBreaking;
1214 if (dProfileBreakingWaveHeight >= dProfileDeepWaterWaveHeight)
1226 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1235 double dSeaDepth =
m_pRasterGrid->m_Cell[nX][nY].dGetSeaDepth();
1237 if (dSeaDepth > dDepthLookupMax)
1240 dProfileWaveHeight = dProfileDeepWaterWaveHeight;
1241 dProfileWaveAngle = dProfileDeepWaterWaveAngle;
1250 double dC =
m_dC_0 * tanh((2 *
PI * dSeaDepth) / dL);
1251 double dk = 2 *
PI / dL;
1252 double dn = ((2 * dSeaDepth * dk) / (sinh(2 * dSeaDepth * dk)) + 1) / 2;
1253 double dKs = sqrt(
m_dC_0 / (dn * dC * 2));
1254 double dAlpha = (180 /
PI) * asin((dC /
m_dC_0) * sin((
PI / 180) * dWaveToNormalAngle));
1255 double dKr = sqrt(cos((
PI / 180) * dWaveToNormalAngle) / cos((
PI / 180) * dAlpha));
1256 dProfileWaveHeight = dProfileDeepWaterWaveHeight * dKs * dKr;
1259 dProfileWaveAngle =
dKeepWithin360(dAlpha + 90 + dFluxOrientationThis);
1262 dProfileWaveAngle =
dKeepWithin360(dAlpha + 270 + dFluxOrientationThis);
1267 dProfileBreakingWaveHeight = dProfileWaveHeight;
1268 dProfileBreakingWaveAngle = dProfileWaveAngle;
1278 dProfileWaveAngle = dProfileBreakingWaveAngle;
1280 dProfileWaveHeight = dProfileBreakingWaveHeight * (nProfilePoint / nProfileBreakingDist);
1282 dProfileBreakingDepth = dSeaDepth;
1283 nProfileBreakingDist = nProfilePoint;
1288 VdWaveDirection[nProfilePoint] = dProfileWaveAngle;
1289 VdWaveHeight[nProfilePoint] = dProfileWaveHeight;
1290 VbWaveIsBreaking[nProfilePoint] = bBreaking;
1295 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1305 double dWaveHeight = VdWaveHeight[nProfilePoint];
1306 double dWaveAngle = VdWaveDirection[nProfilePoint];
1308 bBreaking = VbWaveIsBreaking[nProfilePoint];
1311 pVdX->push_back(nX);
1312 pVdY->push_back(nY);
1313 pVdHeightX->push_back(dWaveHeight * sin(dWaveAngle *
PI / 180));
1314 pVdHeightY->push_back(dWaveHeight * cos(dWaveAngle *
PI / 180));
1315 pVbBreaking->push_back(bBreaking);
1336 double dDiffProfileDistXY = hypot(dXDist, dYDist);
1342 int nValidPointsWaveHeight = 0;
1343 int nValidPointsWaveSetup = 0;
1345 for (
int nPoint = 0; nPoint < static_cast<int>(VdWaveHeight.size()); nPoint++)
1347 if (VdWaveHeight[nPoint] > 1e-4)
1349 nValidPointsWaveHeight += 1;
1358 nValidPointsWaveHeight -= 1;
1360 for (
int nPoint = 0; nPoint < static_cast<int>(VdWaveSetupSurge.size()); nPoint++)
1362 if (
tAbs(VdWaveSetupSurge[nPoint]) < 1)
1364 nValidPointsWaveSetup += 1;
1373 nValidPointsWaveSetup -= 1;
1375 double dWaveHeight = 0;
1380 dWaveHeight = VdWaveHeight[nValidPointsWaveHeight];
1389 dRunUp = 0.36 * pow(9.81, 0.5) * dtanBeta * pow(dWaveHeight, 0.5) * dDeepWaterWavePeriod;
1395 double dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1396 dRunUp = 1.86 * dWaveHeight * pow(pow(dtanBeta / dS0, 0.5), 0.71);
1402 double dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1405 double dH0OverL0 = (1 / dS0) * dWaveHeight;
1406 double dTmp1 = 0.35 * dWaveHeight * pow(dH0OverL0, 0.5);
1407 double dTmp2 = pow(dH0OverL0 * ((0.563 * dWaveHeight * dWaveHeight) + 0.0004), 0.5);
1408 dRunUp = 1.1 * (dTmp1 + (dTmp2 / 2));
1411 if ((
tAbs(dRunUp) < 1e-4) || (isnan(dRunUp)))
1416 double dWaveSetupSurge = 0;
1421 dWaveSetupSurge = VdWaveSetupSurge[nValidPointsWaveSetup];
1424 if ((
tAbs(dWaveSetupSurge) < 1e-4) || (isnan(dWaveSetupSurge)))
1426 dWaveSetupSurge = 0;
1431 m_VCoast[nCoast].SetCoastWaveHeight(nCoastPoint, dWaveHeight);
1432 m_VCoast[nCoast].SetWaveSetupSurge(nCoastPoint, dWaveSetupSurge);
1433 m_VCoast[nCoast].SetRunUp(nCoastPoint, dRunUp);
1435 if (nProfileBreakingDist > 0)
1438 m_VCoast[nCoast].SetBreakingWaveHeight(nCoastPoint, dProfileBreakingWaveHeight);
1439 m_VCoast[nCoast].SetBreakingWaveAngle(nCoastPoint, dProfileBreakingWaveAngle);
1440 m_VCoast[nCoast].SetDepthOfBreaking(nCoastPoint, dProfileBreakingDepth);
1441 m_VCoast[nCoast].SetBreakingDistance(nCoastPoint, nProfileBreakingDist);
1460#if defined CSHORE_FILE_INOUT
1464int 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)
1467 ofstream CShoreOutStream;
1468 CShoreOutStream.open(
CSHORE_INFILE.c_str(), ios::out | ios::app);
1470 if (CShoreOutStream.fail())
1478 CShoreOutStream << 3 << endl;
1479 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1480 CShoreOutStream <<
"CShore input file created by CoastalME for iteration " <<
m_ulIter <<
", coast " << nCoast <<
", profile " << nProfile << endl;
1481 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1482 CShoreOutStream << nILine <<
" -> ILINE" << endl;
1483 CShoreOutStream << nIProfl <<
" -> IPROFL" << endl;
1484 CShoreOutStream << nIPerm <<
" -> IPERM" << endl;
1485 CShoreOutStream << nIOver <<
" -> IOVER" << endl;
1486 CShoreOutStream << nIWcint <<
" -> IWCINT" << endl;
1487 CShoreOutStream << nIRoll <<
" -> IROLL" << endl;
1488 CShoreOutStream << nIWind <<
" -> IWIND" << endl;
1489 CShoreOutStream << nITide <<
" -> ITIDE" << endl;
1490 CShoreOutStream << fixed;
1491 CShoreOutStream << setw(11) << setprecision(4) << dX <<
" -> DX" << endl;
1493 CShoreOutStream << setw(11) << nILab <<
" -> ILAB" << endl;
1494 CShoreOutStream << setw(11) << nWave <<
" -> NWAVE" << endl;
1495 CShoreOutStream << setw(11) << nSurge <<
" -> NSURGE" << endl;
1498 CShoreOutStream << setw(11) << setprecision(2) << dWaveInitTime;
1499 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1500 CShoreOutStream << setw(11) << dHrms;
1501 CShoreOutStream << setw(11) << dWaveAngle << endl;
1504 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1505 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1506 CShoreOutStream << setw(11) << dHrms;
1507 CShoreOutStream << setw(11) << dWaveAngle << endl;
1510 CShoreOutStream << setw(11) << setprecision(2) << dSurgeInitTime;
1511 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1514 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1515 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1518 CShoreOutStream << setw(8) << pVdXdist->size() <<
" -> NBINP" << endl;
1520 CShoreOutStream << fixed << setprecision(4);
1522 for (
unsigned int i = 0; i < pVdXdist->size(); i++)
1524 CShoreOutStream << setw(11) << pVdXdist->at(i) << setw(11) << pVdBottomElevation->at(i) << setw(11) << pVdWaveFriction->at(i) << endl;
1526 CShoreOutStream << endl;
1529 CShoreOutStream.close();
1540 bool bIsBehindIntervention =
false;
1547 double dProfileDistXY = 0;
1548 double dProfileFricFact;
1549 double dPrevDist = -1;
1551 for (
int i = nProfSize - 1; i >= 0; i--)
1557 if (i == nProfSize - 1)
1564 dProfileDistXY = dProfileDistXY + hypot(dXDist, dYDist);
1569 dProfileDistXY += 0.1;
1576 int const nTopLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
1587 double dTopElev =
m_pRasterGrid->m_Cell[nX][nY].dGetSedimentTopElev() +
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1595 VdVZ->push_back(0.1);
1598 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;
1603 VdVZ->push_back(VdProfileZ);
1609 VdVZ->push_back(VdProfileZ);
1613 VdDistXY->push_back(dProfileDistXY);
1616 double dInterventionHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1619 if (dInterventionHeight > 0 || bIsBehindIntervention)
1623 bIsBehindIntervention =
true;
1630 VdFricF->push_back(dProfileFricFact);
1633 dPrevDist = dProfileDistXY;
1639#if defined CSHORE_FILE_INOUT
1643int CSimulation::nReadCShoreOutput(
int const nProfile,
string const* strCShoreFilename,
int const nExpectedColumns,
int const nCShorecolumn, vector<double>
const* pVdProfileDistXYCME, vector<double> *pVdInterpolatedValues)
1647 InStream.open(strCShoreFilename->c_str(), ios::in);
1650 if (! InStream.is_open())
1653 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", cannot open " << * strCShoreFilename <<
" for input" << endl;
1659 vector<double> VdXYDistCShore;
1660 vector<double> VdValuesCShore;
1664 int nExpectedRows = 0;
1667 while (getline(InStream, strLineIn))
1678 string strErr =
ERR +
"invalid integer for number of expected rows '" + VstrItems[1] +
"' in " + * strCShoreFilename +
"\n";
1686 nExpectedRows = stoi(VstrItems[1]);
1694 int nCols =
static_cast<int>(VstrItems.size());
1696 if (nCols != nExpectedColumns)
1699 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedColumns <<
" CShore output columns but read " << nCols <<
" columns from header section of file " << * strCShoreFilename << endl;
1705 VdXYDistCShore.push_back(strtod(VstrItems[0].c_str(), NULL));
1706 VdValuesCShore.push_back(strtod(VstrItems[nCShorecolumn - 1].c_str(), NULL));
1711 int nReadRows =
static_cast<int>(VdXYDistCShore.size());
1713 if (nReadRows != nExpectedRows)
1716 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedRows <<
" CShore output rows, but read " << nReadRows <<
" rows from file " << * strCShoreFilename << endl;
1725 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for profile " << nProfile <<
", only " << nReadRows <<
" CShore output rows in file " << * strCShoreFilename << endl;
1728 VdXYDistCShore.push_back(VdXYDistCShore[0]);
1729 VdValuesCShore.push_back(VdValuesCShore[0]);
1736 vector<double> VdXYDistCShoreTmp(nReadRows, 0);
1738 for (
int i = 0; i < nReadRows; i++)
1739 VdXYDistCShoreTmp[i] = VdXYDistCShore[nReadRows - 1] - VdXYDistCShore[i];
1742 reverse(VdXYDistCShoreTmp.begin(), VdXYDistCShoreTmp.end());
1745 reverse(VdValuesCShore.begin(), VdValuesCShore.end());
1748 vector<double> VdDistXYCopy(pVdProfileDistXYCME->begin(), pVdProfileDistXYCME->end());
1757#if defined CSHORE_ARG_INOUT || CSHORE_BOTH
1761void 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)
1768 bool bTooShort =
false;
1771 if (nOutSize < nProfileSize)
1774 nTooShort = nProfileSize - nOutSize;
1795 double dLastDiff = pVdXYDistFromCShore->at(nOutSize - 1) - pVdXYDistFromCShore->at(nOutSize - 2);
1797 for (
int n = 0; n < nTooShort; n++)
1798 pVdXYDistFromCShore->at(nOutSize + n) = pVdXYDistFromCShore->at(nOutSize - 1 + n) + dLastDiff;
1800 for (
int n = 0; n < nTooShort; n++)
1801 pVdFreeSurfaceStdCShore->at(nOutSize + n) = pVdFreeSurfaceStdCShore->at(nOutSize - 1);
1803 for (
int n = 0; n < nTooShort; n++)
1804 pVdWaveSetupSurgeCShore->at(nOutSize + n) = pVdWaveSetupSurgeCShore->at(nOutSize - 1);
1808 for (
int n = 0; n < nTooShort; n++)
1809 pVdSinWaveAngleRadiansCShore->at(nOutSize + n) = pVdSinWaveAngleRadiansCShore->at(nOutSize - 1);
1811 dLastDiff = pVdFractionBreakingWavesCShore->at(nOutSize - 1) - pVdFractionBreakingWavesCShore->at(nOutSize - 2);
1813 for (
int n = 0; n < nTooShort; n++)
1814 pVdFractionBreakingWavesCShore->at(nOutSize + n) =
tMin(pVdFractionBreakingWavesCShore->at(nOutSize - 1 + n) + dLastDiff, 1.0);
1825 vector<double> VdXYDistCShoreTmp(nProfileSize);
1826 copy(pVdXYDistFromCShore->begin(), pVdXYDistFromCShore->begin() + nProfileSize, begin(VdXYDistCShoreTmp));
1829 vector<double> VdFreeSurfaceStdCShoreTmp(nProfileSize);
1830 reverse_copy(pVdFreeSurfaceStdCShore->begin(), pVdFreeSurfaceStdCShore->begin() + nProfileSize, begin(VdFreeSurfaceStdCShoreTmp));
1832 vector<double> VdWaveSetupSurgeCShoreTmp(nProfileSize);
1833 reverse_copy(pVdWaveSetupSurgeCShore->begin(), pVdWaveSetupSurgeCShore->begin() + nProfileSize, begin(VdWaveSetupSurgeCShoreTmp));
1835 vector<double> VdSinWaveAngleRadiansCShoreTmp(nProfileSize);
1836 reverse_copy(pVdSinWaveAngleRadiansCShore->begin(), pVdSinWaveAngleRadiansCShore->begin() + nProfileSize, begin(VdSinWaveAngleRadiansCShoreTmp));
1838 vector<double> VdFractionBreakingWavesCShoreTmp(nProfileSize);
1839 reverse_copy(pVdFractionBreakingWavesCShore->begin(), pVdFractionBreakingWavesCShore->begin() + nProfileSize, begin(VdFractionBreakingWavesCShoreTmp));
1876 bool bModfiedWaveHeightisBreaking =
false;
1877 bool bProfileIsinShadowZone =
false;
1880 int nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1881 double dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1882 double dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1883 double dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1886 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1894 bProfileIsinShadowZone =
true;
1897 double dWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight();
1903 bModfiedWaveHeightisBreaking =
true;
1906 dThisBreakingWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveAngle();
1908 nThisBreakingDist = nProfilePoint;
1914 if (bProfileIsinShadowZone && bModfiedWaveHeightisBreaking)
1917 if (dThisBreakingWaveHeight > dThisBreakingDepth * 0.78)
1919 dThisBreakingWaveHeight = dThisBreakingDepth * 0.78;
1923 m_VCoast[nCoast].SetBreakingWaveHeight(nThisCoastPoint, dThisBreakingWaveHeight);
1924 m_VCoast[nCoast].SetBreakingWaveAngle(nThisCoastPoint, dThisBreakingWaveAngle);
1925 m_VCoast[nCoast].SetDepthOfBreaking(nThisCoastPoint, dThisBreakingDepth);
1926 m_VCoast[nCoast].SetBreakingDistance(nThisCoastPoint, nThisBreakingDist);
1931 else if (bProfileIsinShadowZone && (! bModfiedWaveHeightisBreaking))
1959 int const nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1960 double dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1961 double dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1962 double dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1963 double dThisWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nThisCoastPoint);
1965 double dThisRunUp =
m_VCoast[nCoast].dGetRunUp(nThisCoastPoint);
1982 pTmpProfile = pNextProfile;
1993 int const nDistBetween = nNextCoastPoint - nThisCoastPoint;
1996 if (nDistBetween <= 0)
2000 int nNextBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nNextCoastPoint);
2001 double dNextBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nNextCoastPoint);
2002 double dNextBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nNextCoastPoint);
2003 double dNextBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nNextCoastPoint);
2004 double dNextWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nNextCoastPoint);
2005 double dNextRunUp =
m_VCoast[nCoast].dGetRunUp(nNextCoastPoint);
2008 for (
int n = nThisCoastPoint; n <= nNextCoastPoint; n++)
2011 int nDist = n - nThisCoastPoint;
2012 double dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween);
2013 double dNextWeight = 1 - dThisWeight;
2014 double dWaveSetupSurge = 0;
2017 dWaveSetupSurge = (dThisWeight * dThisWaveSetupSurge) + (dNextWeight * dNextWaveSetupSurge);
2018 m_VCoast[nCoast].SetWaveSetupSurge(n, dWaveSetupSurge);
2020 dRunUp = (dThisWeight * dThisRunUp) + (dNextWeight * dNextRunUp);
2021 m_VCoast[nCoast].SetRunUp(n, dRunUp);
2033 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
2048 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
2052 m_VCoast[nCoast].SetBreakingWaveHeight(n, dNextBreakingWaveHeight);
2053 m_VCoast[nCoast].SetBreakingWaveAngle(n, dNextBreakingWaveAngle);
2054 m_VCoast[nCoast].SetDepthOfBreaking(n, dNextBreakingDepth);
2055 m_VCoast[nCoast].SetBreakingDistance(n, nNextBreakingDist);
2064 for (
int n = nThisCoastPoint + 1; n <= nNextCoastPoint; n++)
2068 m_VCoast[nCoast].SetBreakingWaveHeight(n, dThisBreakingWaveHeight);
2069 m_VCoast[nCoast].SetBreakingWaveAngle(n, dThisBreakingWaveAngle);
2070 m_VCoast[nCoast].SetDepthOfBreaking(n, dThisBreakingDepth);
2071 m_VCoast[nCoast].SetBreakingDistance(n, nThisBreakingDist);
2078 for (
int n = nThisCoastPoint + 1; n < nNextCoastPoint; n++)
2080 int nDist = n - nThisCoastPoint;
2087 if ((dNextBreakingDepth > 0) && (dThisBreakingDepth > 0))
2090 dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween),
2091 dNextWeight = 1 - dThisWeight;
2093 dBreakingWaveHeight = (dThisWeight * dThisBreakingWaveHeight) + (dNextWeight * dNextBreakingWaveHeight),
2094 dBreakingWaveAngle = (dThisWeight * dThisBreakingWaveAngle) + (dNextWeight * dNextBreakingWaveAngle),
2095 dBreakingDepth = (dThisWeight * dThisBreakingDepth) + (dNextWeight * dNextBreakingDepth),
2096 dBreakingDist = (dThisWeight * nThisBreakingDist) + (dNextWeight * nNextBreakingDist);
2099 else if (dNextBreakingDepth > 0)
2101 dBreakingWaveHeight = dNextBreakingWaveHeight,
2102 dBreakingWaveAngle = dNextBreakingWaveAngle,
2103 dBreakingDepth = dNextBreakingDepth,
2104 dBreakingDist = nNextBreakingDist;
2107 else if (dThisBreakingDepth > 0)
2109 dBreakingWaveHeight = dThisBreakingWaveHeight,
2110 dBreakingWaveAngle = dThisBreakingWaveAngle,
2111 dBreakingDepth = dThisBreakingDepth,
2112 dBreakingDist = nThisBreakingDist;
2117 m_VCoast[nCoast].SetBreakingWaveHeight(n, dBreakingWaveHeight);
2118 m_VCoast[nCoast].SetBreakingWaveAngle(n, dBreakingWaveAngle);
2119 m_VCoast[nCoast].SetDepthOfBreaking(n, dBreakingDepth);
2129 int nCoastPoints =
m_VCoast[nCoast].nGetCoastlineSize();
2132 vector<int> nVCoastWaveHeightX;
2133 vector<double> dVCoastWaveHeightY;
2136 for (
int n = 0; n < nCoastPoints; n++)
2138 double dCoastWaveHeight =
m_VCoast[nCoast].dGetCoastWaveHeight(n);
2142 nVCoastWaveHeightX.push_back(n);
2143 dVCoastWaveHeightY.push_back(dCoastWaveHeight);
2148 if ((nVCoastWaveHeightX.size() >= 3) && (nVCoastWaveHeightX.size() == dVCoastWaveHeightY.size()))
2150 for (
int n = 0; n < nCoastPoints; n++)
2152 double dInterpCoastWaveHeight =
dGetInterpolatedValue(&nVCoastWaveHeightX, &dVCoastWaveHeightY, n,
false);
2153 m_VCoast[nCoast].SetCoastWaveHeight(n, dInterpCoastWaveHeight);
2159 for (
int n = 0; n < nCoastPoints; n++)
2161 m_VCoast[nCoast].SetCoastWaveHeight(n, 0);
2171 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
2173 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize; nCoastPoint++)
2178 if (nCoastPoint == 0)
2188 else if (nCoastPoint == nCoastSize - 1)
2214 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 90);
2218 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 270);
2226 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 0);
2230 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 180);
2236 double dAzimuthAngle;
2239 dAzimuthAngle = (180 /
PI) * (
PI * 0.5 - atan(dYDiff / dXDiff));
2242 dAzimuthAngle = (180 /
PI) * (
PI * 1.5 - atan(dYDiff / dXDiff));
2244 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, dAzimuthAngle);
2269 bool bActive =
m_pRasterGrid->m_Cell[nX][nY].bIsInActiveZone();
2274 double dTmpd50 =
m_pRasterGrid->m_Cell[nX][nY].dGetUnconsD50();
2281 VnPolygonD50Count[nID]++;
2282 VdPolygonD50[nID] += dTmpd50;
2307 int nDownDriftNum = 0;
2310 double dWaveHeight = 0;
2311 double dWaveAngle = 0;
2319 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2322 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2323 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2328 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2336 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2341 nDownDriftNum = nTmp;
2355 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2358 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2359 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2364 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2372 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2377 nDownDriftNum = nTmp;
2391 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2394 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2395 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2400 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2408 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2413 nDownDriftNum = nTmp;
2427 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2430 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2431 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2436 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2444 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2449 nDownDriftNum = nTmp;
2460 dWaveHeight /= nRead;
2461 dWaveAngle /= nRead;
2473 double dDeepWaterWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveHeight();
2481 double dDeepWaterWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveAngle();
2489 int nShadowZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetShadowZoneNumber();
2491 if (nShadowZoneCode <= 0)
2494 if ((nShadow == 4) || (nShadow + nDownDrift == 4) || (nShadow + nCoast == 4))
2496 m_pRasterGrid->m_Cell[nX][nY].SetShadowZoneNumber(nShadowNum);
2503 int nDownDriftZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetDownDriftZoneNumber();
2505 if ((nDownDriftZoneCode == 0) && (nDownDrift == 4))
2507 m_pRasterGrid->m_Cell[nX][nY].SetDownDriftZoneNumber(nDownDriftNum);
2517 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
2519 for (
int nPoly = 0; nPoly <
m_VCoast[nCoast].nGetNumPolygons(); nPoly++)
2524 if (VnPolygonD50Count[nID] > 0)
2525 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 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.
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)
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
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
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.
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.