Geometry#
Sets#
Bramble.CartesianProduct
source
CartesianProduct{D, T}(box::NTuple{D, Tuple{T, T}}, collapsed::NTuple{D, Bool})
Cartesian product of D closed intervals embedded in \(\mathbb{R}^D\) with scalar coordinate type T.
Fields
box: Tuple ofDinterval endpoint pairs(min, max).collapsed: Tuple ofDboolean flags indicating whether each dimension is degenerate (min == max).
Bramble.CartesianProduct — Union{Tuple{Integer}, Tuple{D}} where D
source
(X::CartesianProduct{D, T})(i::Integer) -> Tuple{T, T}
Return the i-th component interval endpoints (min, max).
Throws
BoundsError: Ifi < 1ori > D.
Base.eltype — Union{Tuple{Bramble.CartesianProduct{D, T}}, Tuple{T}, Tuple{D}} where {D, T}
source
eltype(X::CartesianProduct{D, T}) -> Type{T}
eltype(::Type{<:CartesianProduct{D, T}}) -> Type{T}
Return the scalar coordinate type T of CartesianProduct X.
Base.first — Tuple{Bramble.CartesianProduct{1}}
source
first(X::CartesianProduct{1}) -> T
last(X::CartesianProduct{1}) -> T
Return the lower (first) or upper (last) bound of a 1D CartesianProduct.
Bramble.is_collapsed — Union{Tuple{T}, Tuple{T, T}} where T<:Number
source
is_collapsed(a::Number, b::Number) -> Bool
is_collapsed(X::CartesianProduct) -> Bool
is_collapsed(X::CartesianProduct, i::Integer) -> Bool
Check whether an interval endpoint pair, a Cartesian set, or a coordinate dimension i is degenerate (min == max).
For an \(n\)-dimensional CartesianProduct X, is_collapsed(X) returns true if any coordinate dimension is collapsed (any(X.collapsed)), equivalently when the topological dimension is strictly less than the spatial embedding dimension D. is_collapsed(X, i) queries whether the i-th coordinate axis is degenerate.
Arguments
a,b: Scalar interval endpoints.X: Cartesian product set.i: Coordinate dimension index (1 <= i <= D).
Throws
BoundsError: Ifi < 1ori > D.
Bramble.point_type — Union{Tuple{Bramble.CartesianProduct{1, T}}, Tuple{T}} where T
source
point_type(X::CartesianProduct{1, T}) -> Type{T}
point_type(X::CartesianProduct{D, T}) -> Type{NTuple{D, T}}
point_type(::Type{<:CartesianProduct{1, T}}) -> Type{T}
point_type(::Type{<:CartesianProduct{D, T}}) -> Type{NTuple{D, T}}
Return the coordinate point representation type for a point in X.
Bramble.print_set_axes — Union{Tuple{D}, Tuple{Bramble.PrettyPrinter, Bramble.CartesianProduct{D}}} where D
source
print_set_axes(pp::PrettyPrinter, X::CartesianProduct{D})
Print one label: [min, max] line per coordinate of a multi-dimensional set, collapsing degenerate axes. The companion of print_set_extent for D > 1, and likewise shared with Domain's renderer.
Bramble.print_set_extent — Tuple{Bramble.PrettyPrinter, Bramble.CartesianProduct{1}}
source
print_set_extent(pp::PrettyPrinter, X::CartesianProduct{1})
Print a 1D set's extent: Point at v when the interval is degenerate, Interval [a, b] otherwise.
Shared with Domain's own detailed renderer, which used to carry a verbatim copy (gpena/Bramble.jl#47). Lives here rather than in geometry/pretty_print.jl because that file is included before this one, so a signature naming CartesianProduct there would not resolve.
Bramble.set — Tuple{Bramble.CartesianProduct}
source
set(X::CartesianProduct) -> CartesianProduct
Identity accessor returning the geometric set X.
Markers#
Bramble.DomainMarkers
source
DomainMarkers(symbols::Tuple, tuples::Tuple, conditions::Tuple)
DomainMarkers(symbols::Tuple, tuples::Tuple, conditions::Tuple, regions::Tuple)
Container categorizing and indexing boundary and interior markers for a computational domain.
Every field is a statically typed tuple, so symbols, tuples, conditions and regions markers are each an unrolled, zero-allocation sweep to iterate. The three-argument form has no regions.
Fields
symbols: Tuple of markers identified by a single predefined boundarySymbol(e.g.:left).tuples: Tuple of markers identified by collections of predefined boundary symbols, given as a tuple, vector or set (e.g.(:top, :right),[:top, :right]), stored asSet{Symbol}.conditions: Statically typed tuple of predicate function markersf(x)orf(x, t).regions: Tuple of polygon markers:L => polygon(V)and level-set markers:L => levelset(φ). On a mesh, each gives the three labelsL(nodes inside the region),L_boundary(nodes on its boundary) andL_exterior(nodes outside it).
See also: markers, symbols, tuples, conditions.
Bramble.DomainMarkers — Tuple{Number, Any}
source
(dm::DomainMarkers)(t::Number, p) -> EvaluatedParametricDomainMarkers
Evaluate the condition markers of dm at timestamp t and parameter p. Each (x, t, p) predicate is fixed at (t, p) and each spatial x predicate is kept as it is; see conditions.
Bramble.DomainMarkers — Tuple{Number}
source
(dm::DomainMarkers)(t::Number) -> EvaluatedDomainMarkers
Evaluate the condition markers of dm at timestamp t. Each (x, t) predicate is fixed at t and each spatial x predicate is kept as it is; see conditions.
Bramble.EvaluatedDomainMarkers
source
EvaluatedDomainMarkers(original_markers::DomainMarkers, evaluation_time::Number)
DomainMarkers collection evaluated at timestamp t. The collection may hold (x, t) predicates, spatial x predicates, or both; conditions fixes only the former at t.
Fields
original_markers: UnderlyingDomainMarkersobject.evaluation_time: Evaluation timestampt.
Bramble.EvaluatedParametricDomainMarkers
source
EvaluatedParametricDomainMarkers(original_markers::DomainMarkers, evaluation_time::Number, p)
Time- and parameter-evaluated wrapper for a DomainMarkers collection whose conditions accept (x, t, p) rather than (x, t), evaluated at timestamp t and parameter p.
Kept separate from EvaluatedDomainMarkers rather than adding a p field to it: the two-argument Base.Fix2(identifier(m), t) this file already builds for the (x, t) case would otherwise need a runtime branch on whether p is present, and this exact kind of branch-carrying Union/optional field is what made Enzyme's strict-aliasing type analysis reject AnySegment{D} (gpena/Bramble.jl#240) – a fresh concrete type costs only the two conditions bodies, which differ, and keeps every existing EvaluatedDomainMarkers call site untouched.
Fields
original_markers: UnderlyingDomainMarkersobject.evaluation_time: Evaluation timestampt.p: Evaluation parameter, passed through unmodified (e.g. aVectoror a scalar).
Bramble.Marker
source
Marker(label::Symbol, identifier::F)
Labeled geometric region or boundary marker on a computational domain.
Arguments
label: Region identifier (e.g.:inlet,:wall,:boundary).identifier: Location specification, either a predefined boundarySymbol(e.g.:left), aSet{Symbol}of boundary names, or a boolean spatial predicate functionf(x). Polygon and level-set pairs are kept apart, in theregionsofDomainMarkers.markersbuilds aMarkerfrom a tuple, vector or set of boundary symbols by storing it as aSet{Symbol}.
Bramble.MarkerPair
source
MarkerPair{F}
Type alias for Pair{Symbol, F} used to specify region markers (e.g. :boundary => :left).
Bramble.conditions — Tuple{Bramble.DomainMarkers}
source
conditions(domain_markers::DomainMarkers) -> Tuple
Return the tuple of predicate condition markers configured in domain_markers.
Bramble.conditions — Tuple{Bramble.EvaluatedDomainMarkers}
source
conditions(edm::EvaluatedDomainMarkers) -> Tuple
Return condition markers evaluated at timestamp edm.evaluation_time, each a spatial predicate of x.
A predicate f with a one-argument method and no two-argument method is spatial and passes through unchanged. Any other predicate is fixed at t as Base.Fix2(f, t). So (x, t = 0.0) -> ... is fixed at t, not left at its default. A predicate typed on its argument ((x::NTuple{2, Float64}) -> ...) has no Tuple{Any} method, so it is also wrapped and must accept (x, t).
A ComposedFunction or a Base.Fix1/Base.Fix2 is classified by what it wraps, not by its own varargs call method: a composition by its innermost function, which receives every argument, and a Fix by the function it fixes, with one more argument since the Fix supplies one itself. So (>(0.5)) ∘ first and Base.Fix1(<, 0.5) are spatial and pass through. A lone Base.Fix2(isless, 0.5) is not, as isless has no generic two-argument method, so it is wrapped like any typed predicate.
Bramble.conditions — Tuple{Bramble.EvaluatedParametricDomainMarkers}
source
conditions(edm::EvaluatedParametricDomainMarkers) -> Tuple
Return condition markers evaluated at edm.evaluation_time and edm.p, each a spatial predicate of x.
A predicate f with a one-argument method and no two- or three-argument method is spatial and passes through unchanged, a ComposedFunction or Base.Fix1/Base.Fix2 being judged by what it wraps, as in the method above. Any other predicate is fixed at (t, p) as x -> f(x, t, p), so (x, t = 0, p = 1) -> ... is fixed at both. An (x, t) predicate is not fixed at t alone, and its wrapper throws a MethodError when called; dirichlet_constraints and semidiscretize never send one here: a set holding an (x, t) condition beside an (x, t, p) one is refused, so only (x, t, p) conditions, with any spatial x ones beside them, route to this path.
Base.Fix{N} generalizes Base.Fix1/Base.Fix2 to insert its fixed value at position N of whatever args a given call supplies, not at position N of f's own argument list (Base.Fix's own docstring example: Fix{1}(Fix{2}(f, 4), 4) fixes the first and second arg, not the first and fourth). So Base.Fix{3}(f, p) first, fixing f's own third argument to p and leaving a 2-argument (x, t) -> f(x, t, p); Base.Fix2 on that then fixes its second argument to t, landing on x -> f(x, t, p). Reversing the order – Base.Fix2(Base.Fix2(f, p), t), the tempting reading of "fix p, then fix t" – instead inserts p at position 2 and shoves t to position 3, calling f(x, p, t) (caught by the test that checks a (1.0, 3.0) vs a swapped-order failure, not by inspection).
Bramble.identifier — Tuple{Bramble.Marker}
source
identifier(m::Marker{F}) -> F
identifier(m::MarkerPair{F}) -> F
Return the identifying symbol, set of symbols, predicate function, polygon or level set of marker m.
Bramble.label — Tuple{Bramble.Marker}
source
label(m::Marker) -> Symbol
label(m::MarkerPair) -> Symbol
Return the Symbol label of marker m.
Bramble.label_conditions — Tuple{Union{Bramble.DomainMarkers, Bramble.EvaluatedDomainMarkers, Bramble.EvaluatedParametricDomainMarkers}}
source
label_conditions(markers)
Return an iterator yielding labels of all condition predicate markers.
Bramble.label_identifiers — Tuple{Union{Bramble.DomainMarkers, Bramble.EvaluatedDomainMarkers, Bramble.EvaluatedParametricDomainMarkers}}
source
label_identifiers(markers)
labels(markers)
Return a tuple of the Symbol label of every marker in markers, a DomainMarkers, an EvaluatedDomainMarkers or an EvaluatedParametricDomainMarkers.
Concatenates the per-category labels of symbols, tuples, and conditions, then the three labels of each polygon or level-set marker (built with the marker), as a single compile-time-unrolled tuple build, so this allocates 0 bytes. For the labels of one category alone, label_symbols, label_tuples, or label_conditions are equally zero-allocation.
Bramble.label_symbols — Tuple{Union{Bramble.DomainMarkers, Bramble.EvaluatedDomainMarkers, Bramble.EvaluatedParametricDomainMarkers}}
source
label_symbols(markers)
Return an iterator yielding labels of all single-symbol markers.
Bramble.label_tuples — Tuple{Union{Bramble.DomainMarkers, Bramble.EvaluatedDomainMarkers, Bramble.EvaluatedParametricDomainMarkers}}
source
label_tuples(markers)
Return an iterator yielding labels of all multi-symbol markers.
Bramble.symbols — Tuple{Bramble.DomainMarkers}
source
symbols(domain_markers::DomainMarkers) -> Tuple
Return the tuple of single-symbol markers configured in domain_markers.
Bramble.symbols — Tuple{Union{Bramble.EvaluatedDomainMarkers, Bramble.EvaluatedParametricDomainMarkers}}
source
symbols(edm::Union{EvaluatedDomainMarkers, EvaluatedParametricDomainMarkers}) -> Tuple
Return single-symbol markers from the underlying domain markers.
Bramble.tuples — Tuple{Bramble.DomainMarkers}
source
tuples(domain_markers::DomainMarkers) -> Tuple
Return the tuple of multi-symbol markers configured in domain_markers.
Bramble.tuples — Tuple{Union{Bramble.EvaluatedDomainMarkers, Bramble.EvaluatedParametricDomainMarkers}}
source
tuples(edm::Union{EvaluatedDomainMarkers, EvaluatedParametricDomainMarkers}) -> Tuple
Return multi-symbol markers from the underlying domain markers.
Domains#
Bramble.Domain
source
Domain(set::SetType, markers::MarkersType)
Computational domain pairing a geometric set (e.g. CartesianProduct) with labeled DomainMarkers.
Fields
set: Geometric set defining the spatial bounding box or interval.markers:DomainMarkerscollection indexing labeled boundaries and subregions.
See also: domain, CartesianProduct, DomainMarkers.
Bramble.Domain — Tuple{Number}
source
(Ω::Domain)(t::Number) -> Domain
Evaluate a Domain at timestamp t.
The result holds the markers with each (x, t) predicate fixed at t and each spatial x predicate unchanged, so mesh(Ω(t), ...) marks the points where the predicates hold at t. A static domain evaluates too: a time-dependent problem on a fixed geometry. Meshing the unevaluated Ω of a time-dependent domain is not supported: its (x, t) predicates have no time.
Base.eltype — Tuple{Bramble.Domain}
source
eltype(Ω::Domain) -> Type
eltype(::Type{<:Domain{SetType}}) -> Type
Return the coordinate element type of Domain Ω.
Base.extrema — Tuple{Bramble.Domain}
source
extrema(Ω::Domain) -> Tuple
extrema(Ω::Domain, i::Integer) -> Tuple{T, T}
Return the coordinate interval endpoints of domain Ω.
Base.in — Tuple{Any, Bramble.Domain}
source
in(x, Ω::Domain) -> Bool
Query whether point x lies within the closed domain Ω.
Bramble.conditions — Tuple{Bramble.Domain}
source
conditions(Ω::Domain) -> Tuple
Return the tuple of condition predicate markers associated with domain Ω.
Bramble.is_collapsed — Tuple{Bramble.Domain}
source
is_collapsed(Ω::Domain) -> Bool
is_collapsed(Ω::Domain, i::Integer) -> Bool
Return whether the underlying geometric set of domain Ω is collapsed across any dimension, or along coordinate dimension i.
Bramble.marker_identifiers — Tuple{Bramble.Domain}
source
marker_identifiers(Ω::Domain) -> Tuple
Return a tuple of the identifying symbols, symbol sets, predicate functions, polygons or level sets of all markers in domain Ω.
The tuple lists the identifiers of symbols, then tuples, then conditions, then the polygon and level-set markers. It is built as a compile-time-unrolled tuple, like label_identifiers, so its type is concrete even when the kinds are mixed.
Note
Building the tuple, like iterating symbols, tuples, or conditions directly, or through label_symbols/label_tuples/label_conditions, allocates 0 bytes.
Bramble.point_type — Tuple{Bramble.Domain}
source
point_type(Ω::Domain) -> Type
point_type(::Type{<:Domain{SetType}}) -> Type
Return the coordinate point representation type of Domain Ω.
Bramble.set — Tuple{Bramble.Domain}
source
set(Ω::Domain) -> CartesianProduct
Return the geometric set defining Domain Ω.
Bramble.symbols — Tuple{Bramble.Domain}
source
symbols(Ω::Domain) -> Tuple
Return the tuple of single-symbol markers associated with domain Ω.
Bramble.tuples — Tuple{Bramble.Domain}
source
tuples(Ω::Domain) -> Tuple
Return the tuple of multi-symbol markers associated with domain Ω.
Polygons#
Bramble.Polygon
source
Polygon{T}
Simple polygon in \(\mathbb{R}^2\), possibly non-convex, with scalar coordinate type T.
Build it with polygon, which validates the vertices and stores them counter-clockwise.
Fields
vertices: the vertices in counter-clockwise order; the last one joins the first, and no vertex is repeated.
The validation and the three labels of a polygon marker are in the Geometry API page. Orientation, folding back and crossing are exact: a bounding-box test rejects most pairs of edges, a floating-point orientation decides when it exceeds its error bound, and Rational{BigInt} decides the nearly degenerate rest. The area is judged with a tolerance, |2A| > 8nεL² for n vertices and extent L; a sliver below it is rejected as zero area. The tolerance that classifies the nodes on a mesh is in the mesh internals page.
Level sets#
Bramble.LevelSet
source
LevelSet{F}
Region of \(\mathbb{R}^2\) described by a level-set function φ: the set where φ < 0, bounded by the curve φ = 0.
Build it with levelset. It is a marker value, not a predicate: a bare function in a domain is a predicate marker, so the wrapper tells the two apart.
Fields
φ: the level-set function, called asφ(x)withx = (x₁, x₂).
The validation and the three labels of a level-set marker are in the Geometry API page.
Pretty printing#
Bramble.PrettyPrinter
source
PrettyPrinter(io::I, indent_level::Int) where {I <: IO}
Helper struct managing visual formatting, indentation, and styled console output.
Carries no compact flag: compact versus detailed is decided by which show method the caller reached: two-argument show for the embeddable one-liner, MIME"text/plain" for the detailed block, rather than by a runtime flag every renderer had to branch on (gpena/Bramble.jl#45). A PrettyPrinter is therefore only ever built inside a detailed renderer.
Bramble.get_dimension_label — Tuple{Int64}
source
get_dimension_label(i::Int) -> String
Return the standard coordinate label for dimension index i.
Bramble.print_colored — Tuple{Bramble.PrettyPrinter, Any}
source
print_colored(pp::PrettyPrinter, text; color = :default, bold = false)
Print styled text according to current color settings.
Bramble.print_dimension_info — Tuple{Bramble.PrettyPrinter, String, Any, Any, Bool}
source
print_dimension_info(pp::PrettyPrinter, label::String, min_val, max_val, collapsed::Bool)
Print coordinate dimension bounds.
Bramble.print_empty_message — Union{Tuple{Bramble.PrettyPrinter}, Tuple{Bramble.PrettyPrinter, String}}
source
print_empty_message(pp::PrettyPrinter, message::String = "(none)")
Print an empty collection indicator in muted text.
Bramble.print_header — Union{Tuple{Bramble.PrettyPrinter, String}, Tuple{Bramble.PrettyPrinter, String, String}}
source
print_header(pp::PrettyPrinter, title::String, type_info::String = "")
Print a prominent header with optional type information.
Bramble.print_indent — Tuple{Bramble.PrettyPrinter}
source
print_indent(pp::PrettyPrinter)
Print leading spaces corresponding to the current indentation level.
Bramble.print_interval — Tuple{Bramble.PrettyPrinter, Any, Any}
source
print_interval(pp::PrettyPrinter, min_val, max_val; collapsed = false)
Print formatted interval endpoints or a collapsed point marker.
Bramble.print_joined — Tuple{Any, Bramble.PrettyPrinter, Any}
source
print_joined(f, pp::PrettyPrinter, items; sep = ", ")
Print each of items by calling f(item), separating consecutive ones with sep.
Replaces seven hand-rolled variants of the same loop across the geometry and mesh renderers (gpena/Bramble.jl#47): i < length(xs) && print(io, ", ") in five places and a first flag in print_marker_summary, which had to guard its optional groups. f is passed as a closure in the same style as _each_marked in assembly/dirichlet_constraints.jl, which measured at zero allocations, so the pattern costs nothing here.
items may be any iterable; the separator is written before each entry after the first, so an empty or single-element collection prints no separator at all and a caller with optional groups just filters them out rather than tracking whether anything came before.
Bramble.print_key_value — Tuple{Bramble.PrettyPrinter, String, String}
source
print_key_value(pp::PrettyPrinter, key::String, value::String; key_color = :green, value_color = :blue, separator = " => ")
Print a key-value pair formatted with distinct colors.
Bramble.print_labels_list — Tuple{Bramble.PrettyPrinter, Any}
source
print_labels_list(pp::PrettyPrinter, labels; prefix = "Labels: ")
Print a comma-separated list of symbols.
Bramble.print_marker_summary — Union{Tuple{Bramble.PrettyPrinter, Int64, Int64, Int64}, Tuple{Bramble.PrettyPrinter, Vararg{Int64, 4}}, Tuple{Bramble.PrettyPrinter, Vararg{Int64, 5}}}
source
print_marker_summary(pp::PrettyPrinter, n_sym::Int, n_tup::Int, n_cond::Int, n_poly::Int = 0, n_ls::Int = 0)
Print categorized counts of symbols, tuples, function condition markers, polygon markers and level-set markers without intermediate allocations.
Bramble.print_section_header — Tuple{Bramble.PrettyPrinter, String}
source
print_section_header(pp::PrettyPrinter, title::String)
Print a section header with accent color.
Bramble.print_value — Tuple{Bramble.PrettyPrinter, Any}
source
print_value(pp::PrettyPrinter, value; color = :blue)
Print a colored value.
Bramble.show_block — Tuple{Any, IO}
source
show_block(f, io::IO)
Render a detailed (MIME"text/plain") block and print it to io without its trailing newline.
f(inner) writes to inner, an IO carrying io's own :color and :compact settings, so printstyled still emits styling. The buffered text is printed with one trailing newline removed: display supplies the final newline itself, and a renderer emitting its own leaves a blank line behind (gpena/Bramble.jl#46).
Replaces an earlier remove_trailing_newline(io) that rewrote the caller's stream in place and silently did nothing unless io happened to be a bare IOBuffer, which at the REPL, and inside array display, it never is. Buffering into a stream this function owns is what makes the trim actually happen.
Bramble.with_indent — Union{Tuple{Bramble.PrettyPrinter}, Tuple{Bramble.PrettyPrinter, Int64}}
source
with_indent(pp::PrettyPrinter, levels::Int = 1) -> PrettyPrinter
Return a new PrettyPrinter instance with indentation increased by levels.