Basis Functions
Basis functions are the building blocks of spline spaces. This module provides both B-spline and NURBS basis functions in univariate and tensor product forms.
Base Types
TinyGismo.gsBasis — Type
gsBasisAbstract base type for all basis function types in TinyGismo.
Details
gsBasis is the parent type for all spline basis functions, including:
BSplineBasis: Univariate B-spline basesTensorBSplineBasis: Tensor product B-spline basesNurbsBasis: Univariate NURBS basesTensorNurbsBasis: Tensor product NURBS bases
All basis types support common operations such as evaluation, differentiation, degree elevation, and refinement.
See Also
Generic Basis Operations
These methods work on all basis types (B-spline and NURBS).
Element and Activity Queries
TinyGismo.knotSpans — Function
knotSpans(basis::gsBasis)Returns a list of the Knot Spans, i.e. elements in reference space.
For a tensor product basis the spans tile the parameter domain, ordered with the first parametric direction running fastest.
Common Methods
Each of these returns a gsVector with one entry per parametric direction.
TinyGismo.elementIndex — Function
elementIndex(basis::gsBasis, u::Union{Vector{Float64}, Matrix{Float64}})Get the index of the knot span element containing a parametric point.
Arguments
basis: The basisu: A parametric point (vector) or multiple points (matrix, one per column)
Returns
The element index (1-indexed)
Details
Returns the index of the knot span containing the given parameter value(s).
TinyGismo.elementInSupportOf — Function
elementInSupportOf(basis::gsBasis, j::Int)Get the knot spans in the support of the j-th basis function.
Arguments
basis: The basisj: The basis function index (1-indexed)
Returns
A gsMatrix{Float64} holding the lower and upper corner of one element contained in the support of basis function j — the coordinates of an element, not a list of element indices, and not the whole support.
See Also
TinyGismo.active! — Function
active!(basis::gsBasis, u::Union{Vector{Float64}, Matrix{Float64}}, out::gsMatrix{Int32})Get the indices of active basis functions at parametric point(s) (in-place).
Arguments
basis: The basisu: A parametric point (vector) or multiple points (matrix)out: Output gsMatrix{Int32} to store active basis indices (modified in-place, 1-indexed)
Details
Returns the indices of all basis functions that are nonzero at the given parametric point(s).
TinyGismo.isActive — Function
isActive(basis::gsBasis, i::Int, u::Vector{Float64})Check if the i-th basis function is active (nonzero) at a parametric point.
Arguments
basis: The basisi: The basis function index (1-indexed)u: The parametric point
Returns
Boolean indicating whether the basis function is active at the point
TinyGismo.boundary — Function
boundary(basis::gsBasis, s::Int)
boundary(geo::gsGeometry, s::Int)Extract a side of the domain.
For a basis, returns the indices of the basis functions that are nonzero on that side, as a single-column matrix (read it with toVector).
For a geometry, returns that side as a geometry of one lower parametric dimension, wrapped in a C++ unique_ptr to the abstract base class — dereference it with [] before use, e.g. west = boundary(geo, 1)[].
Arguments
basis/geo: The basis or geometrys: The boxSide describing the side:1/2are west and east ($u = 0$ and $u = 1$),3/4are south and north.
Degree and Continuity Operations
TinyGismo.degreeElevate! — Function
degreeElevate!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=0)Elevate the polynomial degree of a basis or geometry.
Arguments
obj: A basis or geometry object (modified in-place)i: The amount to elevate degree by (default: 1)dir: The parametric direction, 1-based, or0for all directions (default:0)
Directions outside 0:parDim(obj) are rejected with an error.
Note
This operation modifies the object in-place.
TinyGismo.degreeReduce! — Function
degreeReduce!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=0)Reduce the polynomial degree of a basis or geometry.
Arguments
obj: A basis or geometry object (modified in-place)i: The amount to reduce degree by (default: 1)dir: The parametric direction, 1-based, or0for all directions (default:0)
Directions outside 0:parDim(obj) are rejected with an error.
Note
This operation modifies the object in-place.
TinyGismo.degreeIncrease! — Function
degreeIncrease!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=0)Increase the polynomial degree of a basis or geometry.
Arguments
obj: A basis or geometry object (modified in-place)i: The amount to increase degree by (default: 1)dir: The parametric direction, 1-based, or0for all directions (default:0)
Directions outside 0:parDim(obj) are rejected with an error.
Note
This operation modifies the object in-place.
TinyGismo.degreeDecrease! — Function
degreeDecrease!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=0)Decrease the polynomial degree of a basis or geometry.
Arguments
obj: A basis or geometry object (modified in-place)i: The amount to decrease degree by (default: 1)dir: The parametric direction, 1-based, or0for all directions (default:0)
Directions outside 0:parDim(obj) are rejected with an error.
Note
This operation modifies the object in-place.
TinyGismo.elevateContinuity! — Function
elevateContinuity!(basis::gsBasis, i::Int=1)Elevate the continuity of the basis.
Arguments
basis: The basis (modified in-place)i: The number of continuity levels to increase (default: 1)
Details
Elevates continuity by increasing the polynomial degree and adjusting knot multiplicities.
Note
This operation modifies the basis in-place.
TinyGismo.reduceContinuity! — Function
reduceContinuity!(basis::gsBasis, i::Int=1)Reduce the continuity of the basis.
Arguments
basis: The basis (modified in-place)i: The number of continuity levels to decrease (default: 1)
Note
This operation modifies the basis in-place.
TinyGismo.setDegree! — Function
setDegree!(basis::gsBasis, i::Int)Set the polynomial degree of the basis to a specific value.
Arguments
basis: The basis (modified in-place)i: The target polynomial degree
Note
This operation modifies the basis in-place.
TinyGismo.setDegreePreservingMultiplicity! — Function
setDegreePreservingMultiplicity!(basis::gsBasis, i::Int)Set the polynomial degree while preserving knot multiplicities.
Arguments
basis: The basis (modified in-place)i: The target polynomial degree
Note
This operation modifies the basis in-place.
Geometric Operations
TinyGismo.reverse! — Function
reverse!(basis::gsBasis)Reverse the basis (flip the parametric direction).
Arguments
basis: The basis (modified in-place)
Note
This operation modifies the basis in-place.
Evaluation
TinyGismo.eval! — Function
eval!(obj::Union{gsBasis, gsGeometry}, u::Vector{Float64}, out::gsMatrix{Float64})Evaluate basis functions or geometry at parametric point(s) (in-place).
Arguments
obj: A basis or geometry objectu: Parametric point(s) (vector or matrix where columns are points)out: Output gsMatrix{Float64} to store values (modified in-place)
Details
For basis objects, evaluates all basis functions that are nonzero at the given point(s). For geometry objects, evaluates the geometry at the given parametric point(s).
TinyGismo._eval — Function
_eval(obj::Union{gsBasis, gsGeometry}, u::Vector{Float64})Evaluate basis functions or geometry at parametric point(s).
Arguments
obj: A basis or geometry objectu: Parametric point(s)
Returns
For basis objects, returns a matrix of basis function values. For geometry objects, returns a matrix of evaluated points.
TinyGismo.evalSingle! — Function
evalSingle!(basis::gsBasis, i::Int, u::Vector{Float64}, out::gsMatrix{Float64})Evaluate a single basis function at parametric point(s) (in-place).
Arguments
basis: The basisi: The basis function index (1-indexed)u: Parametric point(s)out: Output gsMatrix{Float64} (modified in-place)
TinyGismo.evalSingle — Function
evalSingle(basis::gsBasis, i::Int, u::Vector{Float64})Evaluate a single basis function at parametric point(s).
Arguments
basis: The basisi: The basis function index (1-indexed)u: Parametric point(s)
Returns
The basis function values
TinyGismo.evalFunc! — Function
evalFunc!(basis::gsBasis, u::Vector{Float64}, coefs::Union{Vector{Float64}, Matrix{Float64}}, out::gsMatrix{Float64})Evaluate a function represented in the basis (in-place).
Arguments
basis: The basisu: Parametric evaluation pointscoefs: Control point coefficients (vector or matrix)out: Output gsMatrix{Float64} to store function values (modified in-place)
Details
Evaluates the function defined by ∑(coefsi × basisi) at the given points.
TinyGismo.evalFunc — Function
evalFunc(basis::gsBasis, u::Vector{Float64}, coefs::Union{Vector{Float64}, Matrix{Float64}})Evaluate a function represented in the basis.
Arguments
basis: The basisu: Parametric evaluation pointscoefs: Control point coefficients (vector or matrix)
Returns
A matrix of function values
Derivatives
TinyGismo.deriv! — Function
deriv!(obj::Union{gsBasis, gsGeometry}, u::Vector{Float64}, out::gsMatrix{Float64})Evaluate the first derivative (in-place).
Arguments
obj: A basis or geometry objectu: Parametric evaluation pointsout: Output gsMatrix{Float64} to store derivatives (modified in-place)
Details
For basis objects, evaluates the derivatives of basis functions. For geometry objects, evaluates the derivative (tangent) of the geometry.
TinyGismo.deriv — Function
deriv(obj::Union{gsBasis, gsGeometry}, u::Union{Vector{Float64}, Matrix{Float64}})Evaluate the first derivative.
Arguments
obj: A basis or geometry objectu: Parametric evaluation points
Returns
For basis objects, returns a matrix of basis function derivatives. For geometry objects, returns a matrix of derivative (tangent) vectors.
TinyGismo.derivSingle! — Function
derivSingle!(basis::gsBasis, i::Int, u::Vector{Float64}, out::gsMatrix{Float64})Evaluate the first derivative of a single basis function (in-place).
Arguments
basis: The basisi: The basis function index (1-indexed)u: Parametric evaluation pointsout: Output gsMatrix{Float64} (modified in-place)
TinyGismo.derivSingle — Function
derivSingle(basis::gsBasis, i::Int, u::Vector{Float64})Evaluate the first derivative of a single basis function.
Arguments
basis: The basisi: The basis function index (1-indexed)u: Parametric evaluation points
Returns
The derivative values
TinyGismo.derivFunc — Function
derivFunc(basis::gsBasis, u::Vector{Float64}, coefs::Union{Vector{Float64}, Matrix{Float64}})Evaluate the first derivative of a function represented in the basis.
Arguments
basis: The basisu: Parametric evaluation pointscoefs: Control point coefficients (vector or matrix)
Returns
A matrix of derivative values
TinyGismo.deriv2! — Function
deriv2!(obj::Union{gsBasis, gsGeometry}, u::Vector{Float64}, out::gsMatrix{Float64})Evaluate the second derivative (in-place).
Arguments
obj: A basis or geometry objectu: Parametric evaluation pointsout: Output gsMatrix{Float64} to store second derivatives (modified in-place)
Details
For basis objects, evaluates the second derivatives of basis functions. For geometry objects, evaluates the second derivative (curvature information) of the geometry.
TinyGismo.deriv2 — Function
deriv2(obj::Union{gsBasis, gsGeometry}, u::Union{Vector{Float64}, Matrix{Float64}})Evaluate the second derivative.
Arguments
obj: A basis or geometry objectu: Parametric evaluation points
Returns
A matrix of second derivative vectors
TinyGismo.deriv2Single! — Function
deriv2Single!(basis::gsBasis, i::Int, u::Vector{Float64}, out::gsMatrix{Float64})Evaluate the second derivative of a single basis function (in-place).
Arguments
basis: The basisi: The basis function index (1-indexed)u: Parametric evaluation pointsout: Output gsMatrix{Float64} (modified in-place)
TinyGismo.deriv2Single — Function
deriv2Single(basis::gsBasis, i::Int, u::Vector{Float64})Evaluate the second derivative of a single basis function.
Arguments
basis: The basisi: The basis function index (1-indexed)u: Parametric evaluation points
Returns
The second derivative values
TinyGismo.deriv2Func — Function
deriv2Func(basis::gsBasis, u::Vector{Float64}, coefs::Union{Vector{Float64}, Matrix{Float64}})Evaluate the second derivative of a function represented in the basis.
Arguments
basis: The basisu: Parametric evaluation pointscoefs: Control point coefficients (vector or matrix)
Returns
A matrix of second derivative values
Refinement
TinyGismo.uniformRefine! — Function
uniformRefine!(basis::gsBasis, numKnots::Int=1, mul::Int=1)Uniformly refine the basis by inserting knots.
Arguments
basis: The basis (modified in-place)numKnots: Number of knots to insert in each span (default: 1)mul: Multiplicity of each inserted knot (default: 1)
Note
This operation modifies the basis in-place.
TinyGismo.uniformCoarsen! — Function
uniformCoarsen!(basis::gsBasis, numKnots::Int=1)Uniformly coarsen the basis by removing knots.
Arguments
basis: The basis (modified in-place)numKnots: Number of knots to remove from each span (default: 1)
Note
This operation modifies the basis in-place.
TinyGismo.uniformRefine_withCoefs! — Function
uniformRefine_withCoefs!(basis::gsBasis, coefs::Matrix{Float64}, numKnots::Int=1, mul::Int=1)Uniformly refine the basis and compute the matching refined control points.
Arguments
basis: The basis (modified in-place)coefs: Control point coefficients, one row per basis functionnumKnots: Number of knots to insert in each span (default: 1)mul: Multiplicity of each inserted knot (default: 1)
Returns
A gsMatrix of refined coefficients, with one row per function of the refined basis
Details
The refined basis together with the returned coefficients represents exactly the same function as the original pair did.
The coefficients are not updated in place: refinement adds control points, so the result has more rows than coefs. Only the basis is modified in place, hence the !.
coefs must have exactly size(basis) rows, otherwise an error is raised.
Examples
basis = BSplineBasis(kv)newcoefs = toMatrix(uniformRefine_withCoefs!(basis, coefs))refined = BSpline(basis, newcoefs) # the same curve in a richer spaceB-Spline Bases
Constructors
TinyGismo.BSplineBasis — Type
BSplineBasis(knotVector::KnotVector)Construct a univariate B-spline basis from a knot vector.
Arguments
knotVector: The knot vector defining the basis
Returns
A B-spline basis object
Examples
kv = KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0])basis = BSplineBasis(kv)TinyGismo.TensorBSplineBasis — Type
TensorBSplineBasis{2}(knotVector1::KnotVector, knotVector2::KnotVector)Construct a bivariate tensor product B-spline basis from two knot vectors.
The parametric dimension must be given explicitly as a type parameter; there is no unparameterized TensorBSplineBasis(kv1, kv2) convenience constructor.
Arguments
knotVector1,knotVector2: Knot vectors for each parametric direction
Returns
A TensorBSplineBasis{2}
Examples
kv1 = KnotVector([0.0, 0.0, 0.0, 1.0, 1.0, 1.0])kv2 = KnotVector([0.0, 0.0, 1.0, 1.0])basis = TensorBSplineBasis{2}(kv1, kv2)Query Functions
TinyGismo.knots — Function
knots(basis::BSplineBasis, i::Int=1)Get the knot vector for a given parametric direction.
Arguments
basis: The B-spline basisi: The parametric direction (default: 1)
Returns
The knot vector for direction i
TinyGismo.knot — Function
knot(basis::BSplineBasis, i::Int)Get the i-th knot value.
Arguments
basis: The B-spline basisi: The knot index
Returns
The knot value at index i
Base.size — Method
Base.size(basis::BSplineBasis)Get the number of basis functions in the B-spline basis.
Alias for the C++ size() method.
Base.size — Method
Base.size(basis::TensorBSplineBasis)Get the number of basis functions in the tensor product B-spline basis.
Alias for the C++ size() method.
Base.size — Method
Base.size(basis::NurbsBasis)Get the number of basis functions in the NURBS basis.
Alias for the C++ size() method.
Base.size — Method
Base.size(basis::TensorNurbsBasis)Get the number of basis functions in the tensor product NURBS basis.
Alias for the C++ size() method.
TinyGismo.numElements — Function
numElements(basis::gsBasis)
numElements(basis::gsBasis, side::Int)
numElements(kv::KnotVector)Get the number of elements (knot spans).
Without a second argument this is the total element count of the whole domain — the product over all parametric directions for a tensor product basis.
Arguments
basis: The basisside: A boxSide (1/2west and east,3/4south and north), not a parametric direction. The result is the number of elements lying along that boundary side. Passing0(or-1) gives the total, as in the one-argument form.
Returns
The number of elements
Note
To count elements per parametric direction on a tensor product basis, use TinyGismo.component: numElements(component(basis, i)).
TinyGismo.numTotalElements — Function
numTotalElements(basis::TensorBSplineBasis)Get the total number of elements in a tensor product basis.
Arguments
basis: The tensor product B-spline basis
Returns
The total number of elements across all parametric directions
TinyGismo.degree — Function
degree(obj::Union{KnotVector, BSplineBasis, NurbsBasis, BSpline, Nurbs})
degree(obj::Union{TensorBSplineBasis, TensorNurbsBasis, TensorBSpline, TensorNurbs}, i::Int)Get the polynomial degree of a knot vector, basis or geometry.
Knot vectors and univariate objects take no further argument. Tensor product objects require the parametric direction i (1-based), since the degree may differ per direction.
Arguments
obj: The knot vector, basis or geometry objecti: The parametric direction, 1-based (tensor product objects only)
Returns
The polynomial degree
Examples
kv = KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0])degree(kv) # 2, deduced from the end multiplicitiesdegree(BSplineBasis(kv)) # 2degree(TensorBSplineBasis{2}(kv, kv), 1)TinyGismo.order — Function
order(basis::BSplineBasis)Get the order of the B-spline basis.
The order equals the polynomial degree plus one.
Arguments
basis: The B-spline basis
Returns
The order of the basis (degree + 1)
TinyGismo.component — Function
component(basis::TensorBSplineBasis, i::Int)Get the univariate B-spline basis component for a parametric direction.
Arguments
basis: The tensor product B-spline basisi: The parametric direction (1-indexed)
Returns
The univariate B-spline basis for direction i
Active Basis Functions
TinyGismo.numActive — Function
numActive(basis::gsBasis)Get the number of basis functions that are nonzero on any single element.
This does not depend on the evaluation point: it is p + 1 for a univariate basis of degree p, and the product of pᵢ + 1 over the parametric directions of a tensor product basis.
Arguments
basis: Any B-spline or NURBS basis, univariate or tensor product
Returns
The number of active basis functions per element
Examples
numActive(BSplineBasis(kv)) # p + 1numActive(TensorBSplineBasis{2}(k1, k2)) # (p1 + 1) * (p2 + 1)See Also
active!for the indices of those functions at a given point
Refinement Operations
TinyGismo.insertKnot! — Function
insertKnot!(basis::BSplineBasis, knot::Float64, mult::Int=1)Insert a knot into the basis.
This operation refines the basis by inserting a knot value. The multiplicity determines how many times the knot is inserted.
Arguments
basis: The B-spline basis (modified in-place)knot: The knot value to insertmult: The multiplicity of insertion (default: 1)
Note
This operation modifies the basis in-place.
TinyGismo.removeKnot! — Function
removeKnot!(basis::BSplineBasis, knot::Float64, mult::Int=1)Remove a knot from the basis.
Arguments
basis: The B-spline basis (modified in-place)knot: The knot value to removemult: The multiplicity of removal (default: 1)
Note
This operation modifies the basis in-place.
TinyGismo.insertKnots! — Function
insertKnots!(basis::BSplineBasis, knots::Vector{Float64})Insert multiple knots into the basis.
Arguments
basis: The B-spline basis (modified in-place)knots: A vector of knot values to insert
Note
This operation modifies the basis in-place.
NURBS Bases
Constructors
TinyGismo.NurbsBasis — Type
NurbsBasis(knotVector::KnotVector)
NurbsBasis(knotVector::KnotVector, weights::Vector{Float64})
NurbsBasis(basis::BSplineBasis, weights::Vector{Float64})Construct a univariate NURBS (Non-Uniform Rational B-Spline) basis from a knot vector and optional weights.
Arguments
knotVector: The knot vector defining the basisweights: Control point weights (optional, defaults to uniform weights)basis: Existing B-spline basis to convert to NURBS
Returns
A NURBS basis object
Details
NURBS bases generalize B-spline bases by associating weights with control points, allowing for more flexible shape control and exact representation of conic sections.
Examples
kv = KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0])basis = NurbsBasis(kv)# With weightsw = [1.0, 1.0, sqrt(2)/2, 1.0, 1.0]basis = NurbsBasis(kv, w)TinyGismo.TensorNurbsBasis — Type
TensorNurbsBasis{2}(knotVector1::KnotVector, knotVector2::KnotVector, weights::Matrix{Float64})Construct a bivariate tensor product NURBS basis from two knot vectors and weights.
The parametric dimension must be given explicitly as a type parameter.
Arguments
knotVector1,knotVector2: Knot vectors for each parametric directionweights: One weight per basis function as a single-column matrix, ordered lexicographically with the first parametric direction running fastest
Returns
A TensorNurbsBasis{2}
Details
Tensor product NURBS surfaces are formed by taking the tensor product of univariate NURBS bases, with weights controlling the influence of each control point.
Examples
kv1 = KnotVector([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]) # 3 functionskv2 = KnotVector([0.0, 0.0, 1.0, 1.0]) # 2 functionsw = reshape([1.0, sqrt(2)/2, 1.0, 1.0, sqrt(2)/2, 1.0], 6, 1)basis = TensorNurbsBasis{2}(kv1, kv2, w)Query Functions
TinyGismo.weights — Function
weights(nurbs::Union{Nurbs, TensorNurbs})
weights(basis::Union{NurbsBasis, TensorNurbsBasis})Get all control point weights, one per basis function. A geometry and its TinyGismo.basis carry the same weights.
Arguments
nurbs/basis: The NURBS geometry or NURBS basis
Returns
A single-column gsMatrix of all weights; convert it with toVector
Hierarchical Bases
Hierarchical bases add local refinement: a tensor basis is taken as the coarsest level, and finer levels are introduced only over the regions that need them. Two flavours are available and differ only in truncation.
| Partition of unity after refinement | Use | |
|---|---|---|
THBSplineBasis | yes | the usual choice |
HBSplineBasis | no | when the untruncated functions are wanted |
In G+Smo these are one class template with truncation switched on or off, so everything below applies equally to both.
Constructors
TinyGismo.THBSplineBasis — Type
THBSplineBasis{d}(tensorBasis::TensorBSplineBasis{d})
THBSplineBasis{d}(tensorBasis, boxes::Matrix{Float64})
THBSplineBasis{d}(tensorBasis, boxes::Vector{Int64})A truncated hierarchical B-spline (THB-spline) basis over d parametric directions, d ∈ 1:3.
Built from a tensor B-spline basis, which becomes its coarsest level; further levels are added locally by refineElements! or refine!.
Truncation keeps the basis a partition of unity, which HBSplineBasis does not — the usual reason to prefer it. Otherwise the two are interchangeable.
The two-argument forms refine at construction. The Matrix form takes parametric corner coordinates, d × 2k, each consecutive pair of columns one box; note it rounds outward, its upper corner being inclusive of the cell containing it. The Vector{Int64} form takes element boxes in the flat layout of RefinementBox.
Example
kv = KnotVector([0.0, 0.0, 0.0, 0.25, 0.5, 0.75, 1.0, 1.0, 1.0])basis = THBSplineBasis{2}(TensorBSplineBasis{2}(kv, kv))refineElements!(basis, RefinementBox(2, 1:2, 1:2))See also HBSplineBasis, THBSpline, numLevels.
TinyGismo.HBSplineBasis — Type
HBSplineBasis{d}(tensorBasis::TensorBSplineBasis{d})
HBSplineBasis{d}(tensorBasis, boxes::Matrix{Float64})
HBSplineBasis{d}(tensorBasis, boxes::Vector{Int64})A hierarchical B-spline (HB-spline) basis over d parametric directions, d ∈ 1:3.
Identical to THBSplineBasis in construction and refinement, but without truncation: coarse functions overlapping a refined region are kept whole. The span is the same, but the basis is no longer a partition of unity there, so prefer THBSplineBasis unless you want the untruncated functions.
Level Queries
TinyGismo.numLevels — Function
numLevels(basis)Get the number of levels of a hierarchical basis.
Levels run 1:numLevels(basis), level 1 being the coarsest; an unrefined basis has one level and coincides with the tensor basis it was built from. In G+Smo this count is maxLevel() + 1, maxLevel being 0-based there.
TinyGismo.levelOf — Function
levelOf(basis, i::Int)Get the level a hierarchical basis function belongs to.
i is a 1-based basis function index and the returned level is 1-based.
TinyGismo.tensorLevel — Function
tensorLevel(basis, level::Int)Get the full tensor B-spline basis underlying one level (1-based) of a hierarchical basis.
This is the uniform basis that level would be if the whole domain were refined to it, not the subset of its functions the hierarchical basis actually uses.
TinyGismo.getLevelAtPoint — Function
getLevelAtPoint(basis, u::Vector{Float64})Get the (1-based) refinement level of the element containing a parametric point — the most direct way to check that a refinement landed where it was meant to.
TinyGismo.levelAtCorner — Function
levelAtCorner(basis, c::Int)Get the (1-based) refinement level at a corner of the parameter domain.
TinyGismo.treeSize — Function
treeSize(basis)Get the number of nodes in the quadtree recording a hierarchical basis' refinement — a diagnostic on how fragmented it is, not a count of elements (use numElements for that).
Elements
TinyGismo.elementBoxes — Function
elementBoxes(basis)Get the elements of a hierarchical basis as a 2d × numElements(basis) matrix.
The first d rows of each column are one element's lower corner in parametric coordinates, the last d its upper corner. The elements partition the parameter domain.
This replaces knotSpans, which is unavailable for hierarchical bases: it hands back copies of a G+Smo domain iterator, and gsHDomainIterator cannot be safely copied upstream — its element cursor points into storage the copy does not own. Reading the boxes out eagerly avoids the problem.
Local Refinement
Refinement is addressed either by parametric coordinates (refine!) or by naming exact elements (refineElements!). The latter goes through RefinementBox, which is also where the level and index conventions are spelled out.
TinyGismo.RefinementBox — Type
RefinementBox(level, lower::NTuple{d,Integer}, upper::NTuple{d,Integer})
RefinementBox(level, ranges::AbstractUnitRange{<:Integer}...)A box of elements on one level of a hierarchical basis, used to refine or unrefine locally.
level is the level the region is refined to, 1-based, with level 1 the coarsest. lower and upper are 1-based, inclusive cell indices in the index space of that same level: the box covers cells lower[i]:upper[i] in direction i.
The indices being given on the target level is the part that catches people out. Each level halves the cells of the one before it, so cell k of level l is cells 2k-1:2k on level l+1. To refine the first cell of a coarse basis one level deeper:
refineElements!(basis, RefinementBox(2, 1:2, 1:2)) # coarse cell (1,1), addressed on level 2RefinementBox(2, (1, 1), (2, 2)) # the same box, corners instead of rangesSee refineElements! and unrefineElements!.
TinyGismo.refine! — Function
refine!(basis, boxes::Matrix{Float64}, refExt::Int = 0)Refine a hierarchical basis over regions given as parametric corner coordinates.
boxes is d × 2k: each consecutive pair of columns is the lower and upper corner of one box. Every box is refined one level deeper than the level containing it. refExt widens each box by that many cells first, which keeps a refinement from hugging a feature too tightly.
To refine an exactly known set of elements use refineElements!. See also unrefine!.
TinyGismo.unrefine! — Function
unrefine!(basis, boxes::Matrix{Float64}, refExt::Int = 0)Coarsen a hierarchical basis over regions given as parametric corner coordinates. The inverse of refine!.
TinyGismo.refineElements! — Function
refineElements!(obj, boxes::AbstractVector{<:RefinementBox})
refineElements!(obj, box::RefinementBox)
refineElements!(obj, boxes::Vector{Int64})Refine a hierarchical basis or geometry over an exactly specified set of elements.
obj may be a THBSplineBasis/HBSplineBasis or a THBSpline/ HBSpline; on a geometry the control points are carried along, leaving the map unchanged.
Each box names the level the region is set to, corners indexed on that same level's grid — see RefinementBox. The raw Vector{Int64} form is the same data flattened, [level, lower..., upper...] per box.
Refining a basis alone changes the number of basis functions, so coefficients held alongside it go stale; refineElements_withCoefs! updates both together.
Example
refineElements!(basis, RefinementBox(2, 1:2, 1:2))refineElements!(basis, [RefinementBox(2, 1:2, 1:2), RefinementBox(3, 1:2, 1:2)])TinyGismo.unrefineElements! — Function
unrefineElements!(obj, boxes)Coarsen a hierarchical basis or geometry over an exactly specified set of elements. Takes the same box forms as refineElements!.
The level in a box is the level the region is set to here as well, so undoing a refinement to level l means naming level l-1, on level l-1's grid. Naming level l again asks for the state the basis is already in, and does nothing.
TinyGismo.refineElements_withCoefs! — Function
refineElements_withCoefs!(basis, coefs::Matrix{Float64}, boxes) -> gsMatrixRefine a hierarchical basis and return the coefficients describing the same function over the refined basis — refinement is exact, so the function is unchanged.
The basis is refined in place; the coefficients cannot be, since refinement changes the number of basis functions, so the result is a new matrix with a different number of rows. coefs must have one row per function of the basis before refinement, which is checked.
See also unrefineElements_withCoefs!, refine_withCoefs!.
TinyGismo.unrefineElements_withCoefs! — Function
unrefineElements_withCoefs!(basis, coefs::Matrix{Float64}, boxes) -> gsMatrixCoarsen a hierarchical basis and return the matching coefficients. The inverse of refineElements_withCoefs!; unlike it, coarsening is generally not exact.
TinyGismo.refine_withCoefs! — Function
refine_withCoefs!(basis, coefs::Matrix{Float64}, boxes::Matrix{Float64}) -> gsMatrixRefine a hierarchical basis over parametric-coordinate boxes and return the matching coefficients. The refine! counterpart of refineElements_withCoefs!.
TinyGismo.refineSide! — Function
refineSide!(basis, side::Int, level::Int)Refine every element along one side of the parameter domain up to level (1-based).
Sides follow the G+Smo numbering: 1 = west, 2 = east, 3 = south, 4 = north, 5 = front, 6 = back.
TinyGismo.refineBasisFunction! — Function
refineBasisFunction!(basis, i::Int)Refine the support of the i-th (1-based) basis function of a hierarchical basis.
TinyGismo.increaseMultiplicity! — Function
increaseMultiplicity!(obj, level::Int, dir::Int, knotValue::Float64, mult::Int = 1)Raise the multiplicity of a knot on one level of a hierarchical basis or geometry, reducing continuity there. level and dir are both 1-based; dir has no "all directions" mode, so 0 is rejected.
Evaluation, derivatives and the degree operations are inherited unchanged from gsBasis — see Generic Basis Operations. knotSpans is the one exception: it is not available for hierarchical bases, and elementBoxes replaces it.