Geometry¶
Classes and functions for creating and manipulating tensor product Bspline and NURBS patches.
See Geometry manipulation in pyiga for examples on how to create custom geometries.

class
pyiga.geometry.
NurbsFunc
(kvs, coeffs, weights, premultiplied=False)¶ Any function that is given in terms of a tensor product NURBS basis with coefficients and weights.
Parameters:  kvs (seq) – tuple of d
KnotVector
s.  coeffs (ndarray) – coefficient array; see
BSplineFunc
for format. The constructor may modify coeffs during premultiplication!  weights (ndarray) – coefficients for weight function in the same format as coeffs. If weights=None is passed, the weights are assumed to be given as the last vector component of coeffs instead.
 premultiplied (bool) – pass True if the coefficients are already premultiplied by the weights.

kvs
¶ the knot vectors representing the tensor product basis
Type: seq

coeffs
¶ the premultiplied coefficients for the function, including the weights in the last vector component
Type: ndarray

sdim
¶ dimension of the parameter domain
Type: int

dim
¶ dimension of the output of the function
Type: int
The evaluation functions have the same prototypes and behavior as those in
BSplineFunc
.
apply_matrix
(A)¶ Apply a matrix to each control point of this function, leave the weights unchanged, and return the result.
A should either be a single matrix or an array of matrices, one for each control point. Standard numpy broadcasting rules apply.

boundary
(bdspec)¶ Return one side of the boundary as a
NurbsFunc
.Parameters: bdspec – the side of the boundary to return; see compute_dirichlet_bc()
Returns: NurbsFunc
– representation of the boundary side; has sdim reduced by 1 and the same dim as this function

coeffs_weights
()¶ Return the nonpremultiplied coefficients and weights as a pair of arrays.

is_scalar
()¶ Returns True if the function is scalarvalued.

is_vector
()¶ Returns True if the function is vectorvalued.

scale
(factor)¶ Scale all control points either by a scalar factor or componentwise by a vector, leave the weights unchanged, and return the resulting new function.

support
¶ Return a sequence of pairs (lower,upper), one per source dimension, which describe the extent of the support in the parameter space.

translate
(offset)¶ Return a version of this geometry translated by the specified offset.
 kvs (seq) – tuple of d

class
pyiga.geometry.
UserFunction
(f, support, dim=None, jac=None)¶ A function (supporting the same basic protocol as
BSplineFunc
) which is given in terms of a userdefined callable.Parameters:  f (callable) – a function of d variables; may be scalar or vectorvalued
 support – a sequence of d pairs of the form (lower,upper) describing
the support of the function (see
BSplineFunc.support
)  dim (int) – the dimension of the function output; by default, is automatically determined by calling f
 jac (callable) – optionally, a function evaluating the Jacobian matrix of the function
The
sdim
attribute (seeBSplineFunc.sdim
) is determined from the length of support.

pyiga.geometry.
bspline_quarter_annulus
(r1=1.0, r2=2.0)¶ A Bspline approximation of a quarter annulus in the first quadrant.
Parameters:  r1 (float) – inner radius
 r2 (float) – outer radius
Returns: BSplineFunc
2D geometry

pyiga.geometry.
circle
(r=1.0)¶ Construct a circle with radius r using NURBS.

pyiga.geometry.
circular_arc
(alpha, r=1.0)¶ Construct a circular arc with angle alpha and radius r.
The arc is centered at the origin, starts on the positive x axis and travels in counterclockwise direction.

pyiga.geometry.
circular_arc_3pt
(alpha, r=1.0)¶ Construct a circular arc with angle alpha and radius r using 3 control points.
The angle alpha must be between 0 and pi.

pyiga.geometry.
circular_arc_5pt
(alpha, r=1.0)¶ Construct a circular arc with angle alpha and radius r using 5 control points.

pyiga.geometry.
circular_arc_7pt
(alpha, r=1.0)¶ Construct a circular arc with angle alpha and radius r using 7 control points.

pyiga.geometry.
identity
(extents)¶ Identity mapping (using linear splines) over a ddimensional box given by extents as a list of (min,max) pairs or of
KnotVector
.Returns: BSplineFunc
geometry

pyiga.geometry.
line_segment
(x0, x1, support=(0.0, 1.0), intervals=1)¶ Return a
BSplineFunc
which describes the line between the vectors x0 and x1.If specified, support describes the interval in which the function is supported; by default, it is the interval (0,1).
If specified, intervals is the number of intervals in the underlying linear spline space. By default, the minimal spline space with 2 dofs is used.

pyiga.geometry.
outer_product
(G1, G2)¶ Compute the outer product of two
BSplineFunc
orNurbsFunc
geometries. This means that given two input functions\[G_1(y), G_2(x),\]it returns a new function
\[G(x,y) = G_1(y) G_2(x),\]where the multiplication is componentwise in the case of vector functions. The returned function is a
NurbsFunc
if either input is and aBSplineFunc
otherwise. It has source dimension (BSplineFunc.sdim
) equal to the sum of the source dimensions of the input functions.G1 and G2 should have the same image dimension (
BSplineFunc.dim
), and the output then has the same as well. However, broadcasting according to standard Numpy rules is permissible; e.g., one function can be vectorvalued and the other scalarvalued.The coefficients of the result are the pointwise products of the coefficients of the input functions over a new tensor product spline space.

pyiga.geometry.
outer_sum
(G1, G2)¶ Compute the outer sum of two
BSplineFunc
orNurbsFunc
geometries. This means that given two input functions\[G_1(y), G_2(x),\]it returns a new function
\[G(x,y) = G_1(y) + G_2(x).\]The returned function is a
NurbsFunc
if either input is and aBSplineFunc
otherwise. It has source dimension (BSplineFunc.sdim
) equal to the sum of the source dimensions of the input functions.G1 and G2 should have the same image dimension (
BSplineFunc.dim
), and the output then has the same as well. However, broadcasting according to standard Numpy rules is permissible; e.g., one function can be vectorvalued and the other scalarvalued.The coefficients of the result are the pointwise sums of the coefficients of the input functions over a new tensor product spline space.

pyiga.geometry.
perturbed_square
(num_intervals=5, noise=0.02)¶ Randomly perturbed unit square.
Unit square with given number of intervals per direction; the control points are perturbed randomly according to the given noise level.
Returns: BSplineFunc
2D geometry

pyiga.geometry.
quarter_annulus
(r1=1.0, r2=2.0)¶ A NURBS representation of a quarter annulus in the first quadrant.
Parameters:  r1 (float) – inner radius
 r2 (float) – outer radius
Returns: NurbsFunc
2D geometry

pyiga.geometry.
semicircle
(r=1.0)¶ Construct a semicircle in the upper halfplane with radius r using NURBS.

pyiga.geometry.
tensor_product
(G1, G2, *Gs)¶ Compute the tensor product of two or more
BSplineFunc
orNurbsFunc
functions. This means that given two input functions\[G_1(y), G_2(x),\]it returns a new function
\[G(x,y) = G_2(x) \times G_1(y),\]where \(\times\) means that vectors are joined together. The resulting
BSplineFunc
orNurbsFunc
has source dimension (BSplineFunc.sdim
) equal to the sum of the source dimensions of the input functions, and target dimension (BSplineFunc.dim
) equal to the sum of the target dimensions of the input functions.

pyiga.geometry.
twisted_box
()¶ A 3D volume that resembles a box with its right face twisted and bent upwards.
Corresponds to gismo data file twistedFlatQuarterAnnulus.xml.
Returns: BSplineFunc
3D geometry

pyiga.geometry.
unit_cube
(dim=3, num_intervals=1)¶ The dimdimensional unit cube with num_intervals intervals per coordinate direction.
Returns: BSplineFunc
geometry

pyiga.geometry.
unit_square
(num_intervals=1)¶ Unit square with given number of intervals per direction.
Returns: BSplineFunc
2D geometry