Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into global_SimManager_…
Browse files Browse the repository at this point in the history
…SimAir
  • Loading branch information
Myoldmopar committed Nov 14, 2020
2 parents b40f5d0 + 12adf59 commit 3c810e4
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 174 deletions.
28 changes: 17 additions & 11 deletions src/EnergyPlus/CurveManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1750,9 +1750,13 @@ namespace CurveManager {
std::size_t rowNum = indVarInstance.at("external_file_starting_row_number").get<std::size_t>() - 1;

if (!state.dataCurveManager->btwxtManager.tableFiles.count(filePath)) {
state.dataCurveManager->btwxtManager.tableFiles.emplace(filePath, TableFile{state, filePath});
TableFile tableFile;
ErrorsFound |= tableFile.load(state, filePath);
state.dataCurveManager->btwxtManager.tableFiles.emplace(filePath, tableFile);
}

if (ErrorsFound) continue; // Unable to load file so continue on to see if there are other errors before fataling

axis = state.dataCurveManager->btwxtManager.tableFiles[filePath].getArray(state, {colNum, rowNum});

// remove NANs
Expand Down Expand Up @@ -1940,10 +1944,15 @@ namespace CurveManager {
std::size_t colNum = fields.at("external_file_column_number").get<std::size_t>() - 1;
std::size_t rowNum = fields.at("external_file_starting_row_number").get<std::size_t>() - 1;


if (!state.dataCurveManager->btwxtManager.tableFiles.count(filePath)) {
state.dataCurveManager->btwxtManager.tableFiles.emplace(filePath, TableFile{state, filePath});
TableFile tableFile;
ErrorsFound |= tableFile.load(state, filePath);
state.dataCurveManager->btwxtManager.tableFiles.emplace(filePath, tableFile);
}

if (ErrorsFound) continue; // Unable to load file so continue on to see if there are other errors before fataling

lookupValues = state.dataCurveManager->btwxtManager.tableFiles[filePath].getArray(state, {colNum, rowNum});

// remove NANs
Expand Down Expand Up @@ -2040,19 +2049,15 @@ namespace CurveManager {
tableFiles.clear();
}

TableFile::TableFile(EnergyPlusData &state, std::string path)
{
load(state, path);
}

void TableFile::load(EnergyPlusData &state, std::string path)
bool TableFile::load(EnergyPlusData &state, std::string path)
{
filePath = path;
bool fileFound;
std::string fullPath;
DataSystemVariables::CheckForActualFileName(state, path, fileFound, fullPath);
if (!fileFound) {
ShowFatalError(state, "File \"" + filePath + "\" : File not found.");
std::string contextString = "CurveManager::TableFile::load: ";
DataSystemVariables::CheckForActualFileName(state, path, fileFound, fullPath, contextString);
if(!fileFound){
return true;
}
std::ifstream file(fullPath);
std::string line("");
Expand Down Expand Up @@ -2086,6 +2091,7 @@ namespace CurveManager {
++colNum;
}
}
return false;
}

std::vector<double>& TableFile::getArray(EnergyPlusData &state, std::pair<std::size_t, std::size_t> colAndRow) {
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/CurveManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ namespace CurveManager {
std::string filePath;
std::vector<std::vector<std::string>> contents;
std::map<std::pair<std::size_t, std::size_t>, std::vector<double>> arrays;
void load(EnergyPlusData &state, std::string path);
bool load(EnergyPlusData &state, std::string path);
std::vector<double>& getArray(EnergyPlusData &state, std::pair<std::size_t, std::size_t> colAndRow);

private:
Expand Down
2 changes: 0 additions & 2 deletions src/EnergyPlus/DataSurfaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ namespace DataSurfaces {
Array1D<Real64> SurfWinBmBmSolar; // Exterior beam-to-beam solar transmitted through window, or window plus blind, into zone (W)
Array1D<Real64> SurfWinBmDifSolar; // Exterior beam-to-diffuse solar transmitted through window, or window plus blind, into zone (W)
Array1D<Real64> SurfWinDifSolar; // Exterior diffuse solar transmitted through window, or window plus shade/blind, into zone (W)
Array1D<Real64> SurfWinDirSolTransAtIncAngle; // Window's beam-beam solar transmittance at current timestep's angle of incidence
Array1D<Real64> SurfWinHeatGain; // Total heat gain from window = WinTransSolar + (IR and convection from glazing, or,
// if interior shade, IR and convection from zone-side of shade plus gap air convection to zone) +
// (IR convection from frame) + (IR and convection from divider if no interior shade) (W)
Expand Down Expand Up @@ -1280,7 +1279,6 @@ namespace DataSurfaces {
SurfWinBmBmSolar.deallocate();
SurfWinBmDifSolar.deallocate();
SurfWinDifSolar.deallocate();
SurfWinDirSolTransAtIncAngle.deallocate();
SurfWinHeatGain.deallocate();
SurfWinHeatTransfer.deallocate();
SurfWinHeatGainRep.deallocate();
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/DataSurfaces.hh
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ namespace DataSurfaces {
extern Array1D<Real64> SurfWinBmBmSolar; // Exterior beam-to-beam solar transmitted through window, or window plus blind, into zone (W)
extern Array1D<Real64> SurfWinBmDifSolar; // Exterior beam-to-diffuse solar transmitted through window, or window plus blind, into zone (W)
extern Array1D<Real64> SurfWinDifSolar; // Exterior diffuse solar transmitted through window, or window plus shade/blind, into zone (W)
extern Array1D<Real64> SurfWinDirSolTransAtIncAngle; // Window's beam-beam solar transmittance at current timestep's angle of incidence
extern Array1D<Real64> SurfWinHeatGain; // Total heat gain from window = WinTransSolar + (IR and convection from glazing, or,
// if interior shade, IR and convection from zone-side of shade plus gap air convection to zone) +
// (IR convection from frame) + (IR and convection from divider if no interior shade) (W)
Expand Down
130 changes: 44 additions & 86 deletions src/EnergyPlus/DataSystemVariables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

//C++ Headers
#include <utility>

// ObjexxFCL Headers
#include <ObjexxFCL/environment.hh>
#include <ObjexxFCL/string.functions.hh>
Expand Down Expand Up @@ -179,7 +182,6 @@ namespace DataSystemVariables {
bool lMinimalShadowing(false); // TRUE if MinimalShadowing is to override Solar Distribution flag
std::string envinputpath1;
std::string envinputpath2;
std::string envprogrampath;
bool TestAllPaths(false);
int iEnvSetThreads(0);
bool lEnvSetThreadsInput(false);
Expand All @@ -200,7 +202,8 @@ namespace DataSystemVariables {
void CheckForActualFileName(EnergyPlusData &state,
std::string const &originalInputFileName, // name as input for object
bool &FileFound, // Set to true if file found and is in CheckedFileName
std::string &CheckedFileName // Blank if not found.
std::string &CheckedFileName, // Blank if not found.
const std::string contextString //
)
{

Expand All @@ -215,26 +218,11 @@ namespace DataSystemVariables {
// be accurate. This searches a few folders (CurrentWorkingFolder, Program folder) to see
// if the file can be found. (It may have been input with full path so that is checked first.)

// METHODOLOGY EMPLOYED:
// na

// REFERENCES:
// na

// USE STATEMENTS:
// na

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:

// SUBROUTINE PARAMETER DEFINITIONS:

// INTERFACE BLOCK SPECIFICATIONS:
// na

// DERIVED TYPE DEFINITIONS:
// na

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
std::string InputFileName; // save for changing out path characters
std::string::size_type pos;
Expand All @@ -251,81 +239,51 @@ namespace DataSystemVariables {
firstTime = false;
}


FileFound = false;
CheckedFileName.clear();
InputFileName = originalInputFileName;
makeNativePath(InputFileName);

if (FileSystem::fileExists(InputFileName)) {
FileFound = true;
CheckedFileName = InputFileName;
print(state.files.audit, "{}={}\n", "found (user input)", getAbsolutePath(CheckedFileName));
return;
} else {
print(state.files.audit, "{}={}\n", "not found (user input)", getAbsolutePath(InputFileName));
}

// Look relative to input file path
if (FileSystem::fileExists(DataStringGlobals::inputDirPathName + InputFileName)) {
FileFound = true;
CheckedFileName = DataStringGlobals::inputDirPathName + InputFileName;
print(state.files.audit, "{}={}\n", "found (input file)", getAbsolutePath(CheckedFileName));
return;
} else {
print(state.files.audit, "{}={}\n", "not found (input file)", getAbsolutePath(DataStringGlobals::inputDirPathName + InputFileName));
}

// Look relative to input path
if (FileSystem::fileExists(envinputpath1 + InputFileName)) {
FileFound = true;
CheckedFileName = envinputpath1 + InputFileName;
print(state.files.audit, "{}={}\n", "found (epin)", getAbsolutePath(CheckedFileName));
return;
} else {
print(state.files.audit, "{}={}\n", "not found (epin)", getAbsolutePath(envinputpath1 + InputFileName));
}

// Look relative to input path
if (FileSystem::fileExists(envinputpath2 + InputFileName)) {
FileFound = true;
CheckedFileName = envinputpath2 + InputFileName;
print(state.files.audit, "{}={}\n", "found (input_path)", getAbsolutePath(CheckedFileName));
return;
} else {
print(state.files.audit, "{}={}\n", "not found (input_path)", getAbsolutePath(envinputpath2 + InputFileName));
}

// Look relative to program path
if (FileSystem::fileExists(envprogrampath + InputFileName)) {
FileFound = true;
CheckedFileName = envprogrampath + InputFileName;
print(state.files.audit, "{}={}\n", "found (program_path)", getAbsolutePath(CheckedFileName));
return;
} else {
print(state.files.audit, "{}={}\n", "not found (program_path)", getAbsolutePath(envprogrampath + InputFileName));
}

if (!TestAllPaths) return;

// Look relative to current working folder
if (FileSystem::fileExists(CurrentWorkingFolder + InputFileName)) {
FileFound = true;
CheckedFileName = CurrentWorkingFolder + InputFileName;
print(state.files.audit, "{}={}\n", "found (CWF)", getAbsolutePath(CheckedFileName));
return;
} else {
print(state.files.audit, "{}={}\n", "not found (CWF)", getAbsolutePath(CurrentWorkingFolder + InputFileName));
std::vector<std::pair<std::string, std::string>> pathsChecked;

const std::array<std::pair<std::string, std::string>, 7> pathsToCheck = {{
{InputFileName, "Current Working Directory"},
{DataStringGlobals::inputDirPathName + InputFileName, "IDF Directory"},
{DataStringGlobals::exeDirectory + InputFileName, "EnergyPlus Executable Directory"},
{envinputpath1 + InputFileName, "\"epin\" Environment Variable"},
{envinputpath2 + InputFileName, "\"input_path\" Environment Variable"},
{CurrentWorkingFolder + InputFileName, "INI File Directory"},
{ProgramPath + InputFileName, "\"program\", \"dir\" from INI File"}}
};

std::size_t numPathsToNotTest = (TestAllPaths) ? pathsToCheck.size()-2 : pathsToCheck.size();

for(std::size_t i = 0; i < numPathsToNotTest; i++) {
if (FileSystem::fileExists(pathsToCheck[i].first)) {
FileFound = true;
CheckedFileName = pathsToCheck[i].first;
print(state.files.audit, "{}={}\n", "found (" + pathsToCheck[i].second +")", getAbsolutePath(CheckedFileName));
return;
} else {
std::pair <std::string,std::string> currentPath(getParentDirectoryPath(getAbsolutePath(pathsToCheck[i].first)), pathsToCheck[i].second);
bool found = false;
for(auto path: pathsChecked){
if (path.first == currentPath.first){
found = true;
}
}
if (!found){
pathsChecked.push_back(currentPath);
}
print(state.files.audit, "{}={}\n", "not found (" + pathsToCheck[i].second +")\"", getAbsolutePath(pathsToCheck[i].first));
}
}

// Look relative to program path
if (FileSystem::fileExists(ProgramPath + InputFileName)) {
FileFound = true;
CheckedFileName = ProgramPath + InputFileName;
print(state.files.audit, "{}={}\n", "found (program path - ini)", getAbsolutePath(CheckedFileName));
return;
} else {
print(state.files.audit, "{}={}\n", "not found (program path - ini)", getAbsolutePath(ProgramPath + InputFileName));
if (!FileFound) {
ShowSevereError(state, contextString+ "\"" + originalInputFileName + "\" not found.");
ShowContinueError(state, " Paths searched:");
for(auto path: pathsChecked){
ShowContinueError(state, " " + path.second +": \"" + path.first +"\"");
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/EnergyPlus/DataSystemVariables.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

// EnergyPlus Headers
#include <EnergyPlus/EnergyPlus.hh>
#include <EnergyPlus/IOFiles.hh>

namespace EnergyPlus {

Expand Down Expand Up @@ -171,7 +172,8 @@ namespace DataSystemVariables {
void CheckForActualFileName(EnergyPlusData &state,
std::string const &originalInputFileName, // name as input for object
bool &FileFound, // Set to true if file found and is in CheckedFileName
std::string &CheckedFileName // Blank if not found.
std::string &foundFileName, // Blank if not found.
const std::string contextString = std::string()
);

// Needed for unit tests, should not be normally called.
Expand Down
8 changes: 5 additions & 3 deletions src/EnergyPlus/ExternalInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,11 @@ namespace ExternalInterface {
cNumericFieldNames);
// Get the FMU name
FMU(Loop).Name = cAlphaArgs(1);
CheckForActualFileName(state, cAlphaArgs(1), fileExist, tempFullFileName);

std::string contextString = cCurrentModuleObject + ", " + cAlphaFieldNames(1) + ": ";

CheckForActualFileName(state, cAlphaArgs(1), fileExist, tempFullFileName, contextString);

if (fileExist) {
pos = index(FMU(Loop).Name, pathChar, true); // look backwards
if (pos != std::string::npos) {
Expand All @@ -1165,8 +1169,6 @@ namespace ExternalInterface {
}
fullFileName(Loop) = tempFullFileName;
} else {
ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport:");
ShowContinueError(state, "file not located = \"" + cAlphaArgs(1) + "\".");
ErrorsFound = true;
}
// Get fmu time out
Expand Down
8 changes: 3 additions & 5 deletions src/EnergyPlus/HeatBalanceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6294,14 +6294,12 @@ namespace HeatBalanceManager {
ConstructionFound = false;
// ErrorsFound = .FALSE.
EOFonFile = false;
std::string contextString = "HeatBalanceManager::SearchWindow5DataFile: ";

CheckForActualFileName(state, DesiredFileName, exists, state.files.TempFullFileName.fileName, contextString);

CheckForActualFileName(state, DesiredFileName, exists, state.files.TempFullFileName.fileName);
// INQUIRE(FILE=TRIM(DesiredFileName), EXIST=exists)
if (!exists) {
ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Could not locate Window5 Data File, expecting it as file name=" +
DesiredFileName);
ShowContinueError(state, "Certain run environments require a full path to be included with the file name in the input field.");
ShowContinueError(state, "Try again with putting full path and file name in the field.");
ShowFatalError(state, "Program terminates due to these conditions.");
}

Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/HeatBalanceSurfaceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,6 @@ namespace HeatBalanceSurfaceManager {
SurfWinBmBmSolar(SurfNum) = 0.0;
SurfWinBmDifSolar(SurfNum) = 0.0;
SurfWinDifSolar(SurfNum) = 0.0;
SurfWinDirSolTransAtIncAngle(SurfNum) = 0.0;
// energy
SurfWinTransSolarEnergy(SurfNum) = 0.0;
SurfWinBmSolarEnergy(SurfNum) = 0.0;
Expand Down
18 changes: 7 additions & 11 deletions src/EnergyPlus/ScheduleManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,11 @@ namespace ScheduleManager {
inputProcessor->getObjectItem(
state, CurrentModuleObject, 1, Alphas, NumAlphas, Numbers, NumNumbers, Status, lNumericBlanks, lAlphaBlanks, cAlphaFields, cNumericFields);
std::string ShadingSunlitFracFileName = Alphas(1);
CheckForActualFileName(state, ShadingSunlitFracFileName, FileExists, state.files.TempFullFileName.fileName);

std::string contextString = CurrentModuleObject + ", " + cAlphaFields(1) + ": ";
CheckForActualFileName(state, ShadingSunlitFracFileName, FileExists, state.files.TempFullFileName.fileName, contextString);

if (!FileExists) {
ShowSevereError(state, RoutineName + ":\"" + ShadingSunlitFracFileName +
"\" not found when External Shading Calculation Method = ImportedShading.");
ShowContinueError(state, "Certain run environments require a full path to be included with the file name in the input field.");
ShowContinueError(state, "Try again with putting full path and file name in the field.");
ShowFatalError(state, "Program terminates due to previous condition.");
}

Expand Down Expand Up @@ -1758,16 +1757,13 @@ namespace ScheduleManager {
// ENDDO
// ENDIF

CheckForActualFileName(state, Alphas(3), FileExists, state.files.TempFullFileName.fileName);
std::string contextString = CurrentModuleObject + "=\"" + Alphas(1) + "\", " + cAlphaFields(3) + ": ";

CheckForActualFileName(state, Alphas(3), FileExists, state.files.TempFullFileName.fileName, contextString);

// INQUIRE(file=Alphas(3),EXIST=FileExists)
// Setup file reading parameters
if (!FileExists) {
DisplayString("Missing " + Alphas(3));
ShowSevereError(state, RoutineName + CurrentModuleObject + "=\"" + Alphas(1) + "\", " + cAlphaFields(3) + "=\"" + Alphas(3) +
"\" not found.");
ShowContinueError(state, "Certain run environments require a full path to be included with the file name in the input field.");
ShowContinueError(state, "Try again with putting full path and file name in the field.");
ErrorsFound = true;
} else {
auto SchdFile = state.files.TempFullFileName.try_open();
Expand Down
Loading

5 comments on commit 3c810e4

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global_SimManager_SimAir (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (3034 of 3034 tests passed, 14 test warnings)

Messages:\n

  • 14 tests had: AUD diffs.

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global_SimManager_SimAir (Myoldmopar) - x86_64-MacOS-10.15-clang-11.0.0: OK (2994 of 2994 tests passed, 11 test warnings)

Messages:\n

  • 11 tests had: AUD diffs.

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global_SimManager_SimAir (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1558 of 1558 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global_SimManager_SimAir (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2249 of 2250 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 718
  • Failed: 1

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global_SimManager_SimAir (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: OK (722 of 722 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.