当你有多个提升的输入时,你如何在 promotes_inputs=[] 中应用 src_indices?

How do you apply src_indices in promotes_inputs=[], when you have multiple promoted inputs?

The docs only show examples for when a component promotes a single input. 我如何使用 src_indices 来指示我的提升输入中只有一个占用特定的切片?

    p.model.add_subsystem('ComputeWakePosition', ComputeWakePosition(num_wake_points_per_side=4),
                          promotes_inputs=['wake_upper_lengths',
                                           'wake_lower_lengths',
                                           'wake_upper_angles',
                                           'wake_lower_angles',
                                           'displaced_cw_coordinates'], <-- I want to specify src_indices for this input only.
                          promotes_outputs=['upper_wake_coordinates',
                                            'lower_wake_coordinates'])

我想我可以只对那个输入使用 connect,但是考虑到我写的其他所有内容都没有使用它,如果有办法避免它就好了。

有一个名为 promotes 的函数,您可以在添加子系统后调用您的组。在上面的代码中,您可以从 add_subsystem 调用中删除 displaced_cw_coordinates 变量的提升,并进行单独的调用,例如 p.model.promotes('ComputeWakePosition', inputs=['displaced_cw_coordinates'], src_indices=[2,4,6,8])