Temperature export in discontinuous problem

Hi,

VTXTemperatureExport object does not seem to be implemented for the discontinuous case. I run into the error:

NotImplementedError: Export type <class ‘festim.exports.vtx.VTXTemperatureExport’> not implemented

When running the following:

import festim as F
import numpy as np


my_model = F.HydrogenTransportProblemDiscontinuous()

mat = F.Material(
    D_0=1,
    E_D=0,
)


vol = F.VolumeSubdomain1D(id=1, borders=[0, 1], material=mat)

my_model.subdomains = [vol]


my_model.mesh = F.Mesh1D(np.linspace(0, 1, 100))


my_model.species = [F.Species("H", subdomains=[vol])]


my_model.temperature = 700


my_model.settings = F.Settings(transient=False, atol=1e-9, rtol=1e-9)


temp_export = F.VTXTemperatureExport(
    filename="mwe_exports/temperature.bp",
)


my_model.exports = [temp_export]


my_model.initialise()

my_model.run()

Note: please format your code correctly with triple signs ``` and not quote blocks >. I modified your post

I reproduce the error

Traceback (most recent call last):
  File "/home/remidm/FESTIM/mwe.py", line 40, in <module>
    my_model.run()
  File "/home/remidm/FESTIM/src/festim/hydrogen_transport_problem.py", line 1861, in run
    self.post_processing()
  File "/home/remidm/FESTIM/src/festim/hydrogen_transport_problem.py", line 1708, in post_processing
    raise NotImplementedError(
NotImplementedError: Export type <class 'festim.exports.vtx.VTXTemperatureExport'> not implemented

This is because we have not yet implemented the VTXTemperatureExport support in the HydrogenTransportProblemDiscontinuous class.

Now in your case you can manually export the temperature at the end of the simulation (or maybe even just after initialise()

import festim as F
import numpy as np


my_model = F.HydrogenTransportProblemDiscontinuous()

mat = F.Material(
    D_0=1,
    E_D=0,
)


vol = F.VolumeSubdomain1D(id=1, borders=[0, 1], material=mat)

my_model.subdomains = [vol]


my_model.mesh = F.Mesh1D(np.linspace(0, 1, 100))


my_model.species = [F.Species("H", subdomains=[vol])]


# Had to change this because it only makes sense to export the temperature
# to a file if it's a function of x and not a constant.
my_model.temperature = lambda x: 700 + 100 * x[0]


my_model.settings = F.Settings(transient=False, atol=1e-9, rtol=1e-9)


# temp_export = F.VTXTemperatureExport(
#     filename="mwe_exports/temperature.bp",
# )


# my_model.exports = [temp_export]

my_model.initialise()
my_model.run()

from dolfinx import fem
from dolfinx.io import VTXWriter
from mpi4py import MPI
from pathlib import Path

assert isinstance(my_model.temperature_fenics, fem.Function), (
    f"Temperature field is not a fenics function, got {type(my_model.temperature_fenics)}"
)

with VTXWriter(
    MPI.COMM_WORLD,
    Path("mwe_exports/temperature.bp"),
    my_model.temperature_fenics,
    "BP4",
) as writer:
    writer.write(0.0)

Opening temperature.bp in Paraview: