-
Notifications
You must be signed in to change notification settings - Fork 197
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
ModelObjectLists used to store Speed Data for coils aren't removed when a parent of the coil is removed #4241
Comments
…g the test Remove() test was failing, because the childrne coils Speed Data Lists aren't deleted: They aren't listed as children of the coils... and ParentObject::remove will removed them without explicitly calling the Coil::remove method. **This is not specific to this object**. I will file a separate issue: #4241
@jmarrec Let's say ModelObjectList was a child on the coil. So when you go to clone the parent of the coil, it would now clone the ModelObjectList as well as every SpeedData object on it. But we don't want that? We just want the coil to be cloned and then have the original SpeedData items on it? |
I think I was incorrectly thinking what the current behavior is... (I was assuming it was like I thought it should be :D) the current behavior is that if you clone the Coil, you clone the SpeedDataList, which is a ModelObjectList, so that also clones the modelobject on the modelobjectlist. Now you have two Coils, which are refererencing two CoilCoolingDXVariableSpeedSpeedData objects. Coil::remove also removes the ModelObjectList, along with it all CoilCoolingDXVariableSpeedSpeedData referenced. That's mostly where I thought this shouldn't be the case. I was assuming that it would be a valid scenario to actually have the same speeddata referenced by two different coils. See this example: I create two coils referencing the same speeddata. I remove one coil. Now I end up with one coil left, with a broken ModelObject List that has a blank and 0 speeds...
Not sure what's the sensible way to deal with this. Thoughts @joseph-robertson ? @kbenne |
I'd like to point out (to my chagrin) that ParentObject::remove (of which CoilCoolingDXVariableSpeed is one) uses Model / Workspace::removeObjects. The removeObjects method OpenStudio/src/utilities/idf/Workspace.cpp Line 1420 in 088c554
I think changing the implementation of Workspace::removeObjects so that it calls the virtual ::remove methods is a bad idea though, because I think there will be a million different unwanted changes in behavior from this. I think there would probably even be a bevy of runtime segmentation faults as objects try to delete themselves twice. So in my opinion this is not a strategy unless @jmarrec really feels energetic and brave. I think the idea of making the speedDataList (the ModelObjectList causing trouble) a child of CoilCoolingDXVariableSpeed might be the most workable. In order to address some of the concerns with this strategy raised here (regarding clone mostly), what if CoilCoolingDXVariableSpeedSpeedData becomes a ResourceObject like Curve? I think that would fix most of the problem and bring CoilCoolingDXVariableSpeedSpeedData inline with Curve, which I think makes a lot of sense. The only remaining annoyance is that making speedDataList a child will have it show up in the InspectorGadget of the app. It would be nice if the app IG policy had a way to omit an entire child, and not just its fields. |
@kbenne I think removeObjects is "correct" in not calling ModelObject_Impl::remove or we'll get a ton of double delete indeed... I think your idea of children/resource is worth a try (I honestly cannot reason through this cloning stuff without spending an hour playing with it, and I haven't done it right now), and what the App does or doesn't do with the InspectorGadget should not be a concern here. We should definitely start by writing all the tests to exhibit the behavior we do expect to do TDD here... I'd also like to point out that we probably have another dozen examples like this where if you assign the same object to two things it's entering the "undefined behavior" land. For eg: I can put the same CoilHeatingElectric into a PTAC and an ATU... I probably shouldn't, but it works. (I also don't think we should spend too much time overthinking this stuff) m = Model.new
c = CoilHeatingElectric.new(m)
fan = FanSystemModel.new(m)
cc = CoilCoolingDXSingleSpeed.new(m)
ptac = OpenStudio::Model::ZoneHVACPackagedTerminalAirConditioner.new(m, m.alwaysOnDiscreteSchedule, fan, c, cc)
atu = AirTerminalSingleDuctConstantVolumeReheat.new(m, m.alwaysOnDiscreteSchedule, c)
c == atu.reheatCoil && c == ptac.heatingCoil |
Enhancement Request
Found on #4236, e2e41ca
Detailed Description
Here is a MCVE
OpenStudio/src/model/CoilCoolingDXVariableSpeed.cpp
Lines 615 to 620 in 83b05b5
OpenStudio/src/model/ParentObject.cpp
Lines 67 to 95 in 83b05b5
Possible Implementation
The issue is the fact that to be deleted via ParentObject_Impl::remove, the coil would have to list its Speed Data ModelObjectList as a children. That's not a good idea though, because of how ModelObjectList behaves when it's cloned/deleted (it clones every object referenced / deletes every object)
I do not see any possible implementation at the moment. I'm just filing so we have a trace.
The text was updated successfully, but these errors were encountered: