Resources for understanding fenicsx/dolfinx better

Hi,
I’ve been using fenicsx for a few months now, and I’ve noticed I am still frequently struggling to understand how it works exactly.

My experience is that a lot of problems can be solved with very simple code, for which it works very fast and intuitively. There are many nice tutorial that solve various problems in a structured way. However, there are also cases where I need a bit more control and then suddenly it turns out to be much more difficult than expected. Some examples of things I have struggled with (or still am):

  • Why do we need some workaround to get the internal forces to get reaction forces? These must have already been computed to solve the problem, why can’t I read them? Why doesn’t this workaround work with a custom material model?
  • Why can’t we get more information from the solver? What were the residuals during the iterations? We can create our own custom solvers, but does that mean I’m giving up a more efficient c++ implementation?
  • Why can constitutive models only use UFL-based functions? (Without a workaround)
  • Why is there no arc-length solver available by default?

For these questions there are often good answers, but even if I learn how to make a specific case work, I find it difficult to learn why it works or is necessary to do in that way. The dolfinx paper has been useful for understanding some of the design philosophy and interplay between different components. I wondered if there are more resources about what is happening “under the hood”, to help me understand what can be done, and what the fundamental limitations are?

Thank you!

As i am not an expert in solid mechanics I cannot really say anything about this. Maybe at @bleyerj can comment.

You can get plenty of information from the solver.
For a non-linear problem you can set
dolfinx.log.set_log_level(dolfinx.log.LogLevel.INFO) prior to solvign to get more information. This is for isntance done in: Implementation — FEniCSx tutorial
You can also add more logging to the sub-space solver, by setting ksp_monitor, as done in for instance with


def monitor(ksp, its, rnorm):
    print(its, rnorm)

solver.setMonitor(monitor)

where solver is the krylov subspace solver.

DOLFINx and the FEniCS project revolve around using UFL (the unified form language) to represent variational problems.
Please note that DOLFINx materials is not a work-around, but a solution to a specific problem (if you have a material model that doesn’t fit ufl, you can use DOLFINx materials for them).

The FEniCS project is an open source project. Most of the contributors do not work full time on development of the core code, and thus we cannot support and maintain every kind of solver.

For legacy FEniCS someone implement an Arc-length solver: GitHub - pprachas/fenics_arclength: A Riks arclength solver implemented in FEniCS but it seems like they haven’t ported it to dolfinx.

There seems to be an arc-length solver in DOLFINy by (@michalhabera ), see:
https://orbilu.uni.lu/handle/10993/54222
and source code

I have written some tutorials:
https://jsdokken.com/FEniCS23-tutorial/README.html
https://jsdokken.com/dolfinx-tutorial/
that goes through some of the design choices and the underlying structure.

1 Like