Skip to content

Support manifold geometries in FEniCS#105

Merged
UZerbinati merged 4 commits intomainfrom
dokken/manifold
Feb 21, 2026
Merged

Support manifold geometries in FEniCS#105
UZerbinati merged 4 commits intomainfrom
dokken/manifold

Conversation

@jorgensd
Copy link
Collaborator

@jorgensd jorgensd commented Feb 17, 2026

Missing functionality pointed out by @andre-massing.
Add support for arbitrary order curved manifolds with DOLFINx.

@jorgensd
Copy link
Collaborator Author

Example from Andre:

from mpi4py import MPI
from petsc4py import PETSc
from slepc4py import SLEPc
from packaging.version import Version
import dolfinx.fem.petsc
import numpy as np
import ufl
import pyvista
import ngsPETSc.utils.fenicsx as ngfx

from netgen.occ import *
from netgen.meshing import MeshingStep
from math import sin, cos, pi
from netgen.webgui import Draw

def Curve(t): return Pnt(0, 3+1.5*cos(t), sin(t))
n = 100
pnts = [Curve(2*pi*t/n) for t in range(n+1)]

spline = SplineApproximation(pnts)
f = Face(Wire(spline))

torus = f.Revolve(Axis((0,0,0), Z), 360)
torus_geo = OCCGeometry(torus)
Draw(torus)

ngmesh = torus_geo.GenerateMesh(maxh=0.5, perfstepsend=MeshingStep.MESHSURFACE)
Draw(ngmesh)
meshing_options = {"perfstepsend" : MeshingStep.MESHSURFACE}

geoModel = ngfx.GeometricModel(torus_geo, MPI.COMM_WORLD)
mesh, (ct, ft), region_map = geoModel.model_to_mesh(gdim=3, hmax=0.5, meshing_options=meshing_options)


order = 8
mesh = geoModel.curveField(order)

# mesh, (ct, ft), region_map = geoModel.model_to_mesh(gdim=3, hmax=0.3, meshing_options={})

with dolfinx.io.VTXWriter(mesh.comm, "mesh.bp", mesh) as bp:
    bp.write(0.0)

# with dolfinx.io.XDMFFile(mesh.comm, "manifold.xdmf", "w") as xdmf:
#     xdmf.write_mesh(mesh)
#     xdmf.write_meshtags(ct, mesh.geometry)
#     mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
#     xdmf.write_meshtags(ft, mesh.geometry)

grid = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh))
grid.cell_data["ct"] = ct.values

plotter = pyvista.Plotter()
plotter.add_mesh(
    grid, show_edges=True, scalars="ct", cmap="blues", show_scalar_bar=False
)
plotter.view_xy()
if not pyvista.OFF_SCREEN:
    plotter.show()

@jorgensd
Copy link
Collaborator Author

@UZerbinati can we merge this?:)

@jorgensd
Copy link
Collaborator Author

and then make a new release so that I can use this through pypi?:)

@UZerbinati
Copy link
Collaborator

Happy to merge, but for the release it would be ideal to wait for a couple until mid March, because we are waiting to release some fix also for Firedrake side of things :)

@UZerbinati UZerbinati merged commit 220c556 into main Feb 21, 2026
9 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants