Skip to content

Commit

Permalink
Address nullptr-based failures
Browse files Browse the repository at this point in the history
  • Loading branch information
amirroth committed Dec 20, 2024
1 parent dfc8545 commit 13c52af
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/EnergyPlus/AirflowNetwork/src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9880,7 +9880,7 @@ namespace AirflowNetwork {
// Note in the following that individual venting control for a window/door takes
// precedence over zone-level control
if (MultizoneSurfaceData(i).IndVentControl) {
VentTemp = MultizoneSurfaceData(i).ventTempControlSched->getCurrentVal();
VentTemp = MultizoneSurfaceData(i).ventTempControlSched ? MultizoneSurfaceData(i).ventTempControlSched->getCurrentVal() : 0.0;
VentCtrlNum = MultizoneSurfaceData(i).VentSurfCtrNum;
if (MultizoneSurfaceData(i).ventAvailSched != nullptr) {
VentingSchVal = MultizoneSurfaceData(i).ventAvailSched->getCurrentVal();
Expand Down
8 changes: 4 additions & 4 deletions src/EnergyPlus/InternalHeatGains.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3222,18 +3222,18 @@ namespace InternalHeatGains {
} else {
print(state.files.eio, "N/A,");
}
print(state.files.eio, "{},", people.workEffSched->Name);
print(state.files.eio, "{},", people.workEffSched ? people.workEffSched->Name : "");

print(state.files.eio, clothingTypeEIOStrings[static_cast<int>(people.clothingType)]);
print(state.files.eio, clothingTypeEIOStrings[(int)people.clothingType]);

if (people.clothingType == ClothingType::CalculationSchedule) {
print(state.files.eio, "{},", people.clothingMethodSched->Name);
} else {
print(state.files.eio, "N/A,");
}

print(state.files.eio, "{},", people.clothingSched->Name);
print(state.files.eio, "{},", people.airVelocitySched->Name);
print(state.files.eio, "{},", people.clothingSched ? people.clothingSched->Name : "");
print(state.files.eio, "{},", people.airVelocitySched ? people.airVelocitySched->Name : "");

print(state.files.eio, "{},", yesNoNames[(int)people.Fanger]);
print(state.files.eio, "{},", yesNoNames[(int)people.Pierce]);
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/PlantCentralGSHP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2883,7 +2883,7 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c

HWOutletTemp = HWInletTemp;

if (this->ancillaryPowerSched->getCurrentVal() > 0) {
if (this->ancillaryPowerSched != nullptr) {
WrapperElecPowerCool += (this->AncillaryPower * this->ancillaryPowerSched->getCurrentVal());
}

Expand Down Expand Up @@ -3275,7 +3275,7 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c
CHWOutletTemp = CHWInletTemp;

// Add ancilliary power if necessary
if (this->ancillaryPowerSched->getCurrentVal() > 0) {
if (this->ancillaryPowerSched != nullptr) {
WrapperElecPowerHeat += (this->AncillaryPower * this->ancillaryPowerSched->getCurrentVal());
}

Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/Pumps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1816,8 +1816,8 @@ void CalcPumps(EnergyPlusData &state, int const PumpNum, Real64 const FlowReques
// Get RPM value for reporting as output
// RPM is calculated using pump affinity laws for rotation speed
if (thisPumpPlant.UsePressureForPumpCalcs && thisPump.HasVFD) {
RotSpeed_Min = thisPump.VFD.minRPMSched->getCurrentVal();
RotSpeed_Max = thisPump.VFD.maxRPMSched->getCurrentVal();
RotSpeed_Min = thisPump.VFD.minRPMSched ? thisPump.VFD.minRPMSched->getCurrentVal() : 0.0;
RotSpeed_Max = thisPump.VFD.maxRPMSched ? thisPump.VFD.maxRPMSched->getCurrentVal() : 0.0;
if (thisPump.PumpMassFlowRateMaxRPM < DataBranchAirLoopPlant::MassFlowTolerance ||
thisPump.PumpMassFlowRateMinRPM < DataBranchAirLoopPlant::MassFlowTolerance) {
thisPump.VFD.PumpActualRPM = 0.0;
Expand Down
10 changes: 5 additions & 5 deletions src/EnergyPlus/SQLiteProcedures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2314,13 +2314,13 @@ bool SQLite::NominalPeople::insertIntoSQLite(sqlite3_stmt *insertStmt)
sqliteBindText(insertStmt, 2, name);
sqliteBindForeignKey(insertStmt, 3, zonePtr);
sqliteBindDouble(insertStmt, 4, numberOfPeople);
sqliteBindForeignKey(insertStmt, 5, numberOfPeopleSched->Num);
sqliteBindForeignKey(insertStmt, 6, activityLevelSched->Num);
sqliteBindForeignKey(insertStmt, 5, numberOfPeopleSched ? numberOfPeopleSched->Num : -1);
sqliteBindForeignKey(insertStmt, 6, activityLevelSched ? activityLevelSched->Num : -1);
sqliteBindDouble(insertStmt, 7, fractionRadiant);
sqliteBindDouble(insertStmt, 8, fractionConvected);
sqliteBindForeignKey(insertStmt, 9, workEffSched->Num);
sqliteBindForeignKey(insertStmt, 10, clothingSched->Num);
sqliteBindForeignKey(insertStmt, 11, airVelocitySched->Num);
sqliteBindForeignKey(insertStmt, 9, workEffSched ? workEffSched->Num : -1);
sqliteBindForeignKey(insertStmt, 10, clothingSched ? clothingSched->Num : -1);
sqliteBindForeignKey(insertStmt, 11, airVelocitySched ? airVelocitySched->Num : -1);
sqliteBindLogical(insertStmt, 12, fanger);
sqliteBindLogical(insertStmt, 13, pierce);
sqliteBindLogical(insertStmt, 14, ksu);
Expand Down
18 changes: 16 additions & 2 deletions src/EnergyPlus/ScheduleManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((daySched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down Expand Up @@ -806,6 +808,8 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((daySched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down Expand Up @@ -879,6 +883,8 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((daySched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down Expand Up @@ -1072,6 +1078,8 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == 0) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down Expand Up @@ -1199,7 +1207,6 @@ namespace Sched {
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");

} else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down Expand Up @@ -1779,10 +1786,11 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) { // No warning here for constant schedules
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");

}

sched->currentVal = Numbers(1);
Expand Down Expand Up @@ -1828,6 +1836,8 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down Expand Up @@ -1894,6 +1904,8 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down Expand Up @@ -1960,6 +1972,8 @@ namespace Sched {

// Validate ScheduleType
if (lAlphaBlanks(2)) {
ShowWarningEmptyField(state, eoh, cAlphaFields(2));
ShowContinueError(state, "Schedule will not be validated.");
} else if ((sched->schedTypeNum = GetScheduleTypeNum(state, Alphas(2))) == SchedNum_Invalid) {
ShowWarningItemNotFound(state, eoh, cAlphaFields(2), Alphas(2));
ShowContinueError(state, "Schedule will not be validated.");
Expand Down

0 comments on commit 13c52af

Please sign in to comment.