Adding Non-Nodal Degrees of Freedom to a Problem

I am planning on creating models where a mechanical model (PDE solved in FEniCSx) is coupled to some rigid bodies, so there will be additional degrees of freedom not associated with nodes in the mesh (e.g., a mass connected to an elastic body by a spring). These additional degrees of freedom will be coupled to the nodal degrees of freedom, so if possible, I would like to incorporate them into my energy equations that I then minimize like normal.

Are there ways of introducing (and solving for) non-nodal degrees of freedom into FEniCSx problems, or will this require a very customized solver? I am more than happy to write a custom solver, but I would really like to retain the benefits of things like symbolic differentiation that FEniCSx/UFL provides.

Any guidance would be greatly appreciated!

Im not quite familiar enough with these concepts to be very assertive, but you could use real function spaces for this, if the degrees of freedom are constant across the domain.

If it varies in a piecewise constant fashion across the domain, the API reference — scifem is an alternative.

This is perfect! I have not come across the scifem library before, so thank you for pointing me to it. It looks like Real Function Spaces is exactly what I am looking for. Thanks!