Skip to content

Commit 449b0a5

Browse files
authored
Update Interpolations compat (#120)
* Add default Inf tol for cornerindices using new point coordinatetype method * Pass build strictness to composite components * More BSpline type annotations, update Interpolations.jl compat * Add CompatHelper and add prerelease to CI matrix * Add tests * Remove extra MESHSIZED_PARAMS assignment
1 parent c27a3ae commit 449b0a5

File tree

12 files changed

+115
-37
lines changed

12 files changed

+115
-37
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- '1.10'
4040
- '1.11'
4141
- '1.12'
42+
- 'pre'
4243
os:
4344
- ubuntu-latest
4445
arch:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CompatHelper
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
workflow_dispatch:
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
jobs:
10+
CompatHelper:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check if Julia is already available in the PATH
14+
id: julia_in_path
15+
run: which julia
16+
continue-on-error: true
17+
- name: Install Julia, but only if it is not already available in the PATH
18+
uses: julia-actions/setup-julia@v2
19+
with:
20+
version: '1'
21+
arch: ${{ runner.arch }}
22+
if: steps.julia_in_path.outcome != 'success'
23+
- name: "Add the General registry via Git"
24+
run: |
25+
import Pkg
26+
ENV["JULIA_PKG_SERVER"] = ""
27+
Pkg.Registry.add("General")
28+
shell: julia --color=yes {0}
29+
- name: "Install CompatHelper"
30+
run: |
31+
import Pkg
32+
name = "CompatHelper"
33+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
34+
version = "3"
35+
Pkg.add(; name, uuid, version)
36+
shell: julia --color=yes {0}
37+
- name: "Run CompatHelper"
38+
run: |
39+
import CompatHelper
40+
CompatHelper.main()
41+
shell: julia --color=yes {0}
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
# This repo uses Documenter, so we can reuse our [Documenter SSH key](https://documenter.juliadocs.org/stable/man/hosting/walkthrough/).
45+
# If we didn't have one of those setup, we could configure a dedicated ssh deploy key `COMPATHELPER_PRIV` following https://juliaregistries.github.io/CompatHelper.jl/dev/#Creating-SSH-Key.
46+
# Either way, we need an SSH key if we want the PRs that CompatHelper creates to be able to trigger CI workflows themselves.
47+
# That is because GITHUB_TOKEN's can't trigger other workflows (see https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow).
48+
# Check if you have a deploy key setup using these docs: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-deploy-keys.
49+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
50+
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}

CHANGELOG.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ The format of this changelog is based on
1414
- Deprecate `SolidModels.MeshingParameters` in favour of new `mesh_scale`, `mesh_order`,
1515
`mesh_grading_default` accessed from `SolidModels`.
1616
- Improvements to `SolidModels.render!` to improve stability and performance.
17-
+ Change `SolidModels.restrict_to_volume!` to perform a check if the simulation domain
18-
already bounds all two and three dimensional objects, if so skips operation.
19-
+ Change `SolidModels.render!` to incorporate a two stage `_fragment_and_map!` operation,
20-
reconciling vertices and segments before reconciling all entities. This improves the
21-
robustness of the OpenCascade integration which can error in synchronization if too much
22-
reconciliation is required all at once by `fragment`.
23-
+ These two operations in conjunction with the removal of `MeshSized` entities results in
24-
a ~3x performance improvement in rendering the QPU17 example to `SolidModel`, and ~4.5x
25-
reduction in time from schematic to mesh.
17+
18+
+ Change `SolidModels.restrict_to_volume!` to perform a check if the simulation domain
19+
already bounds all two and three dimensional objects, if so skips operation.
20+
+ Change `SolidModels.render!` to incorporate a two stage `_fragment_and_map!` operation,
21+
reconciling vertices and segments before reconciling all entities. This improves the
22+
robustness of the OpenCascade integration which can error in synchronization if too much
23+
reconciliation is required all at once by `fragment`.
24+
+ These two operations in conjunction with the removal of `MeshSized` entities results in
25+
a ~3x performance improvement in rendering the QPU17 example to `SolidModel`, and ~4.5x
26+
reduction in time from schematic to mesh.
2627

2728
## 1.7.0 (2025-11-26)
2829

2930
- Added `xor2d` for polygon XOR
3031

3132
- Improved support for wave port boundaries in a `SolidModel`
32-
33+
3334
+ `SolidModelTargets` now take `wave_port_layers`, a list of layer symbols used to define wave port boundary conditions
3435
+ Added support for `LineSegment` in SolidModel
3536
+ Added `add_wave_ports!` to automatically place wave port boundaries where specified paths/routes intersect the simulation area
@@ -46,7 +47,7 @@ For developers, the test suite now uses the TestItem framework, and new benchmar
4647
## 1.6.0 (2025-10-16)
4748

4849
- Improved metadata handling for `LayoutTarget` and `SolidModelTarget`
49-
50+
5051
+ SolidModelTargets will now ignore `NORENDER_META` (the `:norender` layer)
5152
+ SolidModelTargets now take `ignored_layers`, a list of layer symbols which are not rendered
5253
+ LayoutTargets now allow overriding the mapping of `GDSMeta` by setting `target.map_meta_dict[my_gdsmeta] = my_override`, allowing changes to different `GDSMeta` or `nothing` rather than always mapping a `GDSMeta` to itself
@@ -64,7 +65,7 @@ For developers, the test suite now uses the TestItem framework, and new benchmar
6465
## 1.5.0 (2025-10-10)
6566

6667
- Added `auto_speed`, `endpoints_curvature`, and `auto_curvature` keyword options to `bspline!` and `BSplineRouting`
67-
68+
6869
+ `auto_speed` sets the speed at endpoints to avoid sharp bends (minimizing the integrated square of the curvature derivative with respect to arclength)
6970
+ `endpoints_curvature` sets boundary conditions on the curvature (by inserting extra waypoints)
7071
+ `auto_curvature` B-spline sets curvature at endpoints to match previous segment (or to zero if there is no previous segment)

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ForwardDiff = "0.10"
5555
Gmsh = "0.3.1"
5656
GraphMakie = "0.5"
5757
Graphs = "1"
58-
Interpolations = "0.14, 0.15"
58+
Interpolations = "0.14, 0.15, 0.16"
5959
IntervalSets = "0.7"
6060
IntervalTrees = "1"
6161
LoggingExtras = "1"

docs/src/solidmodels.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ achieved through addition of custom size fields like this, it is generally sugge
9191
incorporate this information back into the `MeshSized` style used on the original entities.
9292

9393
!!! info
94-
94+
9595
If [`SolidModels.mesh_control_points`](@ref) is modified, then it is important to call
9696
[`SolidModels.finalize_size_fields!`](@ref) in order to ensure that the `KDTree` are rebuilt.
9797
Additionally, to generate a new mesh `SolidModels.gmsh.model.mesh.clear()` must be called

src/DeviceLayout.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ Return the coordinate type of the geometry.
191191
coordinatetype(::Type{S}) where {T, S <: AbstractGeometry{T}} = T
192192
coordinatetype(::S) where {T, S <: AbstractGeometry{T}} = T
193193
coordinatetype(::AbstractArray{S}) where {T, S <: AbstractGeometry{T}} = T
194-
coordinatetype(iterable) = promote_type(coordinatetype.(iterable))
194+
coordinatetype(iterable) = promote_type(coordinatetype.(iterable)...)
195+
coordinatetype(::Point{T}) where {T} = T
196+
coordinatetype(::Type{Point{T}}) where {T} = T
195197

196198
# Entity interface
197199
include("entities.jl")

src/paths/segments/bspline.jl

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,40 @@ import QuadGK: quadgk
88
import ForwardDiff: Dual, partials, value, Partials
99
using LinearAlgebra
1010

11+
# Patch in new boundary condition for Interpolations.jl allowing us to specify derivative
12+
struct NeumannBC{GT <: Interpolations.GridType, T} <: Interpolations.BoundaryCondition
13+
gt::GT
14+
g0::T
15+
g1::T
16+
end
17+
NeumannBC(g0, g1) = NeumannBC(Interpolations.OnGrid(), g0, g1)
18+
19+
# Concrete type of interpolation, only used in BSpline struct definition
20+
const LayoutBSplineItp{T} = Interpolations.ScaledInterpolation{
21+
Point{T},
22+
1,
23+
Interpolations.BSplineInterpolation{
24+
Point{T},
25+
1,
26+
Interpolations.OffsetArrays.OffsetVector{Point{T}, Vector{Point{T}}},
27+
Interpolations.BSpline{
28+
Interpolations.Cubic{NeumannBC{Interpolations.OnGrid, Point{T}}}
29+
},
30+
Tuple{Base.OneTo{Int64}}
31+
},
32+
Interpolations.BSpline{
33+
Interpolations.Cubic{NeumannBC{Interpolations.OnGrid, Point{T}}}
34+
},
35+
Tuple{
36+
StepRangeLen{
37+
Float64,
38+
Base.TwicePrecision{Float64},
39+
Base.TwicePrecision{Float64},
40+
Int64
41+
}
42+
}
43+
}
44+
1145
"""
1246
mutable struct BSpline{T} <: ContinuousSegment{T}
1347
@@ -25,9 +59,9 @@ mutable struct BSpline{T} <: ContinuousSegment{T}
2559
p::Vector{Point{T}}
2660
t0::Point{T}
2761
t1::Point{T}
28-
r::Paths.Interpolations.AbstractInterpolation{Point{T}} # function of t between 0 and 1
29-
p0
30-
p1
62+
r::LayoutBSplineItp{T} # function of t between 0 and 1
63+
p0::Point{T}
64+
p1::Point{T}
3165
α0::typeof(1.0°)
3266
α1::typeof(1.0°)
3367
function BSpline{T}(p::Vector{Point{T}}, t0::Point{T}, t1::Point{T}) where {T}
@@ -387,14 +421,6 @@ function _bspline_tangents(scale, dir0, dir1, speed0::Coordinate, speed1=speed0)
387421
return t0, t1
388422
end
389423

390-
# Patch in new boundary condition for Interpolations.jl allowing us to specify derivative
391-
struct NeumannBC{GT <: Interpolations.GridType} <: Interpolations.BoundaryCondition
392-
gt::GT
393-
g0
394-
g1
395-
end
396-
NeumannBC(g0, g1) = NeumannBC(Interpolations.OnGrid(), g0, g1)
397-
398424
"""
399425
`Cubic{NeumannBC}` `OnGrid` amounts to setting `y_1'(x) = g0` at `x = 0`
400426
and `y_n'(x) = g1` at `x = 1`.
@@ -407,7 +433,7 @@ function prefiltering_system(
407433
::Type{T},
408434
::Type{TC},
409435
n::Int,
410-
degree::Cubic{NeumannBC{Interpolations.OnGrid}}
436+
degree::Cubic{<:NeumannBC{Interpolations.OnGrid}}
411437
) where {T, TC}
412438
dl, d, du = Interpolations.inner_system_diags(T, n, degree)
413439
d[1] = -oneunit(T) / 2

src/polygons.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,11 @@ end
655655
cornerindices(p, x) = cornerindices(points(p), x)
656656
cornerindices(p::Point, x) = cornerindices([p], x)
657657
cornerindices(p::Vector{<:Point}, p0::Point) = cornerindices(p, [p0])
658-
function cornerindices(p::Vector{<:Point}, p0::Vector{<:Point}; tol)
658+
function cornerindices(
659+
p::Vector{<:Point},
660+
p0::Vector{<:Point};
661+
tol=DeviceLayout.coordinatetype(p)(Inf)
662+
)
659663
# Pick the closest to p0 satisfying tolerance.
660664
return filter!(x -> x > 0, map(p0) do px
661665
idx = findfirst(p_idx -> isapprox(px, p_idx), p)

src/schematics/schematics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ function build!(sch::Schematic, geometry_fn=geometry; strict=:error)
13481348
# One of the node cs's references will be its Component
13491349
for (i, subref) in pairs(refs(node_cs)) # Just check all of them
13501350
if structure(subref) isa AbstractCompositeComponent
1351-
build!(schematic(structure(subref)))
1351+
build!(schematic(structure(subref)); strict=strict)
13521352
end
13531353
if structure(subref) isa AbstractComponent
13541354
try

src/solidmodels/render.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,6 @@ meshgrading(node::Paths.Node; kwargs...) = -1.0
445445
sizeandgrading(e::GeometryEntity; kwargs...) =
446446
(float(meshsize(e; kwargs...)), float(meshgrading(e; kwargs...)))
447447

448-
"""
449-
Global defaults for key meshing parameters.
450-
"""
451-
MESHSIZE_PARAMS[:mesh_scale] = 1.0
452-
MESHSIZE_PARAMS[:mesh_order] = 1
453-
MESHSIZE_PARAMS[:global_α] = 0.9
454-
455448
"""
456449
set_gmsh_option(s, o::Number)
457450
set_gmsh_option(s, o::AbstractString)

0 commit comments

Comments
 (0)