Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
36fb26b
Compute size fields without adding in physical groups and removing
hughcars Oct 30, 2025
eec04b6
Add in commented out not working KDTree version
hughcars Oct 30, 2025
7fc2fa6
Move to kd tree sampling model
hughcars Oct 31, 2025
ffcdee7
Rename CALLBACK_PARAMS, hoist callback function out of render, to all…
hughcars Oct 31, 2025
7044a6e
Add sampling algorithm for splines, approximates with 10 segment line…
hughcars Oct 31, 2025
55e82b4
Remove MeshingParameters, hoist things into global dictionary and add…
hughcars Nov 3, 2025
00a91cb
Restore MeshingParameters, put deprecation warning in place rather th…
hughcars Nov 3, 2025
aa05c05
Style fixes and some exports
hughcars Nov 3, 2025
1dd6423
Fix some more default dictionary calls
hughcars Nov 3, 2025
4911da4
JuliaFormatter
hughcars Nov 4, 2025
ec55375
Add some tests and tidy up some API
hughcars Nov 4, 2025
d3050f7
Fix test, and Aqua violation
hughcars Nov 4, 2025
8c83d24
Move bruteforce version to unit test
hughcars Nov 4, 2025
9a0571e
Add coverage for some accessor methods. Fix render! doc string, simpl…
hughcars Nov 5, 2025
e76d2a8
Update docs
hughcars Nov 5, 2025
38b8203
Update CHANGELOG
hughcars Nov 7, 2025
62f8973
Fix depwarn
hughcars Nov 24, 2025
2c30f1e
PR Feedback: documentation improvements
hughcars Nov 26, 2025
928d9bc
Bump NearestNeighbors to 0.4.24 where the no allocation nn fix is made
hughcars Nov 28, 2025
9d3bdaf
Break SolidModel schematic tests into more granular test items
hughcars Nov 28, 2025
8790b9a
Switch to single threaded default, resolving possible race condition
hughcars Dec 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ The format of this changelog is based on
[Keep a Changelog](https://keepachangelog.com/), and this project adheres to
[Semantic Versioning](https://semver.org/).

## Upcoming

- Mesh size fields are no longer controlled via `PhysicalGroup` internally, this change
allows for changing the size field associated to a `SolidModel` after `render!` via the
global parameters accessed in `MeshSized`. This reduces the number of entities in any
global boolean operations, improving performance, along with separating the concerns of
rendering and meshing thereby improving user experience.
- Deprecate `SolidModels.MeshingParameters` in favour of new `mesh_scale`, `mesh_order`,
`mesh_grading_default` accessed from `SolidModels`.

## 1.7.0 (2025-11-26)

- Added `xor2d` for polygon XOR

- Improved support for wave port boundaries in a `SolidModel`

+ `SolidModelTargets` now take `wave_port_layers`, a list of layer symbols used to define wave port boundary conditions
+ Added support for `LineSegment` in SolidModel
+ Added `add_wave_ports!` to automatically place wave port boundaries where specified paths/routes intersect the simulation area
Expand All @@ -26,7 +36,7 @@ For developers, the test suite now uses the TestItem framework, and new benchmar
## 1.6.0 (2025-10-16)

- Improved metadata handling for `LayoutTarget` and `SolidModelTarget`

+ SolidModelTargets will now ignore `NORENDER_META` (the `:norender` layer)
+ SolidModelTargets now take `ignored_layers`, a list of layer symbols which are not rendered
+ 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
Expand All @@ -44,7 +54,7 @@ For developers, the test suite now uses the TestItem framework, and new benchmar
## 1.5.0 (2025-10-10)

- Added `auto_speed`, `endpoints_curvature`, and `auto_curvature` keyword options to `bspline!` and `BSplineRouting`

+ `auto_speed` sets the speed at endpoints to avoid sharp bends (minimizing the integrated square of the curvature derivative with respect to arclength)
+ `endpoints_curvature` sets boundary conditions on the curvature (by inserting extra waypoints)
+ `auto_curvature` B-spline sets curvature at endpoints to match previous segment (or to zero if there is no previous segment)
Expand Down
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Clipper = "c8f6d549-b3ab-5508-a0d1-48fe138e8cc1"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Gmsh = "705231aa-382f-11e9-3f0c-b7cb4346fdeb"
Expand All @@ -21,6 +22,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
NamedTupleTools = "d9ec5142-1e00-5aa0-9d6a-321866360f50"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgTemplates = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
Expand All @@ -47,6 +49,7 @@ Cairo = "1.0"
Clipper = "0.6"
ColorSchemes = "3"
CoordinateTransformations = "0.6"
Distances = "0.10.12"
FileIO = "1.6"
ForwardDiff = "0.10"
Gmsh = "0.3.1"
Expand All @@ -58,6 +61,7 @@ IntervalTrees = "1"
LoggingExtras = "1"
MetaGraphs = "0.8"
NamedTupleTools = "0.14"
NearestNeighbors = "0.4.24"
Optim = "1"
Pkg = "1"
PkgTemplates = "0.7"
Expand Down
8 changes: 4 additions & 4 deletions benchmark/polygons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ end
dir = mktempdir()
SUITE["polygons"]["rectangles"]["render"] = @benchmarkable rectangles(10_000)
SUITE["polygons"]["rectangles"]["render_gds"] =
@benchmarkable rectangles(10_000, output_dir=$dir)
@benchmarkable rectangles(10_000, output_dir=($dir))
SUITE["polygons"]["rectangles"]["render_units"] =
@benchmarkable rectangles_units(10_000, $nm)
SUITE["polygons"]["rectangles"]["render_units_gds"] =
@benchmarkable rectangles_units(10_000, $nm, output_dir=$dir)
@benchmarkable rectangles_units(10_000, $nm, output_dir=($dir))
SUITE["polygons"]["rectangles"]["render_convertunits"] =
@benchmarkable rectangles_units(10_000, $μm)
SUITE["polygons"]["circles"]["direct"] = @benchmarkable circles_direct(1_000)
SUITE["polygons"]["circles"]["direct_gds"] =
@benchmarkable circles_direct(1_000, output_dir=$dir)
@benchmarkable circles_direct(1_000, output_dir=($dir))
SUITE["polygons"]["circles"]["direct_units"] =
@benchmarkable circles_direct_units(1_000, $nm)
SUITE["polygons"]["circles"]["direct_units_gds"] =
@benchmarkable circles_direct_units(1_000, $nm, output_dir=$dir)
@benchmarkable circles_direct_units(1_000, $nm, output_dir=($dir))
SUITE["polygons"]["circles"]["entity_delta"] = @benchmarkable circles_entity_delta(1_000)
SUITE["polygons"]["circles"]["entity_atol"] = @benchmarkable circles_entity_atol(1_000)
41 changes: 40 additions & 1 deletion docs/src/solidmodels.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,49 @@ Other operations:

### Meshing

Entities can carry mesh sizing information with them when rendered to a `SolidModel`. Many entities will default to a maximal size to reasonably resolve the geometry. This is particularly useful together with adaptive mesh refinement to efficiently refine your mesh to minimize estimated error with as few elements as possible. You can also style entities with [`MeshSized`](@ref) to manually control mesh sizing, and provide `MeshingParameters` to `render!` using the `meshing_parameters` keyword argument.
Entities can carry mesh sizing information with them when rendered to a `SolidModel`. Many
entities will default to a maximal size to reasonably resolve the geometry. This is
particularly useful together with adaptive mesh refinement to efficiently refine your mesh
to minimize estimated error with as few elements as possible. You can also style entities
with [`MeshSized`](@ref) to manually control mesh sizing, the [`SolidModels.mesh_scale`](@ref),
[`SolidModels.mesh_order`](@ref) and [`SolidModels.mesh_grading_default`](@ref) methods are used to modify the
global default parameters used in each sizing field (see [`MeshSized`](@ref)).

Size fields within a `SolidModel` are specified in terms of control points, which are
spatial locations combined with an `(h, α)` as in [`MeshSized`](@ref). When a model is
rendered, a set of control points are computed from the geometry, and these are then used to
create `KDTree` structures to allow for rapid evaluation. Additional points can be manually
inserted after `render!` is called using [`DeviceLayout.SolidModels.add_mesh_size_point`](@ref), and the global size parameters
[`SolidModels.mesh_scale`](@ref), [`SolidModels.mesh_order`](@ref) and [`SolidModels.mesh_grading_default`](@ref) modified without requiring `render!`
to be called again. This allows for iteration on the mesh for a given fixed geometry. Manual
modification of the control points is in general not necessary but can be achieved through
[`DeviceLayout.SolidModels.add_mesh_size_point`](@ref), [`DeviceLayout.SolidModels.finalize_size_fields!`](@ref),
[`DeviceLayout.SolidModels.clear_mesh_control_points!`](@ref) and
[`DeviceLayout.SolidModels.reset_mesh_control!`](@ref). Once an improved mesh has been
achieved through addition of custom size fields like this, it is generally suggested to
incorporate this information back into the `MeshSized` style used on the original entities.

!!! info

If [`SolidModels.mesh_control_points`](@ref) is modified, then it is important to call
[`SolidModels.finalize_size_fields!`](@ref) in order to ensure that the `KDTree` are rebuilt.
Additionally, to generate a new mesh `SolidModels.gmsh.model.mesh.clear()` must be called
otherwise `gmsh` will return only any previously generated mesh.

```@docs
SolidModels.MeshingParameters
SolidModels.mesh_order
SolidModels.mesh_scale
SolidModels.mesh_grading_default
SolidModels.set_gmsh_option
SolidModels.get_gmsh_number
SolidModels.get_gmsh_string
SolidModels.mesh_control_points
SolidModels.mesh_control_trees
SolidModels.add_mesh_size_point
SolidModels.finalize_size_fields!
SolidModels.clear_mesh_control_points!
SolidModels.reset_mesh_control!
```

## Example
Expand Down
2 changes: 2 additions & 0 deletions examples/SingleTransmon/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DeviceLayout = "ebf59a4a-04ec-49d7-8cd4-c9382ceb8e85"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
PRIMA = "0a7d04aa-8ac2-47b3-b7a7-9dbd6ad661ed"
10 changes: 3 additions & 7 deletions examples/SingleTransmon/SingleTransmon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,9 @@ function single_transmon(;

# Adjust mesh_scale to increase the resolution of the mesh, < 1 will result in greater
# resolution near edges of the geometry.
meshing_parameters = SolidModels.MeshingParameters(
mesh_scale=1.0,
α_default=0.9,
mesh_order=mesh_order,
options=Dict("General.Verbosity" => 1) # General Gmsh option input
)
render!(sm, floorplan, tech, meshing_parameters=meshing_parameters)
SolidModels.set_gmsh_option("General.Verbosity", 1)
SolidModels.mesh_order(2)
render!(sm, floorplan, tech)

if save_mesh
# SolidModels.gmsh.option.set_number("General.NumThreads", 1) # Force single-threaded (deterministic) meshing
Expand Down
11 changes: 8 additions & 3 deletions src/paths/paths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ function terminate!(
) where {T}
termlen = gap + rounding
iszero(termlen) && return
termsty = Termination(pa, rounding; initial=initial, cpwopen=!iszero(gap))
termsty = Termination(pa, rounding; initial=initial, cpwopen=(!iszero(gap)))
# Nonzero rounding: splice and delete to make room for rounded part
if !iszero(rounding)
orig_sty = initial ? undecorated(style0(pa)) : laststyle(pa)
Expand Down Expand Up @@ -1237,9 +1237,14 @@ function terminate!(
)
splice!(pa, split_idx, split(split_node, split_len))
termsty = if initial
Termination(Path(pa[2:end]), rounding; initial=initial, cpwopen=!iszero(gap))
Termination(Path(pa[2:end]), rounding; initial=initial, cpwopen=(!iszero(gap)))
else
Termination(Path(pa[1:(end - 1)]), rounding; initial=initial, cpwopen=!iszero(gap))
Termination(
Path(pa[1:(end - 1)]),
rounding;
initial=initial,
cpwopen=(!iszero(gap))
)
end
end

Expand Down
6 changes: 3 additions & 3 deletions src/paths/routes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ function route!(
)
_route!(path, p_end, α_end, rule, sty, waypoints, waydirs)
isapprox_angle(α1(path), α_end) || @error """
Could not automatically route to destination with the correct arrival angle \
(got $(α1(path)) instead of $α_end). Try adding or adjusting waypoints.\
""" _group = :route
Could not automatically route to destination with the correct arrival angle \
(got $(α1(path)) instead of $α_end). Try adding or adjusting waypoints.\
""" _group = :route
pts = promote(p1(path), p_end)
return isapprox(pts...; atol=atol) || @error """
Could not automatically route to destination with the correct arrival point \
Expand Down
Loading