Skip to content

Commit

Permalink
Merge pull request #10768 from NREL/fix10766KivaCustomMaterial
Browse files Browse the repository at this point in the history
Fix Foundation:Kiva Custom Block Material Input Processing
  • Loading branch information
Myoldmopar authored Sep 30, 2024
2 parents e7ecb2d + 005f6b4 commit 8c106b8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/EnergyPlus/SurfaceGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11455,7 +11455,7 @@ namespace SurfaceGeometry {
for (int blockNum = 0; blockNum < numBlocks; blockNum++) {
Kiva::InputBlock block;
if (!s_ipsc->lAlphaFieldBlanks(alpF)) {
int index = Util::FindItemInPtrList(s_ipsc->cAlphaArgs(alpF), s_mat->materials);
int index = Material::GetMaterialNum(state, s_ipsc->cAlphaArgs(alpF));
if (index == 0) {
ErrorsFound = true;
ShowSevereError(state,
Expand Down
17 changes: 0 additions & 17 deletions src/EnergyPlus/UtilityRoutines.hh
Original file line number Diff line number Diff line change
Expand Up @@ -374,23 +374,6 @@ namespace Util {
return 0; // Not found
}

template <typename Container, class = typename std::enable_if<!std::is_same<typename Container::value_type, std::string>::value>::type>
// Container needs and operator[i] and elements need Name
inline int FindItemInPtrList(std::string_view const String, Container const &ListOfItems, int const NumItems)
{
for (typename Container::size_type i = 0, e = NumItems; i < e; ++i) {
if (String == ListOfItems[i]->Name) return int(i + 1); // 1-based return index
}
return 0; // Not found
}

template <typename Container, class = typename std::enable_if<!std::is_same<typename Container::value_type, std::string>::value>::type>
// Container needs and operator[i] and elements need Name
inline int FindItemInPtrList(std::string_view const String, Container const &ListOfItems)
{
return Util::FindItemInPtrList(String, ListOfItems, ListOfItems.isize());
}

template <typename Container, class = typename std::enable_if<!std::is_same<typename Container::value_type, std::string>::value>::type>
// Container needs isize() and operator[i] and elements need Name
inline int FindItemInList(std::string_view const String, Container const &ListOfItems)
Expand Down
51 changes: 51 additions & 0 deletions tst/EnergyPlus/unit/SurfaceGeometry.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12068,6 +12068,57 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetKivaFoundationTest2)
" ** ~~~ ** will be overridden with the Autoselected depth (40.0 m)"});
EXPECT_TRUE(compare_err_stream(error_string, true));
}
TEST_F(EnergyPlusFixture, SurfaceGeometry_GetKivaFoundationTest3)
{
bool ErrorsFound(false);

std::string const idf_objects = delimited_string({
"Material,",
" exterior vertical ins, !- Name",
" Rough, !- Roughness",
" 0.04611624, !- Thickness {m}",
" 0.029427, !- Conductivity {W/m-K}",
" 32.04, !- Density {kg/m3}",
" 1214.23, !- Specific Heat {J/kg-K}",
" 0.9, !- Thermal Absorptance",
" 0.7, !- Solar Absorptance",
" 0.7; !- Visible Absorptance",

"Foundation:Kiva,",
" Foundation Kiva 1, !- Name",
" 20, !- Initial Indoor Air Temperature {C}",
" , !- Interior Horizontal Insulation Material Name",
" , !- Interior Horizontal Insulation Depth {m}",
" , !- Interior Horizontal Insulation Width {m}",
" , !- Interior Vertical Insulation Material Name",
" , !- Interior Vertical Insulation Depth {m}",
" , !- Exterior Horizontal Insulation Material Name",
" , !- Exterior Horizontal Insulation Depth {m}",
" , !- Exterior Horizontal Insulation Width {m}",
" , !- Exterior Vertical Insulation Material Name",
" , !- Exterior Vertical Insulation Depth {m}",
" 0.3048, !- Wall Height Above Grade {m}",
" 0.2032, !- Wall Depth Below Slab {m}",
" , !- Footing Wall Construction Name",
" , !- Footing Material Name",
" , !- Footing Depth {m}",
" exterior vertical ins, !- Custom Block Material Name 1",
" 2.4384, !- Custom Block Depth 1 {m}",
" 0.2159, !- Custom Block X Position 1 {m}",
" 0; !- Custom Block Z Position 1 {m}",
});

ASSERT_TRUE(process_idf(idf_objects));

state->dataEnvrn->Elevation = 600.;

Material::GetMaterialData(*state, ErrorsFound);
EXPECT_FALSE(ErrorsFound);

GetFoundationData(*state, ErrorsFound);
EXPECT_FALSE(ErrorsFound);
EXPECT_TRUE(compare_err_stream(""));
}
TEST_F(EnergyPlusFixture, SurfaceGeometry_ZoneAndSpaceAreas)
{

Expand Down

4 comments on commit 8c106b8

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-RelWithDebInfo: Tests Failed (0 of 0 tests passed, 0 test warnings)

Build Badge Test Badge Coverage 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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (2914 of 2914 tests passed, 0 test warnings)

Build Badge Test 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.

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2892 of 2892 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-RelWithDebInfo: OK (799 of 799 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.