Class: SurfaceMatching
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- SurfaceMatching
- Defined in:
- lib/measures/SurfaceMatching/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml.
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(model) ⇒ Object
define the arguments that the user will input
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/measures/SurfaceMatching/measure.rb', line 24 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # make an argument to remove existing costs intersect_surfaces = OpenStudio::Measure::OSArgument.makeBoolArgument('intersect_surfaces', true) intersect_surfaces.setDisplayName('Intersect Surfaces Before Matching?') intersect_surfaces.setDefaultValue(true) args << intersect_surfaces return args end |
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml
19 20 21 |
# File 'lib/measures/SurfaceMatching/measure.rb', line 19 def name return 'SurfaceMatching' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/measures/SurfaceMatching/measure.rb', line 37 def run(model, runner, user_arguments) super(model, runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end # assign the user inputs to variables intersect_surfaces = runner.getBoolArgumentValue('intersect_surfaces', user_arguments) # matched surface counter initialMatchedSurfaceCounter = 0 surfaces = model.getSurfaces surfaces.each do |surface| if surface.outsideBoundaryCondition == 'Surface' next if !surface.adjacentSurface.is_initialized # don't count as matched if boundary condition is right but no matched object initialMatchedSurfaceCounter += 1 end end # reporting initial condition of model runner.registerInitialCondition("The initial model has #{initialMatchedSurfaceCounter} matched surfaces.") # put all of the spaces in the model into a vector spaces = OpenStudio::Model::SpaceVector.new model.getSpaces.each do |space| spaces << space end # intersect surfaces if intersect_surfaces OpenStudio::Model.intersectSurfaces(spaces) runner.registerInfo('Intersecting surfaces, this will create additional geometry.') end # match surfaces for each space in the vector OpenStudio::Model.matchSurfaces(spaces) runner.registerInfo('Matching surfaces..') # matched surface counter finalMatchedSurfaceCounter = 0 surfaces.each do |surface| if surface.outsideBoundaryCondition == 'Surface' finalMatchedSurfaceCounter += 1 end end # reporting final condition of model runner.registerFinalCondition("The final model has #{finalMatchedSurfaceCounter} matched surfaces.") return true end |