OpenStudioCore:model
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
openstudio::model::Model Class Reference

#include <Model.hpp>

+ Inheritance diagram for openstudio::model::Model:

Public Member Functions

void connect (ModelObject sourceObject, unsigned sourcePort, ModelObject targetObject, unsigned targetPort) const
 Connects the sourcePort on the source ModelObject to the targetPort on the target ModelObject. More...
 
void disconnect (ModelObject object, unsigned port)
 Disconnects the port on the given ModelObject. More...
 
boost::optional< ComponentDatainsertComponent (const Component &component)
 Inserts Component into Model and returns the primary object, if possible. More...
 
std::vector< ModelObjectmodelObjects (bool sorted=false) const
 Get all model objects. More...
 
bool operator== (const Model &other) const
 Equality test, tests if this Model shares the same implementation object with other. More...
 
std::vector
< openstudio::IdfObject
purgeUnusedResourceObjects ()
 Removes all ResourceObjects with nonResourceObjectUseCount() == 0. More...
 
std::vector
< openstudio::IdfObject
purgeUnusedResourceObjects (IddObjectType iddObjectType)
 Removes all ResourceObjects of given IddObjectType with directUseCount() == 0. More...
 
Constructors and Destructors
 Model ()
 Creates a new, empty Model. More...
 
 Model (const openstudio::IdfFile &idfFile)
 Creates a new Model with one ModelObject for each IdfObject in the given IdfFile. More...
 
 Model (const openstudio::Workspace &workspace)
 Creates a new Model with one ModelObject for each WorkspaceObjects in the given Workspace. More...
 
virtual ~Model ()
 
Getters
boost::optional< SqlFilesqlFile () const
 Returns the EnergyPlus output SqlFile if set. More...
 
boost::optional< Buildingbuilding () const
 Get the Building object if there is one, this implementation uses a cached reference to the Building object which can be significantly faster than calling getOptionalUniqueModelObject<Building>(). More...
 
boost::optional
< LifeCycleCostParameters
lifeCycleCostParameters () const
 Get the LifeCycleCostParameters object if there is one, this implementation uses a cached reference to the LifeCycleCostParameters object which can be significantly faster than calling getOptionalUniqueModelObject<LifeCycleCostParameters>(). More...
 
boost::optional< RunPeriodrunPeriod () const
 Get the RunPeriod object if there is one, this implementation uses a cached reference to the RunPeriod object which can be significantly faster than calling getOptionalUniqueModelObject<RunPeriod>(). More...
 
boost::optional< YearDescriptionyearDescription () const
 Get the YearDescription object if there is one, this implementation uses a cached reference to the YearDescription object which can be significantly faster than calling getOptionalUniqueModelObject<YearDescription>(). More...
 
boost::optional< WeatherFileweatherFile () const
 Get the WeatherFile object if there is one, this implementation uses a cached reference to the WeatherFile object which can be significantly faster than calling getOptionalUniqueModelObject<WeatherFile>(). More...
 
Schedule alwaysOnDiscreteSchedule () const
 Get an always on schedule with discrete type limits if there is one. More...
 
SpaceType plenumSpaceType () const
 Get the space type used for plenums if there is one. More...
 
Setters
bool setSqlFile (const SqlFile &sqlFile)
 Sets the EnergyPlus output SqlFile. More...
 
bool resetSqlFile ()
 Resets the EnergyPlus output SqlFile. More...
 
Template Methods
template<typename T >
boost::optional< T > getModelObject (const Handle &handle) const
 Returns the ModelObject referenced by handle if it is of type T. More...
 
template<typename T >
getUniqueModelObject ()
 Returns the unique ModelObject of type T, creates a one if none are found. More...
 
template<typename T >
boost::optional< T > getOptionalUniqueModelObject () const
 Returns the unique ModelObject of type T if it is found. More...
 
template<typename T >
std::vector< T > getModelObjects (bool sorted=false) const
 Returns all ModelObjects of type T. More...
 
template<typename T >
std::vector< T > getConcreteModelObjects () const
 Returns all ModelObjects of type T, using T::iddObjectType() to speed up the search. More...
 
template<typename T >
std::vector< T > getModelObjects (const std::vector< openstudio::Handle > &handles) const
 Returns the subset of ModelObjects referenced by handles which are of type T. More...
 
template<typename T >
boost::optional< T > getModelObjectByName (const std::string &name) const
 Returns the ModelObjects of type T with name (exactMatch). More...
 
template<typename T >
std::vector< T > getModelObjectsByName (const std::string &name, bool exactMatch=true) const
 Returns all ModelObjects of type T with given name. More...
 
template<typename T >
boost::optional< T > getConcreteModelObjectByName (const std::string &name) const
 
template<typename T >
std::vector< T > getConcreteModelObjectsByName (const std::string &name) const
 
- Public Member Functions inherited from openstudio::Workspace
std::vector< WorkspaceObjectaddAndInsertObjects (const std::vector< IdfObject > &objectsToAdd, const std::vector< IdfObject > &objectsToInsert)
 
std::vector< WorkspaceObjectaddAndInsertObjects (const std::vector< WorkspaceObject > &objectsToAdd, const std::vector< WorkspaceObject > &objectsToInsert)
 
std::vector< WorkspaceObjectaddAndInsertObjects (const std::vector< WorkspaceObject > &objectsToAdd, const std::vector< std::vector< WorkspaceObject > > &objectsToInsert)
 
boost::optional< WorkspaceObjectaddObject (const IdfObject &idfObject)
 
std::vector< WorkspaceObjectaddObjects (const std::vector< IdfObject > &idfObjects)
 
std::vector< WorkspaceObjectaddObjects (const std::vector< WorkspaceObject > &objects)
 
bool canBeTarget (const Handle &handle, const std::set< std::string > &referenceListNames) const
 
cast () const
 
Workspace clone (bool keepHandles=false) const
 
Workspace cloneSubset (const std::vector< Handle > &handles, bool keepHandles=false, StrictnessLevel level=StrictnessLevel::Draft) const
 
bool connectProgressBar (const openstudio::ProgressBar &progressBar) const
 
bool disconnectProgressBar (const openstudio::ProgressBar &progressBar) const
 
bool fastNaming () const
 
boost::optional< IddObjectgetIddObject (const IddObjectType &type) const
 
boost::optional< WorkspaceObjectgetObject (Handle handle) const
 
boost::optional< WorkspaceObjectgetObjectByNameAndReference (std::string name, const std::vector< std::string > &referenceNames) const
 
boost::optional< WorkspaceObjectgetObjectByTypeAndName (IddObjectType objectType, const std::string &name) const
 
std::vector< WorkspaceObjectgetObjects (const std::vector< Handle > &handles) const
 
std::vector< WorkspaceObjectgetObjectsByName (const std::string &name, bool exactMatch=true) const
 
std::vector< WorkspaceObjectgetObjectsByReference (const std::string &referenceName) const
 
std::vector< WorkspaceObjectgetObjectsByReference (const std::vector< std::string > &referenceNames) const
 
std::vector< WorkspaceObjectgetObjectsByType (IddObjectType objectType) const
 
std::vector< WorkspaceObjectgetObjectsByType (const IddObject &objectType) const
 
std::vector< WorkspaceObjectgetObjectsByTypeAndName (IddObjectType objectType, const std::string &name) const
 
std::vector< Handle > handles (bool sorted=false) const
 
IddFile iddFile () const
 
IddFileType iddFileType () const
 
boost::optional< WorkspaceObjectinsertObject (const IdfObject &idfObject)
 
std::vector< WorkspaceObjectinsertObjects (const std::vector< IdfObject > &idfObjects)
 
std::vector< WorkspaceObjectinsertObjects (const std::vector< WorkspaceObject > &objects)
 
bool isInIddFile (IddObjectType type) const
 
bool isMember (const Handle &handle) const
 
bool isValid () const
 
bool isValid (StrictnessLevel level) const
 
std::vector< std::pair< QUrl,
openstudio::path > > 
locateUrls (const std::vector< URLSearchPath > &t_paths, bool t_create_relative_paths, const openstudio::path &t_infile)
 
boost::optional< std::string > name (const Handle &handle) const
 
std::string nextName (const std::string &name, bool fillIn) const
 
std::string nextName (const IddObjectType &iddObjectType, bool fillIn) const
 
unsigned numObjects () const
 
unsigned numObjectsOfType (IddObjectType type) const
 
unsigned numObjectsOfType (const IddObject &objectType) const
 
std::vector< WorkspaceObjectobjects (bool sorted=false) const
 
std::vector< WorkspaceObjectobjectsWithURLFields () const
 
bool operator!= (const Workspace &other) const
 
std::ostream & operator<< (std::ostream &os, const Workspace &workspace)
 
bool operator== (const Workspace &other) const
 
boost::optional< T > optionalCast () const
 
WorkspaceObjectOrder order ()
 
const WorkspaceObjectOrder order () const
 
bool removeObject (const Handle &handle)
 
bool removeObjects (const std::vector< Handle > &handles)
 
bool save (const openstudio::path &p, bool overwrite=false)
 
void setFastNaming (bool fastNaming)
 
bool setStrictnessLevel (StrictnessLevel level)
 
std::vector< Handle > sort (const std::vector< Handle > &handles) const
 
std::vector< WorkspaceObjectsort (const std::vector< WorkspaceObject > &objects) const
 
StrictnessLevel strictnessLevel () const
 
bool swap (WorkspaceObject &currentObject, IdfObject &newObject, bool keepTargets=false)
 
void swap (Workspace &other)
 
IdfFile toIdfFile () const
 
ValidityReport validityReport () const
 
ValidityReport validityReport (StrictnessLevel level) const
 
VersionString version () const
 
boost::optional< WorkspaceObjectversionObject () const
 
 Workspace (const Workspace &other)
 
 Workspace (StrictnessLevel level)
 
 Workspace ()
 
 Workspace (const IdfFile &idfFile, StrictnessLevel level=StrictnessLevel::None)
 
 Workspace (StrictnessLevel level, IddFileType iddFileType)
 
virtual ~Workspace ()
 

Static Public Member Functions

static boost::optional< Modelload (const path &p)
 Load Model from file. More...
 
- Static Public Member Functions inherited from openstudio::Workspace
static boost::optional< Workspaceload (const openstudio::path &p)
 
static boost::optional< Workspaceload (const openstudio::path &p, const IddFile &iddFile)
 
static boost::optional< Workspaceload (const openstudio::path &p, const IddFileType &iddFileType)
 

Related Functions

(Note that these are not member functions.)

bool compareInputAndOutput (const ModelObject &object, const std::string &attributeName, double inputResult, double outputResult, double tol, LogLevel logLevel=Debug)
 Compare inputResult to outputResult. More...
 
typedef std::vector< ModelModelVector
 
typedef boost::optional< ModelOptionalModel
 

Additional Inherited Members

- Public Types inherited from openstudio::Workspace
typedef boost::optional
< Workspace
OptionalWorkspace
 
typedef std::vector< WorkspaceWorkspaceVector
 
- Protected Types inherited from openstudio::Workspace
typedef detail::Workspace_Impl ImplType
 
- Protected Member Functions inherited from openstudio::Workspace
virtual void addVersionObject ()
 
std::vector< WorkspaceObjectallObjects () const
 
 Workspace (std::shared_ptr< detail::Workspace_Impl > impl)
 

Detailed Description

Model derives from Workspace and is a container for ModelObjects as defined by the OpenStudio IDD.

The OpenStudio Model is primarily a container for ModelObjects which together define a complete or partial model of a building for energy simulation. A ModelObject cannot exist outside of a Model which ensures that each ModelObject can access the full Model to search for related ModelObjects. Model also accepts a connection to EnergyPlus simulation output through the SqlFile access to the SQLite output of EnergyPlus. Each ModelObject may then access simulation output in its own context. Connection to simulation data from other simulation engines is planned for the future.

The OpenStudio Model input data model is based on the schema defined by the OpenStudio IDD. Each concrete ModelObject wraps a particular data type in the OpenStudio IDD and Model enforces collection level constraints such as preventing multiple definitions of unique objects, updating reference fields that point from one ModelObject to another when the target's name changes, etc. Most of Model's capabilities for managing data according to an IDD schema are implemented in the Workspace base class. See the Workspace documentation in the utilities sub-project for more information about Workspace.

Constructor & Destructor Documentation

openstudio::model::Model::Model ( )

Creates a new, empty Model.

openstudio::model::Model::Model ( const openstudio::IdfFile idfFile)
explicit

Creates a new Model with one ModelObject for each IdfObject in the given IdfFile.

Any unwrapped IDD types will be wrapped with GenericModelObject.

openstudio::model::Model::Model ( const openstudio::Workspace workspace)
explicit

Creates a new Model with one ModelObject for each WorkspaceObjects in the given Workspace.

Any unwrapped IDD types will be wrapped with GenericModelObject.

virtual openstudio::model::Model::~Model ( )
inlinevirtual

Member Function Documentation

Schedule openstudio::model::Model::alwaysOnDiscreteSchedule ( ) const

Get an always on schedule with discrete type limits if there is one.

create a new schedule if necessary and add it to the model

boost::optional<Building> openstudio::model::Model::building ( ) const

Get the Building object if there is one, this implementation uses a cached reference to the Building object which can be significantly faster than calling getOptionalUniqueModelObject<Building>().

void openstudio::model::Model::connect ( ModelObject  sourceObject,
unsigned  sourcePort,
ModelObject  targetObject,
unsigned  targetPort 
) const

Connects the sourcePort on the source ModelObject to the targetPort on the target ModelObject.

void openstudio::model::Model::disconnect ( ModelObject  object,
unsigned  port 
)

Disconnects the port on the given ModelObject.

template<typename T >
boost::optional<T> openstudio::model::Model::getConcreteModelObjectByName ( const std::string &  name) const
inline
template<typename T >
std::vector<T> openstudio::model::Model::getConcreteModelObjects ( ) const
inline

Returns all ModelObjects of type T, using T::iddObjectType() to speed up the search.

This method will only work for concrete model objects (leaves in the ModelObject inheritance tree), hence the name.

template<typename T >
std::vector<T> openstudio::model::Model::getConcreteModelObjectsByName ( const std::string &  name) const
inline
template<typename T >
boost::optional<T> openstudio::model::Model::getModelObject ( const Handle &  handle) const
inline

Returns the ModelObject referenced by handle if it is of type T.

This method can be used with T as a concrete type (e.g. Zone) or as an abstract class (e.g. ParentObject).

Todo:
Use of this template method requires knowledge of the size of the implementation object. Therefore, to use model.getModelObject<Zone>(handle) the user must include both Zone.hpp and Zone_Impl.hpp. It may be better to instantiate each version of this template method to avoid exposing the implementation objects, this is an open question.
template<typename T >
boost::optional<T> openstudio::model::Model::getModelObjectByName ( const std::string &  name) const
inline

Returns the ModelObjects of type T with name (exactMatch).

This method can be used with T as a concrete type (e.g. Zone) or as an abstract class (e.g. ParentObject), but please see getConcreteModelObjectByName if T is concrete.

Todo:
Use of this template method requires knowledge of the size of the implementation object. Therefore, to use model.getModelObjectsByName<Zone>("Zone1") the user must include both Zone.hpp and Zone_Impl.hpp. It may be better to instantiate each version of this template method to avoid exposing the implementation objects, this is an open question.
template<typename T >
std::vector<T> openstudio::model::Model::getModelObjects ( bool  sorted = false) const
inline

Returns all ModelObjects of type T.

This method can be used with T as a concrete type (e.g. Zone) or as an abstract class (e.g. ParentObject).

Todo:
Use of this template method requires knowledge of the size of the implementation object. Therefore, to use model.getModelObjects<Zone>(), the user must include both Zone.hpp and Zone_Impl.hpp. It may be better to instantiate each version of this template method to avoid exposing the implementation objects, this is an open question.
template<typename T >
std::vector<T> openstudio::model::Model::getModelObjects ( const std::vector< openstudio::Handle > &  handles) const
inline

Returns the subset of ModelObjects referenced by handles which are of type T.

This method can be used with T as a concrete type (e.g. Zone) or as an abstract class (e.g. ParentObject).

Todo:
Use of this template method requires knowledge of the size of the implementation object. Therefore, to use model.getModelObjects<Zone>(handles) the user must include both Zone.hpp and Zone_Impl.hpp. It may be better to instantiate each version of this template method to avoid exposing the implementation objects, this is an open question.
template<typename T >
std::vector<T> openstudio::model::Model::getModelObjectsByName ( const std::string &  name,
bool  exactMatch = true 
) const
inline

Returns all ModelObjects of type T with given name.

This method can be used with T as a concrete type (e.g. Zone) or as an abstract class (e.g. ParentObject).

Todo:
Use of this template method requires knowledge of the size of the implementation object. Therefore, to use model.getModelObjectsByName<Zone>("Zone1") the user must include both Zone.hpp and Zone_Impl.hpp. It may be better to instantiate each version of this template method to avoid exposing the implementation objects, this is an open question.
template<typename T >
boost::optional<T> openstudio::model::Model::getOptionalUniqueModelObject ( ) const
inline

Returns the unique ModelObject of type T if it is found.

Todo:
Use of this template method requires knowledge of the size of the implementation object. Therefore, to use model.getOptionalUniqueModelObject<Facility>() the user must include both Facility.hpp and Facility_Impl.hpp. It may be better to instantiate each version of this template method to avoid exposing the implementation objects, this is an open question.
template<typename T >
T openstudio::model::Model::getUniqueModelObject ( )
inline

Returns the unique ModelObject of type T, creates a one if none are found.

Todo:
Use of this template method requires knowledge of the size of the implementation object. Therefore, to use model.getUniqueModelObject<Facility>() the user must include both Facility.hpp and Facility_Impl.hpp. It may be better to instantiate each version of this template method to avoid exposing the implementation objects, this is an open question.
boost::optional<ComponentData> openstudio::model::Model::insertComponent ( const Component component)

Inserts Component into Model and returns the primary object, if possible.

boost::optional<LifeCycleCostParameters> openstudio::model::Model::lifeCycleCostParameters ( ) const

Get the LifeCycleCostParameters object if there is one, this implementation uses a cached reference to the LifeCycleCostParameters object which can be significantly faster than calling getOptionalUniqueModelObject<LifeCycleCostParameters>().

static boost::optional<Model> openstudio::model::Model::load ( const path &  p)
static

Load Model from file.

std::vector<ModelObject> openstudio::model::Model::modelObjects ( bool  sorted = false) const

Get all model objects.

If sorted, then the objects are returned in the preferred order.

bool openstudio::model::Model::operator== ( const Model other) const

Equality test, tests if this Model shares the same implementation object with other.

SpaceType openstudio::model::Model::plenumSpaceType ( ) const

Get the space type used for plenums if there is one.

Create a new space type if necessary and add it to the model

std::vector<openstudio::IdfObject> openstudio::model::Model::purgeUnusedResourceObjects ( )

Removes all ResourceObjects with nonResourceObjectUseCount() == 0.

All objects removed in the course of the purge are returned to support undos. Note that ResourceObjects may have children that are not ResourceObjects, and these may be removed as well.

std::vector<openstudio::IdfObject> openstudio::model::Model::purgeUnusedResourceObjects ( IddObjectType  iddObjectType)

Removes all ResourceObjects of given IddObjectType with directUseCount() == 0.

All objects removed in the course of the purge are returned to support undos. Note that ResourceObjects may have children that are not ResourceObjects, and these may be removed as well.

bool openstudio::model::Model::resetSqlFile ( )

Resets the EnergyPlus output SqlFile.

boost::optional<RunPeriod> openstudio::model::Model::runPeriod ( ) const

Get the RunPeriod object if there is one, this implementation uses a cached reference to the RunPeriod object which can be significantly faster than calling getOptionalUniqueModelObject<RunPeriod>().

bool openstudio::model::Model::setSqlFile ( const SqlFile sqlFile)

Sets the EnergyPlus output SqlFile.

SqlFile must correspond to EnergyPlus simulation of this Model.

boost::optional<SqlFile> openstudio::model::Model::sqlFile ( ) const

Returns the EnergyPlus output SqlFile if set.

boost::optional<WeatherFile> openstudio::model::Model::weatherFile ( ) const

Get the WeatherFile object if there is one, this implementation uses a cached reference to the WeatherFile object which can be significantly faster than calling getOptionalUniqueModelObject<WeatherFile>().

boost::optional<YearDescription> openstudio::model::Model::yearDescription ( ) const

Get the YearDescription object if there is one, this implementation uses a cached reference to the YearDescription object which can be significantly faster than calling getOptionalUniqueModelObject<YearDescription>().

Friends And Related Function Documentation

bool compareInputAndOutput ( const ModelObject object,
const std::string &  attributeName,
double  inputResult,
double  outputResult,
double  tol,
LogLevel  logLevel = Debug 
)
related

Compare inputResult to outputResult.

The intention is for inputResult to be the value of attributeName calculated using input data, and for outputResult to be the value of attributeName extracted from the Model::sqlFile(). Returns false and logs a message on the Model log channel at logLevel if the (relative) error is greater than tol.

typedef std::vector<Model> ModelVector
related
typedef boost::optional<Model> OptionalModel
related