Skip to content

Simulation connections

A workflow type whose analysis needs to know which faces of the CAD model touch declares simulation connections: the simulation counterpart of the geometrical contacts the CAD stack detects. The platform detects the contacts of the assigned CAD model on demand, caches them per CAD state, and combines them with what the user declared whenever the effective connections are needed. Detected contacts are never stored in the workflow configuration; the configuration holds the user's intent only, so it stays small however large the assembly is.

Declaring the connections

The configuration schema declares the connections with simulationConnections, naming the data interface input that holds the CAD model and how the detected face pairs are grouped into connections. The block names the values a connection carries once; they become the fields of the connection defaults and of every value-carrying correction:

configurationSchema {
    simulationConnections("connections", cadInput = "geometry", grouping = ConnectionGrouping.BODY_PAIR) {
        label("Connections")
        connectionValues {
            enum("connectionType", "ConnectionType", listOf("BONDED", "SLIDING"), default = "BONDED") { label("Connection type") }
            real("frictionCoefficient", default = 0.0) { label("Friction coefficient") }
        }
    }
}

cadInput is the input holding the CAD model (simscale.std.cad:cad-model) whose detected contacts feed the connections. The CAD lives in the CAD session manager, so the input is external data (dataProviderType = DataProviderType.EXTERNAL): its data entry only references the CAD and its state. BODY_PAIR produces one connection per pair of bodies in contact, holding all face pairs between the two bodies; structural analyses group this way. FACE_PAIR produces one connection per detected face pair. A workflow type may declare several connections fields, each with its own binding.

The field is its own schema element type, and at the JSON level a compound with a fixed structure:

Field Holds
connectionDefaults The connection values every detected contact gets unless a correction says otherwise. Whether users may change them is the workflow type author's call: leave the fields as they are for editable defaults, or fix them in the UI configuration.
ignoreDetectedContacts A switch that starts the connections from an empty set instead of the detected contacts; afterwards only manual additions count.
connectionCorrections A list with one element per user intervention. Every element carries an optional name, two face assignments, facesA and facesB, and is one of the subtypes ADD (a manual connection between faces the detector does not pair, with its own values), EXCLUDE (a detected contact that must not become a connection) or OVERRIDE (a detected contact whose connection gets these values instead of the defaults).

Naming a connection is itself a correction. A user who only renames a detected connection stores an OVERRIDE that changes no values, which is what keeps connections nameable without storing every detected contact; the connection still counts as detected, and the name travels with it. A connection nobody named is named after the two bodies it connects, as the CAD model names them, so every connection has a name wherever it is shown.

Because the corrections are entity assignments, they accept saved selections, are checked against the CAD by the entity validation, are projected on a CAD swap like every other assignment, and are resolved for methods by the workflow runner.

The binding must match the rest of the workflow type: cadInput names an input the data interface declares, and the field sits at a fixed location of the configuration — in the schema or a nested compound, not inside a list or a subtype. simkit component build reports a field that does not, and the component registry rejects it at registration; such a field would derive nothing, and a run would hand its methods no connections.

The binding counts as a use of its input: a workflow type input must otherwise reach an operation, but the platform reads the CAD input to derive the connections, so no operation has to consume it for that.

What the platform does with the declaration

  • Nothing at creation time. Creating a workflow or assigning the CAD stores the configuration; the contact detection is started in the background so that the result is typically cached by the time anybody asks for it.
  • The connections view of a workflow version combines the detected contacts with the corrections and reports the effective connections, each with its origin (detected, changed, added, excluded) and its status; while the detection is still running the view reports that and lists the manual additions.
  • At run time the run passes through its own DERIVING_CONNECTIONS state, where the workflow runner derives the effective connections once, before it schedules the first operation, and records them with the run. Every operation of the run therefore sees the same connections, and the run keeps a record of what its methods were handed even after the CAD stack's detection changes. A detection which has not finished is retried at a growing interval, so the run waits visibly in that state until its connections are there. simkit run connections <run> shows what a run recorded and handed to its methods.

A run derives from exactly one CAD model per rule: an input holding several data entries (one per parameter value combination), or anything but a CAD model, fails the run with the reason. An input left unassigned yields no connections. Nothing the run records is ever degraded: when saved selections cannot be read or a service is temporarily unavailable, the run waits and tries again rather than resolving a correction to fewer faces.

Handing the connections to an operation

The workflow definition names the connections in an operation's configuration mapping:

SolverConfigValueModel.fromDefaults {
    connections = effectiveConnections("/connections", ConnectionsValueModel::fromReference)
}

ConnectionsValueModel is the element model generated from the consuming method's own configuration schema, so the list reads the way that method declares it. The method declares the fields every connection carries with effectiveConnectionFields(), next to the connection values it reads, so its models match what the platform writes:

configurationSchema {
    compoundList("connections") {
        effectiveConnectionFields()
        enum("connectionType", "ConnectionType", listOf("BONDED", "SLIDING"), default = "BONDED")
    }
}

Pass EffectiveConnectionValueModel::fromReference instead to read the platform's own shape; that model is generated from the same fields.

Each resolved connection carries its name (the user's, or the default one), the two sides and the connection values that apply to it:

{ "name": "Bracket to housing", "regionA": "B1", "regionB": "B2",
  "facesA": ["B1_TE9"], "facesB": ["B2_TE33"], "connectionType": "SLIDING" }

The values declared in connectionValues sit next to the sides, where the consuming method's own configuration schema names them. Connections which produce nothing are absent: an exclusion, an orphaned correction, and anything still pending. Methods never derive anything and never see corrections; a method that needs the CAD stack for its own reasons uses the CAD library.

Testing

simkit component build checks the binding. Validation rules over the connections work like any others in *.workflow-type.test.kts scripts:

workflowTypeTest {
    test("a negative friction coefficient in the defaults is reported") {
        validate {
            config("""{ "connections": { "connectionDefaults": { "connectionType": "SLIDING", "frictionCoefficient": -0.1 } } }""")
        }.shouldHaveError("connections_connection_defaults_friction_coefficient")
    }
}

What an operation is handed depends on the connections a run derives, which a component test cannot detect. State them instead with connections(path, json) in the test context, in the shape a run records, and resolve the mapping against it:

workflowTypeTest {
    test("the solver is handed the connections") {
        val configuration =
            resolveOperationConfiguration("solve") {
                config("""{ "connections": { "connectionDefaults": { "connectionType": "BONDED" }, "ignoreDetectedContacts": false, "connectionCorrections": [] } }""")
                connections(
                    "/connections",
                    """[ { "name": "", "regionA": "B1", "regionB": "B2", "facesA": ["B1_TE9"], "facesB": ["B2_TE33"], "connectionType": "BONDED" } ]""",
                )
            }
        check(configuration["connections"].size() == 1)
    }
}

Example

The test-connections workflow type in the workflows repository (e2e/components/workflow-types/test-connections-workflow) shows the whole topic in one place: a simulationConnections field with two connection values, bound to an external CAD input (the test counterpart of simscale.std.cad:cad-model) and grouped per body pair, a validation rule over the defaults, an operation handed the effective connections, and component tests for each.