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

Preserve SubSurface Outside Boundary Condition Object in ModelMerger #5154

Merged
merged 2 commits into from Apr 19, 2024

Conversation

macumber
Copy link
Contributor

Pull request overview

Fixes #5153

Preserve SubSurface Outside Boundary Condition Object in ModelMerger

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. component - Geometry Editor labels Apr 18, 2024
Comment on lines 360 to 381
// match new to cloned subsurfaces
for (const auto& newSubSurface : newSurface.subSurfaces()) {
m_newMergedHandles.insert(newSubSurface.handle());
for (auto& cloneSubSurface : clone.subSurfaces()) {
if (circularEqual(newSubSurface.vertices(), cloneSubSurface.vertices(), 0.01)) {
m_currentToNewHandleMapping[cloneSubSurface.handle()] = newSubSurface.handle();
m_newToCurrentHandleMapping[newSubSurface.handle()] = cloneSubSurface.handle();

boost::optional<SubSurface> newAdjacentSubSurface = newSubSurface.adjacentSubSurface();
if (newAdjacentSubSurface) {
boost::optional<UUID> currentAdjacentSubSurfaceHandle = getCurrentModelHandle(newAdjacentSubSurface->handle());
if (currentAdjacentSubSurfaceHandle) {
boost::optional<SubSurface> currentAdjacentSubSurface = m_currentModel.getModelObject<SubSurface>(*currentAdjacentSubSurfaceHandle);
if (currentAdjacentSubSurface) {
cloneSubSurface.setAdjacentSubSurface(*currentAdjacentSubSurface);
}
}
}
break;
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, so:

  1. We always emplace subSurfaces in m_newMergedHandles
  2. we do resolve m_currentToNewHandleMapping and m_newToCurrentHandleMapping
  3. Only if newAdjacentSubSurface then we try to setAdjacentSubSurface

Do we need 1 & 2 if newAdjacentSubSurface is empty?

I can see it follows the intent, but matching via circularEqual is expensive and it could be a big slow down on large models with lots of surfaces & more importantly lots of subsurfaces on each surface.

Copy link
Contributor Author

@macumber macumber Apr 18, 2024

Choose a reason for hiding this comment

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

The issue was that clone clones all the children without any support for the handle mapping so I tried to find a way to find the same sub surfaces in both models after the clone. I thought about matching sub surfaces based on names but there are some degenerate cases that would fail on (e.g. merge model {Space1 with SubSurface1, Space2 with SubSurface2} with model {Space1 with SubSurface2, Space2 with SubSurface1} might change object names based on the order spaces are processed).

My thought was to add all sub surfaces to the handle mappings for completeness, but we don't 100% need it. I would be ok to only do the checks if adjacentSubSurface is not empty. I'll update this now.

Changes to clone to support the handle mapping would be possible, and might be generally useful, just a bigger change.

Copy link
Contributor Author

@macumber macumber Apr 18, 2024

Choose a reason for hiding this comment

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

I made the change and tested it locally. I updated my branch and pushed the change however I can no longer build after the branch was updated to latest develop, I don't have my environment set up for 3.8.0 yet. Is there a wiki for setting up the new environment?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Basically you want python (ideally 3.8), and probably set a system ruby to 3.2.2 (though you can build without, but some tests won't run).

Install ninja too.

https://github.com/NREL/OpenStudio/blob/develop/BUILDING.md#full-example

pip install 'conan>2'
git clone git@github.com/NREL/OpenStudio.git
cd OpenStudio
conan install . --output-folder=../OS-build-release --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release
cmake --preset conan-release
cmake --build --preset conan-release

@jmarrec
Copy link
Collaborator

jmarrec commented Apr 19, 2024

Ok build is good, I agree with the code changes, and tests are ok. Let it fly

@jmarrec jmarrec merged commit 969f480 into NREL:develop Apr 19, 2024
2 of 6 checks passed
@jmarrec jmarrec deleted the fix_5153 branch April 19, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Geometry Editor Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interior windows missing required Outside Boundary Condition Object when ModelMerger
2 participants