Structure the cells into Blocks¶
Once the cells are detected (see Cell detection), each BusCell (InternCell, ExternCell, ArchCell)
and ShuntCell has to be organized into Block hierarchy so that a coordinate can later be computed for every node
(see PositionFinder and BlockPositionner).
Blocks are the building elements that are assembled hierarchically to organize the layout of the cells: a Block can
either directly embed a list of Node, or be composed of several sub-Blocks.
The Block hierarchy¶
A Block is identified by a Block.Type:
LEGPRIMARY
A primary block starting on aBUSnode and going up to the first non-switch node, following the patternBUS - n*SWITCH - FICTITIOUS(n >= 0). Such blocks instantiateLegPrimaryBlockand implementLegBlock.FEEDERPRIMARY
A primary block ending on aFEEDERnode, following the patternFICTITIOUS - FEEDER. Such blocks instantiateFeederPrimaryBlock.BODYPRIMARY
A primary block between two non-switch nodes that are not aBUSnor aFEEDER, following the patternFICTITIOUS - n*SWITCH - FICTITIOUS(n >= 0). Such blocks instantiateBodyPrimaryBlock.LEGPARALLEL
SeveralLegPrimaryBlocksharing the same extremities, merged together. Such blocks instantiateLegParallelBlockand implementLegBlock.BODYPARALLEL
Several blocks (of any type, exceptLEGPRIMARYalone, which would be aLEGPARALLEL) sharing the same extremities, merged together. Such blocks instantiateBodyParallelBlock.SERIAL
A chain composed of blocks, each one starting where the previous one ends. Such blocks instantiateSerialBlock.UNDEFINED
A fallback block gathering the remaining blocks when the algorithm could not identify any further merge (see Step 2: merge the blocks below). Such blocks instantiateUndefinedBlock.
Note
All primaryBlocks are leaves of the hierarchy
The Block type hierarchy, showing which types are primary/parallel/composed and which interfaces/classes they map to:
The algorithm ends up building a single root Block per cell, stored by Cell.setRootBlock, on which the size and the
position of the cell will later be computed.
Building the block hierarchy: CellBlockDecomposer¶
For each BusCell, the CellBlockDecomposer.determineComplexCell method builds the block hierarchy in two steps.
Step 1: identify the primary blocks¶
Starting from each BUS node of the cell, the algorithm walks along the chains of SWITCH nodes until it reaches a
non-switch node, creating one LegPrimaryBlock per branch. It does the same starting from each FEEDER node, creating
one FeederPrimaryBlock per branch. The remaining chains of nodes (not starting on a BUS or ending on a FEEDER) are
then explored recursively to create the BodyPrimaryBlock instances, until every node of the cell has been assigned to
exactly as many primary blocks as its cardinality allows (a node shared by several blocks, e.g. a fork node, can belong
to several primary blocks).
A small cell graph and the resulting set of primary blocks (LegPrimaryBlock, BodyPrimaryBlock, FeederPrimaryBlock)
it is decomposed into: two parallel SWITCH branches respectively connect BUS1 and BUS2 to the same first
FICTITIOUS node, each one forming its own LegPrimaryBlock (LegPrimaryBlock 1 on BUS1 and LegPrimaryBlock 2
on BUS2); the BodyPrimaryBlock then connects that FICTITIOUS node to a second one through a SWITCH, and the
FeederPrimaryBlock connects that second FICTITIOUS node directly to the FEEDER:
Step 2: merge the blocks¶
The primary blocks are then merged together, repeatedly, until only one block remains:
Parallel merge: two blocks are parallel if they share two “similar” extremity nodes (in the same order or reversed); two nodes are considered similar as soon as they are the same node, or they are both
FEEDER-like nodes, or they are bothBUSnodes (regardless of whether it is the very sameBusNodeor not). All the blocks found to be parallel to one another are merged into a singleLegParallelBlock(if they are allLegPrimaryBlock) orBodyParallelBlock(otherwise). In the example above,LegPrimaryBlock 1andLegPrimaryBlock 2share the sameFICTITIOUSfork node on one side, and, on the other side,BUS1andBUS2: even thoughBUS1andBUS2are two distinctBusNode, they are still considered similar extremities, so the two blocks are merged into a singleLegParallelBlock.Serial merge: a chain of blocks, each one starting where the previous one ends, is merged into a single
SerialBlock.
Both kinds of merge are attempted alternately until no more blocks can be merged. If, at some point, none of the two
merges can be applied while several blocks remain, the remaining blocks are gathered into an UndefinedBlock: this
means the pattern of the cell is not handled by the algorithm (this can be turned into an exception thanks to the
exceptionIfPatternNotHandled parameter, see PositionVoltageLevelLayoutFactoryParameters).
The resulting LegParallelBlock, together with the BodyPrimaryBlock and FeederPrimaryBlock identified above, each
start where the previous one ends, so they are merged, in a single serial merge, into the final SerialBlock root:
Shunt cells¶
ShuntCell cells are simpler to handle: CellBlockDecomposer.determineShuntCellBlocks directly builds a single
BodyPrimaryBlock containing all the nodes of the cell.