Repository navigation
Conversation
added 3 commits
November 24, 2026 10:13
When the test and trial functions live on different meshes, the assembly intersects their cells and integrates over the pieces. Pieces with an area below sqrt(eps) ≈ 1.5e-8 were skipped, to ignore cells that only touch along an edge. That threshold was absolute: with coordinates in metres, any triangle with sides below about 0.2 mm was dropped without warning, and the matrix came out partly or entirely zero. Compare the area of a piece with the area of the cells it comes from instead, so the result no longer depends on the unit of length. The new test assembles the Gram matrix of two different meshes of a square at three sizes; its entries must sum to the area of the square.
The global degrees of freedom identify the vertices of a node, an edge or a face with those of a cell by their positions. The tolerance was absolute, sqrt(eps) ≈ 1.5e-8: for cells smaller than that, every vertex matched the first vertex of the cell, and lagrangec0 failed with a singular matrix (for example for a port of a few nanometres). Compare the positions relative to the diameter of the cell instead, so the spaces no longer depend on the unit of length. The new test builds Lagrange spaces of order 1 and 2, with and without Dirichlet conditions, on a mesh scaled from 1e-12 to 1e3, and checks that the coefficients, positions and Gram matrix scale with the mesh.
The previous commit made the tolerance with which trace identifies the vertices of a node, an edge or a face with those of a cell relative to the size of the cell. In a very thin cell, with an aspect ratio below about sqrt(eps), several vertices still lie within that tolerance of each other, and the first match could be the wrong vertex, which collapsed the edge. Take an exact match first, otherwise the nearest vertex within the tolerance. Throw an ArgumentError when a vertex has no match or two equally close matches, when two vertices map to the same one, or when the cell has coincident vertices, instead of building a wrong basis. The new tests build Lagrange spaces on triangles with aspect ratios down to 1e-9 in Float64, Float32 and Float16, and check trace against independently constructed, slightly perturbed edges.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make assembly and Lagrange spaces independent of the unit of length
Several geometric comparisons used the absolute tolerance
sqrt(eps)≈ 1.5e-8, so results depended on the unit of length and broke for small cells:sqrt(eps)were skipped. With coordinates in metres, triangles with sides below about 0.2 mm were dropped, and the Gram matrix came out partly or entirely zero. The threshold is now relative to the areas of the intersected cells.traceinsrc/bases/global/globaldofs.jl): vertices were matched with an absolute tolerance. For cells smaller than about 1e-8, every vertex matched the cell's first vertex, andlagrangec0failed with a singular matrix. The tolerance is now relative to the cell's diameter.tracenow takes an exact match first, otherwise the nearest vertex, and throws anArgumentErrorfor missing, ambiguous or duplicate matches, and for cells with coincident vertices, instead of building a wrong basis.Tests
test/test_mixed_assembly_scale.jl: Gram matrices of two different meshes of a square at several scales; their entries must sum to the area.test/test_lagrange_scale.jl:trace, including invalid correspondences.Behaviour change
tracenow throws for cells with coincident vertices.