I’m trying to compute the local Nusselt number (dimensionless temperature gradient) along an inner circular boundary of a 2D natural convection problem using FEniCSx (DOLFINx + UFL).
Specifically, I need
![]()
where T is temperature, n is the unit normal pointing outward from the fluid region, and D is the cylinder diameter.
My setup:
-
Mesh from Gmsh with physical groups: outer walls and a circular inner boundary.
-
facet_markersare available and correct. -
Temperature field
Tis a second-orderFunction(Q). -
I can compute average Nusselt number using
n = ufl.FacetNormal(domain)
ds_cyl = ufl.Measure(“ds”, domain=domain, subdomain_data=facet_markers, subdomain_id=2)
Nu_avg = fem.assemble_scalar(fem.form(-dot(grad(T), n) * ds_cyl))
However, I’d like to get local values of -∂T/∂n per boundary facet (or vertex) for post-processing (e.g., plotting Nu vs θ around the cylinder).
I’ve tried looping over facets and assembling the flux using a facet-specific measure like:
ds_tag = ufl.Measure(“ds”, domain=domain, subdomain_data=my_tags, subdomain_id=facet_id)
flux = fem.assemble_scalar(fem.form(inner(grad(T), n) * ds_tag))
but I’m unsure if this gives a consistent local gradient or if I should use a projection approach (e.g., project -dot(grad(T), n) onto a function space defined on the boundary).
Questions:
-
What’s the correct or recommended way in FEniCSx to compute local ∂T/∂n on a curved internal boundary?
-
How can one obtain facet-wise or vertex-wise values that are numerically smooth (e.g., suitable for plotting Nu vs θ)?
(I can provide a minimal example if needed — but essentially, it’s a square cavity with an inner circular boundary, steady-state temperature field from a diffusion problem.)