Mapping NodeIDs to DOFs in Ferrite.jl V1.1.0

Hello! What is the canonical way to get the DOFs corresponding to a specific node in Ferrite.jl? I am sure there is a way to iterate over all cells to look for which cells share which nodes, but this seems cumbersome for such a seemingly simple and common task. Does Ferrite really not provide such a function in their API? Thanks in advance!

First, welcome to the Julia community!

@noetheriankoala EDIT:

.. That being said, it is of course a common thing to want to apply forces to nodes, so we have talked about adding utility functions for this :slightly_smiling_face: . But in the meanwhile, maybe this example code can help you?

Is the example code there what you need or a step in the right direction? I wouldn’t know, I only pasted your question verbatim to OpenAI (GPT-5), and got a seemingly fine answer (at least with link to the above, with source code there and in the AI answer itself too).

Ferrite doesn’t offer a built-in “get all DOFs for a given node” function. That’s because internally, DOFs are assigned on a per-cell basis rather than being tied directly to nodes. The system doesn’t keep an explicit node→DOF mapping under the hood. GitHub

A Ferrite collaborator confirmed this outright:

“There has never been a straightforward way of extracting the DOFs on nodes in Ferrite. The reason … is because we distribute the DOFs on cells, which means we never store the node-to-dof information.” GitHub

So yes, it’s kind of glaringly common, but also kind of intentionally missing—because Ferrite’s power lies in weak forms (integrals) rather than point-wise manipulation. That said, application of nodal loads and constraints is common, so they’ve sprinkled helpful code samples in discussions.

Your best workaround (for now)

You’ll be the judge if the AI (and/or me) was helpful. I know the AI is often very helpful for me, for (coding) discussions, for Julia (and Forth, the other language I’m fascinated by, can code in Julia, not always correctly (in any language), but showing Julia errors often fixes. Opus 4 is also claimed good for Julia.

I want to help you, I really do, but this does not seem to fit “General Usage”. I suppose you looked at the docs, and searched for DOF, degrees of freedom and NodeID? I took a quick look, DOF gave me too many results:

I couldn’t change the category to anything (not even sure which subcategory fits, or if it’s needed), like (you might want to, and maybe add another tag?):

The first link you provided is essentially what I am looking for :slight_smile:. I should have spent longer searching through the Ferrite.jl issues. Thanks!