Skip to content

Barycentric refinement, overlap and intersection of curvilinear triangle meshes - #81

Open
PaulOlyslager wants to merge 6 commits into
krcools:masterfrom
PaulOlyslager:feature/curvilinear-barycentric-refinement
Open

PaulOlyslager wants to merge 6 commits into
krcools:masterfrom
PaulOlyslager:feature/curvilinear-barycentric-refinement

Conversation

@PaulOlyslager

Copy link
Copy Markdown
Contributor

Summary

Barycentric refinement of curvilinear triangle meshes, plus the chart functionality BEAST needs to build Buffa-Christiansen and dual Lagrange spaces on them and to assemble local operators between a curvilinear mesh and its refinement.

Changes

  • barycentric_refinement(::CurvilinearMesh{U,3}): every curved triangle is split into the usual six children, curvilinear triangles of the parent's order. Their nodes are the parent chart evaluated at the images of the reference nodes, so the children reproduce the curved surface exactly. Shared nodes are merged by their exact rational position, so the refinement is conforming, and cells are numbered and oriented as for flat meshes.
  • chartinparent(::BarycentricRefinement{U,3}, cell): a child as a flat simplex in the parameter domain of its parent (curved children cannot be located in their parent from their coordinates).
  • Curvilinear charts: subcharts(ch, Val{1}) and faces (curved edges), tangents at a point, tuple parameters in neighborhood, neighborhood_lazy. barytocart no longer allocates.
  • carttobary, overlap and intersection for curvilinear triangles. These are exact when one triangle is an affine reparametrization of the other's map (a cell and its children, two children of a cell, copies of a mesh); otherwise the triangles are taken not to overlap, as for non-coplanar flat triangles.

Fixes

  • center(::CurvilinearSimplex{U,2}) evaluated the chart at an edge midpoint instead of the centroid.
  • indextype(::CurvilinearMesh) returned SVector{N-O+1} instead of SVector{D1}.
  • The type-form coordtype, dimension, universedimension and vertextype never matched a concrete CurvilinearSimplex, because they left out the order parameter.

Tests

test_curvilinear_baryref.jl (orders 1-3: exact geometry, conformity, orientation, agreement with the flat refinement for order 1), additions to test_curvilinear_elements.jl, and test_curvilinear_intersect.jl. The full test suite passes. Flat meshes are unaffected.

The version in Project.toml is not bumped; these are new features, so the next release would be 1.2.0. BEAST.jl uses this in a companion PR.

🤖 Generated with Claude Code

PaulOlyslager and others added 6 commits November 20, 2026 12:09
barycentric_refinement(::CurvilinearMesh{U,3}) splits every curved triangle of
order O into the usual six children, which are curvilinear triangles of the same
order: their nodes are the parent chart evaluated at the images of the
reference nodes, so the children reproduce the curved surface exactly. Shared
nodes are merged by their exact rational barycentric position on the parent
vertex, edge or cell, so the refinement is conforming, and the cells are
numbered and oriented as in the refinement of flat meshes.

Also fix indextype(::CurvilinearMesh), which returned SVector{N-O+1} (right for
lines only, SVector{5} for quadratic triangles) instead of SVector{D1}; the
generic refinement failed on it.

Tested for orders 1-3 on gmshsphere: exact geometry of the children,
conformity (every edge in two cells with opposite orientation, no duplicate
nodes, Euler characteristic 2), orientation, and agreement with the flat
refinement for order 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmP8j8Kddkr1XembbhG7UZ
center(::CurvilinearSimplex{U,2}) evaluated the chart at the barycentric
coordinates (1/2, 1/2), the midpoint of an edge, instead of the centroid
(1/3, 1/3). This misplaced the positions of the functions of every space whose
`pos` is the center of a cell (e.g. Raviart-Thomas, discontinuous and dual
Lagrange spaces in BEAST) by a fraction of the element size. Tested against
barytocart at the centroid and, for order 1, against the flat mesh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmP8j8Kddkr1XembbhG7UZ
- neighborhood_lazy(::CurvilinearSimplex, u) returns the full neighborhood,
  as for quadrilaterals: the lazy one takes the tangents from the chart, which
  is right only for flat simplices.
- tangents(::MeshPointNM) for curvilinear simplices returns all tangents as the
  columns of a matrix, from the unitary base, as for flat simplices.
- faces(::CurvilinearSimplex{U,2}) returns the curved edges (edge j opposite to
  corner j), as faces(::Simplex{3,2}) does.
- neighborhood(::CurvilinearSimplex, u) accepts the parameters as a tuple, as
  for flat simplices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmP8j8Kddkr1XembbhG7UZ
…harts

- chartinparent(::BarycentricRefinement{U,3}, cell): a cell of the barycentric
  refinement as a flat simplex in the parametric domain of its parent. Curved
  children cannot be located in their parent from their coordinates, but their
  parametric domain maps affinely into the parent's.
- subcharts(::CurvilinearSimplex{U,2}, Val{1}): the curved edges with their
  injections into the parametric domain, as for flat triangles.
- silvester/fast_silvester(::Val{P}, x) return static vectors, and the charts
  evaluate them once per point instead of once per node: barytocart no longer
  allocates (same arithmetic, same values).

Tests: chartinparent and subcharts against the parent's chart, orders 1-3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmP8j8Kddkr1XembbhG7UZ
coordtype, dimension, universedimension and vertextype on the type of a
CurvilinearSimplex were defined for CurvilinearSimplex{U,D,C,N,T}, which
leaves out the order O: a UnionAll, which the concrete type of a chart never
equals, so these methods never applied (dimension(eltype(charts)) failed,
for instance). They are now defined for its subtypes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- carttobary for curvilinear triangles: the parameters of the closest point,
  by Gauss-Newton iteration from those in the flat triangle through the
  corners. For a point on the chart it is the inverse of barytocart, also on
  the continuation of the chart beyond the reference triangle.
- overlap and intersection of curvilinear triangles p and q: exact when q is
  an affine reparametrization of the map of p, as are a cell and its
  children in the barycentric refinement, or two children of the same cell.
  The corners of q located in p give the affine map, which is checked at the
  interpolation nodes of q. The intersection is then the triangle of q in
  the parametric domain of p clipped by the reference triangle, as
  curvilinear triangles of the order of p and with its orientation.
  Otherwise the triangles are taken not to overlap, as non coplanar flat
  triangles.

New test test_curvilinear_intersect.jl, for orders 2 and 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@krcools

krcools commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Can you use the existing injections function instead of the very similar chartinparent (even though the latter name is probably much more descriptive). The main point is to suppress code duplication if at all convenient and possible.

This branch has not been deployed

No deployments
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