Skip to content
ForCADDocumentation

forcad_utils Module

Build coordinate grids and rectangular control nets, form rotation matrices, and solve dense systems. Import ndgrid, hexahedron_Xc, rotation, and solve from forcad.

This module contains the public building blocks behind the single- and multipatch APIs. Real arguments use rk, and tensor-product indices are flattened with direction 1 varying fastest. Mathematical subscripts in this module are zero-based unless stated otherwise; Fortran array indices and returned connectivity are one-based. A documented mathematical precondition is not necessarily checked at run time: each procedure states whether an invalid input is represented by a sentinel result or must be excluded by the caller.

B-spline convention

Let . For degree , control count , and knot vector , a spline space requires , equivalently . The active interval is . In Fortran indexing these bounds are knot(degree+1) and knot(nc+1). Basis values use the Cox-de Boor recurrence and are right-continuous on interior spans; the final active endpoint is included explicitly. Rational tensor bases are

[ N_{i,0}(u)= \begin{cases} 1,&u_i\le u



Interfaces

public interface basis_bspline_2der

Evaluate B-spline basis derivatives through second order.

Optional overloads return the lower derivative orders in the same call.

  • private pure subroutine basis_bspline_2der_A(Xt, knot, nc, degree, d2B, dB, B)

    Evaluate dense B-spline values and derivatives through second order.

    Each output has length nc; unsupported derivatives, including all second derivatives when degree<2, are returned as zero.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: Xt

    Evaluation parameter.

    real(kind=rk), intent(in), contiguous :: knot(:)

    Complete knot vector of size nc+degree+1.

    integer, intent(in) :: nc

    Number of basis functions.

    integer, intent(in) :: degree

    Polynomial degree .

    real(kind=rk), intent(out) :: d2B(nc)

    Second derivatives .

    real(kind=rk), intent(out) :: dB(nc)

    First derivatives .

    real(kind=rk), intent(out) :: B(nc)

    Basis values .

  • private pure subroutine basis_bspline_2der_B(Xt, knot, nc, degree, d2B, dB)

    Evaluate dense first and second derivatives of a B-spline basis.

    Values are omitted; both derivative arrays have length nc and are zero outside the local support.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: Xt

    Evaluation parameter.

    real(kind=rk), intent(in), contiguous :: knot(:)

    Complete knot vector of size nc+degree+1.

    integer, intent(in) :: nc

    Number of basis functions.

    integer, intent(in) :: degree

    Polynomial degree .

    real(kind=rk), intent(out) :: d2B(nc)

    Second derivatives .

    real(kind=rk), intent(out) :: dB(nc)

    First derivatives .

  • private pure subroutine basis_bspline_2der_C(Xt, knot, nc, degree, d2B)

    Evaluate only the dense second derivative of a B-spline basis.

    The output has length nc; entries outside local support and all entries for degree<2 are zero.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: Xt

    Evaluation parameter.

    real(kind=rk), intent(in), contiguous :: knot(:)

    Complete knot vector of size nc+degree+1.

    integer, intent(in) :: nc

    Number of basis functions.

    integer, intent(in) :: degree

    Polynomial degree .

    real(kind=rk), intent(out) :: d2B(nc)

    Second derivatives .

public interface basis_bspline_der

Evaluate first derivatives or a requested low-order local derivative table.

The local overload also returns the first active control index and avoids allocating a dense nc-entry basis vector.

  • private pure subroutine basis_bspline_active_ders(Xt, knot, nc, degree, nder, first, N, dN, d2N)

    Return local basis values and optional first or second derivatives. This convenience overload requests at most order two from basis_bspline_der_all_active and never forms a dense nc-vector.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: Xt
    real(kind=rk), intent(in), contiguous :: knot(:)
    integer, intent(in) :: nc
    integer, intent(in) :: degree
    integer, intent(in) :: nder
    integer, intent(out) :: first
    real(kind=rk), intent(out), optional :: N(0:degree)
    real(kind=rk), intent(out), optional :: dN(0:degree)
    real(kind=rk), intent(out), optional :: d2N(0:degree)
  • private pure subroutine basis_bspline_der_A(Xt, knot, nc, degree, dB, B)

    Evaluate the dense B-spline basis and its first derivative at one parameter.

    Both outputs have length nc; entries outside the local support are zero. This is the value-and-derivative overload of basis_bspline_der.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: Xt

    Evaluation parameter.

    real(kind=rk), intent(in), contiguous :: knot(:)

    Complete knot vector of size nc+degree+1.

    integer, intent(in) :: nc

    Number of basis functions.

    integer, intent(in) :: degree

    Polynomial degree .

    real(kind=rk), intent(out) :: dB(nc)

    First derivatives .

    real(kind=rk), intent(out) :: B(nc)

    Basis values .

  • private pure subroutine basis_bspline_der_B(Xt, knot, nc, degree, dB)

    Evaluate only the dense first derivative of a B-spline basis.

    The output has length nc; entries outside the local support are zero.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: Xt

    Evaluation parameter.

    real(kind=rk), intent(in), contiguous :: knot(:)

    Complete knot vector of size nc+degree+1.

    integer, intent(in) :: nc

    Number of basis functions.

    integer, intent(in) :: degree

    Polynomial degree .

    real(kind=rk), intent(out) :: dB(nc)

    First derivatives .

public interface boundary_index

Return flattened indices on a curve endpoint, surface edge, or volume face.

reverse, swap, and flip options map interface orientation without copying the associated control net.

  • private pure subroutine boundary_index_1d(nc, side, reverse, idx)

    Return the selected endpoint index of a one-dimensional control array.

    Side 1 is the minimum endpoint and side 2 the maximum endpoint. Because an endpoint contains one index, reverse has no effect. An invalid side returns the sentinel array [0].

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nc

    Number of controls.

    integer, intent(in) :: side

    Endpoint identifier, 1 for minimum or 2 for maximum.

    logical, intent(in) :: reverse

    Orientation flag; immaterial for a single endpoint.

    integer, intent(out), allocatable :: idx(:)

    One-element endpoint index, or [0] for an invalid side.

  • private pure subroutine boundary_index_2d(nc, side, reverse, idx)

    Return direction-1-fastest control indices on one surface edge.

    Sides 1:4 denote u_min, u_max, v_min, and v_max. The output is ordered along the tangential direction and reverse reverses that ordering. An invalid side returns an empty array.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), contiguous :: nc(:)

    Directional control counts [nu,nv].

    integer, intent(in) :: side

    Surface-edge identifier in 1:4.

    logical, intent(in) :: reverse

    Reverse tangential output ordering when true.

    integer, intent(out), allocatable :: idx(:)

    Flattened one-based edge indices.

  • private pure subroutine boundary_index_3d(nc, side, reverse, swap, flip, idx)

    Return direction-1-fastest control indices on one volume face.

    Sides 1:6 denote the minimum and maximum faces normal to directions 1, 2, and 3. swap exchanges the two face coordinates, flip reverses either mapped coordinate, and reverse reverses the final flattened ordering. An invalid side returns an empty array.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), contiguous :: nc(:)

    Directional control counts [nu,nv,nw].

    integer, intent(in) :: side

    Volume-face identifier in 1:6.

    logical, intent(in) :: reverse

    Reverse the final face ordering when true.

    logical, intent(in) :: swap

    Exchange the two tangential face directions when true.

    logical, intent(in), contiguous :: flip(:)

    Tangential-axis reversal flags; up to the first two entries apply.

    integer, intent(out), allocatable :: idx(:)

    Flattened one-based face indices.

public interface boundary_layer_index

Return flattened indices in a layer measured inward from a boundary.

Layer zero is the boundary itself. Positive layers support arbitrary and interface stencils.

  • private pure subroutine boundary_layer_index_1d(nc, side, layer, reverse, idx)

    Return the endpoint-normal control index at a specified inward layer.

    layer=0 selects the endpoint itself. Side 1 advances from the minimum endpoint and side 2 from the maximum endpoint. This low-level routine assumes `0<=layer

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nc

    Number of controls.

    integer, intent(in) :: side

    Endpoint identifier, 1 for minimum or 2 for maximum.

    integer, intent(in) :: layer

    Zero-based inward layer.

    logical, intent(in) :: reverse

    Orientation flag; immaterial for a one-entry layer.

    integer, intent(out), allocatable :: idx(:)

    One-element layer index, or [0] for an invalid side.

  • private pure subroutine boundary_layer_index_2d(nc, side, layer, reverse, idx)

    Return surface-control indices in an inward layer parallel to one edge.

    Sides and ordering follow boundary_index. layer=0 is the boundary; positive values advance along its inward normal control direction. This low-level routine assumes the layer lies inside the control net.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), contiguous :: nc(:)

    Directional control counts [nu,nv].

    integer, intent(in) :: side

    Surface-edge identifier in 1:4.

    integer, intent(in) :: layer

    Zero-based inward layer.

    logical, intent(in) :: reverse

    Reverse tangential output ordering when true.

    integer, intent(out), allocatable :: idx(:)

    Flattened one-based layer indices; empty for an invalid side.

  • private pure subroutine boundary_layer_index_3d(nc, side, layer, reverse, swap, flip, idx)

    Return volume-control indices in an inward layer parallel to one face.

    Face identifiers and orientation options follow boundary_index. layer=0 is the boundary face; positive layers advance along the inward normal control direction. The caller must supply an in-range layer.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), contiguous :: nc(:)

    Directional control counts [nu,nv,nw].

    integer, intent(in) :: side

    Volume-face identifier in 1:6.

    integer, intent(in) :: layer

    Zero-based inward layer.

    logical, intent(in) :: reverse

    Reverse the final face ordering when true.

    logical, intent(in) :: swap

    Exchange the two tangential directions when true.

    logical, intent(in), contiguous :: flip(:)

    Tangential-axis reversal flags; up to the first two entries apply.

    integer, intent(out), allocatable :: idx(:)

    Flattened one-based layer indices; empty for an invalid side.

public interface compute_multiplicity

Count exact knot multiplicities for one knot or an array of knots.

Callers that compare independently generated floating-point knots should first apply a tolerance policy; multiplicity itself follows knot-vector representation and therefore uses exact stored values.

  • private pure function compute_multiplicity1(knot) result(multiplicity)

    Return exact consecutive run lengths in stored knot order. For a nondecreasing knot vector, each value occupies one run and these are its mathematical knot multiplicities. For arbitrary input, equal values in separated runs produce separate entries. Equality is exact.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: knot(:)

    Return Value integer, allocatable, (:)

  • private pure function compute_multiplicity2(knot, Xth) result(multiplicity)

    Return the longest exact consecutive run of one stored knot value. For a nondecreasing knot vector this is its knot multiplicity. For arbitrary input with separated equal runs, the result is the maximum run length rather than the total occurrence count. Zero means absent.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: knot(:)
    real(kind=rk), intent(in) :: Xth

    Return Value integer

public interface dyad

Compute the dyadic product .

  • private pure function dyad_t1_t1(a, b) result(c)

    Form the dyadic product of two real vectors.

    The allocated result has shape [size(a),size(b)] and entries .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: a(:)

    Row-index factor.

    real(kind=rk), intent(in), contiguous :: b(:)

    Column-index factor.

    Return Value real(kind=rk), allocatable, (:,:)

    Allocated dyadic-product matrix.

public interface elemConn_C0

Build one-based tensor-product element connectivity.

These constructors describe a regular positive-degree layout: each directional count must satisfy nnode=nelem*p+1 with p>=1. Overloads accept scalar counts for curves and directional counts for surfaces or volumes. Direction 1 varies fastest in every element row. Use elemConn_Cn or the rank-specific NURBS cmp_elem bindings for arbitrary knot vectors, repeated knots, or degree-zero spaces.

  • private pure function cmp_elemConn_C0_L(nnode, p) result(elemConn)

    Build curve connectivity for degree-p elements joined with . The required node count satisfies nnode=nelem*p+1.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nnode
    integer, intent(in) :: p

    Return Value integer, allocatable, (:,:)

  • private pure function cmp_elemConn_C0_S(nnode1, nnode2, p1, p2) result(elemConn)

    Build direction-1-fastest tensor connectivity for a surface. The result has local controls per element.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nnode1
    integer, intent(in) :: nnode2
    integer, intent(in) :: p1
    integer, intent(in) :: p2

    Return Value integer, allocatable, (:,:)

  • private pure function cmp_elemConn_C0_V(nnode1, nnode2, nnode3, p1, p2, p3) result(elemConn)

    Build direction-1-fastest tensor connectivity for a volume. The result has controls per element.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nnode1
    integer, intent(in) :: nnode2
    integer, intent(in) :: nnode3
    integer, intent(in) :: p1
    integer, intent(in) :: p2
    integer, intent(in) :: p3

    Return Value integer, allocatable, (:,:)

public interface elemConn_Cn

Build one-based connectivity from active knots and knot multiplicities.

In each direction, size(Xth)-1 supplies the number of active spans; the numerical values in Xth are not inspected. Interior entries vecKnot_mul(2:nelem) shift the first supported control index by the stored knot multiplicity. Entry 1 and the final active-endpoint multiplicity are not used. For a valid degree- spline direction, the metadata must satisfy

where is the multiplicity at the interior active knot preceding element . The routines check only basic array dimensions; callers must provide consistent positive multiplicities and control counts. At multiplicity , the spline space has guaranteed continuity . Returned support indices are one-based, with direction 1 varying fastest.

  • private pure subroutine cmp_elemConn_Cn_L(nnode, p, Xth, vecKnot_mul, elemConn)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nnode

    Control count and nonnegative polynomial degree.

    integer, intent(in) :: p

    Control count and nonnegative polynomial degree.

    real(kind=rk), intent(in), contiguous :: Xth(:)

    Active-knot metadata; only its size is used.

    integer, intent(in), contiguous :: vecKnot_mul(:)

    Run data whose entries 2:nelem determine support shifts.

    integer, intent(out), allocatable :: elemConn(:,:)

    One-based connectivity [nelem,p+1], or shape [0,0] for invalid dimensions.

  • private pure subroutine cmp_elemConn_Cn_S(nnode1, nnode2, p1, p2, Xth1, Xth2, vecKnot_mul1, vecKnot_mul2, elemConn)

    Build surface connectivity as the tensor product of two span maps. Rows and local controls both use direction-1-fastest ordering. The knot values are not read; each directional size supplies its element count. Directional control counts and multiplicities must satisfy the scalar consistency relation documented by elemConn_Cn.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nnode1

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: nnode2

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: p1

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: p2

    Directional control counts and nonnegative polynomial degrees.

    real(kind=rk), intent(in), contiguous :: Xth1(:)

    Active-knot metadata; only the two array sizes are used.

    real(kind=rk), intent(in), contiguous :: Xth2(:)

    Active-knot metadata; only the two array sizes are used.

    integer, intent(in), contiguous :: vecKnot_mul1(:)

    Stored multiplicities corresponding to Xth1 and Xth2.

    integer, intent(in), contiguous :: vecKnot_mul2(:)

    Stored multiplicities corresponding to Xth1 and Xth2.

    integer, intent(out), allocatable :: elemConn(:,:)

    Direction-1-fastest one-based connectivity, or shape [0,0] for invalid dimensions.

  • private pure subroutine cmp_elemConn_Cn_V(nnode1, nnode2, nnode3, p1, p2, p3, Xth1, Xth2, Xth3, vecKnot_mul1, vecKnot_mul2, vecKnot_mul3, elemConn)

    Build volume connectivity as the tensor product of three span maps. Rows and local controls both use direction-1-fastest ordering. Knot values are not read; directional array sizes supply element counts. Every directional control count and multiplicity vector must satisfy the scalar consistency relation documented by elemConn_Cn.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: nnode1

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: nnode2

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: nnode3

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: p1

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: p2

    Directional control counts and nonnegative polynomial degrees.

    integer, intent(in) :: p3

    Directional control counts and nonnegative polynomial degrees.

    real(kind=rk), intent(in), contiguous :: Xth1(:)

    Active-knot metadata; only the three array sizes are used.

    real(kind=rk), intent(in), contiguous :: Xth2(:)

    Active-knot metadata; only the three array sizes are used.

    real(kind=rk), intent(in), contiguous :: Xth3(:)

    Active-knot metadata; only the three array sizes are used.

    integer, intent(in), contiguous :: vecKnot_mul1(:)

    Stored multiplicities corresponding to the directional active knots.

    integer, intent(in), contiguous :: vecKnot_mul2(:)

    Stored multiplicities corresponding to the directional active knots.

    integer, intent(in), contiguous :: vecKnot_mul3(:)

    Stored multiplicities corresponding to the directional active knots.

    integer, intent(out), allocatable :: elemConn(:,:)

    Direction-1-fastest one-based connectivity, or shape [0,0] for invalid dimensions.

public interface gauss_leg

Generate tensor-product Gauss-Legendre points and weights.

Despite its name, degree is the number of quadrature points minus one. Thus points integrate every univariate polynomial of degree at most exactly in exact arithmetic. Tensor products have this directional exactness separately in each coordinate.

Original reference: C. F. Gauss, Methodus nova integralium valores per approximationem inveniendi, H. Dieterich, Gottingae, 1815. Digitized original.

  • private pure subroutine gauss_legendre_1D(interval, degree, Xksi, Wksi)

    Generate a one-dimensional Gauss-Legendre rule on an interval.

    degree+1 nodes integrate polynomials through degree 2*degree+1 in exact arithmetic. degree>=0 and size(interval)>=2 are unchecked shape preconditions. The first two interval entries must also be finite. When they are finite but not strictly increasing, allocated nodes and weights are filled with NaNs.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: interval(:)

    Integration interval; the first two entries are used.

    integer, intent(in) :: degree

    Quadrature order minus one; must be nonnegative.

    real(kind=rk), intent(out), allocatable :: Xksi(:)

    Allocated nodes and weights, each of length degree+1.

    real(kind=rk), intent(out), allocatable :: Wksi(:)

    Allocated nodes and weights, each of length degree+1.

  • private pure subroutine gauss_legendre_2D(interval1, interval2, degree, Xksi, Wksi)

    Generate a tensor-product Gauss-Legendre rule on a rectangle.

    Direction 1 varies fastest. Xksi has shape [(degree(1)+1)*(degree(2)+1),2]; Wksi contains the corresponding products of one-dimensional weights. degree must contain at least two nonnegative entries, and both interval arrays must contain at least two finite entries with increasing first pair; these preconditions are not shape-validated by this wrapper.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: interval1(:)

    Strictly increasing direction-1 interval.

    real(kind=rk), intent(in), contiguous :: interval2(:)

    Strictly increasing direction-2 interval.

    integer, intent(in), contiguous :: degree(:)

    Quadrature orders minus one [q1-1,q2-1].

    real(kind=rk), intent(out), allocatable :: Xksi(:,:)

    Flattened parameter pairs and tensor-product weights.

    real(kind=rk), intent(out), allocatable :: Wksi(:)

    Flattened parameter pairs and tensor-product weights.

  • private pure subroutine gauss_legendre_3D(interval1, interval2, interval3, degree, Xksi, Wksi)

    Generate a tensor-product Gauss-Legendre rule on a cuboid.

    Direction 1 varies fastest, then direction 2. Xksi has three columns and one row per tensor-product point; Wksi uses the same ordering. degree must contain at least three nonnegative entries, and every interval must contain at least two finite entries with increasing first pair; these preconditions are not shape-validated by this wrapper.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: interval1(:)

    Strictly increasing direction-1 interval.

    real(kind=rk), intent(in), contiguous :: interval2(:)

    Strictly increasing direction-2 interval.

    real(kind=rk), intent(in), contiguous :: interval3(:)

    Strictly increasing direction-3 interval.

    integer, intent(in), contiguous :: degree(:)

    Quadrature orders minus one [q1-1,q2-1,q3-1].

    real(kind=rk), intent(out), allocatable :: Xksi(:,:)

    Flattened parameter triples and tensor-product weights.

    real(kind=rk), intent(out), allocatable :: Wksi(:)

    Flattened parameter triples and tensor-product weights.

  • private pure subroutine gauss_legendre_tensor(intervals, degree, Xksi, Wksi, ig)

    Tensor Gauss rule in direction-1-fastest order, or just its one-based point ig. Column d holds the interval for axis d. An invalid selection returns an empty rule.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: intervals(:,:)
    integer, intent(in) :: degree(:)
    real(kind=rk), intent(out), allocatable :: Xksi(:,:)
    real(kind=rk), intent(out), allocatable :: Wksi(:)
    integer, intent(in), optional :: ig

public interface get_array

  • private pure subroutine get_real_vector(input, output, ok)

    Copy owned real-vector data or return an allocated empty result.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), allocatable :: input(:)
    real(kind=rk), intent(out), allocatable :: output(:)
    logical, intent(in) :: ok
  • private pure subroutine get_real_matrix(input, output, ok)

    Copy owned real-matrix data without an intermediate return-value array.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), allocatable :: input(:,:)
    real(kind=rk), intent(out), allocatable :: output(:,:)
    logical, intent(in) :: ok
  • private pure subroutine get_integer_matrix(input, output, ok)

    Copy owned connectivity or return an allocated empty result.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), allocatable :: input(:,:)
    integer, intent(out), allocatable :: output(:,:)
    logical, intent(in) :: ok

public interface infer_knot_shape

Infer directional control counts from flattened tensor-product knot data.

  • private pure subroutine infer_knot_shape_2d(knot1, knot2, ncp, degree, nc, ok)

    Infer a two-dimensional degree and control-net shape from knot lengths.

    Candidates satisfy and . The first candidate uses , where is the exact run length of the first knot. If that candidate is valid, it takes precedence; this is the usual open-clamped inference and no ambiguity search is performed. Otherwise, all degrees are searched and ok is true only for exactly one valid candidate. Ignore degree and nc when ok is false; after an ambiguous search they can retain the first candidate found.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: knot1(:)

    Directional knot vectors.

    real(kind=rk), intent(in), contiguous :: knot2(:)

    Directional knot vectors.

    integer, intent(in) :: ncp

    Flattened control-point count.

    integer, intent(out) :: degree(2)

    Inferred degrees and control counts; meaningful only when ok is true.

    integer, intent(out) :: nc(2)

    Inferred degrees and control counts; meaningful only when ok is true.

    logical, intent(out) :: ok

    True for a valid preferred candidate or a unique fallback candidate.

  • private pure subroutine infer_knot_shape_3d(knot1, knot2, knot3, ncp, degree, nc, ok)

    Infer a three-dimensional degree and control-lattice shape from knot lengths.

    Candidates satisfy and . The exact first-knot run lengths first define the preferred open-clamped candidate . A valid preferred candidate is returned without an ambiguity search. If it is invalid, exhaustive search succeeds only when exactly one candidate is valid. Ignore degree and nc when ok is false.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: knot1(:)

    Directional knot vectors.

    real(kind=rk), intent(in), contiguous :: knot2(:)

    Directional knot vectors.

    real(kind=rk), intent(in), contiguous :: knot3(:)

    Directional knot vectors.

    integer, intent(in) :: ncp

    Flattened control-point count.

    integer, intent(out) :: degree(3)

    Inferred degrees and control counts; meaningful only when ok is true.

    integer, intent(out) :: nc(3)

    Inferred degrees and control counts; meaningful only when ok is true.

    logical, intent(out) :: ok

    True for a valid preferred candidate or a unique fallback candidate.

public interface kron

Compute supported Kronecker products without calling matmul.

Overloads cover vector-vector, vector-matrix, and a three-factor tensor product. Their flattening order is consistent with ForCAD control nets.

  • private pure function kron_t1_t1(u, v) result(w)

    Form the Kronecker product of two vectors.

    The result is ordered in blocks of v: w((i-1)*size(v)+j)=u(i)*v(j).

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: u(:)

    Left vector.

    real(kind=rk), intent(in), contiguous :: v(:)

    Right vector, varying fastest in the result.

    Return Value real(kind=rk), (size(u)*size(v))

    Kronecker product of length size(u)*size(v).

  • private pure function kron_t1_t2(u, A) result(B)

    Form the Kronecker product of a vector and a matrix.

    Every row of A is scaled by each entry of u; the matrix columns are retained and the A row index varies fastest inside each u block.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: u(:)

    Left vector of length m.

    real(kind=rk), intent(in), contiguous :: A(:,:)

    Right matrix of shape [r,c].

    Return Value real(kind=rk), (size(u)*size(A,1),size(A,2))

    Kronecker product of shape [m*r,c].

  • private pure function kron_t2_t2(A, B) result(C)

    Matrix Kronecker product, with the right factor varying fastest.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: A(:,:)
    real(kind=rk), intent(in) :: B(:,:)

    Return Value real(kind=rk), (size(A,1)*size(B,1),size(A,2)*size(B,2))

  • private pure function kron3(u, v, w) result(out)

    Form a flattened three-vector tensor product.

    w varies fastest, followed by v and then u, matching the ordering used by the ForCAD tensor-product geometry modules.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: u(:)

    First tensor factor, varying slowest.

    real(kind=rk), intent(in), contiguous :: v(:)

    Second tensor factor.

    real(kind=rk), intent(in), contiguous :: w(:)

    Third tensor factor, varying fastest.

    Return Value real(kind=rk), (size(u)*size(v)*size(w))

    Flattened product u(i)*v(j)*w(k).

public interface ndgrid

Form a two- or three-dimensional tensor-product coordinate grid.

Returned point rows follow Fortran ordering: the first input vector varies fastest.

  • private pure subroutine ndgrid2(X_dir1, X_dir2, Xt)

    Form all pairs from two directional coordinate vectors. Row i+(j-1)*size(X_dir1) contains [X_dir1(i),X_dir2(j)].

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: X_dir1(:)
    real(kind=rk), intent(in), contiguous :: X_dir2(:)
    real(kind=rk), intent(out), allocatable :: Xt(:,:)
  • private pure subroutine ndgrid3(X_dir1, X_dir2, X_dir3, Xt)

    Form all triples from three directional coordinate vectors. Direction 1 varies fastest, followed by directions 2 and 3.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: X_dir1(:)
    real(kind=rk), intent(in), contiguous :: X_dir2(:)
    real(kind=rk), intent(in), contiguous :: X_dir3(:)
    real(kind=rk), intent(out), allocatable :: Xt(:,:)

public interface normalize_rational_basis

Normalize polynomial values and optional gradients over a supplied weight list. Used for element-local weights by the existing low-level basis interfaces.

  • private pure subroutine normalize_rational_basis_tensor(basis, weights, gradient)

    Apply R=Q/W and R_,a=(Q_,a-R*W_,a)/W with exact radix-power scaling. Values scale the weighted contributions, so inactive large weights cannot erase endpoint interpolation. Derivatives retain their common weight gauge. Values and gradient rows must match the finite positive weight list. A zero denominator or invalid shape/weights produces zero outputs.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(inout) :: basis(:)
    real(kind=rk), intent(in) :: weights(:)
    real(kind=rk), intent(inout), optional :: gradient(:,:)
  • private pure subroutine normalize_rational_basis_curve(basis, weights, gradient)

    View a curve gradient as one column, sharing the tensor calculation without a copy.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(inout) :: basis(:)
    real(kind=rk), intent(in) :: weights(:)
    real(kind=rk), intent(inout), target :: gradient(:)

public interface resize_buffer

  • private pure subroutine resize_buffer_1(buffer, counts)

    Retain an analysis work buffer when its shape is unchanged.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(inout), allocatable :: buffer(:)
    integer, intent(in) :: counts(1)
  • private pure subroutine resize_buffer_2(buffer, counts)

    Retain an analysis work buffer when its shape is unchanged.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(inout), allocatable :: buffer(:,:)
    integer, intent(in) :: counts(2)
  • private pure subroutine resize_buffer_3(buffer, counts)

    Retain an analysis work buffer when its shape is unchanged.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(inout), allocatable :: buffer(:,:,:)
    integer, intent(in) :: counts(3)
  • private pure subroutine resize_buffer_4(buffer, counts)

    Retain an analysis work buffer when its shape is unchanged.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(inout), allocatable :: buffer(:,:,:,:)
    integer, intent(in) :: counts(4)
  • private pure subroutine resize_buffer_5(buffer, counts)

    Retain an analysis work buffer when its shape is unchanged.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(inout), allocatable :: buffer(:,:,:,:,:)
    integer, intent(in) :: counts(5)

public interface unique

Return stable unique integer or real values in first-occurrence order.

  • private pure function unique_integer(vec) result(output)

    Return distinct integer values in stable first-occurrence order.

    Equality is exact. The implementation performs comparisons and uses temporary storage, so it is intended for short metadata and connectivity vectors rather than large unsorted datasets.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), contiguous :: vec(:)

    Input sequence; it is not sorted or modified.

    Return Value integer, allocatable, (:)

    Stable sequence of distinct values.

  • private pure function unique_real(vec) result(output)

    Return numerically distinct real values in stable first-occurrence order.

    Two entries are treated as equal when their absolute difference is at most 32*epsilon(1.0_rk)*maxval(abs(vec)). The comparison is therefore scale-relative but not transitive clustering. Complexity is .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), contiguous :: vec(:)

    Input sequence; an empty input returns an empty result.

    Return Value real(kind=rk), allocatable, (:)

    Stable sequence of tolerance-distinct values.

public interface valid_trace_side

  • private pure function valid_trace_scalar(side) result(valid)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), optional :: side

    Return Value logical

  • private pure function valid_trace_vector(side, ndim) result(valid)

    Accept the default trace or one selector in {-1,0,+1} per parameter.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), optional :: side(:)
    integer, intent(in) :: ndim

    Return Value logical


Derived Types

type, public ::  axis_transfer

Fine coefficients by row, coarse coefficients by column.

Components

Type Visibility Attributes Name Initial
integer, public, allocatable :: col(:)
integer, public, allocatable :: ptr(:)
real(kind=rk), public, allocatable :: val(:)

type, public ::  bernstein_span

One active B-spline span expressed in its own Bernstein coordinate.

Components

Type Visibility Attributes Name Initial
real(kind=rk), public :: bounds_knot(2)
real(kind=rk), public :: domain(2)
integer, public :: first

Functions

public pure function active_knot_multiplicity(knot, nc, degree) result(multiplicity)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Return multiplicities of distinct knots on the active interval. The result includes both active endpoints and follows their order in the knot vector. A valid nondecreasing vector is assumed. Invalid degree/count/size metadata or a nonpositive active interval returns an allocated zero-length array; other invariants are not checked.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree

Return Value integer, allocatable, (:)

public pure function active_knots(knot, nc, degree) result(Xth)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Return distinct stored knots on the closed active interval. A nondecreasing knot vector is a mathematical precondition. Invalid degree/count/size metadata returns an allocated zero-length array; other knot-vector invariants are not checked here.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree

Return Value real(kind=rk), allocatable, (:)

public pure function active_span(knot, nc, degree, element) result(span)

Locate a one-based positive-length element in the stored knot vector. Return zero for an absent element or invalid degree/count/size metadata.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree
integer, intent(in) :: element

Return Value integer

public pure function active_span_count(knot, nc, degree) result(nspan)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Count positive-length knot spans in the active interval. Repeated knots do not create zero-measure elements. A valid nondecreasing knot vector is assumed; only degree/count/size metadata is checked.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree

Return Value integer

public pure function basis_bernstein(Xt, nc) result(B)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Evaluate all Bernstein basis polynomials of degree nc-1 on [0,1].

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt

Bernstein parameter, normally in [0,1].

integer, intent(in) :: nc

Number of basis functions; the degree is nc-1.

Return Value real(kind=rk), allocatable, (:)

public pure function basis_bspline(Xt, knot, nc, degree) result(B)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Evaluate the complete degree-degree B-spline basis at one parameter.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt

Parameter value.

real(kind=rk), intent(in), contiguous :: knot(:)

Valid knot vector.

integer, intent(in) :: nc

Number of basis functions/control points.

integer, intent(in) :: degree

Polynomial degree.

Return Value real(kind=rk), (nc)

public pure function boundary_axes(side, swap, flip, reverse) result(axes)

Signed tangential storage axes, followed by the normal. An edge uses the first tangent.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: side
logical, intent(in), optional :: swap
logical, intent(in), optional :: flip(:)
logical, intent(in), optional :: reverse

Return Value integer, (3)

public pure function compute_knot_vector(Xth_dir, degree, continuity) result(knot)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Construct a knot vector from breakpoints and requested continuity.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: Xth_dir(:)

Ordered breakpoint values.

integer, intent(in) :: degree

Nonnegative polynomial degree .

integer, intent(in), contiguous :: continuity(:)

Repetition specification for every breakpoint. Shape mismatch, negative degree, or any value greater than degree returns an allocated empty vector.

Return Value real(kind=rk), allocatable, (:)

public pure function det(A) result(detA)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Compute a small determinant or a surface-Jacobian area factor.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: A(:,:)

Return Value real(kind=rk)

public pure function eye(n) result(I)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Allocate an n by n identity matrix.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Nonnegative matrix order.

Return Value real(kind=rk), allocatable, (:,:)

public pure function findspan(n, degree, Xth, knot, side) result(s)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Locate the zero-based knot span containing a parameter.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(in) :: degree
real(kind=rk), intent(in) :: Xth
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in), optional :: side

-1 for the left trace; omitted, 0 or +1 for the right trace.

Return Value integer

public pure function hexahedron_Xc(L, nc) result(Xc)

License
BSD 3-Clause

Generate a uniformly spaced axis-aligned hexahedral control net.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: L(:)

Signed axis extents [Lx,Ly,Lz].

integer, intent(in), contiguous :: nc(:)

Directional point counts [nx,ny,nz], each greater than one. The result has shape [product(nc),3], with x/direction 1 fastest.

Return Value real(kind=rk), allocatable, (:,:)

public pure function interpolatory_boundary_layer(knot, nc, degree, side) result(layer)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Return the inward layer interpolated by an active endpoint.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)

Valid knot vector.

integer, intent(in) :: nc

Number of basis functions.

integer, intent(in) :: degree

Polynomial degree.

integer, intent(in) :: side

Rank-specific side identifier in the range 1:6.

Return Value integer

public pure elemental function interval_ratio(a, b, lo, hi) result(value)

Compute (b-a)/(hi-lo) without overflowing a difference or its reciprocal.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: a
real(kind=rk), intent(in) :: b
real(kind=rk), intent(in) :: lo
real(kind=rk), intent(in) :: hi

Return Value real(kind=rk)

public pure recursive function inv(A) result(A_inv)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Compute a small inverse or full-rank Moore-Penrose pseudoinverse.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: A(:,:)

Return Value real(kind=rk), allocatable, (:,:)

public pure function knot_end(knot, nc, degree) result(b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Return the upper active parameter bound . Input is assumed to satisfy valid_knot_vector.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree

Return Value real(kind=rk)

public pure function knot_start(knot, nc, degree) result(a)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Return the lower active parameter bound . Input is assumed to satisfy valid_knot_vector.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree

Return Value real(kind=rk)

public pure function knot_tolerance(knot, first, last) result(tol)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Compute a scale- and span-aware tolerance for knot comparisons.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)

Knot vector; an empty vector returns zero.

integer, intent(in) :: first

First inspected one-based index, clamped to the array.

integer, intent(in) :: last

Last inspected one-based index; reversed bounds are accepted.

Return Value real(kind=rk)

public pure function kron_eye(A, ncoord) result(B)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Expand a scalar operator independently over ncoord components.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: A(:,:)

Scalar operator [m,n].

integer, intent(in) :: ncoord

Number of independent components.

Return Value real(kind=rk), allocatable, (:,:)

public pure function linspace(a, b, n) result(x)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Allocate n inclusive uniformly spaced values from a to b. n=1 returns [a]; n<1 returns a zero-length array.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: a
real(kind=rk), intent(in) :: b
integer, intent(in) :: n

Return Value real(kind=rk), allocatable, (:)

public pure function map_parameter(Xt, knot, nc, degree, wrap_parameter, side) result(u)

Optionally wrap one spline parameter into its active interval. Disabled wrapping and invalid spline states leave the parameter unchanged. Wrapping maps into , except that the left seam trace uses . It changes parameter evaluation only; cyclic geometry is not required.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt

Input parameter.

real(kind=rk), intent(in), contiguous :: knot(:)

Knot vector.

integer, intent(in) :: nc

Number of control points.

integer, intent(in) :: degree

Polynomial degree.

logical, intent(in) :: wrap_parameter

Enable modulo mapping when true.

integer, intent(in), optional :: side

A negative side takes the left trace at the wrapped seam.

Return Value real(kind=rk)

public pure function nearest_sample_index(points, query) result(index)

Stream finite metric rows and compare distances as fractionradix*power. Each coordinate pair is scaled before subtraction, so a huge common coordinate cannot erase a tiny residual in another coordinate. Only the shared query/point prefix participates; exact ties retain the first row.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: points(:,:)
real(kind=rk), intent(in) :: query(:)

Return Value integer

public pure function nonuniform_weights(Wc) result(nonuniform)

Only exactly equal weights cancel from the rational basis.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Wc(:)

Return Value logical

public pure function periodic_topology(knot, degree, Xc, Wc, nc, dir) result(periodic)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Verify a cyclic tensor-product spline topology in one parameter direction.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)

Complete candidate knot vector.

integer, intent(in) :: degree

Polynomial degree in the selected direction.

real(kind=rk), intent(in), contiguous :: Xc(:,:)

Curve controls, packed lines, or flattened tensor-product controls.

real(kind=rk), intent(in), optional, contiguous :: Wc(:)

Optional flattened positive rational weights.

integer, intent(in), optional, contiguous :: nc(:)

Optional tensor-product control counts.

integer, intent(in), optional :: dir

Selected tensor direction when nc is present.

Return Value logical

public pure function repelem(a, b) result(c)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Repeat each value according to a corresponding nonnegative count. Values retain input order. Shape mismatch or a negative count returns a zero-length array.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: a(:)

Values to repeat.

integer, intent(in), contiguous :: b(:)

Repetition counts with size(b)==size(a).

Return Value real(kind=rk), allocatable, (:)

public pure function reverse_control_order(nc, dir) result(order)

Source row for reversing one tensor axis; direction 1 varies fastest.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc(:)
integer, intent(in) :: dir

Return Value integer, allocatable, (:)

public pure function rotation(alpha, beta, theta) result(R)

License
BSD 3-Clause

Return an active right-handed Euler rotation matrix.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: alpha

Rotation about the x axis in degrees.

real(kind=rk), intent(in) :: beta

Rotation about the y axis in degrees.

real(kind=rk), intent(in) :: theta

Rotation about the z axis in degrees.

Return Value real(kind=rk), (3,3)

public pure elemental function scaled_measure(mantissa, power) result(measure)

A positive quadrature measure, or zero when its magnitude cannot be represented.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: mantissa
integer, intent(in) :: power

Return Value real(kind=rk)

public pure function scaled_norm(vector) result(value)

Euclidean norm without squaring the original scale.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: vector(:)

Return Value real(kind=rk)

public pure function scaled_product(values) result(value)

Multiply short scale factors without intermediate overflow or underflow.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: values(:)

Return Value real(kind=rk)

public pure function solve(A, B) result(X)

License
BSD 3-Clause

Solve the square dense system for one or more right-hand sides.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: A(:,:)

Square coefficient matrix, shape [n,n].

real(kind=rk), intent(in), contiguous :: B(:,:)

Right-hand sides, shape [n,nrhs].

Return Value real(kind=rk), allocatable, (:,:)

public pure function solve_least_squares_qr(A, B) result(X)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Solve an overdetermined full-rank least-squares problem by pivoted QR.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: A(:,:)

Design matrix [m,n] with m>=n>=1.

real(kind=rk), intent(in) :: B(:,:)

Right-hand sides [m,nrhs].

Return Value real(kind=rk), allocatable, (:,:)

public pure function solve_spd_banded(A_band, B) result(X)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Solve a symmetric positive-definite band system by banded Cholesky factorization.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: A_band(0:,:)

Lower symmetric band storage, lower bound zero in dimension 1.

real(kind=rk), intent(in), contiguous :: B(:,:)

Right-hand sides, shape [n,nrhs].

Return Value real(kind=rk), allocatable, (:,:)

public pure function spline_connectivity(nc, degree, knot1, knot2, knot3) result(elem)

Full-knot connectivity; exterior and active endpoint multiplicities stay literal.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
real(kind=rk), intent(in), contiguous :: knot1(:)
real(kind=rk), intent(in), optional, contiguous :: knot2(:)
real(kind=rk), intent(in), optional, contiguous :: knot3(:)

Return Value integer, allocatable, (:,:)

public pure function spline_span_plan(nc, degree, knot1, knot2, knot3) result(plan)

Plan active full-knot spans once for whole-patch decomposition.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
real(kind=rk), intent(in), contiguous :: knot1(:)
real(kind=rk), intent(in), optional, contiguous :: knot2(:)
real(kind=rk), intent(in), optional, contiguous :: knot3(:)

Return Value integer, allocatable, (:,:)

public pure elemental function structural_nonzero(x) result(nonzero)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Test exact structural nonzero status for sparse/refinement coefficients. Returns false only for positive or negative floating-point zero. Every finite nonzero value, infinity, and NaN is structural; no tolerance is applied. Keeping NaNs structural allows invalid arithmetic to propagate.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: x

Return Value logical

public pure function tetragon_Xc(L, nc) result(Xc)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Generate a uniformly spaced planar rectangular control net.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: L(:)

Signed axis extents [Lx,Ly].

integer, intent(in), contiguous :: nc(:)

Directional point counts [nx,ny], each greater than one. The result has shape [product(nc),3], lies in z=0, and stores x/direction 1 fastest.

Return Value real(kind=rk), allocatable, (:,:)

public pure function valid_knot_vector(knot, nc, degree) result(valid)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Validate the structural invariants of a one-dimensional spline space.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)

Candidate knot vector.

integer, intent(in) :: nc

Number of control points.

integer, intent(in) :: degree

Candidate polynomial degree, satisfying `0<=degree

Return Value logical

public pure function valid_weights(Wc) result(valid)

NURBS weights are nonempty, finite, and strictly positive.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Wc(:)

Return Value logical

public pure function weighted_tangent_measure(jacobian, weight, power) result(measure)

Combine the factored native weight with sqrt(det(J^T J)) before rounding.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: jacobian(:,:)
real(kind=rk), intent(in) :: weight
integer, intent(in) :: power

Return Value real(kind=rk)


Subroutines

public pure subroutine add_scaled_term(term, shift, parts, powers, n)

Insert a signed term into a nonoverlapping expansion, smallest parts first.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: term
integer, intent(in) :: shift
real(kind=rk), intent(inout) :: parts(:)
integer, intent(inout) :: powers(:)
integer, intent(inout) :: n

public pure subroutine affine_knot_residual(start, finish, point, mantissa, power, signed_result)

Absolute determinant of three parameter pairs as mantissa times radix**power. Its zero identifies exact affine alignment, even for a discontinuous trace. Splitting each factor at half precision gives four exact products. FastTwoSum retains the rounding residual of each addition. Separate radix exponents keep both tiny and overflowing products comparable.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: start(2)
real(kind=rk), intent(in) :: finish(2)
real(kind=rk), intent(in) :: point(2)
real(kind=rk), intent(out) :: mantissa
integer, intent(out) :: power
logical, intent(in), optional :: signed_result

public pure subroutine basis_bspline_der_all_active(Xt, knot, nc, degree, nder, first, ders, side, wrap)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Evaluate all nonzero B-spline basis derivatives through nder. Implements Algorithm A2.3 of Piegl and Tiller, The NURBS Book, 2nd edition. Rows above degree are identically zero. The caller supplies ders(0:nder,0:degree); on return first is the one-based index associated with column zero. For , row contains ; rows are zero.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt

Parameter value on, or within tolerance of, the active interval.

real(kind=rk), intent(in), contiguous :: knot(:)

Valid knot vector.

integer, intent(in) :: nc

Number of basis functions.

integer, intent(in) :: degree

Polynomial degree.

integer, intent(in) :: nder

Highest derivative order requested; must be nonnegative.

integer, intent(out) :: first

First globally active one-based basis index.

real(kind=rk), intent(out), contiguous :: ders(0:,0:)

Derivative table; row k contains .

integer, intent(in), optional :: side

At an interior knot use the left trace (-1) or right trace (0, +1).

logical, intent(in), optional :: wrap

Enable wrapping before selecting the span.

public pure subroutine basis_bspline_der_order(Xt, knot, nc, degree, nder, B)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Evaluate one arbitrary derivative order as a dense basis vector.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree
integer, intent(in) :: nder

Nonnegative derivative order.

real(kind=rk), intent(out), contiguous :: B(:)

public pure subroutine basis_bspline_der_order_active(Xt, knot, nc, degree, nder, first, B)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Evaluate one arbitrary derivative order on local support only.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree
integer, intent(in) :: nder

Nonnegative derivative order.

integer, intent(out) :: first
real(kind=rk), intent(out) :: B(0:degree)

public pure subroutine bezier_element_data(knot1, nc, degree, ie, Xc, Wc, make_piece, Xout, Wout, ids, bounds, err, C, knot2, knot3, rational, spans)

Exact local Bernstein extraction by insertion of the two element endpoints. C is weight-independent: N=CB, H_bezier=transpose(C)H_active. Geometry uses successive positive directional contractions; the tensor matrix is allocated only when requested. Parameter bounds remain literal.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot1(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
integer, intent(in) :: ie
real(kind=rk), intent(in) :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
logical, intent(in) :: make_piece
real(kind=rk), intent(out), allocatable :: Xout(:,:)
real(kind=rk), intent(out), allocatable :: Wout(:)
integer, intent(out), allocatable :: ids(:)
real(kind=rk), intent(out) :: bounds(2,size(nc))
type(debug), intent(inout) :: err
real(kind=rk), intent(out), optional, allocatable :: C(:,:)
real(kind=rk), intent(in), optional, contiguous :: knot2(:)
real(kind=rk), intent(in), optional, contiguous :: knot3(:)
logical, intent(in), optional :: rational
integer, intent(in), optional :: spans(:)

public pure subroutine check_affine_map(ncoord, linear, translation, center, err, category, shape_code, value_code)

Check an affine change of physical coordinates before updating any control net.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncoord
real(kind=rk), intent(in) :: linear(:,:)
real(kind=rk), intent(in), optional :: translation(:)
real(kind=rk), intent(in), optional :: center(:)
type(debug), intent(inout) :: err
character(len=*), intent(in) :: category
integer, intent(in) :: shape_code
integer, intent(in) :: value_code

public pure subroutine coarsen_control_lines(knot, degree, Xc, Wc, nc, dir, Xth, r, err, controls, weight_exponent, counts, tol, error_bound)

Remove knots transactionally in packed directional control lines. An explicit physical tolerance replaces A5.8's coefficient equality test. Each candidate and source are clamped for comparison, then reinserted on the call-entry interior knots, so one budget controls the complete update, including every earlier accepted request. Bounds follow nonnegative partition of unity, with no sampling or dense map.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(inout), allocatable :: knot(:)
integer, intent(in) :: degree
real(kind=rk), intent(in), contiguous :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: dir
real(kind=rk), intent(in) :: Xth(:)
integer, intent(in) :: r(:)
type(debug), intent(inout) :: err
real(kind=rk), intent(out), allocatable :: controls(:,:)
integer, intent(out) :: weight_exponent
integer, intent(out), allocatable :: counts(:)
real(kind=rk), intent(in), optional :: tol
real(kind=rk), intent(out), optional :: error_bound

public pure subroutine curve_frame(controls, gradient, width, weight, strict, tangent, speed, measure, valid, hessian, curvature_vector)

Unnormalized curve tangent and weighted length, shared by integration and IGA.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: controls(:,:)
real(kind=rk), intent(in), contiguous :: gradient(:,:)
real(kind=rk), intent(in) :: width
real(kind=rk), intent(in) :: weight
logical, intent(in) :: strict
real(kind=rk), intent(out), target :: tangent(:)
real(kind=rk), intent(out) :: speed
real(kind=rk), intent(out) :: measure
logical, intent(out) :: valid
real(kind=rk), intent(in), optional :: hessian(:,:,:)
real(kind=rk), intent(out), optional, target :: curvature_vector(:)

public pure subroutine disjoint_set_map(parent, map, active, include_aliases)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Compress a disjoint-set forest and return compact component identifiers.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), contiguous :: parent(:)

Parent forest; paths are shortened in place.

integer, intent(out), allocatable :: map(:)

Component identifier for every input member.

logical, intent(in), optional :: active(:)

Number components in first active-member order. Entirely inactive components receive zero.

logical, intent(in), optional :: include_aliases

Also label inactive occurrences of participating components; used for geometry design variables.

public pure subroutine disjoint_set_union(parent, a, b)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Merge two disjoint-set components using path halving.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), contiguous :: parent(:)

Parent forest initialized with parent(i)=i.

integer, intent(in) :: a

One-based member of the first component.

integer, intent(in) :: b

One-based member of the second component.

public pure subroutine elevate_degree_A_5_9(t, knot, degree, Xcw, nc_new, knot_new, Xcw_new, Tmap, success)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Elevate a spline degree while preserving bounded or periodic topology.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: t

Nonnegative number of degree elevations.

real(kind=rk), intent(in), contiguous :: knot(:)

Original valid knot vector.

integer, intent(in) :: degree

Original polynomial degree.

real(kind=rk), intent(in), contiguous :: Xcw(:,:)

Original control variables, one point per row.

integer, intent(out) :: nc_new

New control-point count.

real(kind=rk), intent(out), allocatable :: knot_new(:)

Elevated knot vector.

real(kind=rk), intent(out), allocatable :: Xcw_new(:,:)

Elevated control variables.

real(kind=rk), intent(out), optional, allocatable :: Tmap(:,:)

Optional transformation satisfying Xcw_new=matmul(Tmap,Xcw).

logical, intent(out), optional :: success

Optional operation status.

public pure subroutine equilibrate_field_row(val, weights, valid, shift)

Form (Aw)/max(abs(Aw)) with a common radix exponent before checking partition of unity.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(inout) :: val(:)
real(kind=rk), intent(in) :: weights(:)
logical, intent(out) :: valid
integer, intent(in), optional :: shift(:)

public pure subroutine eval_bernstein_endpoint(knot, p, side, first, ders, resolved)

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: p
integer, intent(in) :: side
integer, intent(out) :: first
real(kind=rk), intent(out) :: ders(:,:)
logical, intent(out) :: resolved

public pure subroutine eval_bernstein_pair(a, b, reverse, xi, da, db, resolved)

Arguments

Type IntentOptional Attributes Name
type(bernstein_span), intent(in) :: a
type(bernstein_span), intent(in) :: b
logical, intent(in) :: reverse
real(kind=rk), intent(in) :: xi
real(kind=rk), intent(out) :: da(:,:)
real(kind=rk), intent(out) :: db(:,:)
logical, intent(out) :: resolved

public impure subroutine export_vtk_legacy(filename, points, elemConn, vtkCellType, point_data, field_names, encoding, cell_data, cell_field_names)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Write points, connectivity, and optional scalar fields in legacy VTK format.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename

Destination path.

real(kind=rk), intent(in), contiguous :: points(:,:)

Coordinates, shape [npoint,2] or [npoint,3].

integer, intent(in), contiguous :: elemConn(:,:)

One-based cell connectivity, one cell per row.

integer, intent(in) :: vtkCellType

Numeric VTK legacy cell identifier.

real(kind=rk), intent(in), optional, contiguous :: point_data(:,:)

Optional scalar fields, shape [npoint,nfield].

character(len=*), intent(in), optional, contiguous :: field_names(:)

Optional names corresponding to point_data columns.

character(len=*), intent(in), optional :: encoding

Optional "ASCII" or "BINARY"; binary is the default.

real(kind=rk), intent(in), optional, contiguous :: cell_data(:,:)

Optional scalar cell fields, shape [ncell,nfield].

character(len=*), intent(in), optional, contiguous :: cell_field_names(:)

Optional names corresponding to cell_data columns.

public pure subroutine fill_uniform(a, b, x)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Fill an existing array with inclusive uniformly spaced values.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: a

First value.

real(kind=rk), intent(in) :: b

Last value when size(x)>1.

real(kind=rk), intent(out), contiguous :: x(:)

Caller-owned contiguous output array.

public pure subroutine geometry_derivative(Xt1, nc, degree, knot1, Xc, Wc, order, wrap, Xg, knot2, knot3, Xt2, Xt3, side, row_power)

One positive-order geometry derivative, with local span coordinates. Bernstein extraction normalizes each axis before the rational recurrence. Anchored contractions remove translations; one combined width scale restores the original parameter units, including arbitrary mixed orders. With row_power, the derivative in native units is Xg(row,:)2*row_power(row). Any unrepresentable required workspace returns an empty result. Callers validate owned geometry, matching finite parameter axes, rank 1:3, and a nonnegative derivative multi-index with positive total order.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt1(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
real(kind=rk), intent(in), contiguous :: knot1(:)
real(kind=rk), intent(in), contiguous :: Xc(:,:)
real(kind=rk), intent(in), optional, contiguous :: Wc(:)
integer, intent(in) :: order(:)
logical, intent(in) :: wrap(:)
real(kind=rk), intent(out), allocatable :: Xg(:,:)
real(kind=rk), intent(in), optional, contiguous :: knot2(:)
real(kind=rk), intent(in), optional, contiguous :: knot3(:)
real(kind=rk), intent(in), optional :: Xt2(:)
real(kind=rk), intent(in), optional :: Xt3(:)
integer, intent(in), optional :: side(:)
integer, intent(out), optional, allocatable :: row_power(:)

public pure subroutine geometry_jet(Xc, param_gradient, jacobian, ids, basis, point, param_hessian, curvature)

Contract the local spline jet with the control net in native knot coordinates.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xc(:,:)
real(kind=rk), intent(in), contiguous :: param_gradient(:,:)
real(kind=rk), intent(out) :: jacobian(:,:)
integer, intent(in), optional :: ids(:)
real(kind=rk), intent(in), optional :: basis(:)
real(kind=rk), intent(out), optional :: point(:)
real(kind=rk), intent(in), optional :: param_hessian(:,:,:)
real(kind=rk), intent(out), optional :: curvature(:,:,:)

public pure subroutine gradient_sensitivity(basis, gradient, q, Xc, ids, valid, dgradient_dXc, dgradient_dlogWc, param_gradient)

Design derivatives of the ambient physical basis gradients at fixed parameters. Write N=I-QQ^T, h_ab=g_a dot g_b, and v_b=P_b-X. Then d g_a/d P_bj = h_ab N(:,j) - g_b g_aj, including changes of the tangent plane. The log-weight derivative contracts this tensor against v_b and adds (delta_ab-R_a)g_b from differentiating the rational basis.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: basis(:)
real(kind=rk), intent(in) :: gradient(:,:)
real(kind=rk), intent(in) :: q(:,:)
real(kind=rk), intent(in) :: Xc(:,:)
integer, intent(in), optional :: ids(:)
logical, intent(out) :: valid
real(kind=rk), intent(out), optional :: dgradient_dXc(:,:,:,:)
real(kind=rk), intent(out), optional :: dgradient_dlogWc(:,:,:)
real(kind=rk), intent(in), optional :: param_gradient(:,:)

public pure recursive subroutine insert_knot_A_5_1(p, UP, Pw, u, k, s, r, nq, UQ, Qw, T)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Insert a knot without changing the represented homogeneous geometry.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: p

Polynomial degree.

real(kind=rk), intent(in), contiguous :: UP(0:)

Original valid knot vector, lower bound zero.

real(kind=rk), intent(in), contiguous :: Pw(0:,:)

Original homogeneous or polynomial control variables by row.

real(kind=rk), intent(in) :: u

Knot value to insert.

integer, intent(in) :: k

Zero-based span containing u.

integer, intent(in) :: s

Existing multiplicity of u.

integer, intent(in) :: r

Number of insertions, satisfying s+r<=p+1.

integer, intent(out) :: nq

New highest zero-based control index; -1 signals invalid input.

real(kind=rk), intent(out), allocatable :: UQ(:)

Refined knot vector.

real(kind=rk), intent(out), allocatable :: Qw(:,:)

Refined control variables.

real(kind=rk), intent(out), optional, allocatable :: T(:,:)

Optional refinement transformation.

public pure subroutine insert_knot_periodic_A_5_1(p, UP, Pw, u, k, s, r, nq, UQ, Qw, T)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Insert a knot while retaining a verified cyclic B-spline representation.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: p

Polynomial degree.

real(kind=rk), intent(in), contiguous :: UP(0:)

Verified periodic knot vector.

real(kind=rk), intent(in), contiguous :: Pw(0:,:)

Periodic homogeneous or polynomial control variables.

real(kind=rk), intent(in) :: u

Knot value in the active interval.

integer, intent(in) :: k

Initial zero-based span containing u.

integer, intent(in) :: s

Initial multiplicity of u.

integer, intent(in) :: r

Nonnegative insertion count.

integer, intent(out) :: nq

New highest zero-based control index.

real(kind=rk), intent(out), allocatable :: UQ(:)

Refined periodic knot vector.

real(kind=rk), intent(out), allocatable :: Qw(:,:)

Refined periodic control variables.

real(kind=rk), intent(out), optional, allocatable :: T(:,:)

Optional periodic refinement transformation.

public pure subroutine isoparametric_grid(knot1, knot2, nc, degree, Xt, elemConn, res, knot3)

Sample active isoparametric grid lines in direction order with a common point count. Valid source knot vectors and counts are required. Within each line family the lowest remaining parameter direction varies fastest, matching control order.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot1(:)
real(kind=rk), intent(in), contiguous :: knot2(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
real(kind=rk), intent(out), allocatable :: Xt(:,:)
integer, intent(out), allocatable :: elemConn(:,:)
integer, intent(in), optional :: res
real(kind=rk), intent(in), optional, contiguous :: knot3(:)

public pure subroutine jacobian_frame(jacobian, contravariant, measure, inverted, valid, q)

Contravariant frame J(J^TJ)^(-1), without forming the Gram matrix. Column-scaled, reorthogonalized QR for up to three parametric directions.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: jacobian(:,:)
real(kind=rk), intent(out) :: contravariant(:,:)
real(kind=rk), intent(out) :: measure
logical, intent(out) :: inverted
logical, intent(out) :: valid
real(kind=rk), intent(out), optional :: q(:,:)

Orthonormal tangent frame from the same QR factorization.

public pure subroutine jacobian_log_sensitivity(basis, param_gradient, jacobian, Xc, djacobian_dlogWc, valid, ids)

Differentiate the geometry Jacobian at fixed knot parameters. Differentiating R_b*(P_b-X) in direction alpha gives the b-th log-weight column.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: basis(:)
real(kind=rk), intent(in) :: param_gradient(:,:)
real(kind=rk), intent(in) :: jacobian(:,:)
real(kind=rk), intent(in) :: Xc(:,:)
real(kind=rk), intent(out) :: djacobian_dlogWc(:,:,:)
logical, intent(out) :: valid
integer, intent(in), optional :: ids(:)

public pure subroutine map_analysis_point(Xc, ids, basis, param_gradient, widths, gauss_weight, strict, gradient, measure, valid, point, jacobian, param_hessian, physical_hessian, dmeasure_dXc, dmeasure_dlogWc, dgradient_dXc, dgradient_dlogWc, djacobian_dlogWc)

Map one tensor-product analysis point using its active controls. Widths and the Gauss weight belong to the parent-to-knot map. Parametric and physical Hessians are supplied together when requested.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xc(:,:)
integer, intent(in) :: ids(:)
real(kind=rk), intent(in) :: basis(:)
real(kind=rk), intent(in), contiguous :: param_gradient(:,:)
real(kind=rk), intent(in) :: widths(:)
real(kind=rk), intent(in) :: gauss_weight
logical, intent(in) :: strict
real(kind=rk), intent(out) :: gradient(:,:)
real(kind=rk), intent(out) :: measure
logical, intent(out) :: valid
real(kind=rk), intent(out), optional :: point(:)
real(kind=rk), intent(out), optional :: jacobian(:,:)
real(kind=rk), intent(in), optional :: param_hessian(:,:,:)
real(kind=rk), intent(out), optional :: physical_hessian(:,:,:)
real(kind=rk), intent(out), optional :: dmeasure_dXc(:,:)
real(kind=rk), intent(out), optional :: dmeasure_dlogWc(:)
real(kind=rk), intent(out), optional :: dgradient_dXc(:,:,:,:)
real(kind=rk), intent(out), optional :: dgradient_dlogWc(:,:,:)
real(kind=rk), intent(out), optional :: djacobian_dlogWc(:,:,:)

public pure subroutine map_basis_derivatives(param_gradient, frame, physical_gradient, param_hessian, geometry_hessian, physical_hessian)

Map local parametric gradients and symmetric Hessians to physical coordinates. frame=J(J^TJ)^(-1) is supplied by jacobian_frame. The Hessian inputs are required together with physical_hessian. Shapes must match, with one through three parametric directions; arbitrary embeddings are allowed.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: param_gradient(:,:)
real(kind=rk), intent(in) :: frame(:,:)
real(kind=rk), intent(out) :: physical_gradient(:,:)
real(kind=rk), intent(in), optional :: param_hessian(:,:,:)
real(kind=rk), intent(in), optional :: geometry_hessian(:,:,:)
real(kind=rk), intent(out), optional :: physical_hessian(:,:,:)

public pure subroutine map_parameter_values(values, lo, hi, a, b, mapped, err)

Affine coordinates, including exterior knots, with exact endpoint assignment. Radix-scaled differences avoid overflowing an otherwise representable map. The internal target may descend; public reparameterization requires increasing bounds.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: values(:)
real(kind=rk), intent(in) :: lo
real(kind=rk), intent(in) :: hi
real(kind=rk), intent(in) :: a
real(kind=rk), intent(in) :: b
real(kind=rk), intent(out), allocatable :: mapped(:)
type(debug), intent(inout) :: err

public pure subroutine measure_sensitivity(measure, ndim, basis, gradient, Xc, ids, valid, dmeasure_dXc, dmeasure_dlogWc)

Derivatives of one weighted physical measure at fixed knot parameters. For local rational basis R and physical gradient g, they are mg_a and m((P_a-X) dot g_a - ndim*R_a) for a regular patch of any codimension.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: measure
integer, intent(in) :: ndim
real(kind=rk), intent(in) :: basis(:)
real(kind=rk), intent(in) :: gradient(:,:)
real(kind=rk), intent(in) :: Xc(:,:)
integer, intent(in), optional :: ids(:)
logical, intent(out) :: valid
real(kind=rk), intent(out), optional :: dmeasure_dXc(:,:)
real(kind=rk), intent(out), optional :: dmeasure_dlogWc(:)

public pure subroutine nearest_spline_point(Xc, Wc, nc, degree, knot1, point, tol, maxit, nearest_Xt, nearest_Xg, err, knot2, knot3, initial_Xt, wrap)

Stream span-aware seeds, then minimize distance with local spline jets. Work is support-sized; knots and physical offsets use independent radix gauges. Full breaks bound the selected continuous component. This is a local candidate, not a global certificate. Armijo (1966), Bertsekas (1982), Piegl--Tiller sec.6.1.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
real(kind=rk), intent(in) :: knot1(:)
real(kind=rk), intent(in) :: point(:)
real(kind=rk), intent(in) :: tol
integer, intent(in) :: maxit
real(kind=rk), intent(out) :: nearest_Xt(:)
real(kind=rk), intent(out), optional :: nearest_Xg(:)
type(debug), intent(inout) :: err
real(kind=rk), intent(in), optional :: knot2(:)
real(kind=rk), intent(in), optional :: knot3(:)
real(kind=rk), intent(in), optional :: initial_Xt(:)
logical, intent(in), optional :: wrap(:)

public pure subroutine nested_edge_transfer(coarse, fine, degree, rowptr, col, val, ok, reverse)

Oslo refinement evaluates the coarse blossom at fine(i+1), ..., fine(i+p) to obtain Q_i. Both input vectors are ascending. CSR rows and columns retain their original fine and coarse storage orders, including when the edge orientation reverses. Lyche, A note on the Oslo algorithm, Eq. 1.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: coarse(:)
real(kind=rk), intent(in), contiguous :: fine(:)
integer, intent(in) :: degree
integer, intent(out), allocatable :: rowptr(:)
integer, intent(out), allocatable :: col(:)
real(kind=rk), intent(out), allocatable :: val(:)
logical, intent(out) :: ok
logical, intent(in), optional :: reverse

public pure subroutine normalize_field_constraints(rowptr, col, val, weights, valid)

Convert homogeneous CSR rows to ordinary rational field coefficients. Exponent scaling avoids overflow in A_ijw_j; Aw=0 certifies the denominator.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: rowptr(:)
integer, intent(in) :: col(:)
real(kind=rk), intent(inout) :: val(:)
real(kind=rk), intent(in) :: weights(:)
logical, intent(out) :: valid

public pure subroutine pack_refinement_controls(Xc, Wc, nc, dir, Xdir, weight_exponent, err)

Pack any tensor direction as rows, with orthogonal lines then coordinates in columns. Counts, controls and optional stored weights must describe a valid geometry. Omitted or unallocated weights select polynomial controls. One radix-power gauge is shared by the complete homogeneous net and restored by unpacking. Prefer a gauge keeping every nonzero homogeneous component normal; use subnormal range only when necessary. An unrepresentable workspace returns empty Xdir and optionally sets err, before any geometry is changed.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xc(:,:)
real(kind=rk), intent(in), optional :: Wc(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: dir
real(kind=rk), intent(out), allocatable :: Xdir(:,:)
integer, intent(out) :: weight_exponent
type(debug), intent(inout), optional :: err

public pure subroutine prepare_bernstein_pair(ka, kb, p, span, reverse, a, b, resolved, order)

Cache extraction and the affine displacement of the paired ends in B's span units.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: ka(:)
real(kind=rk), intent(in), contiguous :: kb(:)
integer, intent(in) :: p
integer, intent(in) :: span
logical, intent(in) :: reverse
type(bernstein_span), intent(out) :: a
type(bernstein_span), intent(out) :: b
logical, intent(out) :: resolved
integer, intent(in), optional :: order

public pure subroutine query_parameter_axis(knot, nc, degree, cached, parameters, valid, resolution, explicit)

Explicit parameters take precedence over a resolution, then a cached grid.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree
real(kind=rk), intent(in), allocatable :: cached(:)
real(kind=rk), intent(out), allocatable :: parameters(:)
logical, intent(out) :: valid
integer, intent(in), optional :: resolution
real(kind=rk), intent(in), optional :: explicit(:)

public pure subroutine reduce_control_lines(knot, degree, Xc, Wc, nc, dir, t, tol, err, controls, weight_exponent, reduced, error_bound)

Degree reduction with one physical budget against the call-entry geometry. Local inverse elevation and candidate-only knot removal construct proposals; re-elevation on a common basis bounds their complete Euclidean deviation.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(inout), allocatable :: knot(:)
integer, intent(in) :: degree
real(kind=rk), intent(in), contiguous :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: dir
integer, intent(in) :: t
real(kind=rk), intent(in) :: tol
type(debug), intent(inout) :: err
real(kind=rk), intent(out), allocatable :: controls(:,:)
integer, intent(out) :: weight_exponent
integer, intent(out) :: reduced
real(kind=rk), intent(out) :: error_bound

public pure subroutine refine_control_lines(knot, degree, controls, Xth, r, err, Tmap, bounded)

Refine packed control lines with one shared knot-insertion policy. Source data and finite, matching requests with nonnegative counts are prevalidated. Work arrays may change before failure; callers commit only when err is OK. Zero counts need no control workspace. Dense maps allocate only on request. Bounded mode cuts the stored spline rather than its periodic extension.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(inout), allocatable :: knot(:)
integer, intent(in) :: degree
real(kind=rk), intent(inout), allocatable :: controls(:,:)
real(kind=rk), intent(in) :: Xth(:)
integer, intent(in) :: r(:)
type(debug), intent(inout) :: err
real(kind=rk), intent(out), optional, allocatable :: Tmap(:,:)
logical, intent(in), optional :: bounded

public pure subroutine refine_control_net(knot, degree, Xc, Wc, nc, dir, knots, Xout, Wout, err, B, Bs, Xth, r, t)

Share homogeneous insertion/elevation, decoding and optional fixed-weight maps. Valid source geometry and direction are preconditions. Supply either t, or matching Xth/r arrays. Only requested maps allocate; identity requests leave Xout unallocated so callers retain their sampling caches.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: degree
real(kind=rk), intent(in), contiguous :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: dir
real(kind=rk), intent(out), allocatable :: knots(:)
real(kind=rk), intent(out), allocatable :: Xout(:,:)
real(kind=rk), intent(out), allocatable :: Wout(:)
type(debug), intent(inout) :: err
real(kind=rk), intent(out), optional, allocatable :: B(:,:)
real(kind=rk), intent(out), optional, allocatable :: Bs(:,:)
real(kind=rk), intent(in), optional :: Xth(:)
integer, intent(in), optional :: r(:)
integer, intent(in), optional :: t

public pure subroutine refinement_operators(A, nc_old, nc_new, dir, ncoord, Wc_old, Wc_new, B, Bs)

Lift a directional refinement map into the stored tensor control order. Bs=D_new^(-1)A_tensorD_old maps Euclidean controls at fixed weights; B=Bs (x) I_ncoord uses point-major coordinate packing. Unallocated weights represent a polynomial space. Counts and weights must match the map. Only requested outputs allocate; B alone does not require a dense Bs.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: A(:,:)
integer, intent(in) :: nc_old(:)
integer, intent(in) :: nc_new(:)
integer, intent(in) :: dir
integer, intent(in) :: ncoord
real(kind=rk), intent(in), allocatable :: Wc_old(:)
real(kind=rk), intent(in), allocatable :: Wc_new(:)
real(kind=rk), intent(out), optional, allocatable :: B(:,:)
real(kind=rk), intent(out), optional, allocatable :: Bs(:,:)

public pure subroutine remove_knots_A_5_8(p, knot, Pw, u, r, s, num, t, knot_new, Pw_new, approximate)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Attempt knot removal using Algorithm A5.8 of Piegl and Tiller. r must be the one-based index of the final occurrence of the interior knot u, s must be its complete current multiplicity, and 1<=num<=s. Each removal is accepted by componentwise comparisons in the supplied control-variable space using

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: p
real(kind=rk), intent(in), contiguous :: knot(:)
real(kind=rk), intent(in), contiguous :: Pw(:,:)
real(kind=rk), intent(in) :: u
integer, intent(in) :: r
integer, intent(in) :: s
integer, intent(in) :: num
integer, intent(out) :: t
real(kind=rk), intent(out), allocatable :: knot_new(:)
real(kind=rk), intent(out), allocatable :: Pw_new(:,:)
logical, intent(in), optional :: approximate

Candidate-only mode; callers must separately bound physical error.

public pure subroutine reorient_patch(nc, degree, axes, knot1, Xc, Wc, k1out, xout, wout, err, knot2, k2out, knot3, k3out)

Copy a tensor patch into signed axis order, including every exterior knot and stored weight. Source geometry and directional knot inputs/outputs must match the rank (1, 2 or 3).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
integer, intent(in) :: axes(:)
real(kind=rk), intent(in) :: knot1(:)
real(kind=rk), intent(in) :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
real(kind=rk), intent(out), allocatable :: k1out(:)
real(kind=rk), intent(out), allocatable :: xout(:,:)
real(kind=rk), intent(out), allocatable :: wout(:)
type(debug), intent(inout) :: err
real(kind=rk), intent(in), optional :: knot2(:)
real(kind=rk), intent(out), optional, allocatable :: k2out(:)
real(kind=rk), intent(in), optional :: knot3(:)
real(kind=rk), intent(out), optional, allocatable :: k3out(:)

public pure subroutine reparameterize_knots(knot, nc, degree, a, b, mapped, err, category)

Transform a valid full knot vector, preserving every equality and strict gap.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: knot(:)
integer, intent(in) :: nc
integer, intent(in) :: degree
real(kind=rk), intent(in) :: a
real(kind=rk), intent(in) :: b
real(kind=rk), intent(out), allocatable :: mapped(:)
type(debug), intent(inout) :: err
character(len=*), intent(in), optional :: category

public pure subroutine restrict_control_net(Xc, Wc, nc, dir, knot, degree, a, b, knots, Xout, Wout, err)

Restrict one tensor direction without sampling or a dense extraction map. Complete source geometry and a valid direction are caller preconditions. Output weights retain a common workspace gauge to avoid rounding small weights independently when restoring the source's arbitrary projective scale.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: dir
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: degree
real(kind=rk), intent(in) :: a
real(kind=rk), intent(in) :: b
real(kind=rk), intent(out), allocatable :: knots(:)
real(kind=rk), intent(out), allocatable :: Xout(:,:)
real(kind=rk), intent(out), allocatable :: Wout(:)
type(debug), intent(inout) :: err

public pure subroutine rotate_points(points, n, alpha, beta, theta)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Rotate the first n rows of a point array in place.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(inout), contiguous :: points(:,:)

Point rows to modify.

integer, intent(in) :: n

Maximum number of leading rows to rotate.

real(kind=rk), intent(in) :: alpha

Rotation about x in degrees.

real(kind=rk), intent(in) :: beta

Rotation about y in degrees.

real(kind=rk), intent(in) :: theta

Rotation about z in degrees.

public pure elemental subroutine scaled_difference(a, b, difference, power)

Represent b-a as differenceradix*power without overflowing subtraction.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: a
real(kind=rk), intent(in) :: b
real(kind=rk), intent(out) :: difference
integer, intent(out) :: power

public pure subroutine slice_control_net(Xc, Wc, nc, dir, knot, degree, Xt, wrap_parameter, Xout, Wout, err)

Contract one tensor direction in homogeneous coordinates, retaining the others in order. The source geometry and direction must be valid. Only the active degree+1 controls on each line are read; no full homogeneous net or dense operator is allocated. Coordinate numerators and weight denominators use separate radix gauges so normalizing a small weight cannot erase a finite control. Output weights share one representable gauge; lossy subnormal scaling is rejected.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: Xc(:,:)
real(kind=rk), intent(in), allocatable :: Wc(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: dir
real(kind=rk), intent(in), contiguous :: knot(:)
integer, intent(in) :: degree
real(kind=rk), intent(in) :: Xt
logical, intent(in) :: wrap_parameter
real(kind=rk), intent(out), allocatable :: Xout(:,:)
real(kind=rk), intent(out), allocatable :: Wout(:)
type(debug), intent(inout) :: err

public pure subroutine sparse_left_matmul(A, B, C)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Compute C=matmul(A,B) by scanning structural nonzeros of A. Intended for local-support refinement maps, where A is structurally sparse but the existing API still needs a dense transformation matrix. NaN coefficients remain structural and therefore propagate rather than being silently dropped. Incompatible inner dimensions return C(0,0). This is not a compressed sparse representation: every entry of dense A is inspected and exact zeros alone are skipped. For dimensions and , work is , including the scan and result initialization. A, B, and the returned C all remain dense; result storage is .

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: A(:,:)

Left matrix, commonly a refinement transformation.

real(kind=rk), intent(in), contiguous :: B(:,:)

Dense right-hand matrix.

real(kind=rk), intent(out), allocatable :: C(:,:)

Allocatable result of shape [size(A,1),size(B,2)].

public pure subroutine spline_element(nc, degree, knot1, ie, ids, bounds, err, knot2, knot3, spans)

Local support in literal full knots, including repeated active endpoints. Valid knots/counts/degrees and optional planned spans are caller preconditions; no source net is copied.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
real(kind=rk), intent(in), contiguous :: knot1(:)
integer, intent(in) :: ie
integer, intent(out), allocatable :: ids(:)
real(kind=rk), intent(out) :: bounds(2,size(nc))
type(debug), intent(inout) :: err
real(kind=rk), intent(in), optional, contiguous :: knot2(:)
real(kind=rk), intent(in), optional, contiguous :: knot3(:)
integer, intent(in), optional :: spans(:)

public pure subroutine tensor_ansatz(Xc, Wc, rational, degree, nc, knot1, knot2, object_err, err, ie, ig, basis, gradient, measure, ngauss, strict, Xg, dXg_dXt, d2Tgc_dXg2, dmeasure_dXc, dmeasure_dlogWc, dgradient_dXc, dgradient_dlogWc, knot3, curve_second, djacobian_dXc, djacobian_dlogWc)

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), allocatable :: Xc(:,:)
real(kind=rk), intent(inout), allocatable, target :: Wc(:)
logical, intent(in) :: rational
integer, intent(in) :: degree(:)
integer, intent(in) :: nc(:)
real(kind=rk), intent(in), allocatable :: knot1(:)
real(kind=rk), intent(inout), optional, allocatable, target :: knot2(:)
type(debug), intent(inout), target :: object_err
type(debug), intent(out), optional, target :: err
integer, intent(in) :: ie
integer, intent(in) :: ig
real(kind=rk), intent(out), allocatable, target :: basis(:)
real(kind=rk), intent(out), allocatable, target :: gradient(:,:)
real(kind=rk), intent(out), target :: measure
integer, intent(in), optional :: ngauss(:)
logical, intent(in), optional :: strict
real(kind=rk), intent(out), optional, allocatable, target :: Xg(:)
real(kind=rk), intent(out), optional, allocatable, target :: dXg_dXt(:,:)
real(kind=rk), intent(out), optional, allocatable, target :: d2Tgc_dXg2(:,:,:)
real(kind=rk), intent(out), optional, allocatable, target :: dmeasure_dXc(:,:)
real(kind=rk), intent(out), optional, allocatable, target :: dmeasure_dlogWc(:)
real(kind=rk), intent(out), optional, allocatable, target :: dgradient_dXc(:,:,:,:)
real(kind=rk), intent(out), optional, allocatable, target :: dgradient_dlogWc(:,:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: knot3(:)
real(kind=rk), intent(out), optional, allocatable, target :: curve_second(:)
real(kind=rk), intent(out), optional, allocatable, target :: djacobian_dXc(:,:)
real(kind=rk), intent(out), optional, allocatable, target :: djacobian_dlogWc(:,:,:)

public pure subroutine tensor_ansatz_element(Xc, Wc, rational, degree, nc, knot1, knot2, object_err, err, ie, basis, gradient, measure, ngauss, strict, Xg, dXg_dXt, d2Tgc_dXg2, dmeasure_dXc, dmeasure_dlogWc, dgradient_dXc, dgradient_dlogWc, knot3, curve_second, djacobian_dXc, djacobian_dlogWc)

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), allocatable :: Xc(:,:)
real(kind=rk), intent(inout), allocatable, target :: Wc(:)
logical, intent(in) :: rational
integer, intent(in) :: degree(:)
integer, intent(in) :: nc(:)
real(kind=rk), intent(in), allocatable :: knot1(:)
real(kind=rk), intent(inout), optional, allocatable, target :: knot2(:)
type(debug), intent(inout), target :: object_err
type(debug), intent(out), optional, target :: err
integer, intent(in) :: ie
real(kind=rk), intent(inout), allocatable :: basis(:,:)
real(kind=rk), intent(inout), allocatable :: gradient(:,:,:)
real(kind=rk), intent(inout), allocatable :: measure(:)
integer, intent(in), optional :: ngauss(:)
logical, intent(in), optional :: strict
real(kind=rk), intent(inout), optional, allocatable, target :: Xg(:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: dXg_dXt(:,:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: d2Tgc_dXg2(:,:,:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: dmeasure_dXc(:,:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: dmeasure_dlogWc(:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: dgradient_dXc(:,:,:,:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: dgradient_dlogWc(:,:,:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: knot3(:)
real(kind=rk), intent(inout), optional, allocatable, target :: curve_second(:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: djacobian_dXc(:,:,:)
real(kind=rk), intent(inout), optional, allocatable, target :: djacobian_dlogWc(:,:,:,:)

public pure subroutine tensor_basis_derivative_at(Xt, nc, degree, knot1, order, wrap, values, first_active, elem, Wc, knot2, knot3, side)

Evaluate one mixed basis derivative, with local, dense or selected output. Source knots/counts/degrees and parameter/order/wrapping lengths must agree. Constructor padding avoids an ifx 2026.2 Release RESHAPE optimizer failure. Directional scratch occupies one local buffer; no global basis is allocated.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: degree(:)
real(kind=rk), intent(in), contiguous :: knot1(:)
integer, intent(in) :: order(:)
logical, intent(in) :: wrap(:)
real(kind=rk), intent(out) :: values(:)
integer, intent(out), optional :: first_active(:)
integer, intent(in), optional :: elem(:)
real(kind=rk), intent(in), optional, contiguous :: Wc(:)
real(kind=rk), intent(in), optional, contiguous :: knot2(:)
real(kind=rk), intent(in), optional, contiguous :: knot3(:)
integer, intent(in), optional :: side(:)

public pure subroutine tensor_basis_derivative_local(first1, nc1, ders1, first2, nc2, ders2, first3, nc3, ders3, values, Wc, elem, checked)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Compute one tensor-product B-spline or rational basis derivative on its local support. The three directional derivative tables include rows zero through the requested derivative order. Unused directions are represented by a table containing one. Rational derivatives use a multivariate quotient recurrence that extends the rational-surface recurrence in Piegl and Tiller, The NURBS Book, 2nd edition, Algorithm A4.4 to three tensor-product directions. The derivative multi-index is given by the last row present in each directional table. For example, upper row bounds (1,0,2) request . values uses direction-1-fastest local ordering. Optional elem selects zero-order values in list order, retaining repeats and zeroing invalid or inactive IDs. The rational path evaluates numerator and denominator derivatives in a common exact radix-power gauge, so a uniform finite weight rescaling does not alter the recurrence.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: first1
integer, intent(in) :: nc1
real(kind=rk), intent(in), contiguous :: ders1(0:,0:)
integer, intent(in) :: first2
integer, intent(in) :: nc2
real(kind=rk), intent(in), contiguous :: ders2(0:,0:)
integer, intent(in) :: first3
integer, intent(in) :: nc3
real(kind=rk), intent(in), contiguous :: ders3(0:,0:)
real(kind=rk), intent(out), contiguous :: values(0:)

Supported derivative values, or selected values when elem is supplied.

real(kind=rk), intent(in), optional, contiguous :: Wc(:)

Global rational weights, or one local weight per elem entry; absent for polynomial values.

integer, intent(in), optional :: elem(:)

Zero-order selection with matching local weights.

logical, intent(in), optional :: checked

Signal lost rational derivative workspace with nonfinite values.

public pure subroutine tensor_basis_derivatives2_local(first1, nc1, ders1, first2, nc2, ders2, first3, nc3, ders3, basis, gradient, hessian, Wc)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Compute a tensor-product basis, gradient, and Hessian on local support. The derivative tables contain rows zero through one, or through two when hessian is requested. Unused directions use a matching one-column identity table. Rational derivatives apply the quotient rule through the requested total order. This is a fused tensor-product specialization of the multivariate quotient recurrence, extending the rational-surface recurrence in Piegl and Tiller, The NURBS Book, Algorithm A4.4 to as many as three parametric directions. Direction 1 varies fastest in basis. gradient(:,i) stores , while hessian(:,i,j) stores the mixed derivative . When Wc is present, its active entries are first multiplied by one common exact radix power selected from their largest model exponent. This preserves the projective quotient and its derivatives.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: first1

First active control index in each parameter direction.

integer, intent(in) :: nc1

Control counts in the same direction order.

real(kind=rk), intent(in), contiguous :: ders1(0:,0:)

Univariate basis jets indexed by derivative order and local basis index.

integer, intent(in) :: first2

First active control index in each parameter direction.

integer, intent(in) :: nc2

Control counts in the same direction order.

real(kind=rk), intent(in), contiguous :: ders2(0:,0:)

Univariate basis jets indexed by derivative order and local basis index.

integer, intent(in) :: first3

First active control index in each parameter direction.

integer, intent(in) :: nc3

Control counts in the same direction order.

real(kind=rk), intent(in), contiguous :: ders3(0:,0:)

Univariate basis jets indexed by derivative order and local basis index.

real(kind=rk), intent(out), contiguous :: basis(0:)

Local tensor-product values.

real(kind=rk), intent(out), contiguous :: gradient(0:,:)

Local parametric gradients, shape [nlocal,rank].

real(kind=rk), intent(out), optional, contiguous :: hessian(0:,:,:)

Optional local parametric Hessians, shape [nlocal,rank,rank].

real(kind=rk), intent(in), optional, contiguous :: Wc(:)

Optional flattened global weight array.

public pure subroutine tensor_basis_jet(Xt, knot1, knot2, knot3, degree, nc, order, wrap, first, basis, gradient, hessian, ders1, ders2, ders3, Wc, elem, side)

Evaluate one local tensor jet, computing only the requested derivative order. Global weights are normalized before any selected-control gathering.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xt(:)
real(kind=rk), intent(in), contiguous :: knot1(:)
real(kind=rk), intent(in), optional, contiguous :: knot2(:)
real(kind=rk), intent(in), optional, contiguous :: knot3(:)
integer, intent(in) :: degree(:)
integer, intent(in) :: nc(:)
integer, intent(in) :: order
logical, intent(in), optional :: wrap(:)
integer, intent(out) :: first(:)
real(kind=rk), intent(out), contiguous :: basis(0:)
real(kind=rk), intent(out), optional, contiguous :: gradient(0:,:)
real(kind=rk), intent(out), optional, contiguous :: hessian(0:,:,:)
real(kind=rk), intent(out), contiguous :: ders1(0:,0:)
real(kind=rk), intent(out), contiguous :: ders2(0:,0:)
real(kind=rk), intent(out), contiguous :: ders3(0:,0:)
real(kind=rk), intent(in), optional, contiguous :: Wc(:)
integer, intent(in), optional :: elem(:)
integer, intent(in), optional :: side(:)

public pure subroutine tensor_measure(Xc, degree, nc, knot1, knot2, Wc, rational, measure, object_err, err, ngauss, strict, knot3)

Integrate the metric density using the same native-knot Jacobian as ansatz. Keep valid quadrature contributions if another point in the element fails.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), allocatable :: Xc(:,:)
integer, intent(in) :: degree(:)
integer, intent(in) :: nc(:)
real(kind=rk), intent(in), allocatable :: knot1(:)
real(kind=rk), intent(in), allocatable :: knot2(:)
real(kind=rk), intent(inout), allocatable, target :: Wc(:)
logical, intent(in) :: rational
real(kind=rk), intent(out) :: measure
type(debug), intent(inout), target :: object_err
type(debug), intent(out), optional, target :: err
integer, intent(in), optional :: ngauss(:)
logical, intent(in), optional :: strict
real(kind=rk), intent(in), optional, contiguous :: knot3(:)

public pure subroutine tensor_transfer(axis, ncoarse, swap_coarse, swap_fine, rowptr, col, val, ok)

Form T(i,j)=T1(i1,j1)*T2(i2,j2) from successful Oslo transfers. The axis list is in common tangent order. Rows follow the fine patch's native order and columns increase in the coarse patch's native order within each row. With one tangent, the existing CSR arrays move directly to the outputs.

Arguments

Type IntentOptional Attributes Name
type(axis_transfer), intent(inout) :: axis(:)
integer, intent(in) :: ncoarse(:)
logical, intent(in) :: swap_coarse
logical, intent(in) :: swap_fine
integer, intent(out), allocatable :: rowptr(:)
integer, intent(out), allocatable :: col(:)
real(kind=rk), intent(out), allocatable :: val(:)
logical, intent(out) :: ok

public pure subroutine transform_geometry(Xc, Xg, linear, translation, center, err, category)

Validate and apply one affine map to owned controls and any sampled cache. All input shapes and finite map entries are checked before either net changes.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(inout), allocatable :: Xc(:,:)
real(kind=rk), intent(inout), allocatable :: Xg(:,:)
real(kind=rk), intent(in), contiguous :: linear(:,:)
real(kind=rk), intent(in), optional, contiguous :: translation(:)
real(kind=rk), intent(in), optional, contiguous :: center(:)
type(debug), intent(inout) :: err
character(len=*), intent(in) :: category

public pure subroutine transform_points(points, linear, translation, center)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Apply one affine transformation to point rows in place.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(inout), contiguous :: points(:,:)

Point rows [npoint,ncoord] to transform.

real(kind=rk), intent(in), contiguous :: linear(:,:)

Square linear map [ncoord,ncoord].

real(kind=rk), intent(in), optional, contiguous :: translation(:)

Translation vector [ncoord].

real(kind=rk), intent(in), optional, contiguous :: center(:)

Fixed center [ncoord] about which linear acts.

public pure subroutine two_sum(a, b, total, remainder)

FastTwoSum with its larger-magnitude operand first.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: a
real(kind=rk), intent(in) :: b
real(kind=rk), intent(out) :: total
real(kind=rk), intent(out) :: remainder

public pure subroutine unpack_refinement_controls(Xdir, nc, dir, ncoord, weight_exponent, Xc, Wc)

Reverse the tensor layout and dehomogenize when a final weight component is present. The layout and positive homogeneous weights must match the supplied counts. Polynomial input leaves Wc unallocated, for forwarding to optional weight arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: Xdir(:,:)
integer, intent(in) :: nc(:)
integer, intent(in) :: dir
integer, intent(in) :: ncoord
integer, intent(in) :: weight_exponent
real(kind=rk), intent(out), allocatable :: Xc(:,:)
real(kind=rk), intent(out), allocatable :: Wc(:)