src/energyplus/ForwardTranslator/ForwardTranslateThermochromicGlazing.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 | #include "../../model/Model.hpp" | ||
| 8 | |||
| 9 | #include "../../model/ThermochromicGlazing.hpp" | ||
| 10 | |||
| 11 | #include "../../utilities/math/FloatCompare.hpp" | ||
| 12 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 13 | #include "../../utilities/idf/Workspace.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/WindowMaterial_GlazingGroup_Thermochromic_FieldEnums.hxx> | ||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | |||
| 18 | #include <algorithm> // For sort | ||
| 19 | |||
| 20 | using namespace openstudio::model; | ||
| 21 | |||
| 22 | namespace openstudio { | ||
| 23 | |||
| 24 | namespace energyplus { | ||
| 25 | |||
| 26 | 4 | boost::optional<IdfObject> ForwardTranslator::translateThermochromicGlazing(model::ThermochromicGlazing& modelObject) { | |
| 27 | |||
| 28 |
1/1✓ Branch 1 taken 4 times.
|
4 | auto groups = modelObject.thermochromicGroups(); |
| 29 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
|
4 | if (groups.empty()) { |
| 30 |
8/8✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 17 taken 3 times.
✓ Branch 20 taken 3 times.
✓ Branch 23 taken 3 times.
|
3 | LOG(Warn, "ThermochromicGlazing '" << modelObject.nameString() << "' has no ThermochromicGroups. Cannot translate."); |
| 31 | 3 | return boost::none; | |
| 32 | } | ||
| 33 | // Instantiate an IdfObject of the class to store the values | ||
| 34 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::WindowMaterial_GlazingGroup_Thermochromic, modelObject); |
| 35 | |||
| 36 | // Sort by optical data temperature (ThermochromicGroup already has the operator< for this, but I'm making it clearer by using a lambda) | ||
| 37 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(groups.begin(), groups.end(), |
| 38 | 8 | [](const ThermochromicGroup& a, const ThermochromicGroup& b) { return a.opticalDataTemperature() < b.opticalDataTemperature(); }); | |
| 39 | |||
| 40 |
2/2✓ Branch 2 taken 1 time.
✓ Branch 5 taken 1 time.
|
1 | auto first_thickness = groups.front().standardGlazing().thickness(); |
| 41 | |||
| 42 |
2/2✓ Branch 5 taken 5 times.
✓ Branch 6 taken 1 time.
|
6 | for (const auto& group : groups) { |
| 43 | |||
| 44 |
1/1✓ Branch 1 taken 5 times.
|
5 | IdfExtensibleGroup eg = idfObject.pushExtensibleGroup(); |
| 45 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | eg.setDouble(WindowMaterial_GlazingGroup_ThermochromicExtensibleFields::OpticalDataTemperature, group.opticalDataTemperature()); |
| 46 |
1/1✓ Branch 1 taken 5 times.
|
5 | auto standardGlazing = group.standardGlazing(); |
| 47 |
2/3✓ Branch 1 taken 5 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
|
10 | if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(standardGlazing)) { |
| 48 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | eg.setString(WindowMaterial_GlazingGroup_ThermochromicExtensibleFields::WindowMaterialGlazingName, wo_->nameString()); |
| 49 | 5 | } | |
| 50 | |||
| 51 | // Check if the thickness is consistent across all groups | ||
| 52 |
3/4✓ Branch 2 taken 5 times.
✓ Branch 5 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
|
5 | if (!openstudio::equal(group.standardGlazing().thickness(), first_thickness)) { |
| 53 | ✗ | LOG(Warn, "ThermochromicGlazing '" << modelObject.nameString() << "' has inconsistent thicknesses across ThermochromicGroups. " | |
| 54 | << "Expected: " << first_thickness << ", found: " << group.standardGlazing().thickness()); | ||
| 55 | } | ||
| 56 | 5 | } | |
| 57 | |||
| 58 |
1/1✓ Branch 1 taken 1 time.
|
1 | return idfObject; |
| 59 | 4 | } // End of translate function | |
| 60 | |||
| 61 | } // end namespace energyplus | ||
| 62 | } // end namespace openstudio | ||
| 63 |