Skip to content

Commit 6f64748

Browse files
x is the same domain as self.function
1 parent d660bca commit 6f64748

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/festim/exports/vtx.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def set_dolfinx_expression(
264264
if "t" in arguments:
265265
kwargs["t"] = time
266266
if "x" in arguments:
267-
x = ufl.SpatialCoordinate(time._ufl_domain)
267+
x = ufl.SpatialCoordinate(self.function.function_space.mesh)
268268
kwargs["x"] = x
269269
if "T" in arguments:
270270
if isinstance(temperature, fem.Function) and mixed_domain:
@@ -288,9 +288,34 @@ def set_dolfinx_expression(
288288
f"Argument {arg} not found in species_dependent_value"
289289
)
290290

291+
self.check_valid_inputs(kwargs, mixed_domain)
292+
291293
# evaluate the user-provided expression with the appropriate arguments and create a
292294
# dolfinx.fem.Expression
293295
self.dolfinx_expression = fem.Expression(
294296
self.expression(**kwargs),
295297
get_interpolation_points(self.function.function_space.element),
296298
)
299+
300+
def check_valid_inputs(self, kwargs: dict, mixed_domain: bool):
301+
"""
302+
Check if we are in the mixed domain/discontinuous case and if the user-provided
303+
expression is valid in this case.
304+
dolfinx.fem.Expression does not support co-dim 0 submeshes and time is defined
305+
on the parent mesh, so we cannot have time-dependent custom fields in the mixed
306+
domain/discontinuous case.
307+
308+
When https://github.com/FEniCS/dolfinx/issues/3207 is resolved we should be
309+
able to support this
310+
"""
311+
312+
# check the domain of all kwargs and check that they are the same
313+
314+
if mixed_domain and "t" in kwargs:
315+
raise NotImplementedError(
316+
"Time-dependent custom fields are not implemented in the case of a "
317+
"mixed domain/discontinuous case."
318+
"dolfinx.fem.Expression does not support co-dim 0 submeshes and time is"
319+
"defined on the parent mesh."
320+
"See https://github.com/FEniCS/dolfinx/issues/3207 for more details."
321+
)

0 commit comments

Comments
 (0)