# \#ufl

**URL:** https://fenicsproject.discourse.group/tag/ufl/50.md

[Latest](https://fenicsproject.discourse.group/latest.md) · [Categories](https://fenicsproject.discourse.group/categories.md) · [Tags](https://fenicsproject.discourse.group/tags.md)

---

## [ArityMismatch with complex PETSc and MixedFunctionSpace](https://fenicsproject.discourse.group/t/aritymismatch-with-complex-petsc-and-mixedfunctionspace/19849)

<div class="topic-metadata">

**Author:** [@ygiro](https://fenicsproject.discourse.group/u/ygiro)\
**Replies:** 2\
**Last updated:** [November 2, 2026, 6:08am UTC](https://fenicsproject.discourse.group/t/aritymismatch-with-complex-petsc-and-mixedfunctionspace/19849 "2026-11-02T06:08:07Z")

</div>

Hi, I am unable to compile forms on mixed function spaces when using complex numbers. The following minimal working example throws no error when running it with the real numbers build of PETSc: from mpi4py import MPI f…

---

## [UFL Conditional Breaking NonlinearProblem](https://fenicsproject.discourse.group/t/ufl-conditional-breaking-nonlinearproblem/19775)

<div class="topic-metadata">

**Author:** [@shivam](https://fenicsproject.discourse.group/u/shivam)\
**Replies:** 2\
**Last updated:** [July 16, 2026, 4:19pm UTC](https://fenicsproject.discourse.group/t/ufl-conditional-breaking-nonlinearproblem/19775 "2026-07-16T16:19:07Z")

</div>

Hey y’all. Just as a preface, I am using v 0.10 of DOLFINx. I am building a axisymmetric contact mechanics model between and analytical rigid indenter and an elastic body using a penalty method, currently using the linea…

---

## [Computing derivative of residual vector w.r.t material parameter for finite element model updating](https://fenicsproject.discourse.group/t/computing-derivative-of-residual-vector-w-r-t-material-parameter-for-finite-element-model-updating/18426)

<div class="topic-metadata">

**Author:** [@SolidMechanicsFan](https://fenicsproject.discourse.group/u/SolidMechanicsFan)\
**Replies:** 7\
**Last updated:** [July 4, 2026, 5:30pm UTC](https://fenicsproject.discourse.group/t/computing-derivative-of-residual-vector-w-r-t-material-parameter-for-finite-element-model-updating/18426 "2026-07-04T17:30:06Z")

</div>

Hi all, I am doing finite-element model updating for hyperelastic material models where I need analytic sensitivities of the residual w.r.t. constant material parameters: \\frac{\\partial \\mathbf{R}}{\\partial m} \\in \\mat…

---

## [How do I define a function with locally varying coefficients?](https://fenicsproject.discourse.group/t/how-do-i-define-a-function-with-locally-varying-coefficients/19643)

<div class="topic-metadata">

**Author:** [@lisa](https://fenicsproject.discourse.group/u/lisa)\
**Replies:** 2\
**Last updated:** [April 8, 2026, 4:33am UTC](https://fenicsproject.discourse.group/t/how-do-i-define-a-function-with-locally-varying-coefficients/19643 "2026-04-08T04:33:21Z")

</div>

Hi everybody! I am trying to define a function, depending on locally varyíng coefficients and on spatial coordinates, but so far without success. Here is my MWE based on a tutorial example “Defining subdomains for diffe…

---

## [Error with UFL condition in complex-valued problems](https://fenicsproject.discourse.group/t/error-with-ufl-condition-in-complex-valued-problems/19611)

<div class="topic-metadata">

**Author:** [@alvarez-pa](https://fenicsproject.discourse.group/u/alvarez-pa)\
**Replies:** 4\
**Last updated:** [March 20, 2026, 11:08am UTC](https://fenicsproject.discourse.group/t/error-with-ufl-condition-in-complex-valued-problems/19611 "2026-03-20T11:08:09Z")

</div>

Hello all, I am trying to use ufl.conditional for a complex-valued problem. For the condition argument, I have tried both binary operators (\<, \<=, \>, \>=) and UFL operators (ufl.lt, ufl.le, ufl.gt, ufl.ge) without succes…

---

## [Using FEMExternalOperator in elasticity: Missing differentiation handler for type FEMExternalOperator](https://fenicsproject.discourse.group/t/using-femexternaloperator-in-elasticity-missing-differentiation-handler-for-type-femexternaloperator/18406)

<div class="topic-metadata">

**Author:** [@SolidMechanicsFan](https://fenicsproject.discourse.group/u/SolidMechanicsFan)\
**Replies:** 0\
**Last updated:** [November 21, 2025, 6:33pm UTC](https://fenicsproject.discourse.group/t/using-femexternaloperator-in-elasticity-missing-differentiation-handler-for-type-femexternaloperator/18406 "2025-11-21T18:33:20Z")

</div>

I’m trying to use dolfinx\_external\_operator.FEMExternalOperator inside a nonlinear hyperelastic variational problem. My strain energy density can not conveniently be represented in UFL form (b-spline function → de-Boor a…

---

## [How can I speed up my integrals? ufl.conditional() needed for the integrals to work in the way that I want them to seems to be causing them to take a large amount of time](https://fenicsproject.discourse.group/t/how-can-i-speed-up-my-integrals-ufl-conditional-needed-for-the-integrals-to-work-in-the-way-that-i-want-them-to-seems-to-be-causing-them-to-take-a-large-amount-of-time/18344)

<div class="topic-metadata">

**Author:** [@fea](https://fenicsproject.discourse.group/u/fea)\
**Replies:** 2\
**Last updated:** [November 8, 2025, 8:11am UTC](https://fenicsproject.discourse.group/t/how-can-i-speed-up-my-integrals-ufl-conditional-needed-for-the-integrals-to-work-in-the-way-that-i-want-them-to-seems-to-be-causing-them-to-take-a-large-amount-of-time/18344 "2025-11-08T08:11:24Z")

</div>

For an iterative procedure I’m using, I need to perform cumulative integrals on the boundaries several times, and ufl.conditional() allows me to perform cumulative integration using Dolfinx and ufl. I noticed that my bou…

---

## [Cumulative integral of an interpolated expression](https://fenicsproject.discourse.group/t/cumulative-integral-of-an-interpolated-expression/18281)

<div class="topic-metadata">

**Author:** [@fea](https://fenicsproject.discourse.group/u/fea)\
**Replies:** 6\
**Last updated:** [October 25, 2025, 7:58am UTC](https://fenicsproject.discourse.group/t/cumulative-integral-of-an-interpolated-expression/18281 "2025-10-25T07:58:46Z")

</div>

To start, I am on the Dolfinx nightly version which is recognized as version DOLFINx version: 0.10.0.0, and I’m on Python version 3.12.3. Without getting into any of the specifics of the full problem that I’m working on…

---

## [Installing legacy FEniCS: Compatibility of ufl\_legacy 2022 with FEniCS 2019](https://fenicsproject.discourse.group/t/installing-legacy-fenics-compatibility-of-ufl-legacy-2022-with-fenics-2019/18163)

<div class="topic-metadata">

**Author:** [@rojin\_anbar](https://fenicsproject.discourse.group/u/rojin_anbar)\
**Replies:** 4\
**Last updated:** [August 29, 2025, 7:32pm UTC](https://fenicsproject.discourse.group/t/installing-legacy-fenics-compatibility-of-ufl-legacy-2022-with-fenics-2019/18163 "2025-08-29T19:32:27Z")

</div>

Hi everyone, I’m setting up legacy FEniCS 2019.1 on a new HPC system using Apptainer containers. I need to remain on the legacy stack because several other codes I use depend on it, so migrating to FEniCSx isn’t an opti…

---

## [Cross product of normal and test function in the variational form using ufl's FacetNormal?](https://fenicsproject.discourse.group/t/cross-product-of-normal-and-test-function-in-the-variational-form-using-ufls-facetnormal/18116)

<div class="topic-metadata">

**Author:** [@fea](https://fenicsproject.discourse.group/u/fea)\
**Replies:** 12\
**Last updated:** [August 25, 2025, 9:49am UTC](https://fenicsproject.discourse.group/t/cross-product-of-normal-and-test-function-in-the-variational-form-using-ufls-facetnormal/18116 "2025-08-25T09:49:53Z")

</div>

For the variational form of the (inhomogeneous) shallow water equations, I need to find u^\\bot = \\textbf{k}\\times \\textbf{u} where \\textbf{k} is the unit vector pointing normal to the surface. I tried to use ufl.FacetN…

---

## [Can an array of values be assigned to the source term?](https://fenicsproject.discourse.group/t/can-an-array-of-values-be-assigned-to-the-source-term/17956)

<div class="topic-metadata">

**Author:** [@fea](https://fenicsproject.discourse.group/u/fea)\
**Replies:** 14\
**Last updated:** [July 16, 2025, 2:36am UTC](https://fenicsproject.discourse.group/t/can-an-array-of-values-be-assigned-to-the-source-term/17956 "2025-07-16T02:36:18Z")

</div>

I want to solve Poisson’s Equation where the forcing term is provided as an array of values rather than one constant or a function like in the tutorial examples. Is there a way to do this? Or am I required to interpolate…

---

## [First order derivatives in non-linear problem](https://fenicsproject.discourse.group/t/first-order-derivatives-in-non-linear-problem/17737)

<div class="topic-metadata">

**Author:** [@mariom121](https://fenicsproject.discourse.group/u/mariom121)\
**Replies:** 0\
**Last updated:** [June 11, 2025, 5:55pm UTC](https://fenicsproject.discourse.group/t/first-order-derivatives-in-non-linear-problem/17737 "2025-06-11T17:55:26Z")

</div>

Dear FenicsX users, I am trying to solve the following non-linear problem: On the \[0,1\] one-dimensional interval with homogeneous Neumann boundary conditions for u. I have been able to successfully solve other non-l…

---

## [Imposing normal velocity Dirichiet BC](https://fenicsproject.discourse.group/t/imposing-normal-velocity-dirichiet-bc/17535)

<div class="topic-metadata">

**Author:** [@Shufan\_Xia1](https://fenicsproject.discourse.group/u/Shufan_Xia1)\
**Replies:** 3\
**Last updated:** [May 7, 2025, 1:23am UTC](https://fenicsproject.discourse.group/t/imposing-normal-velocity-dirichiet-bc/17535 "2025-05-07T01:23:59Z")

</div>

I want to define a Dirichlet BC for velocity on multiple surfaces as velocity with some magnitude A in the direction normal to the surface. I am not sure how to do so. Specifically, I have some mesh defined only on the …

---

## [2D and 1D variational terms in 3D simulation](https://fenicsproject.discourse.group/t/2d-and-1d-variational-terms-in-3d-simulation/17136)

<div class="topic-metadata">

**Author:** [@usiu5555](https://fenicsproject.discourse.group/u/usiu5555)\
**Replies:** 8\
**Last updated:** [March 5, 2025, 7:05am UTC](https://fenicsproject.discourse.group/t/2d-and-1d-variational-terms-in-3d-simulation/17136 "2025-03-05T07:05:05Z")

</div>

I am trying to solve a following problem: \\int\_\\Omega \\nabla u \\nabla v + \\int\_{\\Gamma\_i} 100 \\nabla\_t u \\nabla\_t v = \\int\_{\\partial \\Gamma\_i} f(u) + \\int\_{\\partial \\Omega} v q n First integral is the standard integr…

---

## [Nonlocal (boundary) terms in interior form due to rescaling](https://fenicsproject.discourse.group/t/nonlocal-boundary-terms-in-interior-form-due-to-rescaling/17024)

<div class="topic-metadata">

**Author:** [@Psirus](https://fenicsproject.discourse.group/u/Psirus)\
**Replies:** 0\
**Last updated:** [February 19, 2025, 10:11am UTC](https://fenicsproject.discourse.group/t/nonlocal-boundary-terms-in-interior-form-due-to-rescaling/17024 "2025-02-19T10:11:26Z")

</div>

I’m trying to solve a continuity equation \\frac{\\partial u}{\\partial t} = - \\frac{\\partial \\mathbf{j}\_u}{\\partial x} in 1D on a growing domain \\Omega from 0 to x\_l(t). The growth speed of the domain depends on the val…

---

## [Issue with compute\_gradient: Invalid Type Conversion in FEniCS](https://fenicsproject.discourse.group/t/issue-with-compute-gradient-invalid-type-conversion-in-fenics/16265)

<div class="topic-metadata">

**Author:** [@ekqls5264](https://fenicsproject.discourse.group/u/ekqls5264)\
**Replies:** 2\
**Last updated:** [November 11, 2024, 11:17pm UTC](https://fenicsproject.discourse.group/t/issue-with-compute-gradient-invalid-type-conversion-in-fenics/16265 "2024-11-11T23:17:45Z")

</div>

Hi, I am working with FEniCS and dolfin-adjoint, and I encountered an error while trying to compute the gradient of a functional. The error message I am receiving is: Invalid type conversion: f\_53 can not be converted …

---

## [Issue Related to ufl](https://fenicsproject.discourse.group/t/issue-related-to-ufl/15829)

<div class="topic-metadata">

**Author:** [@Vivek](https://fenicsproject.discourse.group/u/Vivek)\
**Replies:** 12\
**Last updated:** [September 20, 2024, 4:33am UTC](https://fenicsproject.discourse.group/t/issue-related-to-ufl/15829 "2024-09-20T04:33:47Z")

</div>

hello everyone, ia am finding the error while executing the code. and that error related to ufl ModuleNotFoundError: No module named ‘ufl.log’

---

## [Is there a way to get the partial derivative for a gradient vector?](https://fenicsproject.discourse.group/t/is-there-a-way-to-get-the-partial-derivative-for-a-gradient-vector/15753)

<div class="topic-metadata">

**Author:** [@Swani](https://fenicsproject.discourse.group/u/Swani)\
**Replies:** 7\
**Last updated:** [September 12, 2024, 3:16am UTC](https://fenicsproject.discourse.group/t/is-there-a-way-to-get-the-partial-derivative-for-a-gradient-vector/15753 "2024-09-12T03:16:32Z")

</div>

Hello. Dear community :wave: I was wondering if it’s possible to get the partial derivative(Cartesian coordinate) for a gradient vector in legacy FEniCS. (this might be a bit silly, but I’m posting it for the sake of c…

---

## [DOF ordering paramater for UFL element (vs basix)](https://fenicsproject.discourse.group/t/dof-ordering-paramater-for-ufl-element-vs-basix/15564)

<div class="topic-metadata">

**Author:** [@unit54](https://fenicsproject.discourse.group/u/unit54)\
**Replies:** 10\
**Last updated:** [September 3, 2024, 2:49pm UTC](https://fenicsproject.discourse.group/t/dof-ordering-paramater-for-ufl-element-vs-basix/15564 "2024-09-03T14:49:06Z")

</div>

Hello! I am trying to change the default ordering of degrees of freedom in each individual element to align with an external numbering scheme that I imposed (in a custom assembly function). I found the function basix.c…

---

## [Computing entropy viscosity with UFL](https://fenicsproject.discourse.group/t/computing-entropy-viscosity-with-ufl/15254)

<div class="topic-metadata">

**Author:** [@jinyi12](https://fenicsproject.discourse.group/u/jinyi12)\
**Replies:** 2\
**Last updated:** [August 25, 2024, 6:30pm UTC](https://fenicsproject.discourse.group/t/computing-entropy-viscosity-with-ufl/15254 "2024-08-25T18:30:27Z")

</div>

Hello FEniCS community, I’m working on implementing an entropy viscosity method for shock capturing in the 1D Inviscid Burgers’ equation using FEniCSx. However, I’m encountering an error when trying to run my code. Here…

---

## [UFL Measures on Sub-domains not Evaluated](https://fenicsproject.discourse.group/t/ufl-measures-on-sub-domains-not-evaluated/15505)

<div class="topic-metadata">

**Author:** [@Gaurav\_Verma](https://fenicsproject.discourse.group/u/Gaurav_Verma)\
**Replies:** 3\
**Last updated:** [August 12, 2024, 3:34pm UTC](https://fenicsproject.discourse.group/t/ufl-measures-on-sub-domains-not-evaluated/15505 "2024-08-12T15:34:56Z")

</div>

I have a mesh imported from gmsh with defined facet tags for Surfaces and Edges. Now If I want to check area and length of this sub-domains, I am getting zero value of length of subdomains. However, for area, I am able t…

---

## [Question about an issue with assemble() and project() for equations defined as UFL Forms](https://fenicsproject.discourse.group/t/question-about-an-issue-with-assemble-and-project-for-equations-defined-as-ufl-forms/15424)

<div class="topic-metadata">

**Author:** [@Swani](https://fenicsproject.discourse.group/u/Swani)\
**Replies:** 2\
**Last updated:** [August 5, 2024, 3:54am UTC](https://fenicsproject.discourse.group/t/question-about-an-issue-with-assemble-and-project-for-equations-defined-as-ufl-forms/15424 "2024-08-05T03:54:34Z")

</div>

hello.:wave: It’s been a while since I’ve posted. I recently posted to address a question I had while exploring legacy DOLFIN a bit more. I’m having an issue when I’m trying to get the strain energy in the linear elast…

---

## [Get current spatial configuration of the mesh as ufl variable](https://fenicsproject.discourse.group/t/get-current-spatial-configuration-of-the-mesh-as-ufl-variable/14796)

<div class="topic-metadata">

**Author:** [@vinayakvijay](https://fenicsproject.discourse.group/u/vinayakvijay)\
**Replies:** 1\
**Last updated:** [June 23, 2024, 8:23am UTC](https://fenicsproject.discourse.group/t/get-current-spatial-configuration-of-the-mesh-as-ufl-variable/14796 "2024-06-23T08:23:32Z")

</div>

Hello all, I am quite new to FENiCSx so my problem could be very basic. How do i get the current configuration (basically the nodal coordinates) as a ufl.variable which can be then used to create the expressions in the …
