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
kontSpans(basis::gsBasis)Returns a list of the Knot Spans, i.e. elements in reference space.
Common Methods
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
The element indices where the basis function has nonzero support
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)Returns the indices of the basis functions that are nonzero at the domain boundary as single-column-matrix.
Arguments:
basis: The basiss: The boxSide describing the side.
Degree and Continuity Operations
TinyGismo.degreeElevate! — Function
degreeElevate!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=-1)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 direction for tensor product bases (default: -1 for all directions)
Note
This operation modifies the object in-place.
TinyGismo.degreeReduce! — Function
degreeReduce!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=-1)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 direction for tensor product bases (default: -1 for all directions)
Note
This operation modifies the object in-place.
TinyGismo.degreeIncrease! — Function
degreeIncrease!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=-1)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 direction for tensor product bases (default: -1 for all directions)
Note
This operation modifies the object in-place.
TinyGismo.degreeDecrease! — Function
degreeDecrease!(obj::Union{gsBasis, gsGeometry}, i::Int=1, dir::Int=-1)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 direction for tensor product bases (default: -1 for all directions)
Note
This operation modifies the object in-place.
TinyGismo.elevateContinuity! — Function
elevateContinuity!(basis::gsBasis, i::Int=1, dir::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)dir: The direction for tensor product bases (default: -1 for all directions)
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, dir::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)dir: The direction for tensor product bases (default: -1 for all directions)
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 update control point coefficients accordingly.
Arguments
basis: The basis (modified in-place)coefs: Control point coefficients (modified in-place)numKnots: Number of knots to insert in each span (default: 1)mul: Multiplicity of each inserted knot (default: 1)
Details
This function refines the basis and automatically computes the new control points such that the refined basis represents the same geometry/function.
Note
Both the basis and coefficients are modified in-place.
B-Spline Bases
Constructors
TinyGismo.BSplineBasis — Type
BSplineBasis(knotVector::gsKnotVector)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 = gsKnotVector(...)
basis = BSplineBasis(kv)TinyGismo.TensorBSplineBasis — Type
TensorBSplineBasis{2}(knotVector1::gsKnotVector, knotVector2::gsKnotVector)
TensorBSplineBasis{3}(knotVector1::gsKnotVector, knotVector2::gsKnotVector, knotVector3::gsKnotVector)Construct a tensor product B-spline basis from knot vectors.
Arguments
knotVector1,knotVector2,[knotVector3]: Knot vectors for each parametric direction
Returns
A tensor product B-spline basis object (2D or 3D)
Examples
kv1 = gsKnotVector(...)
kv2 = gsKnotVector(...)
basis = TensorBSplineBasis(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
TinyGismo.numElements — Function
numElements(basis::BSplineBasis, side::Int=0)Get the number of elements (knot spans) in the basis.
Arguments
basis: The B-spline basisside: The side/direction to query (default: 0 for all sides)
Returns
The number of elements in the specified direction
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{gsBasis, KnotVector, gsGeometry}, i::Int)Get the polynomial degree of the basis, knot vector, or geometry.
For univariate bases, returns a single degree. For tensor product bases, returns the degree in a specified direction.
Arguments
obj: The B-spline basis, knot vector, or geometry objecti: The parametric direction (for tensor product bases, optional)
Returns
The polynomial degree
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::TensorBSplineBasis, u::Vector{Float64})Get the number of active basis functions at a given parametric point.
For tensor product bases, returns a vector with the number of active basis functions in each direction.
Arguments
basis: The tensor product B-spline basisu: The parametric point
Returns
The number of active basis functions at point u
TinyGismo.numActive! — Function
numActive!(basis::TensorBSplineBasis, u::Vector{Float64}, out::Vector{Int})Get the number of active basis functions at a given parametric point (in-place).
Stores the result in the output vector out.
Arguments
basis: The tensor product B-spline basisu: The parametric pointout: Output vector to store the number of active basis functions in each direction (modified in-place)
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 = gsKnotVector(...)
basis = NurbsBasis(kv)
# With weights
w = [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})
TensorNurbsBasis{3}(knotVector1::KnotVector, knotVector2::KnotVector, knotVector3::KnotVector, weights::Matrix{Float64})Construct a tensor product NURBS basis from knot vectors and weights.
Arguments
knotVector1,knotVector2,[knotVector3]: Knot vectors for each parametric directionweights: Control point weights arranged in a matrix
Returns
A tensor product NURBS basis object (2D or 3D)
Details
Tensor product NURBS surfaces and volumes are formed by taking the tensor product of univariate NURBS bases, with weights controlling the influence of each control point.
Examples
kv1 = gsKnotVector(...)
kv2 = gsKnotVector(...)
w = [1.0 1.0 1.0; 1.0 sqrt(2)/2 1.0; 1.0 1.0 1.0]
basis = TensorNurbsBasis(kv1, kv2, w)Query Functions
TinyGismo.weights — Function
weights(nurbs::Nurbs)Get all control point weights.
Arguments
nurbs: The NURBS curve
Returns
A vector of all weights