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;
1308 for (
int nPoint = 0; nPoint < static_cast<int>(VdWaveSetupSurge.size()); nPoint++)
1310 if (
tAbs(VdWaveSetupSurge[nPoint]) < 1)
1312 nValidPointsWaveSetup += 1;
1319 nValidPointsWaveSetup -= 1;
1321 double dWaveHeight = 0;
1326 dWaveHeight = VdWaveHeight[nValidPointsWaveHeight];
1334 dRunUp = 0.36 * pow(9.81, 0.5) * dtanBeta * pow(dWaveHeight, 0.5) * dDeepWaterWavePeriod;
1339 double dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1340 dRunUp = 1.86 * dWaveHeight * pow(pow(dtanBeta / dS0, 0.5), 0.71);
1345 double dS0 = 2 *
PI * dWaveHeight / (9.81 * dDeepWaterWavePeriod * dDeepWaterWavePeriod);
1348 double dH0OverL0 = (1 / dS0) * dWaveHeight;
1349 double dTmp1 = 0.35 * dWaveHeight * pow(dH0OverL0, 0.5);
1350 double dTmp2 = pow(dH0OverL0 * ((0.563 * dWaveHeight * dWaveHeight) + 0.0004), 0.5);
1351 dRunUp = 1.1 * (dTmp1 + (dTmp2 / 2));
1354 if ((
tAbs(dRunUp) < 1e-4) || (isnan(dRunUp)))
1359 double dWaveSetupSurge = 0;
1364 dWaveSetupSurge = VdWaveSetupSurge[nValidPointsWaveSetup];
1367 if ((
tAbs(dWaveSetupSurge) < 1e-4) || (isnan(dWaveSetupSurge)))
1369 dWaveSetupSurge = 0;
1374 m_VCoast[nCoast].SetCoastWaveHeight(nCoastPoint, dWaveHeight);
1375 m_VCoast[nCoast].SetWaveSetupSurge(nCoastPoint, dWaveSetupSurge);
1376 m_VCoast[nCoast].SetRunUp(nCoastPoint, dRunUp);
1378 if (nProfileBreakingDist > 0)
1381 m_VCoast[nCoast].SetBreakingWaveHeight(nCoastPoint, dProfileBreakingWaveHeight);
1382 m_VCoast[nCoast].SetBreakingWaveAngle(nCoastPoint, dProfileBreakingWaveAngle);
1383 m_VCoast[nCoast].SetDepthOfBreaking(nCoastPoint, dProfileBreakingDepth);
1384 m_VCoast[nCoast].SetBreakingDistance(nCoastPoint, nProfileBreakingDist);
1402#if defined CSHORE_FILE_INOUT
1406int 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)
1409 ofstream CShoreOutStream;
1410 CShoreOutStream.open(
CSHORE_INFILE.c_str(), ios::out | ios::app);
1411 if (CShoreOutStream.fail())
1419 CShoreOutStream << 3 << endl;
1420 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1421 CShoreOutStream <<
"CShore input file created by CoastalME for iteration " <<
m_ulIter <<
", coast " << nCoast <<
", profile " << nProfile << endl;
1422 CShoreOutStream <<
"------------------------------------------------------------" << endl;
1423 CShoreOutStream << nILine <<
" -> ILINE" << endl;
1424 CShoreOutStream << nIProfl <<
" -> IPROFL" << endl;
1425 CShoreOutStream << nIPerm <<
" -> IPERM" << endl;
1426 CShoreOutStream << nIOver <<
" -> IOVER" << endl;
1427 CShoreOutStream << nIWcint <<
" -> IWCINT" << endl;
1428 CShoreOutStream << nIRoll <<
" -> IROLL" << endl;
1429 CShoreOutStream << nIWind <<
" -> IWIND" << endl;
1430 CShoreOutStream << nITide <<
" -> ITIDE" << endl;
1431 CShoreOutStream << fixed;
1432 CShoreOutStream << setw(11) << setprecision(4) << dX <<
" -> DX" << endl;
1434 CShoreOutStream << setw(11) << nILab <<
" -> ILAB" << endl;
1435 CShoreOutStream << setw(11) << nWave <<
" -> NWAVE" << endl;
1436 CShoreOutStream << setw(11) << nSurge <<
" -> NSURGE" << endl;
1439 CShoreOutStream << setw(11) << setprecision(2) << dWaveInitTime;
1440 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1441 CShoreOutStream << setw(11) << dHrms;
1442 CShoreOutStream << setw(11) << dWaveAngle << endl;
1445 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1446 CShoreOutStream << setw(11) << setprecision(4) << dWavePeriod;
1447 CShoreOutStream << setw(11) << dHrms;
1448 CShoreOutStream << setw(11) << dWaveAngle << endl;
1451 CShoreOutStream << setw(11) << setprecision(2) << dSurgeInitTime;
1452 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1455 CShoreOutStream << setw(11) << setprecision(2) << dTimestep;
1456 CShoreOutStream << setw(11) << setprecision(4) << dSurgeLevel << endl;
1459 CShoreOutStream << setw(8) << pVdXdist->size() <<
" -> NBINP" << endl;
1461 CShoreOutStream << fixed << setprecision(4);
1462 for (
unsigned int i = 0; i < pVdXdist->size(); i++)
1464 CShoreOutStream << setw(11) << pVdXdist->at(i) << setw(11) << pVdBottomElevation->at(i) << setw(11) << pVdWaveFriction->at(i) << endl;
1466 CShoreOutStream << endl;
1469 CShoreOutStream.close();
1480 bool bIsBehindIntervention =
false;
1487 double dProfileDistXY = 0;
1488 double dProfileFricFact;
1489 double dPrevDist = -1;
1491 for (
int i = nProfSize - 1; i >= 0; i--)
1497 if (i == nProfSize - 1)
1503 dProfileDistXY = dProfileDistXY + hypot(dXDist, dYDist);
1508 dProfileDistXY += 0.1;
1515 int const nTopLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
1526 double dTopElev =
m_pRasterGrid->m_Cell[nX][nY].dGetSedimentTopElev() +
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1534 VdVZ->push_back(0.1);
1537 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;
1541 VdVZ->push_back(VdProfileZ);
1546 VdVZ->push_back(VdProfileZ);
1550 VdDistXY->push_back(dProfileDistXY);
1553 double dInterventionHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetInterventionHeight();
1556 if (dInterventionHeight > 0 || bIsBehindIntervention)
1560 bIsBehindIntervention =
true;
1566 VdFricF->push_back(dProfileFricFact);
1569 dPrevDist = dProfileDistXY;
1575#if defined CSHORE_FILE_INOUT
1579int CSimulation::nReadCShoreOutput(
int const nProfile,
string const *strCShoreFilename,
int const nExpectedColumns,
int const nCShorecolumn, vector<double>
const* pVdProfileDistXYCME, vector<double>* pVdInterpolatedValues)
1583 InStream.open(strCShoreFilename->c_str(), ios::in);
1586 if (! InStream.is_open())
1589 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", cannot open " << *strCShoreFilename <<
" for input" << endl;
1595 vector<double> VdXYDistCShore;
1596 vector<double> VdValuesCShore;
1600 int nExpectedRows = 0;
1602 while (getline(InStream, strLineIn))
1613 string strErr =
ERR +
"invalid integer for number of expected rows '" + VstrItems[1] +
"' in " + *strCShoreFilename +
"\n";
1621 nExpectedRows = stoi(VstrItems[1]);
1628 int nCols =
static_cast<int>(VstrItems.size());
1629 if (nCols != nExpectedColumns)
1632 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedColumns <<
" CShore output columns but read " << nCols <<
" columns from header section of file " << *strCShoreFilename << endl;
1638 VdXYDistCShore.push_back(strtod(VstrItems[0].c_str(), NULL));
1639 VdValuesCShore.push_back(strtod(VstrItems[nCShorecolumn - 1].c_str(), NULL));
1644 int nReadRows =
static_cast<int>(VdXYDistCShore.size());
1645 if (nReadRows != nExpectedRows)
1648 LogStream <<
m_ulIter <<
": " <<
ERR <<
"for profile " << nProfile <<
", expected " << nExpectedRows <<
" CShore output rows, but read " << nReadRows <<
" rows from file " << *strCShoreFilename << endl;
1657 LogStream <<
m_ulIter <<
": " <<
WARN <<
"for profile " << nProfile <<
", only " << nReadRows <<
" CShore output rows in file " << *strCShoreFilename << endl;
1660 VdXYDistCShore.push_back(VdXYDistCShore[0]);
1661 VdValuesCShore.push_back(VdValuesCShore[0]);
1668 vector<double> VdXYDistCShoreTmp(nReadRows, 0);
1669 for (
int i = 0; i < nReadRows; i++)
1670 VdXYDistCShoreTmp[i] = VdXYDistCShore[nReadRows - 1] - VdXYDistCShore[i];
1673 reverse(VdXYDistCShoreTmp.begin(), VdXYDistCShoreTmp.end());
1676 reverse(VdValuesCShore.begin(), VdValuesCShore.end());
1679 vector<double> VdDistXYCopy(pVdProfileDistXYCME->begin(), pVdProfileDistXYCME->end());
1688#if defined CSHORE_ARG_INOUT || CSHORE_BOTH
1692void 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)
1699 bool bTooShort =
false;
1701 if (nOutSize < nProfileSize)
1704 nTooShort = nProfileSize - nOutSize;
1725 double dLastDiff = pVdXYDistFromCShore->at(nOutSize-1) - pVdXYDistFromCShore->at(nOutSize-2);
1726 for (
int n = 0; n < nTooShort; n++)
1727 pVdXYDistFromCShore->at(nOutSize + n) = pVdXYDistFromCShore->at(nOutSize-1 + n) + dLastDiff;
1729 for (
int n = 0; n < nTooShort; n++)
1730 pVdFreeSurfaceStdCShore->at(nOutSize + n) = pVdFreeSurfaceStdCShore->at(nOutSize-1);
1732 for (
int n = 0; n < nTooShort; n++)
1733 pVdWaveSetupSurgeCShore->at(nOutSize + n) = pVdWaveSetupSurgeCShore->at(nOutSize-1);
1737 for (
int n = 0; n < nTooShort; n++)
1738 pVdSinWaveAngleRadiansCShore->at(nOutSize + n) = pVdSinWaveAngleRadiansCShore->at(nOutSize-1);
1740 dLastDiff = pVdFractionBreakingWavesCShore->at(nOutSize-1) - pVdFractionBreakingWavesCShore->at(nOutSize-2);
1741 for (
int n = 0; n < nTooShort; n++)
1742 pVdFractionBreakingWavesCShore->at(nOutSize + n) =
tMin(pVdFractionBreakingWavesCShore->at(nOutSize-1 + n) + dLastDiff, 1.0);
1753 vector<double> VdXYDistCShoreTmp(nProfileSize);
1754 copy(pVdXYDistFromCShore->begin(), pVdXYDistFromCShore->begin() + nProfileSize, begin(VdXYDistCShoreTmp));
1757 vector<double> VdFreeSurfaceStdCShoreTmp(nProfileSize);
1758 reverse_copy(pVdFreeSurfaceStdCShore->begin(), pVdFreeSurfaceStdCShore->begin() + nProfileSize, begin(VdFreeSurfaceStdCShoreTmp));
1760 vector<double> VdWaveSetupSurgeCShoreTmp(nProfileSize);
1761 reverse_copy(pVdWaveSetupSurgeCShore->begin(), pVdWaveSetupSurgeCShore->begin() + nProfileSize, begin(VdWaveSetupSurgeCShoreTmp));
1763 vector<double> VdSinWaveAngleRadiansCShoreTmp(nProfileSize);
1764 reverse_copy(pVdSinWaveAngleRadiansCShore->begin(), pVdSinWaveAngleRadiansCShore->begin() + nProfileSize, begin(VdSinWaveAngleRadiansCShoreTmp));
1766 vector<double> VdFractionBreakingWavesCShoreTmp(nProfileSize);
1767 reverse_copy(pVdFractionBreakingWavesCShore->begin(), pVdFractionBreakingWavesCShore->begin() + nProfileSize, begin(VdFractionBreakingWavesCShoreTmp));
1804 bool bModfiedWaveHeightisBreaking =
false;
1805 bool bProfileIsinShadowZone =
false;
1808 int nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1809 double dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1810 double dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1811 double dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1814 for (
int nProfilePoint = (nProfileSize - 1); nProfilePoint >= 0; nProfilePoint--)
1822 bProfileIsinShadowZone =
true;
1825 double dWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight();
1831 bModfiedWaveHeightisBreaking =
true;
1834 dThisBreakingWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetWaveAngle();
1836 nThisBreakingDist = nProfilePoint;
1842 if (bProfileIsinShadowZone && bModfiedWaveHeightisBreaking)
1845 if (dThisBreakingWaveHeight > dThisBreakingDepth * 0.78)
1847 dThisBreakingWaveHeight = dThisBreakingDepth * 0.78;
1851 m_VCoast[nCoast].SetBreakingWaveHeight(nThisCoastPoint, dThisBreakingWaveHeight);
1852 m_VCoast[nCoast].SetBreakingWaveAngle(nThisCoastPoint, dThisBreakingWaveAngle);
1853 m_VCoast[nCoast].SetDepthOfBreaking(nThisCoastPoint, dThisBreakingDepth);
1854 m_VCoast[nCoast].SetBreakingDistance(nThisCoastPoint, nThisBreakingDist);
1858 else if (bProfileIsinShadowZone && (! bModfiedWaveHeightisBreaking))
1886 int const nThisBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nThisCoastPoint);
1887 double dThisBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nThisCoastPoint);
1888 double dThisBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nThisCoastPoint);
1889 double dThisBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nThisCoastPoint);
1890 double dThisWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nThisCoastPoint);
1892 double dThisRunUp =
m_VCoast[nCoast].dGetRunUp(nThisCoastPoint);
1908 pTmpProfile = pNextProfile;
1919 int const nDistBetween = nNextCoastPoint - nThisCoastPoint;
1922 if (nDistBetween <= 0)
1926 int nNextBreakingDist =
m_VCoast[nCoast].nGetBreakingDistance(nNextCoastPoint);
1927 double dNextBreakingWaveHeight =
m_VCoast[nCoast].dGetBreakingWaveHeight(nNextCoastPoint);
1928 double dNextBreakingWaveAngle =
m_VCoast[nCoast].dGetBreakingWaveAngle(nNextCoastPoint);
1929 double dNextBreakingDepth =
m_VCoast[nCoast].dGetDepthOfBreaking(nNextCoastPoint);
1930 double dNextWaveSetupSurge =
m_VCoast[nCoast].dGetWaveSetupSurge(nNextCoastPoint);
1931 double dNextRunUp =
m_VCoast[nCoast].dGetRunUp(nNextCoastPoint);
1934 for (
int n = nThisCoastPoint; n <= nNextCoastPoint; n++)
1937 int nDist = n - nThisCoastPoint;
1938 double dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween);
1939 double dNextWeight = 1 - dThisWeight;
1940 double dWaveSetupSurge = 0;
1943 dWaveSetupSurge = (dThisWeight * dThisWaveSetupSurge) + (dNextWeight * dNextWaveSetupSurge);
1944 m_VCoast[nCoast].SetWaveSetupSurge(n, dWaveSetupSurge);
1946 dRunUp = (dThisWeight * dThisRunUp) + (dNextWeight * dNextRunUp);
1947 m_VCoast[nCoast].SetRunUp(n, dRunUp);
1959 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
1973 for (
int n = nThisCoastPoint; n < nNextCoastPoint; n++)
1977 m_VCoast[nCoast].SetBreakingWaveHeight(n, dNextBreakingWaveHeight);
1978 m_VCoast[nCoast].SetBreakingWaveAngle(n, dNextBreakingWaveAngle);
1979 m_VCoast[nCoast].SetDepthOfBreaking(n, dNextBreakingDepth);
1980 m_VCoast[nCoast].SetBreakingDistance(n, nNextBreakingDist);
1988 for (
int n = nThisCoastPoint + 1; n <= nNextCoastPoint; n++)
1992 m_VCoast[nCoast].SetBreakingWaveHeight(n, dThisBreakingWaveHeight);
1993 m_VCoast[nCoast].SetBreakingWaveAngle(n, dThisBreakingWaveAngle);
1994 m_VCoast[nCoast].SetDepthOfBreaking(n, dThisBreakingDepth);
1995 m_VCoast[nCoast].SetBreakingDistance(n, nThisBreakingDist);
2002 for (
int n = nThisCoastPoint + 1; n < nNextCoastPoint; n++)
2004 int nDist = n - nThisCoastPoint;
2011 if ((dNextBreakingDepth > 0) && (dThisBreakingDepth > 0))
2014 dThisWeight = (nDistBetween - nDist) /
static_cast<double>(nDistBetween),
2015 dNextWeight = 1 - dThisWeight;
2017 dBreakingWaveHeight = (dThisWeight * dThisBreakingWaveHeight) + (dNextWeight * dNextBreakingWaveHeight),
2018 dBreakingWaveAngle = (dThisWeight * dThisBreakingWaveAngle) + (dNextWeight * dNextBreakingWaveAngle),
2019 dBreakingDepth = (dThisWeight * dThisBreakingDepth) + (dNextWeight * dNextBreakingDepth),
2020 dBreakingDist = (dThisWeight * nThisBreakingDist) + (dNextWeight * nNextBreakingDist);
2022 else if (dNextBreakingDepth > 0)
2024 dBreakingWaveHeight = dNextBreakingWaveHeight,
2025 dBreakingWaveAngle = dNextBreakingWaveAngle,
2026 dBreakingDepth = dNextBreakingDepth,
2027 dBreakingDist = nNextBreakingDist;
2029 else if (dThisBreakingDepth > 0)
2031 dBreakingWaveHeight = dThisBreakingWaveHeight,
2032 dBreakingWaveAngle = dThisBreakingWaveAngle,
2033 dBreakingDepth = dThisBreakingDepth,
2034 dBreakingDist = nThisBreakingDist;
2039 m_VCoast[nCoast].SetBreakingWaveHeight(n, dBreakingWaveHeight);
2040 m_VCoast[nCoast].SetBreakingWaveAngle(n, dBreakingWaveAngle);
2041 m_VCoast[nCoast].SetDepthOfBreaking(n, dBreakingDepth);
2051 int nCoastPoints =
m_VCoast[nCoast].nGetCoastlineSize();
2054 vector<int> nVCoastWaveHeightX;
2055 vector<double> dVCoastWaveHeightY;
2058 for (
int n = 0; n < nCoastPoints; n++)
2060 double dCoastWaveHeight =
m_VCoast[nCoast].dGetCoastWaveHeight(n);
2064 nVCoastWaveHeightX.push_back(n);
2065 dVCoastWaveHeightY.push_back(dCoastWaveHeight);
2070 if ((nVCoastWaveHeightX.size() >= 3) && (nVCoastWaveHeightX.size() == dVCoastWaveHeightY.size()))
2072 for (
int n = 0; n < nCoastPoints; n++)
2074 double dInterpCoastWaveHeight =
dGetInterpolatedValue(&nVCoastWaveHeightX, &dVCoastWaveHeightY, n,
false);
2075 m_VCoast[nCoast].SetCoastWaveHeight(n, dInterpCoastWaveHeight);
2080 for (
int n = 0; n < nCoastPoints; n++)
2082 m_VCoast[nCoast].SetCoastWaveHeight(n, 0);
2092 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
2094 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize; nCoastPoint++)
2099 if (nCoastPoint == 0)
2108 else if (nCoastPoint == nCoastSize - 1)
2133 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 90);
2136 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 270);
2143 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 0);
2146 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, 180);
2151 double dAzimuthAngle;
2153 dAzimuthAngle = (180 /
PI) * (
PI * 0.5 - atan(dYDiff / dXDiff));
2155 dAzimuthAngle = (180 /
PI) * (
PI * 1.5 - atan(dYDiff / dXDiff));
2157 m_VCoast[nCoast].SetFluxOrientation(nCoastPoint, dAzimuthAngle);
2182 bool bActive =
m_pRasterGrid->m_Cell[nX][nY].bIsInActiveZone();
2187 double dTmpd50 =
m_pRasterGrid->m_Cell[nX][nY].dGetUnconsD50();
2193 VnPolygonD50Count[nID]++;
2194 VdPolygonD50[nID] += dTmpd50;
2219 int nDownDriftNum = 0;
2222 double dWaveHeight = 0;
2223 double dWaveAngle = 0;
2230 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2233 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2234 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2239 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2246 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2250 nDownDriftNum = nTmp;
2262 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2265 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2266 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2271 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2278 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2282 nDownDriftNum = nTmp;
2294 if (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].bIsInContiguousSea())
2297 dWaveHeight +=
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveHeight();
2298 dWaveAngle += (
m_pRasterGrid->m_Cell[nXTmp][nYTmp].dGetWaveAngle());
2303 int nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetShadowZoneNumber();
2310 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2314 nDownDriftNum = nTmp;
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();
2342 nTmp =
m_pRasterGrid->m_Cell[nXTmp][nYTmp].nGetDownDriftZoneNumber();
2346 nDownDriftNum = nTmp;
2356 dWaveHeight /= nRead;
2357 dWaveAngle /= nRead;
2369 double dDeepWaterWaveHeight =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveHeight();
2376 double dDeepWaterWaveAngle =
m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveAngle();
2383 int nShadowZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetShadowZoneNumber();
2384 if (nShadowZoneCode <= 0)
2387 if ((nShadow == 4) || (nShadow + nDownDrift == 4) || (nShadow + nCoast == 4))
2389 m_pRasterGrid->m_Cell[nX][nY].SetShadowZoneNumber(nShadowNum);
2396 int nDownDriftZoneCode =
m_pRasterGrid->m_Cell[nX][nY].nGetDownDriftZoneNumber();
2397 if ((nDownDriftZoneCode == 0) && (nDownDrift == 4))
2399 m_pRasterGrid->m_Cell[nX][nY].SetDownDriftZoneNumber(nDownDriftNum);
2409 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
2411 for (
int nPoly = 0; nPoly <
m_VCoast[nCoast].nGetNumPolygons(); nPoly++)
2416 if (VnPolygonD50Count[nID] > 0)
2417 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.
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.