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
gsBasis

Abstract 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 bases
  • TensorBSplineBasis: Tensor product B-spline bases
  • NurbsBasis: Univariate NURBS bases
  • TensorNurbsBasis: Tensor product NURBS bases

All basis types support common operations such as evaluation, differentiation, degree elevation, and refinement.

See Also

source

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.

source
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 basis
  • u: 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).

source
TinyGismo.elementInSupportOf — Function
elementInSupportOf(basis::gsBasis, j::Int)

Get the knot spans in the support of the j-th basis function.

Arguments

  • basis: The basis
  • j: 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

  • knotSpans to iterate over every element of the mesh
  • isActive to test a single function at a single point
source
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 basis
  • u: 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).

source
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 basis
  • i: The basis function index (1-indexed)
  • u: The parametric point

Returns

Boolean indicating whether the basis function is active at the point

source
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 geometry
  • s: The boxSide describing the side: 1/2 are west and east ($u = 0$ and $u = 1$), 3/4 are south and north.
source

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, or 0 for all directions (default: 0)

Directions outside 0:parDim(obj) are rejected with an error.

Note

This operation modifies the object in-place.

source
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, or 0 for all directions (default: 0)

Directions outside 0:parDim(obj) are rejected with an error.

Note

This operation modifies the object in-place.

source
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, or 0 for all directions (default: 0)

Directions outside 0:parDim(obj) are rejected with an error.

Note

This operation modifies the object in-place.

source
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, or 0 for all directions (default: 0)

Directions outside 0:parDim(obj) are rejected with an error.

Note

This operation modifies the object in-place.

source
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.

source
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.

source
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.

source
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.

source

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.

source

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 object
  • u: 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).

source
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 object
  • u: Parametric point(s)

Returns

For basis objects, returns a matrix of basis function values. For geometry objects, returns a matrix of evaluated points.

source
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 basis
  • i: The basis function index (1-indexed)
  • u: Parametric point(s)
  • out: Output gsMatrix{Float64} (modified in-place)
source
TinyGismo.evalSingle — Function
evalSingle(basis::gsBasis, i::Int, u::Vector{Float64})

Evaluate a single basis function at parametric point(s).

Arguments

  • basis: The basis
  • i: The basis function index (1-indexed)
  • u: Parametric point(s)

Returns

The basis function values

source
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 basis
  • u: Parametric evaluation points
  • coefs: 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.

source
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 basis
  • u: Parametric evaluation points
  • coefs: Control point coefficients (vector or matrix)

Returns

A matrix of function values

source

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 object
  • u: Parametric evaluation points
  • out: 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.

source
TinyGismo.deriv — Function
deriv(obj::Union{gsBasis, gsGeometry}, u::Union{Vector{Float64}, Matrix{Float64}})

Evaluate the first derivative.

Arguments

  • obj: A basis or geometry object
  • u: Parametric evaluation points

Returns

For basis objects, returns a matrix of basis function derivatives. For geometry objects, returns a matrix of derivative (tangent) vectors.

source
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 basis
  • i: The basis function index (1-indexed)
  • u: Parametric evaluation points
  • out: Output gsMatrix{Float64} (modified in-place)
source
TinyGismo.derivSingle — Function
derivSingle(basis::gsBasis, i::Int, u::Vector{Float64})

Evaluate the first derivative of a single basis function.

Arguments

  • basis: The basis
  • i: The basis function index (1-indexed)
  • u: Parametric evaluation points

Returns

The derivative values

source
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 basis
  • u: Parametric evaluation points
  • coefs: Control point coefficients (vector or matrix)

Returns

A matrix of derivative values

source
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 object
  • u: Parametric evaluation points
  • out: 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.

source
TinyGismo.deriv2 — Function
deriv2(obj::Union{gsBasis, gsGeometry}, u::Union{Vector{Float64}, Matrix{Float64}})

Evaluate the second derivative.

Arguments

  • obj: A basis or geometry object
  • u: Parametric evaluation points

Returns

A matrix of second derivative vectors

source
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 basis
  • i: The basis function index (1-indexed)
  • u: Parametric evaluation points
  • out: Output gsMatrix{Float64} (modified in-place)
source
TinyGismo.deriv2Single — Function
deriv2Single(basis::gsBasis, i::Int, u::Vector{Float64})

Evaluate the second derivative of a single basis function.

Arguments

  • basis: The basis
  • i: The basis function index (1-indexed)
  • u: Parametric evaluation points

Returns

The second derivative values

source
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 basis
  • u: Parametric evaluation points
  • coefs: Control point coefficients (vector or matrix)

Returns

A matrix of second derivative values

source

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.

source
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.

source
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 function
  • numKnots: 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 space
source

B-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)
source
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)
source

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 basis
  • i: The parametric direction (default: 1)

Returns

The knot vector for direction i

source
TinyGismo.knot — Function
knot(basis::BSplineBasis, i::Int)

Get the i-th knot value.

Arguments

  • basis: The B-spline basis
  • i: The knot index

Returns

The knot value at index i

source
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 basis
  • side: A boxSide (1/2 west and east, 3/4 south and north), not a parametric direction. The result is the number of elements lying along that boundary side. Passing 0 (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)).

source
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

source
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 object
  • i: 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)
source
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)

source
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 basis
  • i: The parametric direction (1-indexed)

Returns

The univariate B-spline basis for direction i

source

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
source

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 insert
  • mult: The multiplicity of insertion (default: 1)

Note

This operation modifies the basis in-place.

source
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 remove
  • mult: The multiplicity of removal (default: 1)

Note

This operation modifies the basis in-place.

source
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.

source

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 basis
  • weights: 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)
source
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 direction
  • weights: 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)
source

Query Functions

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 refinementUse
THBSplineBasisyesthe usual choice
HBSplineBasisnowhen 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.

source
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.

source

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.

source
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.

source
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.

source
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.

source
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).

source

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.

source

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 ranges

See refineElements! and unrefineElements!.

source
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!.

source
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!.

source
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)])
source
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.

source
TinyGismo.refineElements_withCoefs! — Function
refineElements_withCoefs!(basis, coefs::Matrix{Float64}, boxes) -> gsMatrix

Refine 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!.

source
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.

source
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.

source

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.