Class DexpiTopologyResolver

java.lang.Object
neqsim.process.processmodel.dexpi.DexpiTopologyResolver

public final class DexpiTopologyResolver extends Object
Resolves the topology (stream connectivity) of a DEXPI P&ID XML document.

This class parses <Nozzle> elements on equipment, <Connection> elements inside piping network segments, and piping components to build a directed graph of equipment-level connections. The graph is then topologically sorted so that equipment can be instantiated in correct upstream-to-downstream order.

DEXPI topology model:

  • Each equipment element contains one or more <Nozzle> children with unique IDs
  • <PipingNetworkSegment> elements contain <Connection> elements linking nozzles and piping components via FromID/ToID attributes
  • Piping components (valves, reducers, tees) appear inline in segments and also participate in connections
Version:
1.0
Author:
NeqSim
  • Field Details

    • logger

      private static final org.apache.logging.log4j.Logger logger
  • Constructor Details

    • DexpiTopologyResolver

      private DexpiTopologyResolver()
  • Method Details

    • resolve

      public static DexpiTopologyResolver.ResolvedTopology resolve(Document document)
      Resolves the topology of a DEXPI XML document.
      Parameters:
      document - the parsed DEXPI XML document
      Returns:
      the resolved topology with equipment in topological order
    • collectEquipmentAndNozzles

      private static void collectEquipmentAndNozzles(Document document, Map<String,String> nozzleToEquipment, Map<String,Element> equipmentElements)
      Collects all equipment elements and their nozzle-to-equipment mappings from the document.
      Parameters:
      document - the XML document
      nozzleToEquipment - map to populate with nozzle ID to equipment ID
      equipmentElements - map to populate with equipment ID to XML element
    • collectNozzlesFrom

      private static void collectNozzlesFrom(Element element, String equipId, Map<String,String> nozzleToEquipment)
      Recursively collects Nozzle elements from an equipment element and its sub-components.
      Parameters:
      element - the parent element
      equipId - the owning equipment ID
      nozzleToEquipment - map to populate
    • collectPipingComponentIds

      private static void collectPipingComponentIds(Document document, Set<String> pipingComponentIds)
      Collects all piping component IDs from PipingComponent wrapper elements.
      Parameters:
      document - the XML document
      pipingComponentIds - set to populate with IDs
    • parseConnections

      private static List<DexpiTopologyResolver.TopologyEdge> parseConnections(Document document, Map<String,String> nozzleToEquipment, Set<String> pipingComponentIds)
      Parses all Connection elements from PipingNetworkSegments into raw edges.
      Parameters:
      document - the XML document
      nozzleToEquipment - nozzle to equipment mapping
      pipingComponentIds - known piping component IDs
      Returns:
      list of raw edges (may reference nozzles, piping components, or off-page connectors)
    • resolveToEquipment

      private static String resolveToEquipment(String id, Map<String,String> nozzleToEquipment)
      Resolves an ID (nozzle or equipment) to an equipment ID.
      Parameters:
      id - the ID to resolve
      nozzleToEquipment - nozzle mapping
      Returns:
      equipment ID, or null if not found
    • collapseToEquipmentEdges

      private static List<DexpiTopologyResolver.TopologyEdge> collapseToEquipmentEdges(List<DexpiTopologyResolver.TopologyEdge> rawEdges, Set<String> equipmentIds, Set<String> pipingComponentIds)
      Collapses raw edges that pass through intermediate piping components into direct equipment-to-equipment edges. For example, Equipment-A > Valve-1 > Equipment-B becomes Equipment-A > Equipment-B.
      Parameters:
      rawEdges - the raw edges from Connection elements
      equipmentIds - the set of actual equipment IDs
      pipingComponentIds - the set of piping component IDs
      Returns:
      list of equipment-level edges
    • topologicalSort

      private static List<String> topologicalSort(Set<String> equipmentIds, List<DexpiTopologyResolver.TopologyEdge> edges)
      Performs a topological sort (Kahn's algorithm) on the equipment graph.
      Parameters:
      equipmentIds - all equipment IDs
      edges - directed edges between equipment
      Returns:
      equipment IDs in topological order
    • isSubComponent

      private static boolean isSubComponent(String componentClass)
      Checks whether a DEXPI ComponentClass is a sub-component of equipment (e.g. Chamber, TubeBundle, Impeller) rather than a top-level equipment item.
      Parameters:
      componentClass - the DEXPI component class name
      Returns:
      true if it is a sub-component