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

Method speedIndex

src/model/FanSystemModel.cpp:644–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642 }
643
644 boost::optional<unsigned> FanSystemModel_Impl::speedIndex(const FanSystemModelSpeed& t_speed) const {
645 boost::optional<unsigned> result;
646
647 // We do it with extensibleGroups() (rather than speeds()) and getString to avoid overhead
648 // of manipulating actual model objects and speed up the routine
649 auto egs = castVector<WorkspaceExtensibleGroup>(extensibleGroups());
650 auto flowFraction = toString(t_speed.flowFraction());
651 auto it = std::find_if(egs.begin(), egs.end(), [&](const WorkspaceExtensibleGroup& eg) {
652 return (eg.getField(OS_Fan_SystemModelExtensibleFields::SpeedFlowFraction).get() == flowFraction);
653 });
654
655 // If found, we compute the index by using std::distance between the start of vector and the iterator returned by std::find_if
656 if (it != egs.end()) {
657 result = std::distance(egs.begin(), it);
658 }
659
660 return result;
661 }
662
663 std::vector<FanSystemModelSpeed> FanSystemModel_Impl::speeds() const {
664

Callers 3

TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45

Calls 6

flowFractionMethod · 0.80
beginMethod · 0.80
toStringFunction · 0.50
endMethod · 0.45
getMethod · 0.45
getFieldMethod · 0.45

Tested by 3

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36