MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / modelToRadPreProcess

Function modelToRadPreProcess

src/radiance/ForwardTranslator.cpp:2219–2340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2217 }
2218
2219 openstudio::model::Model modelToRadPreProcess(const openstudio::model::Model& model) {
2220 auto outmodel = model.clone().cast<model::Model>();
2221 outmodel.purgeUnusedResourceObjects();
2222 outmodel.getUniqueModelObject<openstudio::model::Building>(); // implicitly create building object
2223 outmodel.getUniqueModelObject<openstudio::model::Timestep>(); // implicitly create timestep object
2224 outmodel.getUniqueModelObject<openstudio::model::RunPeriod>(); // implicitly create runperiod object
2225
2226 std::map<std::string, openstudio::model::ThermalZone> thermalZones;
2227
2228 std::vector<openstudio::model::Space> spaces = outmodel.getConcreteModelObjects<openstudio::model::Space>();
2229 for (auto& space : spaces) {
2230 space.hardApplyConstructions();
2231 space.hardApplySpaceType(true);
2232 space.hardApplySpaceLoadSchedules();
2233
2234 // make all surfaces with surface boundary condition adiabatic
2235 std::vector<openstudio::model::Surface> surfaces = space.surfaces();
2236 for (auto& surf_it : surfaces) {
2237 boost::optional<openstudio::model::Surface> adjacentSurface = surf_it.adjacentSurface();
2238 if (adjacentSurface) {
2239
2240 // make sure to hard apply constructions in other space before messing with surface in other space
2241 boost::optional<openstudio::model::Space> adjacentSpace = adjacentSurface->space();
2242 if (adjacentSpace) {
2243 adjacentSpace->hardApplyConstructions();
2244 }
2245
2246 // resets both surfaces
2247 surf_it.resetAdjacentSurface();
2248
2249 // set both to adiabatic
2250 surf_it.setOutsideBoundaryCondition("Adiabatic");
2251 adjacentSurface->setOutsideBoundaryCondition("Adiabatic");
2252
2253 // remove interior windows
2254 for (openstudio::model::SubSurface subSurface : surf_it.subSurfaces()) {
2255 subSurface.remove();
2256 }
2257 for (openstudio::model::SubSurface subSurface : adjacentSurface->subSurfaces()) {
2258 subSurface.remove();
2259 }
2260 }
2261 }
2262
2263 openstudio::model::Space new_space = space.clone(outmodel).optionalCast<openstudio::model::Space>().get();
2264
2265 boost::optional<openstudio::model::ThermalZone> thermalZone = space.thermalZone();
2266
2267 if (thermalZone && thermalZone->name()) {
2268 if (thermalZones.find(*thermalZone->name()) == thermalZones.end()) {
2269 openstudio::model::ThermalZone newThermalZone(outmodel);
2270 newThermalZone.setName(*thermalZone->name());
2271 newThermalZone.setUseIdealAirLoads(true);
2272 thermalZones.insert(std::make_pair(*thermalZone->name(), newThermalZone));
2273 }
2274 auto itr = thermalZones.find(*thermalZone->name());
2275 OS_ASSERT(itr != thermalZones.end()); // We just added it above if we needed it
2276 new_space.setThermalZone(itr->second);

Callers

nothing calls this directly

Calls 15

hardApplySpaceTypeMethod · 0.80
adjacentSurfaceMethod · 0.80
resetAdjacentSurfaceMethod · 0.80
setUseIdealAirLoadsMethod · 0.80
setSolarDistributionMethod · 0.80
OutputVariableClass · 0.50
cloneMethod · 0.45
surfacesMethod · 0.45

Tested by

no test coverage detected