Skip to content

Commit

Permalink
Merge branch 'develop' into 4885_MeasureManager_c++
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec authored Sep 27, 2023
2 parents f4d43bf + 950172b commit 22d99c4
Show file tree
Hide file tree
Showing 41 changed files with 605 additions and 291 deletions.
24 changes: 13 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -833,28 +833,28 @@ if(BUILD_CLI)
if(UNIX)
if(APPLE)
if (ARCH MATCHES arm64)
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-darwin_arm64.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "27ca992c6e5fe5347a7e342eb5b91511")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-darwin_arm64.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "404783d585a63a07f2f9d5b4ba445d99")
else()
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-darwin.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "b6bf19e6958bd41be9788a7f16fd7f27")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-darwin.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "71282202360c68cf9dd0f0d585d560f2")
endif()
else()
if (ARCH MATCHES "arm64")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-linux_arm64.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "979a8839facf2fa1c4096dcbae39ddc2")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-linux_arm64.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "c28e1b84051fbae2ae0a9f7a27416951")
else()
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-linux.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "957681cb4f3b5cf8ad95103a5fae9a72")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-linux.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "f7279e86e0a9f41cfd0ce89060c4d836")
endif()
if (USE_OPENSTUDIO_GEMS_PR)
set(OPENSTUDIO_GEMS_BASEURL "${OPENSTUDIO_GEMS_BASEURL}/openstudio-gems-linux/${OPENSTUDIO_GEMS_PR_NUMBER}")
endif()
endif()
elseif(WIN32)
# OpenStudio gems are only supported on 64 bit windows
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-windows.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "e82889c296b7b76eb1f7b3fc7e22d2aa")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-windows.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "1606f5db801064864c1dc22e8e23459e")
if (USE_OPENSTUDIO_GEMS_PR)
set(OPENSTUDIO_GEMS_BASEURL "${OPENSTUDIO_GEMS_BASEURL}/openstudio-gems-windows/${OPENSTUDIO_GEMS_PR_NUMBER}")
endif()
Expand Down Expand Up @@ -1216,7 +1216,9 @@ if(NOT UNIX)
if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "bin")
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "Ruby" COMPONENT "RubyAPI")
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "CSharp/openstudio/" COMPONENT "CSharpAPI")
if (BUILD_CSHARP_BINDINGS)
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "CSharp/openstudio/" COMPONENT "CSharpAPI")
endif()
endif()
endif()

Expand Down
18 changes: 3 additions & 15 deletions ProjectMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,8 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S
endif()


# Add the -py3 flag if the version used is Python 3
set(SWIG_PYTHON_3_FLAGS "")
if (Python_VERSION_MAJOR)
if (Python_VERSION_MAJOR EQUAL 3)
set(SWIG_PYTHON_3_FLAGS "-py3;-relativeimport")
message(STATUS "${MODULE_NAME} - Building SWIG Bindings for Python 3")
else()
message(STATUS "${MODULE_NAME} - Building SWIG Bindings for Python 2")
endif()
else()
# Python2 has been EOL since January 1, 2020
set(SWIG_PYTHON_3_FLAGS "-py3;-relativeimport")
message(STATUS "${MODULE_NAME} - Couldn't determine version of Python - Building SWIG Bindings for Python 3")
endif()
# The -py3 flag is now deprecated as Python 3 is the default the version used is Python 3
set(SWIG_PYTHON_3_FLAGS "-relativeimport")

add_custom_command(
OUTPUT "${SWIG_WRAPPER_FULL_PATH}" "${PYTHON_GENERATED_SRC}"
Expand Down Expand Up @@ -511,7 +499,7 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S
# This is not working: "cannot open file 'python37.lib'"
target_link_libraries(${swig_target} PUBLIC ${${PARENT_TARGET}_depends})
if (MSVC)
message("Python_LIBRARIES=${Python_LIBRARIES}")
message(DEBUG "Python_LIBRARIES=${Python_LIBRARIES}")
target_link_libraries(${swig_target} PRIVATE Python::Module)
endif()
#target_link_libraries(${swig_target} PUBLIC ${${PARENT_TARGET}_depends}) ${Python_LIBRARIES})
Expand Down
19 changes: 10 additions & 9 deletions csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ install(DIRECTORY "examples"
PATTERN "*.docx"
)

file(TO_NATIVE_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/csharp" CSHARP_LIBRARY_OUTPUT_DIRECTORY)
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/csharp" CSHARP_SOURCE_DIR)
file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/csharp_wrapper" CSHARP_BINARY_DIR)
set(CSHARP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/csharp")

# For csproj.in
file(TO_NATIVE_PATH "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}" CSHARP_LIBRARY_OUTPUT_DIRECTORY_NATIVE)
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/csharp" CSHARP_SOURCE_DIR_NATIVE)

set(CSHARP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CSHARP_VERSION_MINOR ${PROJECT_VERSION_MINOR})
Expand Down Expand Up @@ -48,7 +50,9 @@ endif()

# The Release/Debug can be stripped probably
# Also probably don't need to use multiple `<TargetFrameworks>` which is the reason there's an extra netstandard2.0/ level
set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/netstandard2.0/OpenStudio.dll")
# Note: can't use CMAKE_BUILD_TYPE as it's empty for multi generators (MSVC for eg). So we use a genex
# We use the non-native, cmake_path, version of library output directory otherwise install fails with mistmatched `/` and `\` on windows
set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/$<CONFIG>/netstandard2.0/OpenStudio.dll")

# ignore deprecated warnings since we will export deprecated methods
add_library(csharp_warnings INTERFACE)
Expand All @@ -60,14 +64,11 @@ target_compile_options(csharp_warnings INTERFACE "$<${is_gnu_or_clang_genex}:-Wn
# custom command to make OPENSTUDIO_CSHARP_DLL
add_custom_command(
OUTPUT ${OPENSTUDIO_CSHARP_DLL}
COMMAND "${DOTNET}" "build" "-c" "$<CONFIGURATION>" "/p:Platform=${CSHARP_PLATFORM}" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj"
COMMAND "${DOTNET}" "build" "-c" "$<CONFIG>" "/p:Platform=${CSHARP_PLATFORM}" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj"
DEPENDS ${ALL_CSHARP_WRAPPER_TARGETS} ${ALL_CSHARP_WRAPPER_FILES}
)


install(FILES "${OPENSTUDIO_CSHARP_DLL}" DESTINATION CSharp/openstudio/ CONFIGURATIONS DEBUG COMPONENT "CSharpAPI")


install(FILES "${OPENSTUDIO_CSHARP_DLL}" DESTINATION CSharp/openstudio/ COMPONENT "CSharpAPI")

# keep the following lists aligned with translator_names in ProjectMacros.cmake
set(translator_wrappers
Expand Down
4 changes: 2 additions & 2 deletions csharp/developer/OpenStudio/OpenStudio.csproj.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeReferencedLibInPackage</TargetsForTfmSpecificContentInPackage>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<OutputPath>${CSHARP_LIBRARY_OUTPUT_DIRECTORY}\$(Configuration)\</OutputPath>
<OutputPath>${CSHARP_LIBRARY_OUTPUT_DIRECTORY_NATIVE}\$(Configuration)\</OutputPath>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>${CSHARP_SOURCE_DIR}\developer\OpenStudio\StrongNameKeyFile.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>${CSHARP_SOURCE_DIR_NATIVE}\developer\OpenStudio\StrongNameKeyFile.snk</AssemblyOriginatorKeyFile>


<!-- CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ You can also refer to the [OpenStudio SDK Python Binding Version Compatibility M
* [#4932](https://github.com/NREL/OpenStudio/pull/4932) - Support undisturbed ground temperature models on GroundHeatExchangerVertical
* Fix #4930 - Support undisturbed ground temperature models on GroundHeatExchangerVertical
* Update `GroundHeatExchanger:Vertical` to actually use the Ground Temeprature Model field
* [#4923](https://github.com/NREL/OpenStudio/pull/4923) - Fix #4692 - Modify `Model::load` to use the VersionTranslator instead of loading it assuming the version of the loaded OSM is the same as the current SDK version being used.
* [#4950](https://github.com/NREL/OpenStudio/pull/4950) - Addresses #4946, allow Table:Lookup curves for Coil:*:WaterToAirHeatPumpEquationFit objects
* `Coil:Cooling:WaterToAirHeatPumpEquationFit` and `Coil:Heating:WaterToAirHeatPumpEquationFit` have a few API-breaking changes related to its Curves. The types for the constructor, getters, and setters used to be explicit (e.g., `CurveQuadLinear`); it is now the base class, more generic, `Curve` type for added flexibility.

## Minor changes and bug fixes

Expand Down
2 changes: 1 addition & 1 deletion python/SetupPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(Python_USE_STATIC_LIBS OFF)
if (PYTHON_VERSION)
find_package(Python ${PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy)
else()
find_package(Python REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy)
find_package(Python 3 EXACT REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy)
endif()

execute_process(COMMAND ${Python_EXECUTABLE} -m pytest --version
Expand Down
2 changes: 2 additions & 0 deletions resources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ set(model_resources_src
model/ASHRAECourthouse.osm
model/A205ExampleChiller.RS0001.a205.cbor
model/4837_SpaceVolume.osm
model/empty361.osm
model/empty361/workflow.osw
)


Expand Down
5 changes: 5 additions & 0 deletions resources/model/empty361.osm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

OS:Version,
{e2190a61-e3f3-4d4b-8c0b-7a9c2342180e}, !- Handle
3.6.1; !- Version Identifier

6 changes: 6 additions & 0 deletions resources/model/empty361/workflow.osw
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"created_at" : "20230704T152451Z",
"seed_file" : "../empty361.osm",
"steps" : [],
"updated_at" : "20230704T152548Z"
}
4 changes: 3 additions & 1 deletion src/cli/UpdateCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ sys.argv.append("{}")
}
cmd += fmt::format(R"python(
import importlib.util
spec = importlib.util.spec_from_file_location('__main__', r'{}')
module_name = '__main__'
spec = importlib.util.spec_from_file_location(module_name, r'{}')
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
)python",
pythonScriptPath.generic_string());
Expand Down
17 changes: 17 additions & 0 deletions src/cli/test/test_embedded_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,21 @@ def test_msgpack
assert(data == data2)
end

def test_json_schemer
require 'json_schemer'

schema = {
'type' => 'object',
'properties' => {
'abc' => {
'type' => 'integer',
'minimum' => 11
}
}
}
schemer = JSONSchemer.schema(schema)
assert(schemer.valid?({ 'abc' => 11 }))
assert(!schemer.valid?({ 'abc' => 10 }))
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include "../../model/Node_Impl.hpp"
#include "../../model/CoilCoolingWaterToAirHeatPumpEquationFit.hpp"
#include "../../model/CoilCoolingWaterToAirHeatPumpEquationFit_Impl.hpp"
#include "../../model/CurveQuadLinear.hpp"
#include "../../model/CurveQuintLinear.hpp"
#include "../../model/Curve.hpp"

#include "../../utilities/core/Logger.hpp"
#include "../../utilities/core/Assert.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "../../model/Node_Impl.hpp"
#include "../../model/CoilHeatingWaterToAirHeatPumpEquationFit.hpp"
#include "../../model/CoilHeatingWaterToAirHeatPumpEquationFit_Impl.hpp"
#include "../../model/CurveQuadLinear.hpp"
#include "../../model/Curve.hpp"

#include "../../utilities/core/Logger.hpp"
#include "../../utilities/core/Assert.hpp"
Expand Down
21 changes: 11 additions & 10 deletions src/energyplus/ForwardTranslator/ForwardTranslateSubSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ namespace energyplus {

idfObject.setString(FenestrationSurface_DetailedFields::Name, modelObject.name().get());

openstudio::Vector3d offset(0, 0, 0);
idfObject.clearExtensibleGroups();

openstudio::Vector3d offset(0, 0, 0);
boost::optional<WindowPropertyFrameAndDivider> frameAndDivider = modelObject.windowPropertyFrameAndDivider();
if (frameAndDivider) {
if (!frameAndDivider->isOutsideRevealDepthDefaulted()) {
offset = -frameAndDivider->outsideRevealDepth() * modelObject.outwardNormal();
}
idfObject.setString(FenestrationSurface_DetailedFields::FrameandDividerName, frameAndDivider->name().get());
}

for (const Point3d& point : modelObject.vertices()) {
IdfExtensibleGroup group = idfObject.pushExtensibleGroup();
if (group.empty()) {
Expand All @@ -53,7 +62,7 @@ namespace energyplus {
return boost::none;
}

Point3d newPoint = point + offset;
const Point3d newPoint = point + offset;

group.setDouble(0, newPoint.x());
group.setDouble(1, newPoint.y());
Expand Down Expand Up @@ -137,14 +146,6 @@ namespace energyplus {
idfObject.setDouble(FenestrationSurface_DetailedFields::ViewFactortoGround, *viewFactortoGround);
}

boost::optional<WindowPropertyFrameAndDivider> frameAndDivider = modelObject.windowPropertyFrameAndDivider();
if (frameAndDivider) {
if (!frameAndDivider->isOutsideRevealDepthDefaulted()) {
offset = -frameAndDivider->outsideRevealDepth() * modelObject.outwardNormal();
}
idfObject.setString(FenestrationSurface_DetailedFields::FrameandDividerName, frameAndDivider->name().get());
}

if (!modelObject.isMultiplierDefaulted()) {
idfObject.setDouble(FenestrationSurface_DetailedFields::Multiplier, modelObject.multiplier());
}
Expand Down
49 changes: 44 additions & 5 deletions src/energyplus/Test/WindowPropertyFrameAndDivider_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../ErrorFile.hpp"
#include "../ForwardTranslator.hpp"
#include "../ReverseTranslator.hpp"
#include "../GeometryTranslator.hpp"

#include "../../model/Model.hpp"
#include "../../model/Space.hpp"
Expand All @@ -30,6 +31,8 @@
#include "../../utilities/idf/IdfFile.hpp"

#include <resources.hxx>
#include <utilities/idd/IddEnums.hxx>
#include <utilities/idd/FenestrationSurface_Detailed_FieldEnums.hxx>

#include <sstream>

Expand Down Expand Up @@ -76,8 +79,9 @@ TEST_F(EnergyPlusFixture, WindowPropertyFrameAndDivider) {
EXPECT_DOUBLE_EQ(-1.0, normal.y());
EXPECT_DOUBLE_EQ(0.0, normal.z());

static constexpr double outsideRevealDepth = 1.75;
WindowPropertyFrameAndDivider frameAndDivider(model);
frameAndDivider.setOutsideRevealDepth(1.0);
frameAndDivider.setOutsideRevealDepth(outsideRevealDepth);

EXPECT_FALSE(subSurface2.allowWindowPropertyFrameAndDivider());
EXPECT_TRUE(subSurface2.setSubSurfaceType("GlassDoor"));
Expand All @@ -86,12 +90,47 @@ TEST_F(EnergyPlusFixture, WindowPropertyFrameAndDivider) {
EXPECT_TRUE(subSurface2.setWindowPropertyFrameAndDivider(frameAndDivider));
ASSERT_TRUE(subSurface2.windowPropertyFrameAndDivider());


ForwardTranslator forwardTranslator;
OptionalWorkspace outWorkspace = forwardTranslator.translateModel(model);
ASSERT_TRUE(outWorkspace);
auto workspace = forwardTranslator.translateModel(model);

EXPECT_EQ(2u, workspace.getObjectsByType(IddObjectType::FenestrationSurface_Detailed).size());
ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::WindowProperty_FrameAndDivider).size());

auto pointEqual = [](const Point3d& a, const Point3d& b) {
static constexpr double tol = 1.0e-6;
EXPECT_NEAR(a.x(), b.x(), tol);
EXPECT_NEAR(a.y(), b.y(), tol);
EXPECT_NEAR(a.z(), b.z(), tol);
};

{
auto ss_ = workspace.getObjectByTypeAndName(IddObjectType::FenestrationSurface_Detailed, subSurface1.nameString());
ASSERT_TRUE(ss_);
EXPECT_TRUE(ss_->isEmpty(FenestrationSurface_DetailedFields::FrameandDividerName));
auto idf_vertices = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, *ss_);
ASSERT_EQ(vertices.size(), idf_vertices.size());
for (size_t i = 0; i < vertices.size(); ++i) {
pointEqual(vertices[i], idf_vertices[i]);
}
}

{
auto ss_ = workspace.getObjectByTypeAndName(IddObjectType::FenestrationSurface_Detailed, subSurface2.nameString());
ASSERT_TRUE(ss_);
auto frame_ = ss_->getTarget(FenestrationSurface_DetailedFields::FrameandDividerName);
ASSERT_TRUE(frame_);

auto idf_vertices = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, *ss_);
ASSERT_EQ(vertices.size(), idf_vertices.size());
for (size_t i = 0; i < vertices.size(); ++i) {
auto pt = vertices[i] + Vector3d(0.0, outsideRevealDepth, 0.0);
pointEqual(pt, idf_vertices[i]);
}
}

ReverseTranslator reverseTranslator;
OptionalModel outModel = reverseTranslator.translateWorkspace(*outWorkspace);
OptionalModel outModel = reverseTranslator.translateWorkspace(workspace);
ASSERT_TRUE(outModel);

EXPECT_EQ(1u, outModel->getConcreteModelObjects<WindowPropertyFrameAndDivider>().size());
Expand All @@ -102,7 +141,7 @@ TEST_F(EnergyPlusFixture, WindowPropertyFrameAndDivider) {
vertices = testSubSurface->vertices();
ASSERT_EQ(4u, vertices.size());
EXPECT_DOUBLE_EQ(0.0, vertices[0].x());
EXPECT_DOUBLE_EQ(0.0, vertices[0].y());
EXPECT_DOUBLE_EQ(outsideRevealDepth, vertices[0].y());
EXPECT_DOUBLE_EQ(1.0, vertices[0].z());

testSubSurface = outModel->getConcreteModelObjectByName<SubSurface>("No Offset");
Expand Down
Loading

0 comments on commit 22d99c4

Please sign in to comment.