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

Fix #4166 - Merging FloorSpaceJS can delete unique model Objects such as Facility, Building, Site (and children) #4245

Merged
merged 3 commits into from
Mar 19, 2021

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Mar 16, 2021

Pull request overview

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • 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)
  • Checked behavior in OpenStudioApplication, adjusted policies as needed (src/openstudio_lib/library/OpenStudioPolicy.xml)
  • 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 severity - Normal Bug component - Utilities Geometry Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. component - Geometry Translator labels Mar 16, 2021
@jmarrec jmarrec requested a review from DavidGoldwasser March 16, 2021 14:11
@jmarrec jmarrec self-assigned this Mar 16, 2021
…pacejson( north axis) is overriding the original model
Comment on lines +1019 to +1025
if ((iddObjectType == IddObjectType::OS_Site) || (iddObjectType == IddObjectType::OS_Facility)
|| (iddObjectType == IddObjectType::OS_Building)) {
// These are unique objects, so no need to delete them
continue;
} else {
currenObject.remove();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actual fix in ModelMerge::mergeModels. This works because getCurrentModelObject will grab them just fine, and the mergeSite / mergeFacility will deal with it gracefully, only overriding stuff coming from new_Model if it isn't defaulted.

I think this is functionally equivalent to < 3.1.0, and still works when the floorspace comes up with a northAxis for eg

std::map<UUID, UUID> handleMapping;
mm.mergeModels(model1, model2, handleMapping);

ASSERT_TRUE(model1.getOptionalUniqueModelObject<ClimateZones>());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line fails before fix. This is the MCVE that exhibits the issue present in #4166

Comment on lines +1192 to +1195

// Start with a base model, put some climate zone in there
// Add a Climate Zone to model1 only
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test is a bit more involved than the ModelMerger test: it loads a floorspace.json and will also check that the mapping of things like north_axis actually ends up in the model.

Comment on lines +1208 to +1210
Building building = model.getUniqueModelObject<Building>();
EXPECT_TRUE(building.setNominalFloortoFloorHeight(2.5));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My building has a building, and it has a NominalFloorToFloorHeight.

Comment on lines +1229 to +1237
EXPECT_FALSE(newModel_->getOptionalUniqueModelObject<ClimateZones>());

EXPECT_EQ(0.0, building.northAxis());
EXPECT_EQ(2.5, building.nominalFloortoFloorHeight());

ASSERT_TRUE(newModel_->getOptionalUniqueModelObject<Building>());
EXPECT_EQ(-30.0, newModel_->getOptionalUniqueModelObject<Building>()->northAxis());
EXPECT_FALSE(newModel_->getOptionalUniqueModelObject<Building>()->nominalFloortoFloorHeight());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Prior merge

Comment on lines +1249 to +1258
ASSERT_TRUE(model.getOptionalUniqueModelObject<Building>());
EXPECT_EQ(-30.0, model.getOptionalUniqueModelObject<Building>()->northAxis());
ASSERT_TRUE(model.getOptionalUniqueModelObject<Building>()->nominalFloortoFloorHeight());
EXPECT_EQ(2.5, model.getOptionalUniqueModelObject<Building>()->nominalFloortoFloorHeight());

// New Model isn't touched anyways...
ASSERT_TRUE(newModel_->getOptionalUniqueModelObject<Building>());
EXPECT_EQ(-30.0, newModel_->getOptionalUniqueModelObject<Building>()->northAxis());
EXPECT_FALSE(newModel_->getOptionalUniqueModelObject<Building>()->nominalFloortoFloorHeight());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

post merge:

model new_model (floorspace) Merged: expected
Building Axis 0 -30 -30
nominalFloortoFloorHeight 2.5 NaN 2.5

Copy link
Collaborator

@DavidGoldwasser DavidGoldwasser left a comment

Choose a reason for hiding this comment

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

Looks good, although did see Incremental Windows Build is failing.

@tijcolem
Copy link
Collaborator

@DavidGoldwasser Windows has a unit test failure 2989 - RubyTest-Date_Test-ymd_constructor (Failed) that we know about that will be addressed. This is the only one failing. all other platforms are clean. This is good to go!

@tijcolem tijcolem merged commit b4e9d64 into develop Mar 19, 2021
@tijcolem tijcolem deleted the 4166_CZ_ModelMerger branch March 19, 2021 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Geometry Translator component - Utilities Geometry Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Normal Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merging FloorSpaceJS strips out climate zone assignment.
4 participants