src/energyplus/ForwardTranslator/ForwardTranslateZonePropertyUserViewFactorsBySurfaceName.cpp
| 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 | #include "../ForwardTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | #include "../../model/ZonePropertyUserViewFactorsBySurfaceName.hpp" | ||
| 10 | #include "../../model/ZonePropertyUserViewFactorsBySurfaceName_Impl.hpp" | ||
| 11 | #include "../../model/ThermalZone.hpp" | ||
| 12 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 13 | |||
| 14 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 15 | |||
| 16 | #include <utilities/idd/ZoneProperty_UserViewFactors_BySurfaceName_FieldEnums.hxx> | ||
| 17 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | |||
| 20 | using namespace openstudio::model; | ||
| 21 | |||
| 22 | using namespace std; | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | |||
| 26 | namespace energyplus { | ||
| 27 | |||
| 28 | boost::optional<IdfObject> | ||
| 29 | 1 | ForwardTranslator::translateZonePropertyUserViewFactorsBySurfaceName(ZonePropertyUserViewFactorsBySurfaceName& modelObject) { | |
| 30 |
1/1✓ Branch 1 taken 1 time.
|
1 | ThermalZone zone = modelObject.thermalZone(); |
| 31 |
1/1✓ Branch 1 taken 1 time.
|
1 | boost::optional<IdfObject> _zone = translateAndMapModelObject(zone); |
| 32 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!_zone) { |
| 33 | ✗ | LOG(Error, "ZonePropertyUserViewFactorsBySurfaceName references a zone '" << zone.nameString() | |
| 34 | << "' that was not translated, so it will not be translated either"); | ||
| 35 | } | ||
| 36 | |||
| 37 | // No need to translate it if it doesn't have at least one view factor | ||
| 38 |
1/1✓ Branch 1 taken 1 time.
|
1 | std::vector<ViewFactor> viewFactors = modelObject.viewFactors(); |
| 39 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (viewFactors.empty()) { |
| 40 | ✗ | LOG(Error, "ZonePropertyUserViewFactorsBySurfaceName for zone '" << zone.nameString() | |
| 41 | << "' doesn't have at least one view factor, it will not be translated."); | ||
| 42 | ✗ | return boost::none; | |
| 43 | } | ||
| 44 | |||
| 45 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject idfObject(openstudio::IddObjectType::ZoneProperty_UserViewFactors_BySurfaceName); |
| 46 |
1/1✓ Branch 1 taken 1 time.
|
1 | m_idfObjects.push_back(idfObject); |
| 47 | |||
| 48 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | idfObject.setString(ZoneProperty_UserViewFactors_BySurfaceNameFields::ZoneorZoneListorSpaceorSpaceListName, _zone->name().get()); |
| 49 | |||
| 50 |
2/2✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 time.
|
3 | for (const ViewFactor& viewFactor : viewFactors) { |
| 51 | |||
| 52 |
1/1✓ Branch 1 taken 2 times.
|
2 | ModelObject fromSurface = viewFactor.fromSurface(); |
| 53 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<IdfObject> _fromSurface = translateAndMapModelObject(fromSurface); |
| 54 |
1/1✓ Branch 1 taken 2 times.
|
2 | ModelObject toSurface = viewFactor.toSurface(); |
| 55 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<IdfObject> _toSurface = translateAndMapModelObject(toSurface); |
| 56 | |||
| 57 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | if (_fromSurface && _toSurface) { |
| 58 | // Push group only if ok | ||
| 59 |
1/1✓ Branch 1 taken 2 times.
|
2 | auto eg = idfObject.pushExtensibleGroup(); |
| 60 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | eg.setString(ZoneProperty_UserViewFactors_BySurfaceNameExtensibleFields::FromSurface, _fromSurface->name().get()); |
| 61 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | eg.setString(ZoneProperty_UserViewFactors_BySurfaceNameExtensibleFields::ToSurface, _toSurface->name().get()); |
| 62 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | eg.setDouble(ZoneProperty_UserViewFactors_BySurfaceNameExtensibleFields::ViewFactor, viewFactor.viewFactor()); |
| 63 | 2 | } else { | |
| 64 | ✗ | LOG(Error, "Could not translate a viewFactor group for " << modelObject.briefDescription() << ". Continuing with the rest."); | |
| 65 | } | ||
| 66 | 2 | } | |
| 67 | |||
| 68 |
1/1✓ Branch 1 taken 1 time.
|
1 | return boost::optional<IdfObject>(idfObject); |
| 69 | 1 | } | |
| 70 | |||
| 71 | } // namespace energyplus | ||
| 72 | |||
| 73 | } // namespace openstudio | ||
| 74 |