Skip to content

Commit

Permalink
Memory Issues Addressed
Browse files Browse the repository at this point in the history
At last!  It is with great pleasure that I announce a major issue has
been fixed in the memory usage of large Honeybee models.  It should now
be relatively quick to build Honeybee energy models with as many as 1000
zones and still keep the GH script runtime under a few minutes.  This
also opens up opportunities to have long parametric runs with larger HB
energy models, generating several variations of ~50-zone models without
killing your computer's memory. Enjoy!
  • Loading branch information
chriswmackey committed Jun 13, 2017
1 parent 1c4c429 commit 806188a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
56 changes: 51 additions & 5 deletions src/Honeybee_Honeybee.py
Expand Up @@ -47,7 +47,7 @@

ghenv.Component.Name = "Honeybee_Honeybee"
ghenv.Component.NickName = 'Honeybee'
ghenv.Component.Message = 'VER 0.0.61\nJUN_07_2017'
ghenv.Component.Message = 'VER 0.0.61\nJUN_13_2017'
ghenv.Component.IconDisplayMode = ghenv.Component.IconDisplayMode.icon
ghenv.Component.Category = "Honeybee"
ghenv.Component.SubCategory = "00 | Honeybee"
Expand Down Expand Up @@ -5723,8 +5723,11 @@ def crossProduct(vector1, vector2):
if len(surface.childSrfs) == len(glzCoordinates):
glzAdjcSrfName = childSrfsNames[count]
else:
glzAdjcSrfName = childSrfsNames[count] + "_glzP_" + `count`

try:
glzAdjcSrfName = childSrfsNames[count] + "_glzP_" + `count`
except:
glzAdjcSrfName = childSrfsNames[0] + "_glzP_" + `count`

adjcGlzPt = glzCoordinates[1:]
adjcGlzPt.reverse()
adjcGlzPt = [glzCoordinates[0]] + adjcGlzPt
Expand Down Expand Up @@ -5919,7 +5922,8 @@ def __init__(self, surface, srfNumber, srfID, *arg):
# define if type and BC is defined by user and should be kept
self.srfTypeByUser = False
self.srfBCByUser = False

self.BCObject = self.outdoorBCObject()

# Special attribute for shading control on inidivdual windows that influences the zone properties
self.shdCntrlZoneInstructs = []

Expand Down Expand Up @@ -8289,18 +8293,60 @@ def callFromHoneybeeHive(self, geometryList):
try:
# after the first round meshedFace makes copy.deepcopy crash
# so I need to regenerate meshFaces
bc = []
if HBObject.objectType == "HBZone":
for surface in HBObject.surfaces:
newMesh = rc.Geometry.Mesh()
newMesh.Append(surface.meshedFace)
surface.meshedFace = newMesh

# keep track of boundary conditions
# and then set them to None not to create
# memory issues for large models.
bc.append(copy.copy(surface.BCObject))
surface.BCObject = None
for csrf in surface.childSrfs:
bc.append(copy.copy(csrf.BCObject))
csrf.BCObject = None

elif HBObject.objectType == "HBSurface":
newMesh = rc.Geometry.Mesh()
newMesh.Append(HBObject.meshedFace)
HBObject.meshedFace = newMesh
# keep track of boundary conditions
# and then set them to None not to create
# memory issues for large models.
bc.append(copy.copy(HBObject.BCObject))
HBObject.BCObject = None
for csrf in HBObject.childSrfs:
bc.append(copy.copy(csrf.BCObject))
csrf.BCObject = None

HBObjects.append(copy.deepcopy(HBObject))
newObject = copy.deepcopy(HBObject)

# put the boundary condition objects back
count = 0
if HBObject.objectType == "HBZone":
for c, surface in enumerate(newObject.surfaces):
surface.BCObject = bc[count]
HBObject.surfaces[c].BCObject = bc[count]
count += 1
for cc, csrf in enumerate(surface.childSrfs):
csrf.BCObject = bc[count]
HBObject.surfaces[c].childSrfs[cc].BCObject = bc[count]
count += 1

elif HBObject.objectType == "HBSurface":
newObject.BCObject = bc[count]
HBObject.BCObject = bc[count]
count += 1
for cc, csrf in enumerate(newObject.childSrfs):
csrf.BCObject = bc[count]
HBObject.childSrfs[cc].BCObject = bc[count]
count += 1

HBObjects.append(newObject)
del(bc)
except Exception, e:
print `e`
print "Failed to copy the object. Returning the original objects...\n" +\
Expand Down
Binary file modified userObjects/Honeybee_Honeybee.ghuser
Binary file not shown.

1 comment on commit 806188a

@antonszilasi
Copy link
Member

Choose a reason for hiding this comment

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

@chriswmackey great work Chris!

Please sign in to comment.