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

Method clone

src/model/PlantLoop.cpp:148–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146 }
147
148 ModelObject PlantLoop_Impl::clone(Model model) const {
149 auto plantLoopClone = Loop_Impl::clone(model).cast<PlantLoop>();
150
151 plantLoopClone.setString(supplyInletPort(), "");
152 plantLoopClone.setString(supplyOutletPort(), "");
153 plantLoopClone.setString(demandInletPort(), "");
154 plantLoopClone.setString(demandOutletPort(), "");
155
156 // Sizing:Plant was already cloned because it is declared as a child
157 // And because it has the setParent method overriden, no need to do anything
158
159 {
160 // Perhaps call a clone(Loop loop) instead...
161 auto avmListClone = availabilityManagerAssignmentList().clone(model).cast<AvailabilityManagerAssignmentList>();
162 avmListClone.setName(plantLoopClone.name().get() + " AvailabilityManagerAssigmentList");
163 plantLoopClone.setPointer(OS_PlantLoopFields::AvailabilityManagerListName, avmListClone.handle());
164 }
165
166 plantLoopClone.getImpl<detail::PlantLoop_Impl>()->createTopology();
167
168 // Declare vectors we'll use to store the nodes in order to check if we have the same number of nodes
169 // and since we store them in the same order, we'll be able to clone the SPMs too
170 std::vector<Node> nodes;
171 std::vector<Node> nodeClones;
172
173 /*
174 *==========================================
175 * S U P P L Y S I D E
176 *==========================================
177 */
178
179 auto outputMessagesAndAssert = [](const std::vector<Node>& nodes, const std::vector<Node>& nodeClones, bool isSupplySide, bool isInlet) {
180 // Before the assert, we give out useful debugging info, or a Trace
181 if (nodes.size() != nodeClones.size()) {
182 LOG(Debug, "When cloning with (isSupplySide, isInlet) = (" << isSupplySide << ", " << isInlet << "),"
183 << "found a difference in number of nodes: nodes.size()=" << nodes.size()
184 << ", nodeClones.size()=" << nodeClones.size() << ".\n\nnodes:\n");
185 for (size_t i = 0; i < nodes.size(); ++i) {
186 LOG(Debug, "i=" << i << ", node=" << nodes[i].name().get());
187 }
188
189 LOG(Debug, "\n\nnodeClones:\n");
190 for (size_t i = 0; i < nodeClones.size(); ++i) {
191 LOG(Debug, "i=" << i << ", nodeClone=" << nodeClones[i].name().get());
192 }
193 } else {
194 LOG(Trace, "When cloning with (isSupplySide, isInlet) = (" << isSupplySide << ", " << isInlet << ")," << "nodes.size()=" << nodes.size()
195 << ", nodeClones.size()=" << nodeClones.size());
196
197 for (size_t i = 0; i < nodes.size(); ++i) {
198 LOG(Trace, "i=" << i << "node=" << nodes[i].name().get() << ", nodeClone=" << nodeClones[i].name().get());
199 }
200 }
201
202 // Assert that we have the same number of nodes
203 OS_ASSERT(nodes.size() == nodeClones.size());
204 };
205

Callers

nothing calls this directly

Calls 15

supplyInletNodeMethod · 0.95
supplySplitterMethod · 0.95
demandInletNodeMethod · 0.95
demandSplitterMethod · 0.95
supplyMixerMethod · 0.95
supplyOutletNodeMethod · 0.95
demandMixerMethod · 0.95
demandOutletNodeMethod · 0.95
reverseFunction · 0.85
supplyComponentsMethod · 0.80
demandComponentsMethod · 0.80
pop_backMethod · 0.80

Tested by

no test coverage detected