src/radiance/ForwardTranslator.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef RADIANCE_FORWARDTRANSLATOR_HPP | ||
| 7 | #define RADIANCE_FORWARDTRANSLATOR_HPP | ||
| 8 | |||
| 9 | #include "RadianceAPI.hpp" | ||
| 10 | #include "WindowGroup.hpp" | ||
| 11 | |||
| 12 | #include "../model/Model.hpp" | ||
| 13 | #include "../model/Surface.hpp" | ||
| 14 | #include "../model/SubSurface.hpp" | ||
| 15 | #include "../model/ShadingSurface.hpp" | ||
| 16 | #include "../model/InteriorPartitionSurface.hpp" | ||
| 17 | #include "../model/Luminaire.hpp" | ||
| 18 | #include "../model/DaylightingControl.hpp" | ||
| 19 | #include "../model/IlluminanceMap.hpp" | ||
| 20 | #include "../model/GlareSensor.hpp" | ||
| 21 | |||
| 22 | #include "../utilities/geometry/Point3d.hpp" | ||
| 23 | #include "../utilities/geometry/Vector3d.hpp" | ||
| 24 | |||
| 25 | #include "../utilities/core/Logger.hpp" | ||
| 26 | #include "../utilities/core/StringStreamLogSink.hpp" | ||
| 27 | |||
| 28 | namespace openstudio { | ||
| 29 | |||
| 30 | class RemoteBCL; | ||
| 31 | class LocalBCL; | ||
| 32 | |||
| 33 | namespace radiance { | ||
| 34 | |||
| 35 | /* Translates OpenStudio Building Model to Radiance simulation input. | ||
| 36 | */ | ||
| 37 | class RADIANCE_API ForwardTranslator | ||
| 38 | { | ||
| 39 | public: | ||
| 40 | ForwardTranslator(); | ||
| 41 | |||
| 42 | /** Translates a Model to radiance format in directory outPath | ||
| 43 | */ | ||
| 44 | std::vector<openstudio::path> translateModel(const openstudio::path& outPath, const openstudio::model::Model& model); | ||
| 45 | |||
| 46 | /** Get warning messages generated by the last translation. | ||
| 47 | */ | ||
| 48 | std::vector<LogMessage> warnings() const; | ||
| 49 | |||
| 50 | /** Get error messages generated by the last translation. | ||
| 51 | */ | ||
| 52 | std::vector<LogMessage> errors() const; | ||
| 53 | |||
| 54 | // for now just implement some functionality and let the Ruby script | ||
| 55 | // be the main driver | ||
| 56 | |||
| 57 | /// subtract subsurfaces from surface polygon and return | ||
| 58 | /// resulting polygons as vector of Point3dVector, these vertices | ||
| 59 | /// will be in absolute coodinates | ||
| 60 | static openstudio::Point3dVectorVector getPolygons(const openstudio::model::Surface& surface); | ||
| 61 | |||
| 62 | /// convert subsurface vertices to absolute coodinates | ||
| 63 | static openstudio::Point3dVector getPolygon(const openstudio::model::SubSurface& subSurface); | ||
| 64 | |||
| 65 | /// convert shading surface vertices to absolute coodinates | ||
| 66 | static openstudio::Point3dVector getPolygon(const openstudio::model::ShadingSurface& shadingSurface); | ||
| 67 | |||
| 68 | /// convert interior partition surface vertices to absolute coodinates | ||
| 69 | static openstudio::Point3dVector getPolygon(const openstudio::model::InteriorPartitionSurface& interiorPartitionSurface); | ||
| 70 | |||
| 71 | /// convert luminaire to absolute coodinates | ||
| 72 | static openstudio::Point3dVector getPolygon(const openstudio::model::Luminaire& luminaire); | ||
| 73 | |||
| 74 | /// get daylighting control reference point | ||
| 75 | static openstudio::Point3d getReferencePoint(const openstudio::model::DaylightingControl& control); | ||
| 76 | |||
| 77 | /// get sensor vector | ||
| 78 | static openstudio::Vector3d getSensorVector(const openstudio::model::DaylightingControl& control); | ||
| 79 | |||
| 80 | /// get view vectors, number is determined by the Number of Daylighting Views parameter | ||
| 81 | static openstudio::Vector3dVector getViewVectors(const openstudio::model::DaylightingControl& control); | ||
| 82 | |||
| 83 | /// get glare sensor view vectors, number is determined by the Number of Glare View Vectors parameter | ||
| 84 | static openstudio::Vector3dVector getViewVectors(const openstudio::model::GlareSensor& sensor); | ||
| 85 | |||
| 86 | /// get sensor vector | ||
| 87 | static openstudio::Vector3d getSensorVector(const openstudio::model::GlareSensor& sensor); | ||
| 88 | |||
| 89 | /// get glare sensor reference point | ||
| 90 | static openstudio::Point3d getReferencePoint(const openstudio::model::GlareSensor& sensor); | ||
| 91 | |||
| 92 | /// get output illuminance map reference points | ||
| 93 | static openstudio::Point3dVector getReferencePoints(const openstudio::model::IlluminanceMap& IlluminanceMap); | ||
| 94 | |||
| 95 | /// get sensor vector, this is the same for all points | ||
| 96 | static openstudio::Vector3d getSensorVector(const openstudio::model::IlluminanceMap& IlluminanceMap); | ||
| 97 | |||
| 98 | private: | ||
| 99 | static double PI() { | ||
| 100 | return 3.14159265358979323; | ||
| 101 | } | ||
| 102 | openstudio::model::Model m_model; | ||
| 103 | |||
| 104 | void clear(); | ||
| 105 | |||
| 106 | // create materials library for model, shared for all Spaces | ||
| 107 | std::set<std::string> m_radMaterials; | ||
| 108 | std::set<std::string> m_radMixMaterials; | ||
| 109 | std::set<std::string> m_radMaterialsDC; | ||
| 110 | std::set<std::string> m_radMaterialsWG0; | ||
| 111 | std::set<std::string> m_radMaterialsSwitchableBase; | ||
| 112 | |||
| 113 | std::string switchableGroup_wgMats; | ||
| 114 | |||
| 115 | // materials list for rtcontrib | ||
| 116 | std::set<std::string> m_radDCmats; | ||
| 117 | |||
| 118 | // scene files | ||
| 119 | std::vector<openstudio::path> m_radSceneFiles; | ||
| 120 | |||
| 121 | // create space geometry, hashes of space name to file contents | ||
| 122 | std::map<std::string, std::string> m_radSpaces; | ||
| 123 | std::map<std::string, std::string> m_radSensors; | ||
| 124 | std::map<std::string, std::string> m_radSensorViews; | ||
| 125 | std::map<std::string, std::string> m_radGlareSensors; | ||
| 126 | std::map<std::string, std::string> m_radGlareSensorViewsVTA; | ||
| 127 | std::map<std::string, std::string> m_radGlareSensorViewsVTV; | ||
| 128 | std::map<std::string, std::string> m_radMaps; | ||
| 129 | std::map<std::string, openstudio::Handle> m_radMapHandles; | ||
| 130 | std::map<std::string, std::string> m_radViewPoints; | ||
| 131 | std::map<std::string, std::string> m_radWindowGroups; | ||
| 132 | std::map<std::string, std::string> m_radWindowGroupShades; | ||
| 133 | int m_windowGroupId; | ||
| 134 | std::string shadeBSDF; | ||
| 135 | |||
| 136 | // get window group | ||
| 137 | WindowGroup getWindowGroup(const openstudio::Vector3d& outwardNormal, const model::Space& space, const model::ConstructionBase& construction, | ||
| 138 | const boost::optional<model::ShadingControl>& shadingControl, const openstudio::Point3dVector& polygon); | ||
| 139 | std::vector<WindowGroup> m_windowGroups; | ||
| 140 | |||
| 141 | void siteShadingSurfaceGroups(const openstudio::path& t_radDir, | ||
| 142 | const std::vector<openstudio::model::ShadingSurfaceGroup>& t_radShadingSurfaceGroups, | ||
| 143 | std::vector<openstudio::path>& t_outpaths); | ||
| 144 | |||
| 145 | void buildingShadingSurfaceGroups(const openstudio::path& t_radDir, | ||
| 146 | const std::vector<openstudio::model::ShadingSurfaceGroup>& t_radShadingSurfaceGroups, | ||
| 147 | std::vector<openstudio::path>& t_outpaths); | ||
| 148 | |||
| 149 | void buildingSpaces(const openstudio::path& t_radDir, const std::vector<openstudio::model::Space>& t_spaces, | ||
| 150 | std::vector<openstudio::path>& t_outpaths); | ||
| 151 | |||
| 152 | // get a bsdf possibly from the BCL | ||
| 153 | boost::optional<openstudio::path> getBSDF(double vlt, double vltSpecular, const std::string& shadeType); | ||
| 154 | boost::optional<std::string> getBSDF(openstudio::LocalBCL& bcl, double vlt, double vltSpecular, const std::string& shadeType, | ||
| 155 | const std::string& searchTerm, unsigned tid); | ||
| 156 | boost::optional<std::string> getBSDF(openstudio::RemoteBCL& bcl, double vlt, double vltSpecular, const std::string& shadeType, | ||
| 157 | const std::string& searchTerm, unsigned tid); | ||
| 158 | |||
| 159 | StringStreamLogSink m_logSink; | ||
| 160 | |||
| 161 | − | REGISTER_LOGGER("openstudio.radiance.ForwardTranslator"); | |
| 162 | }; | ||
| 163 | |||
| 164 | RADIANCE_API std::string formatString(double t_d, unsigned t_prec = 15); | ||
| 165 | |||
| 166 | RADIANCE_API std::string cleanName(const std::string& name); | ||
| 167 | |||
| 168 | // simplify model for initial E+ run to calculate window parameters, new model is returned, input model is not changed | ||
| 169 | RADIANCE_API openstudio::model::Model modelToRadPreProcess(const openstudio::model::Model& model); | ||
| 170 | |||
| 171 | } // namespace radiance | ||
| 172 | } // namespace openstudio | ||
| 173 | |||
| 174 | #endif // RADIANCE_FORWARDTRANSLATOR_HPP | ||
| 175 |