Coupling FEniCS and CalculiX via preCICE for electro-thermo-mechanical simulation

Hello PreCICE community,

I would like to ask whether preCICE can be used to couple FEniCS and CalculiX for a sequential multi-physics simulation.

My intended workflow is the following:

  1. Electrical simulation in FEniCS
    I solve an electrical problem to compute Joule heating (heat generation).

  2. Thermal simulation in FEniCS
    Using the electrical losses, I compute the temperature field in the domain.

  3. Thermo-mechanical analysis in CalculiX
    The temperature field obtained from FEniCS is then transferred to CalculiX in order to evaluate thermal stresses due to thermal expansion.

So in practice, I would like to:

  • use FEniCS for the electrical + thermal problems,

  • send the resulting temperature field to CalculiX,

  • and let CalculiX compute the mechanical response (thermal stresses).

My questions are:

  • Is such a coupling supported or recommended with preCICE?

  • Has anyone already coupled FEniCS ↔ CalculiX using preCICE?

  • Does preCICE support one‑way coupling in this kind of thermo-mechanical workflow?

  • Are there any limitations or best practices I should be aware of (data mapping, time stepping, mesh compatibility, etc.)?

Any advice, documentation, or example would be greatly appreciated.

Thank you very much for your help.

Best regards,
Maram

Hi @marambh17,

Welcome to the forum as well!

First of all: as you might already have noticed, FEniCS (now often referred to as “legacy FEniCS”) is being replaced by FEniCSx. Similarly, we are now doing minimal maintenance of the legacy FEniCS adapter, and focusing our efforts on the FEniCSx adapter. For details on that, @NiklasVin and @IshaanDesai are the experts.

I assume you already have solvers for the individual domains. This should be doable in FEniCSx.

You are looking into volume coupling.

  • Similarly to the FEniCS adapter, the FEniCSx adapter can generally do volume coupling. There is a tutorial in this direction.
  • The CalculiX adapter cannot readily do volume coupling at the moment, although there is ongoing work in this direction (currently in lower priority).

We don’t have any examples on this right now, and I am not sure at the moment if we had any user present anything like this before with CalculiX.

However, the (only described) LS-DYNA adapter was developed for this context, for example:

As explained above. Overall, the coupling should be possible, but you would need to write some additional code.

The specific combination of solvers should not matter. I don’t have any examples on top of my head, but maybe someone else has.

One-way coupling (as an alternative of two-way) is always supported. The workflow you describe is supported by the library. For the adapters, see above.

There is documentation on each of these features, but I would recommend starting from the simplest options (one-way explicit coupling, nearest-neighbor data mapping). The meshes can be arbitrary, but of course it would be good to start from coarse meshes, until you get the technicalities working.

Looking forward to see how this might evolve!

Hi @Makis,

Thank you very much for your detailed clarifications and thoughtful replies, they were extremely helpful.

Following your recommendations, I implemented a one‑way coupling using explicit coupling with nearest‑neighbor data mapping. With this setup, I was able to successfully run the coupling workflow. In particular, CalculiX was able to compute the mechanical response (thermal stresses) based on the temperature field provided by FEniCS Legacy, and I obtained consistent mechanical results from CalculiX.

I also visualized the coupling configuration using the preCICE Adapter Visualizer. The workflow corresponds to a one‑way coupling from FEniCS (electro‑thermal) to CalculiX (thermo-mechanical), as shown in the coupling schema below.

Thank you again for the guidance and for pointing out best practices to start from simple coupling options, this was very valuable in getting the setup to work.

@marambh17 thanks for the updates! Could you please describe your CalculiX setup? Are you coupling on a boundary, or the complete domain?

We could eventually also add any such hints into the adapter documentation (PRs welcome):

Hello!
Thank you for the great support, we’re planning to release our work on GitHub, featuring the FEniCS electro-mechanical solver, plus the preCICE coupling with CalculiX and (later) OpenRadioss.
In the meantime, it would be great to outline the coupling steps here for the community @marambh17

CalculiX setup and coupling strategy

Thank you for the question. Below I describe my CalculiX setup and the overall coupling workflow.


1. General coupling strategy

The objective of the coupling is to compute the mechanical displacement field induced by thermal stresses. To achieve this, the temperature field must be available at each mesh node and at each time step of the simulation, since thermal strains directly depend on the local temperature.

The coupling is therefore sequential and thermally driven:

  • The temperature field is computed in FEniCS Legacy.

  • This temperature field is transferred to CalculiX at every time step using preCICE.

  • CalculiX then uses the received temperature field to compute thermal stresses and the resulting mechanical displacements.

The coupling is applied on the complete structural domain, not only on a boundary.


2. :fire: Thermal solver - FEniCS Legacy - and data export

The temperature field resulting from Joule heating is computed using FEniCS legacy.

For each time step:

  • FEniCS solves the transient heat equation.

  • The nodal temperature field is written to preCICE using the writeData API.

  • The temperature is provided at the mesh nodes corresponding to the FEniCS discretization.

The preCICE mapping method used to transfer temperature from FEniCS to CalculiX is nearest-neighbor mapping, which is appropriate here since both meshes represent the same physical domain but different meshes.


3. :rocket: CalculiX model and mesh handling

In CalculiX, I prepared a mesh corresponding to the same physical domain as in FEniCS.

To facilitate temperature coupling:

  • I defined a node set containing all mesh nodes of the CalculiX model (referred to as CalculiXMesh).

  • This node set is used as the interface on which temperature values are applied.

  • The coupling is therefore done on the entire domain, not restricted to a surface or boundary.

This choice ensures that the thermal field is available everywhere in the solid, which is required for a consistent evaluation of thermal strains.


4. :fight_cloud: Multi-step CalculiX analysis

The CalculiX input file is structured into two successive analysis steps:

Step 1: Heat transfer step

  • This step is defined as a pure heat transfer (conduction) step.

  • The temperature values received from FEniCS through preCICE are imposed on the previously defined node set. ReadData

  • The temperature boundary condition is time-dependent, since preCICE updates the nodal temperatures at each coupling time step.

  • In practice, preCICE overwrites the temperature values at the nodes of the set at every iteration, based on the data received from FEniCS.

This step ensures that the temperature field inside CalculiX is fully synchronized with the thermal solution computed in FEniCS legacy.

Step 2: Mechanical step

  • In the second step, a mechanical analysis is performed.

  • Thermal strains are computed internally by CalculiX based on the temperature field obtained in Step 1.

  • From these thermal strains, CalculiX computes the stress field and the resulting mechanical displacement field.

No additional coupling is required in this step, since all the necessary thermal information has already been transferred.


5. :bullseye: Summary

To summarize:

  • The coupling transfers nodal temperature values from FEniCS legacy to CalculiX at every time step.

  • The coupling is performed on the full domain, using a node set containing all CalculiX mesh nodes.

  • A nearest-neighbor mapping is used in preCICE.

  • CalculiX is run with two steps: a heat transfer step driven by the coupled temperature field, followed by a thermo-mechanical step computing thermally induced displacements.

I hope this clarifies the setup and the rationale behind the coupling strategy. I would be happy to provide more details if needed, and I agree that documenting this type of workflow in the adapter documentation could be useful! :slightly_smiling_face: