Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CppCheck DaylightingManager #10703

Merged
merged 8 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 29 additions & 32 deletions src/EnergyPlus/DaylightingManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ void CalcDayltgCoeffsRefPoints(EnergyPlusData &state, int const daylightCtrlNum)
}

auto &thisDayltgCtrl = dl->daylightControl(daylightCtrlNum);
auto &thisEnclDaylight = dl->enclDaylight(thisDayltgCtrl.enclIndex);
auto const &thisEnclDaylight = dl->enclDaylight(thisDayltgCtrl.enclIndex);
int zoneNum = thisDayltgCtrl.zoneIndex;
// Azimuth of view vector in absolute coord sys
Real64 AZVIEW = (thisDayltgCtrl.ViewAzimuthForGlare + state.dataHeatBal->Zone(zoneNum).RelNorth + state.dataHeatBal->BuildingAzimuth +
Expand Down Expand Up @@ -811,7 +811,7 @@ void CalcDayltgCoeffsRefPoints(EnergyPlusData &state, int const daylightCtrlNum)
BRef = 0;

for (int IL = 1; IL <= thisDayltgCtrl.TotalDaylRefPoints; ++IL) {
auto &refPt = thisDayltgCtrl.refPts(IL);
auto const &refPt = thisDayltgCtrl.refPts(IL);
// Reference point in absolute coordinate system
Vector3<Real64> RREF = refPt.absCoords;

Expand Down Expand Up @@ -1067,7 +1067,6 @@ void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum)

// In the following four variables, I=1 for clear sky, 2 for overcast.
int numRefPts; // Number of daylighting reference points in a zone
int IL; // Reference point counter
// glare calculation (radians)
int IConst; // Construction counter
int ICtrl; // Window control counter
Expand Down Expand Up @@ -1122,7 +1121,7 @@ void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum)
Vector3<Real64> VIEWVC2;

if (dl->mapFirstTime && (int)dl->illumMaps.size() > 0) {
IL = -999;
int IL = -999;
for (int MapNum = 1; MapNum <= (int)dl->illumMaps.size(); ++MapNum) {
IL = max(IL, dl->illumMaps(MapNum).TotalMapRefPoints);
}
Expand All @@ -1132,7 +1131,7 @@ void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum)

auto &illumMap = dl->illumMaps(mapNum);
int enclNum = illumMap.enclIndex;
auto &thisEnclDaylight = dl->enclDaylight(enclNum);
auto const &thisEnclDaylight = dl->enclDaylight(enclNum);

// Azimuth of view vector in absolute coord sys - set to zero here, because glare isn't calculated for map points
// but these are arguments to some of the functions that are shared with regular reference points, so initalize here.
Expand Down Expand Up @@ -1165,7 +1164,7 @@ void CalcDayltgCoeffsMapPoints(EnergyPlusData &state, int const mapNum)
}

for (int IL = 1; IL <= numRefPts; ++IL) {
auto &refPt = illumMap.refPts(IL);
auto const &refPt = illumMap.refPts(IL);
Vector3<Real64> RREF = refPt.absCoords;

// -------------
Expand Down Expand Up @@ -2407,7 +2406,7 @@ void InitializeCFSStateData(EnergyPlusData &state,
}
} // do JSurf = 1, TotSurfaces
if (TotHits <= 0) {
auto &sIncRay = state.dataBSDFWindow->ComplexWind(iWin).Geom(CurFenState).sInc(IRay);
auto const &sIncRay = state.dataBSDFWindow->ComplexWind(iWin).Geom(CurFenState).sInc(IRay);
// This ray reached the sky or ground unobstructed
if (sIncRay.z < 0.0) {
// A ground ray
Expand Down Expand Up @@ -2665,7 +2664,7 @@ Real64 CalcObstrMultiplier(EnergyPlusData &state,
// Phi = 0 at the horizon; Phi = Pi/2 at the zenith.

// Locals
auto &dl = state.dataDayltg;
auto const &dl = state.dataDayltg;
auto &s_surf = state.dataSurface;

bool hitObs; // True iff obstruction is hit
Expand Down Expand Up @@ -3962,7 +3961,6 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound)

CheckForGeometricTransform(state, doTransform, OldAspectRatio, NewAspectRatio);

auto &ip = state.dataInputProcessing->inputProcessor;
auto const &ipsc = state.dataIPShortCut;
ipsc->cCurrentModuleObject = "Output:IlluminanceMap";
int TotIllumMaps = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ipsc->cCurrentModuleObject);
Expand All @@ -3973,6 +3971,7 @@ void GetInputIlluminanceMap(EnergyPlusData &state, bool &ErrorsFound)
int IOStat;
int NumAlpha;
int NumNumber;
auto &ip = state.dataInputProcessing->inputProcessor;
for (int MapNum = 1; MapNum <= TotIllumMaps; ++MapNum) {
ip->getObjectItem(state,
ipsc->cCurrentModuleObject,
Expand Down Expand Up @@ -4736,7 +4735,7 @@ void GetInputDayliteRefPt(EnergyPlusData &state, bool &ErrorsFound)
{
// Perform GetInput function for the Daylighting:ReferencePoint object
// Glazer - July 2016
auto &dl = state.dataDayltg;
auto const &dl = state.dataDayltg;
auto &ip = state.dataInputProcessing->inputProcessor;
auto const &ipsc = state.dataIPShortCut;
ipsc->cCurrentModuleObject = "Daylighting:ReferencePoint";
Expand Down Expand Up @@ -4784,7 +4783,7 @@ void GetInputDayliteRefPt(EnergyPlusData &state, bool &ErrorsFound)

bool doesDayLightingUseDElight(EnergyPlusData &state)
{
auto &dl = state.dataDayltg;
auto const &dl = state.dataDayltg;
for (auto const &znDayl : dl->daylightControl) {
if (znDayl.DaylightMethod == DaylightingMethod::DElight) {
return true;
Expand Down Expand Up @@ -5630,7 +5629,7 @@ void manageDaylighting(EnergyPlusData &state)

if (state.dataEnvrn->SunIsUp && (state.dataEnvrn->BeamSolarRad + state.dataEnvrn->GndSolarRad + state.dataEnvrn->DifSolarRad > 0.0)) {
for (int enclNum = 1; enclNum <= state.dataViewFactor->NumOfSolarEnclosures; ++enclNum) {
auto &enclSol = state.dataViewFactor->EnclSolInfo(enclNum);
auto const &enclSol = state.dataViewFactor->EnclSolInfo(enclNum);
if (enclSol.TotalEnclosureDaylRefPoints == 0 || !enclSol.HasInterZoneWindow) continue;

DayltgInterReflIllFrIntWins(state, enclNum);
Expand Down Expand Up @@ -5699,7 +5698,6 @@ void DayltgInteriorIllum(EnergyPlusData &state,
int ISWFLG; // Switchable glazing flag: =1 if one or more windows in a zone
// has switchable glazing that adjusts visible transmittance to just meet
// daylighting setpoint; =0 otherwise.
int ICtrl; // Window shading control pointer
Real64 VTRAT; // Ratio between switched and unswitched visible transmittance at normal incidence
Real64 BACL; // Window background (surround) luminance for glare calc (cd/m2)
Real64 SkyWeight; // Weighting factor used to average two different sky types
Expand Down Expand Up @@ -5937,22 +5935,22 @@ void DayltgInteriorIllum(EnergyPlusData &state,
auto &daylFromWinAtRefPt = thisDayltgCtrl.refPts(IL).extWins(loop).lums;
auto &tmpDayl = tmpDaylFromWinAtRefPt(IL, loop);
for (int iWinCover = 0; iWinCover < (int)WinCover::Num; ++iWinCover) {
auto const &dfhr = DFHR[iWinCover];
auto const &bfhr = BFHR[iWinCover];
auto const &sfhr = SFHR[iWinCover];
auto const &dfhr3 = DFHR[iWinCover];
auto const &bfhr3 = BFHR[iWinCover];
auto const &sfhr3 = SFHR[iWinCover];

// What is this?
if (iWinCover == iWinCover_Shaded && !ShadedOrDiffusingGlassWin) break;

daylFromWinAtRefPt[iLum_Illum][iWinCover] =
dfhr.sun * state.dataEnvrn->HISUNF +
HorIllSkyFac * (dfhr.sky[iSky1] * SkyWeight * horIllSky1 + dfhr.sky[iSky2] * (1.0 - SkyWeight) * horIllSky2);
dfhr3.sun * state.dataEnvrn->HISUNF +
HorIllSkyFac * (dfhr3.sky[iSky1] * SkyWeight * horIllSky1 + dfhr3.sky[iSky2] * (1.0 - SkyWeight) * horIllSky2);
daylFromWinAtRefPt[iLum_Back][iWinCover] =
bfhr.sun * state.dataEnvrn->HISUNF +
HorIllSkyFac * (bfhr.sky[iSky1] * SkyWeight * horIllSky1 + bfhr.sky[iSky2] * (1.0 - SkyWeight) * horIllSky2);
bfhr3.sun * state.dataEnvrn->HISUNF +
HorIllSkyFac * (bfhr3.sky[iSky1] * SkyWeight * horIllSky1 + bfhr3.sky[iSky2] * (1.0 - SkyWeight) * horIllSky2);
daylFromWinAtRefPt[iLum_Source][iWinCover] =
sfhr.sun * state.dataEnvrn->HISUNF +
HorIllSkyFac * (sfhr.sky[iSky1] * SkyWeight * horIllSky1 + sfhr.sky[iSky2] * (1.0 - SkyWeight) * horIllSky2);
sfhr3.sun * state.dataEnvrn->HISUNF +
HorIllSkyFac * (sfhr3.sky[iSky1] * SkyWeight * horIllSky1 + sfhr3.sky[iSky2] * (1.0 - SkyWeight) * horIllSky2);

daylFromWinAtRefPt[iLum_Source][iWinCover] = max(daylFromWinAtRefPt[iLum_Source][iWinCover], 0.0);

Expand Down Expand Up @@ -6238,7 +6236,7 @@ void DayltgInteriorIllum(EnergyPlusData &state,
continueOuterLoop = false;
continue;
}
ICtrl = s_surf->Surface(IWin).activeWindowShadingControl;
int ICtrl = s_surf->Surface(IWin).activeWindowShadingControl;
if (!s_surf->Surface(IWin).HasShadeControl) {
continueOuterLoop = false;
continue;
Expand Down Expand Up @@ -6271,7 +6269,7 @@ void DayltgInteriorIllum(EnergyPlusData &state,
rdayil[iLum_Back] = refPt.lums[iLum_Back] - wdayil[iLum_Back][iWinCover_Bare] + wdayil[iLum_Back][iWinCover_Shaded];
} else {
// switchable glazings already in partially switched state when calc the RDAYIL(IL) & RBACLU(IL)
auto &tmpDayl = tmpDaylFromWinAtRefPt(loop, IL);
auto const &tmpDayl = tmpDaylFromWinAtRefPt(loop, IL);
rdayil[iLum_Illum] = dl->DaylIllum(IL) - wdayil[iLum_Illum][iWinCover_Shaded] + tmpDayl[iLum_Illum][iWinCover_Shaded];
rdayil[iLum_Back] = refPt.lums[iLum_Back] - wdayil[iLum_Back][iWinCover_Shaded] + tmpDayl[iLum_Back][iWinCover_Shaded];
}
Expand Down Expand Up @@ -6379,7 +6377,7 @@ void DayltgInteriorIllum(EnergyPlusData &state,
ANY_BLIND(s_surf->SurfWinShadingFlag(IWin)))
continue;

ICtrl = s_surf->Surface(IWin).activeWindowShadingControl;
int ICtrl = s_surf->Surface(IWin).activeWindowShadingControl;
if (!s_surf->Surface(IWin).HasShadeControl) continue;
if (s_surf->WindowShadingControl(ICtrl).GlareControlIsActive) {

Expand Down Expand Up @@ -8324,7 +8322,7 @@ Real64 DayltgSkyLuminance(EnergyPlusData const &state,
// PHSKY ranges from 0 to Pi starting with 0 at the horizon and Pi/2 at the zenith.

// FUNCTION LOCAL VARIABLE DECLARATIONS:
auto &dl = state.dataDayltg;
auto const &dl = state.dataDayltg;

Real64 G = 0.0; // Angle between sun and element of sky (radians)
Real64 COSG = 0.0; // Cosine of G
Expand Down Expand Up @@ -8766,11 +8764,11 @@ void DayltgInteriorMapIllum(EnergyPlusData &state)
if (s_surf->SurfWinWindowModelType(IWin) == WindowModel::BSDF) break;
if (NOT_SHADED(s_surf->SurfWinShadingFlag(IWin)) && !s_surf->SurfWinSolarDiffusing(IWin)) break;
}
auto const &dfhr = DFHR[iWinCover];
auto const &dfhr3 = DFHR[iWinCover];

thisMap.refPts(ILB).winLums(loop)[iWinCover] = tmpDFHR[iWinCover].sun * state.dataEnvrn->HISUNF +
HorIllSkyFac * (dfhr.sky[iSky1] * SkyWeight * tmpHorIll.sky[iSky1] +
dfhr.sky[iSky2] * (1.0 - SkyWeight) * tmpHorIll.sky[iSky2]);
HorIllSkyFac * (dfhr3.sky[iSky1] * SkyWeight * tmpHorIll.sky[iSky1] +
dfhr3.sky[iSky2] * (1.0 - SkyWeight) * tmpHorIll.sky[iSky2]);
}

} // End of reference point loop
Expand Down Expand Up @@ -9521,7 +9519,7 @@ void DayltgInterReflIllFrIntWins(EnergyPlusData &state, int const enclNum)
auto &s_surf = state.dataSurface;

auto &enclDayl = dl->enclDaylight(enclNum);
auto &enclSol = state.dataViewFactor->EnclSolInfo(enclNum);
auto const &enclSol = state.dataViewFactor->EnclSolInfo(enclNum);

enclDayl.InterReflIllFrIntWins = 0.0;

Expand Down Expand Up @@ -9617,8 +9615,7 @@ void CalcMinIntWinSolidAngs(EnergyPlusData &state)
Vector3<Real64> W23 = W3 - W2;
Real64 HW = W21.magnitude();
Real64 WW = W23.magnitude();
Vector3<Real64> WC =
(is_Rectangle) ? (W2 + (W23 + W21) / 2.0) : (is_Triangle ? (W2 + (W23 + W21) / 3.0) : (W2 + (W23 + W21) / 3.0));
Vector3<Real64> WC = (is_Rectangle) ? (W2 + (W23 + W21) / 2.0) : (W2 + (W23 + W21) / 3.0);

// Vector from ref point to center of window
Vector3<Real64> REFWC = WC - RREF;
Expand Down