Utilities

Utility types and functions for working with Gismo objects.

Knot Span

TinyGismo.KnotSpan — Type
KnotSpan

A single element of the parametric mesh — one knot span of a basis, i.e. one box in the parameter domain on which the basis is a polynomial.

KnotSpan objects are not constructed directly; they are obtained from knotSpans, which returns one per element of a basis.

Common Methods

Each returns a gsVector with one entry per parametric direction, so a knot span of a univariate basis is described by one-element vectors and a knot span of a surface basis by two-element vectors.

Examples

basis = BSplineBasis(KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0]))for span in knotSpans(basis)    lo, up = toVector(lowerCorner(span)), toVector(upperCorner(span))end
source

Matrix and Vector Types

Gismo uses its own matrix and vector types for efficient computation and interfacing with C++.

Constructors

TinyGismo.gsMatrix — Type
gsMatrix{T}()
gsMatrix{T}(rows::Int, cols::Int)

Construct a Gismo matrix with specified dimensions. If you don't specify a type, type constructions defaults to Float64.

Arguments

  • rows: Number of rows
  • cols: Number of columns

Type Parameters

  • T: Element type (typically Float64, Int32, or Int64)

Returns

A gsMatrix object

Details

gsMatrix is a parametric type used throughout Gismo for matrix operations. It's commonly used as output parameters in bang methods (methods ending with !).

Elements are read with TinyGismo.value or m[i, j] and written with TinyGismo.setValue!, so a gsMatrix can be filled directly as well as by being passed to a bang method.

Examples

# Create a matrix for outputout = gsMatrix{Float64}()eval!(geometry, u, out)# Create an integer matrix for active basis indicesactive_out = gsMatrix{Int32}()active!(basis, u, active_out)
source
TinyGismo.gsVector — Type
gsVector{T}()
gsVector{T}(rows::Int)

Construct a Gismo vector with specified length. If you don't specify a type, type constructions defaults to Float64.

Arguments

  • rows: Number of elements

Type Parameters

  • T: Element type (typically Float64, Int32, or Int64)

Returns

A gsVector object

Details

gsVector is a parametric type used throughout Gismo for vector operations.

Examples

result = gsVector{Float64}(3)closestPointTo(geometry, pt, result)
source

Size and Dimension Queries

Base.size — Method
Base.size(matrix::gsMatrix)

Get the dimensions of the matrix as a (rows, cols) tuple.

Unlike the counts above this follows the usual Base.size contract for array-like objects, so size(m, 1) and generic code that walks the axes behave as expected. gsMatrix supports m[i, j], which makes a dimension tuple the far less surprising choice here.

Use length for the total number of entries, which is what the C++ size() method returns.

source
Base.size — Method
Base.size(matrix::gsMatrix, d::Integer)

Get the extent of the matrix along dimension d.

Returns 1 for d > 2, as Base does for any array: size(A, d) is not an error beyond ndims(A), and generic code relies on that.

source
Base.size — Method
Base.size(vector::gsVector, d::Integer)

Get the extent of the vector along dimension d, which is its length for d == 1 and 1 beyond, matching Base.

source
Base.length — Method
Base.length(obj::Union{gsMatrix, gsVector})

Get the total number of entries — rows * cols for a matrix.

This is the value the underlying C++ size() method returns.

source
TinyGismo.rows — Function
rows(obj::Union{gsMatrix, gsVector})

Get the number of rows in a matrix or vector.

Arguments

  • obj: A gsMatrix or gsVector object

Returns

The number of rows

source
TinyGismo.cols — Function
cols(obj::Union{gsMatrix, gsVector})

Get the number of columns in a matrix or vector.

Arguments

  • obj: A gsMatrix or gsVector object

Returns

The number of columns (1 for vectors)

source
TinyGismo.size — Function
TinyGismo.size(obj)

The raw C++ size() method: the number of basis functions of a basis, the number of knots of a knot vector, or the total number of entries of a matrix or vector.

Arguments

Returns

The count, as an unsigned integer

Note

Prefer the Base methods, which need no TinyGismo. prefix:

  • size(basis) and size(kv) forward here and return the same count.
  • size(m) on a matrix or vector returns a dimension tuple instead, following the usual Base.size contract, with length(m) giving the total entry count that this method returns.
source

Conversion Functions

TinyGismo.toMatrix — Function
toMatrix(matrix::gsMatrix)

Convert a gsMatrix to a Julia array.

Arguments

  • matrix: The gsMatrix

Returns

A Julia Matrix with the same dimensions and values

source
TinyGismo.toVector — Function
toVector(matrix::gsMatrix)

Convert a single-column gsMatrix to a Julia vector.

Arguments

  • matrix: The gsMatrix (must have exactly one column)

Returns

A Julia Vector

Throws

RuntimeError if the matrix has more than one column

source
TinyGismo.toValue — Function
toValue(matrix::gsMatrix)

Extract the single value from a 1×1 gsMatrix.

Arguments

  • matrix: The gsMatrix (must be 1×1)

Returns

The scalar value

Throws

RuntimeError if the matrix has more than one element

source

Element Access

TinyGismo.value — Function
value(matrix::gsMatrix, i::Int, j::Int)
value(vector::gsVector, i::Int)

Get a matrix or vector element with bounds checking.

Arguments

  • matrix/vector: The gsMatrix or gsVector
  • i: Row/element index (1-indexed)
  • j: Column index (for matrices only, 1-indexed)

Returns

The value at the specified position

Throws

RuntimeError if indices are out of bounds

source
TinyGismo._value — Function
_value(matrix::gsMatrix, i::Int, j::Int)

Get a matrix element without bounds checking (unsafe).

Arguments

  • matrix: The gsMatrix
  • i: Row index (1-indexed)
  • j: Column index (1-indexed)

Returns

The value at position (i, j)

Warning

This method does not perform bounds checking. Use value() for safe access.

source
TinyGismo.setValue! — Function
setValue!(matrix::gsMatrix, i::Int, j::Int, value)
setValue!(vector::gsVector, i::Int, value)

Write a single element of a gsMatrix or gsVector, with bounds checking.

Arguments

  • matrix/vector: The gsMatrix or gsVector (modified in-place)
  • i: Row/element index (1-indexed)
  • j: Column index (for matrices only, 1-indexed)
  • value: The value to store

Details

Together with the sized constructor this lets you build a gsMatrix yourself, which is what the constructors taking a gsMatrix of coefficients need:

cm = gsMatrix(6, 2)for j in 1:2, i in 1:6    setValue!(cm, i, j, coefs[i, j])endsurface = TensorBSpline{2}(kv1, kv2, cm)

Throws

RuntimeError if indices are out of bounds

source