From 1d990491405c7752049ee184ae8d5bc4200372bf Mon Sep 17 00:00:00 2001 From: Rob Falck Date: Fri, 28 Apr 2023 12:25:09 -0400 Subject: [PATCH 1/3] POEM_083: Specifying order when adding a subsystem. --- POEM_083.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 POEM_083.md diff --git a/POEM_083.md b/POEM_083.md new file mode 100644 index 00000000..be652352 --- /dev/null +++ b/POEM_083.md @@ -0,0 +1,58 @@ +POEM ID: 086 +Title: Specifying order when adding a subsystem +authors: robfalck (Rob Falck) +Competing POEMs: +Related POEMs: N/A +Associated implementation PR: N/A + +Status: + +- [x] Active +- [ ] Requesting decision +- [ ] Accepted +- [ ] Rejected +- [ ] Integrated + +## Motivation + +Adding subsystems to a Group in OpenMDAO currently places the subsystem at the end. +In situations where users may want to insert a subsystem into the middle of the sequence, they're required to alter the ordering after the fact. +It would be simpler if they had the option to specify the insertion point when adding the subsystem. + +## Proposed Solution + +`Group.add_subsystem` will support two new arguments: `before` and `after`. + +When both of these are `None` (the default) the systems will be placed at the end of the current list, which is the current behavior. + +These values can be specified with either strings (the name of the preceeding or following system), or with integers (the index of the preceeding or following system.) + +**These values take effect immediately, not during setup.** + +For instance, adding system 'a' to the beginning of the list and then system 'b' to the beginning of the list will result in system 'b' being first, followed by system 'a'. +In addition, if the name specified in `before` or `after` is not present in the subsystems at the time `add_subsystem` is called, it will result in an error. + +## Example + +### Insert a new system Foo as the first component in a group. +``` +g.add_subsystem('foo', FooComp(), before=0) +``` + +### Add a new system Foo as the last component in a group (current behavior) + +``` +g.add_subsystem('foo', FooComp()) +``` + +or equivalently + +``` +g.add_subsystem('foo', FooComp(), after=-1) +``` + +### Add a new system Foo before a system named 'bar' + +``` +g.add_subsystem('foo', FooComp(), before='bar') +``` From 1f1543e48ec050d39716f89c39fa4ca78436f704 Mon Sep 17 00:00:00 2001 From: Rob Falck Date: Sat, 29 Apr 2023 07:57:29 -0400 Subject: [PATCH 2/3] lint --- POEM_083.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/POEM_083.md b/POEM_083.md index be652352..df026218 100644 --- a/POEM_083.md +++ b/POEM_083.md @@ -1,4 +1,4 @@ -POEM ID: 086 +POEM ID: 083 Title: Specifying order when adding a subsystem authors: robfalck (Rob Falck) Competing POEMs: From 99fd1395268d97593549b1fcca25792585c32cf1 Mon Sep 17 00:00:00 2001 From: Rob Falck Date: Thu, 5 Oct 2023 08:45:33 -0400 Subject: [PATCH 3/3] Reject POEM_083.md Rejecting 083 as auto ordering capability should render this unnecessary. --- POEM_083.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/POEM_083.md b/POEM_083.md index df026218..ba2388e6 100644 --- a/POEM_083.md +++ b/POEM_083.md @@ -7,10 +7,10 @@ Associated implementation PR: N/A Status: -- [x] Active +- [ ] Active - [ ] Requesting decision - [ ] Accepted -- [ ] Rejected +- [x] Rejected - [ ] Integrated ## Motivation